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

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