Blame SOURCES/0019-curl-7.65.3-CVE-2019-5481.patch

b35f73
From 13de299b112a59c373b330f0539166ecc9a7627b Mon Sep 17 00:00:00 2001
b35f73
From: Daniel Stenberg <daniel@haxx.se>
b35f73
Date: Tue, 3 Sep 2019 22:59:32 +0200
b35f73
Subject: [PATCH] security:read_data fix bad realloc()
b35f73
b35f73
... that could end up a double-free
b35f73
b35f73
CVE-2019-5481
b35f73
Bug: https://curl.haxx.se/docs/CVE-2019-5481.html
b35f73
b35f73
Upstream-commit: 9069838b30fb3b48af0123e39f664cea683254a5
b35f73
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
b35f73
---
b35f73
 lib/security.c | 6 ++----
b35f73
 1 file changed, 2 insertions(+), 4 deletions(-)
b35f73
b35f73
diff --git a/lib/security.c b/lib/security.c
b35f73
index 550ea2d..c5e4e13 100644
b35f73
--- a/lib/security.c
b35f73
+++ b/lib/security.c
b35f73
@@ -191,7 +191,6 @@ static CURLcode read_data(struct connectdata *conn,
b35f73
                           struct krb5buffer *buf)
b35f73
 {
b35f73
   int len;
b35f73
-  void *tmp = NULL;
b35f73
   CURLcode result;
b35f73
 
b35f73
   result = socket_read(fd, &len, sizeof(len));
b35f73
@@ -201,12 +200,11 @@ static CURLcode read_data(struct connectdata *conn,
b35f73
   if(len) {
b35f73
     /* only realloc if there was a length */
b35f73
     len = ntohl(len);
b35f73
-    tmp = Curl_saferealloc(buf->data, len);
b35f73
+    buf->data = Curl_saferealloc(buf->data, len);
b35f73
   }
b35f73
-  if(tmp == NULL)
b35f73
+  if(!len || !buf->data)
b35f73
     return CURLE_OUT_OF_MEMORY;
b35f73
 
b35f73
-  buf->data = tmp;
b35f73
   result = socket_read(fd, buf->data, len);
b35f73
   if(result)
b35f73
     return result;
b35f73
-- 
b35f73
2.20.1
b35f73