]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
added a NULL pointer check for the name field as it can in fact be NULL when
authorDaniel Stenberg <daniel@haxx.se>
Mon, 20 Oct 2008 21:56:35 +0000 (21:56 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 20 Oct 2008 21:56:35 +0000 (21:56 +0000)
dereferenced here, if the app passes in a funny combo. Detected by coverity.com

lib/formdata.c

index 62409ec413b63dfe7cef3c7dfbd8740b768b3301..e035271b34951c00a460ce3c83316b82ec350cd8 100644 (file)
@@ -743,8 +743,11 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
         }
         if( !(form->flags & HTTPPOST_PTRNAME) &&
              (form == first_form) ) {
-          /* copy name (without strdup; possibly contains null characters) */
-          form->name = memdup(form->name, form->namelength);
+          /* Note that there's small risk that form->name is NULL here if the
+             app passed in a bad combo, so we better check for that first. */
+          if(form->name)
+            /* copy name (without strdup; possibly contains null characters) */
+            form->name = memdup(form->name, form->namelength);
           if(!form->name) {
             return_value = CURL_FORMADD_MEMORY;
             break;