Bug 1243121 (b) patch for printf format related issues in ldap source tree. draft
authorISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
Sat, 09 Nov 2019 10:59:42 +0900
changeset 81054 fdd020c4ac89aadcdf28ca1cffb7200bc86a3c79
parent 81053 d99a160304829420651472937c6215feef556bad
child 81055 d7ce75a4e4bc7bc0470bed1fc552e7e581f39b68
push id9744
push userishikawa@yk.rim.or.jp
push dateSat, 09 Nov 2019 02:01:06 +0000
treeherdertry-comm-central@56c83244ac0e [default view] [failures only]
bugs1243121
Bug 1243121 (b) patch for printf format related issues in ldap source tree.
ldap/c-sdk/libraries/liblber/io.c
ldap/c-sdk/libraries/libldap/getfilter.c
ldap/c-sdk/libraries/libldap/request.c
ldap/c-sdk/libraries/libldap/tmplout.c
ldap/xpcom/src/nsLDAPOperation.cpp
--- a/ldap/c-sdk/libraries/liblber/io.c
+++ b/ldap/c-sdk/libraries/liblber/io.c
@@ -608,18 +608,18 @@ void ber_dump(BerElement *ber, int inout
     lber_bprint(ber->ber_buf, ber->ber_ptr - ber->ber_buf);
   }
 }
 
 void ber_sos_dump(Seqorset *sos) {
   char msg[80];
   ber_err_print("*** sos dump ***\n");
   while (sos != NULLSEQORSET) {
-    sprintf(msg, "ber_sos_dump: clen %d first 0x%p ptr 0x%p\n", sos->sos_clen,
-            sos->sos_first, sos->sos_ptr);
+    sprintf(msg, "ber_sos_dump: clen %lu first 0x%p ptr 0x%p\n",
+            (long unsigned int)sos->sos_clen, sos->sos_first, sos->sos_ptr);
     ber_err_print(msg);
     sprintf(msg, "              current len %ld contents:\n",
             (long)(sos->sos_ptr - sos->sos_first));
     ber_err_print(msg);
     lber_bprint(sos->sos_first, sos->sos_ptr - sos->sos_first);
 
     sos = sos->sos_next;
   }
@@ -809,18 +809,18 @@ ber_tag_t LDAP_CALL ber_get_next(Sockbuf
 
     toread -= rc;
     ber->ber_rwptr += rc;
   } while (toread > 0);
 
 #ifdef LDAP_DEBUG
   if (lber_debug) {
     char msg[80];
-    sprintf(msg, "ber_get_next: tag 0x%x len %d contents:\n", ber->ber_tag,
-            ber->ber_len);
+    sprintf(msg, "ber_get_next: tag 0x%x len %lu contents:\n", ber->ber_tag,
+            (long unsigned int)ber->ber_len);
     ber_err_print(msg);
     if (lber_debug > 1) ber_dump(ber, 1);
   }
 #endif
 
   *len = (ber_len_t)ber->ber_rwptr - (ber_len_t)orig_rwptr;
   ber->ber_rwptr = NULL;
   ber->ber_struct[BER_STRUCT_VAL].ldapiov_len = ber->ber_len;
--- a/ldap/c-sdk/libraries/libldap/getfilter.c
+++ b/ldap/c-sdk/libraries/libldap/getfilter.c
@@ -347,17 +347,17 @@ static char *filter_add_value(char *f, c
           } else {
             f = NULL; /* overflow */
           }
         }
         break;
 
       case '(':
       case ')':
-        sprintf(x, "\\%02x", (unsigned)*v);
+        sprintf(x, "\\%02x", (unsigned char)*v);
         f = filter_add_strn(f, flimit, x, 3);
         v++;
         break;
 
       case '\\':
         if (escape_all) {
           f = filter_add_strn(f, flimit, "\\5c", 3);
           v++;
--- a/ldap/c-sdk/libraries/libldap/request.c
+++ b/ldap/c-sdk/libraries/libldap/request.c
@@ -338,20 +338,20 @@ int nsldapi_send_server_request(
                        0, 0);
             if (ext_oid) {
               LDAPDebug1(
                   LDAP_DEBUG_TRACE,
                   "nsldapi_send_server_request: Unsolicited response oid: %s\n",
                   ext_oid, 0, 0);
             }
             if (ext_data && ext_data->bv_len && ext_data->bv_val) {
-              LDAPDebug1(
-                  LDAP_DEBUG_TRACE,
-                  "nsldapi_send_server_request: Unsolicited response len: %d\n",
-                  ext_data->bv_len, 0, 0);
+              LDAPDebug1(LDAP_DEBUG_TRACE,
+                         "nsldapi_send_server_request: Unsolicited response "
+                         "len: %lld\n",
+                         (long long int)ext_data->bv_len, 0, 0);
               LDAPDebug1(
                   LDAP_DEBUG_TRACE,
                   "nsldapi_send_server_request: Unsolicited response val: %s\n",
                   ext_data->bv_val, 0, 0);
             }
             if (!ext_oid && !ext_data) {
               LDAPDebug0(LDAP_DEBUG_TRACE,
                          "nsldapi_send_server_request: Unsolicited response is "
--- a/ldap/c-sdk/libraries/libldap/tmplout.c
+++ b/ldap/c-sdk/libraries/libldap/tmplout.c
@@ -613,17 +613,17 @@ static int do_vals2text(LDAP *ld, char *
         while ((s = strchr(s, '$')) != NULL) {
           *s++ = '\0';
           while (ldap_utf8isspace(s)) {
             ++s;
           }
           if (html) {
             sprintf(buf, "<DD>%s<BR>%s", p, eol);
           } else {
-            sprintf(buf, "%-*s%s%s", labelwidth, " ", p, eol);
+            snprintf(buf, 4095, "%-*s%s%s", labelwidth, " ", p, eol);
           }
           (*writeproc)(writeparm, buf, strlen(buf));
           p = s;
         }
         outval = p;
         ++writeoutval;
         break;
 
@@ -657,32 +657,32 @@ static int do_vals2text(LDAP *ld, char *
         }
 
         /*
          * at this point `s' points to the label & `p' to the URL
          */
         if (html) {
           sprintf(buf, "<DD><A HREF=\"%s\">%s</A><BR>%s", p, s, eol);
         } else {
-          sprintf(buf, "%-*s%s%s%-*s%s%s", labelwidth, " ", s, eol,
-                  labelwidth + 2, " ", p, eol);
+          snprintf(buf, 4095, "%-*s%s%s%-*s%s%s", labelwidth, " ", s, eol,
+                   labelwidth + 2, " ", p, eol);
         }
         (*writeproc)(writeparm, buf, strlen(buf));
         break;
 
       default:
         sprintf(buf, " Can't display item type %ld%s", syntaxid, eol);
         (*writeproc)(writeparm, buf, strlen(buf));
     }
 
     if (writeoutval) {
       if (html) {
         sprintf(buf, "<DD>%s<BR>%s", outval, eol);
       } else {
-        sprintf(buf, "%-*s%s%s", labelwidth, " ", outval, eol);
+        snprintf(buf, 4095, "%-*s%s%s", labelwidth, " ", outval, eol);
       }
       (*writeproc)(writeparm, buf, strlen(buf));
     }
   }
 
   if (freebuf) {
     NSLDAPI_FREE(buf);
   }
@@ -741,17 +741,17 @@ static int output_dn(char *buf, char *dn
     return (-1);
   }
 
   if (urlprefix != NULL) {
     sprintf(buf, "<DD><A HREF=\"%s", urlprefix);
     strcat_escaped(buf, dn);
     strcat(buf, "\">");
   } else if (width > 0) {
-    sprintf(buf, "%-*s", width, " ");
+    snprintf(buf, 4095, "%-*s", width, " ");
   } else {
     *buf = '\0';
   }
 
   for (i = 0; dnrdns[i] != NULL && (rdncount == 0 || i < rdncount); ++i) {
     if (i > 0) {
       strcat(buf, ", ");
     }
--- a/ldap/xpcom/src/nsLDAPOperation.cpp
+++ b/ldap/xpcom/src/nsLDAPOperation.cpp
@@ -84,17 +84,17 @@ static nsresult TranslateLDAPErrorToNSEr
 
     case LDAP_FILTER_ERROR:
       return NS_ERROR_LDAP_FILTER_ERROR;
 
     default:
       MOZ_LOG(gLDAPLogModule, mozilla::LogLevel::Error,
               ("TranslateLDAPErrorToNSError: "
                "Do not know how to translate LDAP error: 0x%x",
-               ldapError));
+               static_cast<uint32_t>(ldapError)));
       return NS_ERROR_UNEXPECTED;
   }
 }
 
 // constructor
 nsLDAPOperation::nsLDAPOperation() {}
 
 // destructor