Blame SOURCES/0011-curl-7.61.1-CVE-2019-3823.patch

f036d1
From d26f1025d0a0a6c602d758a2e0917759492473e9 Mon Sep 17 00:00:00 2001
f036d1
From: Daniel Gustafsson <daniel@yesql.se>
f036d1
Date: Sat, 19 Jan 2019 00:42:47 +0100
f036d1
Subject: [PATCH] smtp: avoid risk of buffer overflow in strtol
f036d1
f036d1
If the incoming len 5, but the buffer does not have a termination
f036d1
after 5 bytes, the strtol() call may keep reading through the line
f036d1
buffer until is exceeds its boundary. Fix by ensuring that we are
f036d1
using a bounded read with a temporary buffer on the stack.
f036d1
f036d1
Bug: https://curl.haxx.se/docs/CVE-2019-3823.html
f036d1
Reported-by: Brian Carpenter (Geeknik Labs)
f036d1
CVE-2019-3823
f036d1
f036d1
Upstream-commit: 39df4073e5413fcdbb5a38da0c1ce6f1c0ceb484
f036d1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
f036d1
---
f036d1
 lib/smtp.c | 8 ++++++--
f036d1
 1 file changed, 6 insertions(+), 2 deletions(-)
f036d1
f036d1
diff --git a/lib/smtp.c b/lib/smtp.c
f036d1
index ecf10a4..1b9f92d 100644
f036d1
--- a/lib/smtp.c
f036d1
+++ b/lib/smtp.c
f036d1
@@ -5,7 +5,7 @@
f036d1
  *                            | (__| |_| |  _ <| |___
f036d1
  *                             \___|\___/|_| \_\_____|
f036d1
  *
f036d1
- * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
f036d1
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
f036d1
  *
f036d1
  * This software is licensed as described in the file COPYING, which
f036d1
  * you should have received as part of this distribution. The terms
f036d1
@@ -207,8 +207,12 @@ static bool smtp_endofresp(struct connectdata *conn, char *line, size_t len,
f036d1
      Section 4. Examples of RFC-4954 but some e-mail servers ignore this and
f036d1
      only send the response code instead as per Section 4.2. */
f036d1
   if(line[3] == ' ' || len == 5) {
f036d1
+    char tmpline[6];
f036d1
+
f036d1
     result = TRUE;
f036d1
-    *resp = curlx_sltosi(strtol(line, NULL, 10));
f036d1
+    memset(tmpline, '\0', sizeof(tmpline));
f036d1
+    memcpy(tmpline, line, (len == 5 ? 5 : 3));
f036d1
+    *resp = curlx_sltosi(strtol(tmpline, NULL, 10));
f036d1
 
f036d1
     /* Make sure real server never sends internal value */
f036d1
     if(*resp == 1)
f036d1
-- 
f036d1
2.17.2
f036d1