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