]> granicus.if.org Git - curl/commitdiff
base64: check for integer overflow on large input
authorDaniel Stenberg <daniel@haxx.se>
Tue, 27 Sep 2016 22:05:12 +0000 (00:05 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 31 Oct 2016 07:46:35 +0000 (08:46 +0100)
CVE-2016-8617

Bug: https://curl.haxx.se/docs/adv_20161102C.html
Reported-by: Cure53
lib/base64.c

index ad254595f4726afaa6230a28fee3e0545842d77f..204a2273d196ddfce6a45a28c9380fa6fd9bf26b 100644 (file)
@@ -190,6 +190,11 @@ static CURLcode base64_encode(const char *table64,
   if(!insize)
     insize = strlen(indata);
 
+#if SIZEOF_SIZE_T == 4
+  if(insize > UINT_MAX/4)
+    return CURLE_OUT_OF_MEMORY;
+#endif
+
   base64data = output = malloc(insize * 4 / 3 + 4);
   if(!output)
     return CURLE_OUT_OF_MEMORY;