]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[xmlrpc-c] Coverity 1024180, 1024205, 1024301, 1024847, 1024848, 1024377, 1024378... 2754/head
authorAndrey Volk <andywolk@gmail.com>
Thu, 30 Jan 2025 20:10:39 +0000 (23:10 +0300)
committerAndrey Volk <andywolk@gmail.com>
Tue, 4 Feb 2025 00:46:55 +0000 (03:46 +0300)
libs/xmlrpc-c/lib/abyss/src/handler.c
libs/xmlrpc-c/lib/expat/xmlparse/xmlparse.c
libs/xmlrpc-c/lib/libutil/utf8.c
libs/xmlrpc-c/src/xmlrpc_decompose.c
libs/xmlrpc-c/src/xmlrpc_server_abyss.c
libs/xmlrpc-c/src/xmlrpc_server_cgi.c

index b26217687d8248ee13bab809c941d16a3ac9ce96..c61fc3c607ac19141ebc1542fbda2ba17e4166ec 100644 (file)
@@ -305,7 +305,7 @@ sendDirectoryDocument(TList *      const listP,
         if (k > 24) {
             snprintf(z1, sizeof(z1), "%.10s...%s", z, z + k - 11);
             k = 24;
-            p = z1 + 24;
+            p = z1 + k;
         } else {
             snprintf(z1, sizeof(z1), "%s", z);
             
index 5b647f1a9ecd951e35e017bdc5e70e2b69067edf..61bb8e00f6f476c34f78272a094a57fb0e13d835 100644 (file)
@@ -2416,6 +2416,7 @@ doStartTagNoAtts(XML_Parser       const xmlParserP,
         }
         tag->buf = malloc(INIT_TAG_BUF_SIZE);
         if (!tag->buf) {
+            free(tag);
             *errorCodeP = XML_ERROR_NO_MEMORY;
             return;
         }
@@ -3646,8 +3647,10 @@ doProlog(XML_Parser       const xmlParserP,
       switch (tok) {
       case XML_TOK_PARAM_ENTITY_REF:
         *errorCodeP = XML_ERROR_PARAM_ENTITY_REF;
+        break;
       case XML_TOK_XML_DECL:
         *errorCodeP = XML_ERROR_MISPLACED_XML_PI;
+        break;
       default:
         *errorCodeP = XML_ERROR_SYNTAX;
       }
index 77e436d636ed7b4bcfd825902f4802bc51826047..39432e3fd2ba21f7a6e13525aedd0fb00cad0b17 100644 (file)
@@ -170,7 +170,7 @@ decodeMultibyte(xmlrpc_env * const envP,
 
    Return the character in UTF-16 format as *wcP.
 -----------------------------------------------------------------------------*/
-    wchar_t wc;
+    wchar_t wc = 0;
 
     assert(utf8_seq[0] & 0x80); /* High bit set: this is multibyte seq */
 
index 6323a269ae51d09814f05105e1180309c4a72a36..adee339a220ceb81bb870d384b23d86592142cf3 100644 (file)
@@ -181,9 +181,10 @@ releaseDecompArray(struct arrayDecomp const arrayDecomp,
 
 
 static void
-releaseDecompStruct(struct structDecomp const structDecomp,
+releaseDecompStruct(struct structDecomp const *_structDecomp,
                     bool                const oldstyleMemMgmt) {
 
+    struct structDecomp const structDecomp = *_structDecomp;
     unsigned int i;
     for (i = 0; i < structDecomp.mbrCnt; ++i) {
         releaseDecomposition(structDecomp.mbrArray[i].decompTreeP,
@@ -239,7 +240,7 @@ releaseDecomposition(const struct decompTreeNode * const decompRootP,
         releaseDecompArray(decompRootP->store.Tarray, oldstyleMemMgmt);
         break;
     case '{':
-        releaseDecompStruct(decompRootP->store.Tstruct, oldstyleMemMgmt);
+        releaseDecompStruct(&decompRootP->store.Tstruct, oldstyleMemMgmt);
         break;
     }
 }
@@ -259,8 +260,9 @@ decomposeValueWithTree(xmlrpc_env *                  const envP,
 static void
 validateArraySize(xmlrpc_env *         const envP,
                   const xmlrpc_value * const arrayP,
-                  struct arrayDecomp   const arrayDecomp) {
+                  struct arrayDecomp   const *_arrayDecomp) {
     
+    struct arrayDecomp   const arrayDecomp = *_arrayDecomp;
     unsigned int size;
               
     size = xmlrpc_array_size(envP, arrayP);
@@ -284,10 +286,12 @@ validateArraySize(xmlrpc_env *         const envP,
 static void 
 parsearray(xmlrpc_env *         const envP,
            const xmlrpc_value * const arrayP,
-           struct arrayDecomp   const arrayDecomp,
+           struct arrayDecomp   const *_arrayDecomp,
            bool                 const oldstyleMemMgmt) {
 
-    validateArraySize(envP, arrayP, arrayDecomp);
+    struct arrayDecomp   const arrayDecomp = *_arrayDecomp;
+
+    validateArraySize(envP, arrayP, &arrayDecomp);
 
     if (!envP->fault_occurred) {
         unsigned int doneCnt;
@@ -324,9 +328,10 @@ parsearray(xmlrpc_env *         const envP,
 static void 
 parsestruct(xmlrpc_env *        const envP,
             xmlrpc_value *      const structP,
-            struct structDecomp const structDecomp,
+            struct structDecomp const *_structDecomp,
             bool                const oldstyleMemMgmt) {
 
+       struct structDecomp const structDecomp = *_structDecomp;
     unsigned int doneCount;
     
     doneCount = 0;  /* No members done yet */
@@ -569,7 +574,7 @@ decomposeValueWithTree(xmlrpc_env *                  const envP,
                 "%s, but the '(...)' specifier requires type ARRAY",
                 xmlrpc_type_name(xmlrpc_value_type(valueP)));
         else
-            parsearray(envP, valueP, decompRootP->store.Tarray,
+            parsearray(envP, valueP, &decompRootP->store.Tarray,
                        oldstyleMemMgmt);
         break;
 
@@ -580,7 +585,7 @@ decomposeValueWithTree(xmlrpc_env *                  const envP,
                 "%s, but the '{...}' specifier requires type STRUCT",
                 xmlrpc_type_name(xmlrpc_value_type(valueP)));
         else
-            parsestruct(envP, valueP, decompRootP->store.Tstruct,
+            parsestruct(envP, valueP, &decompRootP->store.Tstruct,
                         oldstyleMemMgmt);
         break;
 
index 8471c4c910f4a6dd05943baeac61b73f6b69f5ec..7c6c3dd726bba188d4900cb2fee4f32a78770bc8 100644 (file)
@@ -179,9 +179,11 @@ sendResponse(xmlrpc_env *      const envP,
 
     ResponseStatus(abyssSessionP, 200);
 
+#if 0 /* Uncomment once http_cookie is not NULL again */
     if (http_cookie)
         /* There's an auth cookie, so pass it back in the response. */
         addAuthCookie(envP, abyssSessionP, http_cookie);
+#endif
 
     if ((size_t)(uint32_t)len != len)
         xmlrpc_faultf(envP, "XML-RPC method generated a response too "
index f8ab73a7aa3ead8fea8437f64e961951c0c81ead..607a739f9aa610f50902c4405f0bc1cbf13382f8 100644 (file)
@@ -189,6 +189,7 @@ xmlrpc_server_cgi_process_call(xmlrpc_registry * const registryP) {
     size_t input_size, output_size;
     int code;
     char *message;
+    char *err = NULL;
 
     /* Error-handling preconditions. */
     xmlrpc_env_init(&env);
@@ -209,13 +210,13 @@ xmlrpc_server_cgi_process_call(xmlrpc_registry * const registryP) {
     }
     if (!type || !xmlrpc_strneq(type, "text/xml", strlen("text/xml"))) {
        char *template = "Expected content type: \"text/xml\", received: \"%s\"";
-       size_t err_len = strlen(template) + strlen(type) + 1;
-       char *err = malloc(err_len);
+    size_t err_len = strlen(template) + (type ? strlen(type) : 0) + 1;
 
-       (void)snprintf(err, err_len, template, type);
+    err = malloc(err_len);
+
+    (void)snprintf(err, err_len, template, (type ? type : ""));
         code = 400; message = "Bad Request";
         XMLRPC_FAIL(&env, XMLRPC_INTERNAL_ERROR, err);
-       free(err);
     }
     if (!length_str) {
         code = 411; message = "Length Required";
@@ -254,6 +255,8 @@ xmlrpc_server_cgi_process_call(xmlrpc_registry * const registryP) {
     send_xml(output_data, output_size);
     
  cleanup:
+    if (err)
+        free(err);
     if (input)
         xmlrpc_mem_block_free(input);
     if (output)