]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
security:read_data fix bad realloc()
authorDaniel Stenberg <daniel@haxx.se>
Tue, 3 Sep 2019 20:59:32 +0000 (22:59 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 9 Sep 2019 06:14:34 +0000 (08:14 +0200)
... that could end up a double-free

CVE-2019-5481
Bug: https://curl.haxx.se/docs/CVE-2019-5481.html

lib/security.c

index 550ea2da8db17fe40d9ea784ff2f52ec7edbdcc0..c5e4e135df78fc9201584cf4b00b78ec3a2b8812 100644 (file)
@@ -191,7 +191,6 @@ static CURLcode read_data(struct connectdata *conn,
                           struct krb5buffer *buf)
 {
   int len;
-  void *tmp = NULL;
   CURLcode result;
 
   result = socket_read(fd, &len, sizeof(len));
@@ -201,12 +200,11 @@ static CURLcode read_data(struct connectdata *conn,
   if(len) {
     /* only realloc if there was a length */
     len = ntohl(len);
-    tmp = Curl_saferealloc(buf->data, len);
+    buf->data = Curl_saferealloc(buf->data, len);
   }
-  if(tmp == NULL)
+  if(!len || !buf->data)
     return CURLE_OUT_OF_MEMORY;
 
-  buf->data = tmp;
   result = socket_read(fd, buf->data, len);
   if(result)
     return result;