Blame SOURCES/0008-curl-7.29.0-192c4f78.patch

9d7d3f
From 25089c2c69028f0549facf93f7bdbf7344277f09 Mon Sep 17 00:00:00 2001
9d7d3f
From: Daniel Stenberg <daniel@haxx.se>
9d7d3f
Date: Sun, 19 May 2013 23:24:29 +0200
9d7d3f
Subject: [PATCH] Curl_urldecode: no peeking beyond end of input buffer
9d7d3f
9d7d3f
Security problem: CVE-2013-2174
9d7d3f
9d7d3f
If a program would give a string like "%FF" to curl_easy_unescape() but
9d7d3f
ask for it to decode only the first byte, it would still parse and
9d7d3f
decode the full hex sequence. The function then not only read beyond the
9d7d3f
allowed buffer but it would also deduct the *unsigned* counter variable
9d7d3f
for how many more bytes there's left to read in the buffer by two,
9d7d3f
making the counter wrap. Continuing this, the function would go on
9d7d3f
reading beyond the buffer and soon writing beyond the allocated target
9d7d3f
buffer...
9d7d3f
9d7d3f
Bug: http://curl.haxx.se/docs/adv_20130622.html
9d7d3f
Reported-by: Timo Sirainen
9d7d3f
9d7d3f
[upstream commit 192c4f788d48f82c03e9cef40013f34370e90737]
9d7d3f
9d7d3f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
9d7d3f
---
9d7d3f
 lib/escape.c |    3 ++-
9d7d3f
 1 files changed, 2 insertions(+), 1 deletions(-)
9d7d3f
9d7d3f
diff --git a/lib/escape.c b/lib/escape.c
9d7d3f
index 6a26cf8..a567edb 100644
9d7d3f
--- a/lib/escape.c
9d7d3f
+++ b/lib/escape.c
9d7d3f
@@ -159,7 +159,8 @@ CURLcode Curl_urldecode(struct SessionHandle *data,
9d7d3f
 
9d7d3f
   while(--alloc > 0) {
9d7d3f
     in = *string;
9d7d3f
-    if(('%' == in) && ISXDIGIT(string[1]) && ISXDIGIT(string[2])) {
9d7d3f
+    if(('%' == in) && (alloc > 2) &&
9d7d3f
+       ISXDIGIT(string[1]) && ISXDIGIT(string[2])) {
9d7d3f
       /* this is two hexadecimal digits following a '%' */
9d7d3f
       char hexstr[3];
9d7d3f
       char *ptr;
9d7d3f
-- 
9d7d3f
1.7.1
9d7d3f