]> granicus.if.org Git - curl/commitdiff
ugha, prevent a buffer overflow and allow very long strings in the generated
authorDaniel Stenberg <daniel@haxx.se>
Thu, 25 Jan 2007 20:47:47 +0000 (20:47 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 25 Jan 2007 20:47:47 +0000 (20:47 +0000)
libcurl source...

src/main.c

index bee010c038b0513c26d2ff87209266c2bf7afc04..ab5bbc5950b7fa53b1f5345c63dc4e42666b124c 100644 (file)
@@ -3212,7 +3212,7 @@ CURLcode _my_setopt(CURL *curl, const char *name, CURLoption tag, ...)
 {
   va_list arg;
   CURLcode ret;
-  char buffer[128];
+  char *bufp;
   char value[256];
   bool remark=FALSE;
 
@@ -3249,13 +3249,12 @@ CURLcode _my_setopt(CURL *curl, const char *name, CURLoption tag, ...)
     ret = curl_easy_setopt(curl, tag, oval);
   }
 
-  sprintf(buffer, "%scurl_easy_setopt(hnd, %s, %s);%s",
-          remark?"/* ":"",
-          name, value,
-          remark?" [REMARK] */":"");
-
-  easycode = curl_slist_append(easycode, buffer);
+  bufp = curl_maprintf("%scurl_easy_setopt(hnd, %s, %s);%s",
+                       remark?"/* ":"", name, value,
+                       remark?" [REMARK] */":"");
 
+  easycode = curl_slist_append(easycode, bufp);
+  curl_free(bufp);
   va_end(arg);
 
   return ret;