Compare commits

...

7 Commits
master ... f25

8 changed files with 872 additions and 2 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/curl-[0-9.]*.tar.lzma
/curl-[0-9.]*.tar.xz

View File

@ -0,0 +1,283 @@
From 7ad1cdfb256f7e1b84fc960a8ca1403cca5d930f Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Tue, 8 Nov 2016 15:30:33 +0100
Subject: [PATCH 1/2] printf: fix ".*f" handling
It would always use precision 1 instead of reading it from the argument
list as intended.
Reported-by: Ray Satiro
Bug: #1113
Upstream-commit: 5dd1b65f79bc6dc75b752c53f3fa853b2a3b6d69
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/mprintf.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/mprintf.c b/lib/mprintf.c
index 2c88aa8..e1ad537 100644
--- a/lib/mprintf.c
+++ b/lib/mprintf.c
@@ -303,7 +303,6 @@ static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
flags |= FLAGS_ALT;
break;
case '.':
- flags |= FLAGS_PREC;
if('*' == *fmt) {
/* The precision is picked from a specified parameter */
--
2.7.4
From 3162df571802b2c94d9969b6b269cd0d50c6650d Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Tue, 8 Nov 2016 15:32:37 +0100
Subject: [PATCH 2/2] printf: fix floating point buffer overflow issues
... and add a bunch of floating point printf tests
Upstream-commit: 3ab3c16db6a5674f53cf23d56512a405fde0b2c9
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/mprintf.c | 20 +++++++-
tests/data/test557 | 1 +
tests/libtest/lib557.c | 136 +++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 152 insertions(+), 5 deletions(-)
diff --git a/lib/mprintf.c b/lib/mprintf.c
index e1ad537..e3a690b 100644
--- a/lib/mprintf.c
+++ b/lib/mprintf.c
@@ -92,7 +92,8 @@
# define mp_uintmax_t unsigned long
#endif
-#define BUFFSIZE 256 /* buffer for long-to-str and float-to-str calcs */
+#define BUFFSIZE 326 /* buffer for long-to-str and float-to-str calcs, should
+ fit negative DBL_MAX (317 letters) */
#define MAX_PARAMETERS 128 /* lame static limit */
#ifdef __AMIGA__
@@ -916,12 +917,25 @@ static int dprintf_formatf(
*fptr = 0;
if(width >= 0) {
+ if(width >= (long)sizeof(work))
+ width = sizeof(work)-1;
/* RECURSIVE USAGE */
len = curl_msnprintf(fptr, left, "%ld", width);
fptr += len;
left -= len;
}
if(prec >= 0) {
+ /* for each digit in the integer part, we can have one less
+ precision */
+ size_t maxprec = sizeof(work) - 2;
+ double val = p->data.dnum;
+ while(val >= 10.0) {
+ val /= 10;
+ maxprec--;
+ }
+
+ if(prec > (long)maxprec)
+ prec = maxprec-1;
/* RECURSIVE USAGE */
len = curl_msnprintf(fptr, left, ".%ld", prec);
fptr += len;
@@ -941,7 +955,9 @@ static int dprintf_formatf(
/* NOTE NOTE NOTE!! Not all sprintf implementations return number of
output characters */
(sprintf)(work, formatbuf, p->data.dnum);
-
+#ifdef CURLDEBUG
+ assert(strlen(work) <= sizeof(work));
+#endif
for(fptr=work; *fptr; fptr++)
OUTCHAR(*fptr);
}
diff --git a/tests/data/test557 b/tests/data/test557
index 8d0944a..ad9350f 100644
--- a/tests/data/test557
+++ b/tests/data/test557
@@ -40,6 +40,7 @@ All curl_mprintf() unsigned long tests OK!
All curl_mprintf() signed long tests OK!
All curl_mprintf() curl_off_t tests OK!
All curl_mprintf() strings tests OK!
+All float strings tests OK!
</stdout>
</verify>
diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c
index 683ca08..8c62a0e 100644
--- a/tests/libtest/lib557.c
+++ b/tests/libtest/lib557.c
@@ -1374,16 +1374,31 @@ static int test_curl_off_t_formatting(void)
return failed;
}
-static int string_check(char *buf, const char *buf2)
+static int _string_check(int linenumber, char *buf, const char *buf2)
{
if(strcmp(buf, buf2)) {
/* they shouldn't differ */
- printf("sprintf failed:\nwe '%s'\nsystem: '%s'\n",
- buf, buf2);
+ printf("sprintf line %d failed:\nwe '%s'\nsystem: '%s'\n",
+ linenumber, buf, buf2);
return 1;
}
return 0;
}
+#define string_check(x,y) _string_check(__LINE__, x, y)
+
+static int _strlen_check(int linenumber, char *buf, size_t len)
+{
+ size_t buflen = strlen(buf);
+ if(len != buflen) {
+ /* they shouldn't differ */
+ printf("sprintf strlen:%d failed:\nwe '%d'\nsystem: '%d'\n",
+ linenumber, buflen, len);
+ return 1;
+ }
+ return 0;
+}
+
+#define strlen_check(x,y) _strlen_check(__LINE__, x, y)
/*
* The output strings in this test need to have been verified with a system
@@ -1523,6 +1538,119 @@ static int test_weird_arguments(void)
return errors;
}
+/* DBL_MAX value from Linux */
+#define MAXIMIZE -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
+
+static int test_float_formatting(void)
+{
+ int errors = 0;
+ char buf[512]; /* larger than max float size */
+ curl_msnprintf(buf, sizeof(buf), "%f", 9.0);
+ errors += string_check(buf, "9.000000");
+
+ curl_msnprintf(buf, sizeof(buf), "%.1f", 9.1);
+ errors += string_check(buf, "9.1");
+
+ curl_msnprintf(buf, sizeof(buf), "%.2f", 9.1);
+ errors += string_check(buf, "9.10");
+
+ curl_msnprintf(buf, sizeof(buf), "%.0f", 9.1);
+ errors += string_check(buf, "9");
+
+ curl_msnprintf(buf, sizeof(buf), "%0f", 9.1);
+ errors += string_check(buf, "9.100000");
+
+ curl_msnprintf(buf, sizeof(buf), "%10f", 9.1);
+ errors += string_check(buf, " 9.100000");
+
+ curl_msnprintf(buf, sizeof(buf), "%10.3f", 9.1);
+ errors += string_check(buf, " 9.100");
+
+ curl_msnprintf(buf, sizeof(buf), "%-10.3f", 9.1);
+ errors += string_check(buf, "9.100 ");
+
+ curl_msnprintf(buf, sizeof(buf), "%-10.3f", 9.123456);
+ errors += string_check(buf, "9.123 ");
+
+ curl_msnprintf(buf, sizeof(buf), "%.-2f", 9.1);
+ errors += string_check(buf, "9.100000");
+
+ curl_msnprintf(buf, sizeof(buf), "%*f", 10, 9.1);
+ errors += string_check(buf, " 9.100000");
+
+ curl_msnprintf(buf, sizeof(buf), "%*f", 3, 9.1);
+ errors += string_check(buf, "9.100000");
+
+ curl_msnprintf(buf, sizeof(buf), "%*f", 6, 9.2987654);
+ errors += string_check(buf, "9.298765");
+
+ curl_msnprintf(buf, sizeof(buf), "%*f", 6, 9.298765);
+ errors += string_check(buf, "9.298765");
+
+ curl_msnprintf(buf, sizeof(buf), "%*f", 6, 9.29876);
+ errors += string_check(buf, "9.298760");
+
+ curl_msnprintf(buf, sizeof(buf), "%.*f", 6, 9.2987654);
+ errors += string_check(buf, "9.298765");
+ curl_msnprintf(buf, sizeof(buf), "%.*f", 5, 9.2987654);
+ errors += string_check(buf, "9.29877");
+ curl_msnprintf(buf, sizeof(buf), "%.*f", 4, 9.2987654);
+ errors += string_check(buf, "9.2988");
+ curl_msnprintf(buf, sizeof(buf), "%.*f", 3, 9.2987654);
+ errors += string_check(buf, "9.299");
+ curl_msnprintf(buf, sizeof(buf), "%.*f", 2, 9.2987654);
+ errors += string_check(buf, "9.30");
+ curl_msnprintf(buf, sizeof(buf), "%.*f", 1, 9.2987654);
+ errors += string_check(buf, "9.3");
+ curl_msnprintf(buf, sizeof(buf), "%.*f", 0, 9.2987654);
+ errors += string_check(buf, "9");
+
+ /* very large precisions easily turn into system specific outputs so we only
+ check the output buffer length here as we know the internal limit */
+
+ curl_msnprintf(buf, sizeof(buf), "%.*f", (1<<30), 9.2987654);
+ errors += strlen_check(buf, 325);
+
+ curl_msnprintf(buf, sizeof(buf), "%10000.10000f", 9.2987654);
+ errors += strlen_check(buf, 325);
+
+ curl_msnprintf(buf, sizeof(buf), "%240.10000f",
+ 123456789123456789123456789.2987654);
+ errors += strlen_check(buf, 325);
+
+ /* 1<<31 turns negative (-2147483648) when used signed */
+ curl_msnprintf(buf, sizeof(buf), "%*f", (1<<31), 9.1);
+ errors += string_check(buf, "9.100000");
+
+ /* curl_msnprintf() limits a single float output to 325 bytes maximum
+ width */
+ curl_msnprintf(buf, sizeof(buf), "%*f", (1<<30), 9.1);
+ errors += string_check(buf, " 9.100000");
+ curl_msnprintf(buf, sizeof(buf), "%100000f", 9.1);
+ errors += string_check(buf, " 9.100000");
+
+ curl_msnprintf(buf, sizeof(buf), "%f", MAXIMIZE);
+ errors += strlen_check(buf, 317);
+
+ curl_msnprintf(buf, 2, "%f", MAXIMIZE);
+ errors += strlen_check(buf, 1);
+ curl_msnprintf(buf, 3, "%f", MAXIMIZE);
+ errors += strlen_check(buf, 2);
+ curl_msnprintf(buf, 4, "%f", MAXIMIZE);
+ errors += strlen_check(buf, 3);
+ curl_msnprintf(buf, 5, "%f", MAXIMIZE);
+ errors += strlen_check(buf, 4);
+ curl_msnprintf(buf, 6, "%f", MAXIMIZE);
+ errors += strlen_check(buf, 5);
+
+ if(!errors)
+ printf("All float strings tests OK!\n");
+ else
+ printf("test_float_formatting Failed!\n");
+
+ return errors;
+}
+
int test(char *URL)
{
@@ -1547,6 +1675,8 @@ int test(char *URL)
errors += test_string_formatting();
+ errors += test_float_formatting();
+
if(errors)
return TEST_ERR_MAJOR_BAD;
else
--
2.7.4

View File

@ -0,0 +1,225 @@
From eb160abce0ac45a8e070d9fa995c61a416a58ddd Mon Sep 17 00:00:00 2001
From: Dan Fandrich <dan@coneharvesters.com>
Date: Sat, 11 Mar 2017 10:59:34 +0100
Subject: [PATCH 1/2] tool_writeout: fixed a buffer read overrun on --write-out
If a % ended the statement, the string's trailing NUL would be skipped
and memory past the end of the buffer would be accessed and potentially
displayed as part of the --write-out output. Added tests 1440 and 1441
to check for this kind of condition.
Reported-by: Brian Carpenter
Upstream-commit: 1890d59905414ab84a35892b2e45833654aa5c13
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/tool_writeout.c | 2 +-
tests/data/Makefile.inc | 2 +-
tests/data/test1440 | 31 +++++++++++++++++++++++++++++++
tests/data/test1441 | 31 +++++++++++++++++++++++++++++++
4 files changed, 64 insertions(+), 2 deletions(-)
create mode 100644 tests/data/test1440
create mode 100644 tests/data/test1441
diff --git a/src/tool_writeout.c b/src/tool_writeout.c
index 2fb7774..7843182 100644
--- a/src/tool_writeout.c
+++ b/src/tool_writeout.c
@@ -109,7 +109,7 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
double doubleinfo;
while(ptr && *ptr) {
- if('%' == *ptr) {
+ if('%' == *ptr && ptr[1]) {
if('%' == ptr[1]) {
/* an escaped %-letter */
fputc('%', stream);
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index 8251ab9..2e70895 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -148,7 +148,7 @@ test1408 test1409 test1410 test1411 test1412 test1413 test1414 test1415 \
test1416 test1417 test1418 test1419 test1420 test1421 test1422 test1423 \
test1424 \
test1428 test1429 test1430 test1431 test1432 test1433 test1434 test1435 \
-test1436 test1437 \
+test1436 test1437 test1440 test1441 \
\
test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \
diff --git a/tests/data/test1440 b/tests/data/test1440
new file mode 100644
index 0000000..7ed0c4d
--- /dev/null
+++ b/tests/data/test1440
@@ -0,0 +1,31 @@
+<testcase>
+<info>
+<keywords>
+--write-out
+</keywords>
+</info>
+# Server-side
+<reply>
+</reply>
+
+# Client-side
+<client>
+<server>
+file
+</server>
+
+<name>
+Check --write-out with trailing %{
+</name>
+<command>
+file://localhost/%PWD/log/ --write-out '%{'
+</command>
+</client>
+
+# Verify data
+<verify>
+<stdout nonewline="yes">
+%{
+</stdout>
+</verify>
+</testcase>
diff --git a/tests/data/test1441 b/tests/data/test1441
new file mode 100644
index 0000000..6e253a6
--- /dev/null
+++ b/tests/data/test1441
@@ -0,0 +1,31 @@
+<testcase>
+<info>
+<keywords>
+--write-out
+</keywords>
+</info>
+# Server-side
+<reply>
+</reply>
+
+# Client-side
+<client>
+<server>
+file
+</server>
+
+<name>
+Check --write-out with trailing %
+</name>
+<command>
+file://localhost/%PWD/log/ --write-out '%'
+</command>
+</client>
+
+# Verify data
+<verify>
+<stdout nonewline="yes">
+%
+</stdout>
+</verify>
+</testcase>
--
2.9.3
From 67bee1434a17065da7db3fc2915c494f289f46de Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Fri, 24 Mar 2017 10:14:21 +0100
Subject: [PATCH 2/2] curl: check for end of input in writeout backslash
handling
Reported-by: Brian Carpenter
Added test 1442 to verify
Upstream-commit: 8e65877870c1fac920b65219adec720df810aab9
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/tool_writeout.c | 4 ++--
tests/data/Makefile.inc | 2 +-
tests/data/test1442 | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 38 insertions(+), 3 deletions(-)
create mode 100644 tests/data/test1442
diff --git a/src/tool_writeout.c b/src/tool_writeout.c
index 7843182..5d92bd2 100644
--- a/src/tool_writeout.c
+++ b/src/tool_writeout.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -320,7 +320,7 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
}
}
}
- else if('\\' == *ptr) {
+ else if('\\' == *ptr && ptr[1]) {
switch(ptr[1]) {
case 'r':
fputc('\r', stream);
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index 2e70895..267ff6a 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -148,7 +148,7 @@ test1408 test1409 test1410 test1411 test1412 test1413 test1414 test1415 \
test1416 test1417 test1418 test1419 test1420 test1421 test1422 test1423 \
test1424 \
test1428 test1429 test1430 test1431 test1432 test1433 test1434 test1435 \
-test1436 test1437 test1440 test1441 \
+test1436 test1437 test1440 test1441 test1442 \
\
test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \
diff --git a/tests/data/test1442 b/tests/data/test1442
new file mode 100644
index 0000000..255a4c9
--- /dev/null
+++ b/tests/data/test1442
@@ -0,0 +1,35 @@
+<testcase>
+<info>
+<keywords>
+--write-out
+FILE
+</keywords>
+</info>
+# Server-side
+<reply>
+</reply>
+
+# Client-side
+<client>
+<server>
+file
+</server>
+
+<name>
+Check --write-out with trailing \
+</name>
+<command>
+file://localhost/%PWD/log/non-existent-file.txt --write-out '\'
+</command>
+</client>
+
+# Verify data
+<verify>
+<errorcode>
+37
+</errorcode>
+<stdout nonewline="yes">
+\
+</stdout>
+</verify>
+</testcase>
--
2.9.3

View File

@ -0,0 +1,65 @@
From e7e5ada376af33d00b75c1f80f4b2d0438cb91f6 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Sun, 25 Dec 2016 11:01:17 +0100
Subject: [PATCH] docs/ciphers: link to our own new page about ciphers
... as the former ones always go stale!
Upstream-commit: 209b2302272b86c2bbe4d3d2b62e1695655f8670
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
docs/curl.1 | 6 +-----
docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.3 | 8 ++------
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/docs/curl.1 b/docs/curl.1
index 05d1a8d..915e3d1 100644
--- a/docs/curl.1
+++ b/docs/curl.1
@@ -292,11 +292,7 @@ If this option is used several times, the last one will be used.
.IP "--ciphers <list of ciphers>"
(SSL) Specifies which ciphers to use in the connection. The list of ciphers
must specify valid ciphers. Read up on SSL cipher list details on this URL:
-\fIhttps://www.openssl.org/docs/apps/ciphers.html\fP
-
-NSS ciphers are done differently than OpenSSL and GnuTLS. The full list of NSS
-ciphers is in the NSSCipherSuite entry at this URL:
-\fIhttps://git.fedorahosted.org/cgit/mod_nss.git/plain/docs/mod_nss.html#Directives\fP
+\fIhttps://curl.haxx.se/docs/ssl-ciphers.html\fP
If this option is used several times, the last one will be used.
.IP "--compressed"
diff --git a/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.3 b/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.3
index 71833b5..f6b9459 100644
--- a/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.3
+++ b/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -40,16 +40,12 @@ compile OpenSSL.
You'll find more details about cipher lists on this URL:
- https://www.openssl.org/docs/apps/ciphers.html
+ https://curl.haxx.se/docs/ssl-ciphers.html
For NSS, valid examples of cipher lists include 'rsa_rc4_128_md5',
\'rsa_aes_128_sha\', etc. With NSS you don't add/remove ciphers. If one uses
this option then all known ciphers are disabled and only those passed in are
enabled.
-
-You'll find more details about the NSS cipher lists on this URL:
-
- http://git.fedorahosted.org/cgit/mod_nss.git/plain/docs/mod_nss.html#Directives
.SH DEFAULT
NULL, use internal default
.SH PROTOCOLS
--
2.9.4

View File

@ -0,0 +1,104 @@
From fe9bc87820bd2afa72d014d5316b0287e70587e6 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Thu, 20 Jul 2017 08:05:59 +0200
Subject: [PATCH 1/2] nss: unify the coding style of nss_send() and nss_recv()
No changes in behavior intended by this commit.
Upstream-commit: c89eb6d0f87a3620074bc04a6af255e5dc3a523e
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/vtls/nss.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c
index 4e5f4b3..ab4ddff 100644
--- a/lib/vtls/nss.c
+++ b/lib/vtls/nss.c
@@ -2013,8 +2013,10 @@ static ssize_t nss_send(struct connectdata *conn, /* connection data */
size_t len, /* amount to write */
CURLcode *curlcode)
{
- ssize_t rc = PR_Send(conn->ssl[sockindex].handle, mem, (int)len, 0,
- PR_INTERVAL_NO_WAIT);
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ ssize_t rc;
+
+ rc = PR_Send(connssl->handle, mem, (int)len, 0, PR_INTERVAL_NO_WAIT);
if(rc < 0) {
PRInt32 err = PR_GetError();
if(err == PR_WOULD_BLOCK_ERROR)
@@ -2038,14 +2040,17 @@ static ssize_t nss_send(struct connectdata *conn, /* connection data */
return rc; /* number of bytes */
}
-static ssize_t nss_recv(struct connectdata * conn, /* connection data */
- int num, /* socketindex */
+static ssize_t nss_recv(struct connectdata *conn, /* connection data */
+ int sockindex, /* socketindex */
char *buf, /* store read data here */
size_t buffersize, /* max amount to read */
CURLcode *curlcode)
{
- ssize_t nread = PR_Recv(conn->ssl[num].handle, buf, (int)buffersize, 0,
- PR_INTERVAL_NO_WAIT);
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ ssize_t nread;
+
+ nread = PR_Recv(connssl->handle, buf, (int)buffersize, 0,
+ PR_INTERVAL_NO_WAIT);
if(nread < 0) {
/* failed SSL read */
PRInt32 err = PR_GetError();
--
2.9.4
From f6c464a55a2319901c4f22d0d65cc437f691f55c Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 19 Jul 2017 18:02:26 +0200
Subject: [PATCH 2/2] nss: fix a possible use-after-free in SelectClientCert()
... causing a SIGSEGV in showit() in case the handle used to initiate
the connection has already been freed.
This commit fixes a bug introduced in curl-7_19_5-204-g5f0cae803.
Reported-by: Rob Sanders
Bug: https://bugzilla.redhat.com/1436158
Upstream-commit: 42a4cd4c78b3feb5ca07286479129116e125a730
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/vtls/nss.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c
index ab4ddff..4c90400 100644
--- a/lib/vtls/nss.c
+++ b/lib/vtls/nss.c
@@ -2016,6 +2016,10 @@ static ssize_t nss_send(struct connectdata *conn, /* connection data */
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
ssize_t rc;
+ /* The SelectClientCert() hook uses this for infof() and failf() but the
+ handle stored in nss_setup_connect() could have already been freed. */
+ connssl->data = conn->data;
+
rc = PR_Send(connssl->handle, mem, (int)len, 0, PR_INTERVAL_NO_WAIT);
if(rc < 0) {
PRInt32 err = PR_GetError();
@@ -2049,6 +2053,10 @@ static ssize_t nss_recv(struct connectdata *conn, /* connection data */
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
ssize_t nread;
+ /* The SelectClientCert() hook uses this for infof() and failf() but the
+ handle stored in nss_setup_connect() could have already been freed. */
+ connssl->data = conn->data;
+
nread = PR_Recv(connssl->handle, buf, (int)buffersize, 0,
PR_INTERVAL_NO_WAIT);
if(nread < 0) {
--
2.9.4

View File

@ -0,0 +1,95 @@
From 8846a6507283f2bfe439cc3679ac81aca5ee3447 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Tue, 1 Aug 2017 17:16:07 +0200
Subject: [PATCH] glob: do not continue parsing after a strtoul() overflow
range
Added test 1289 to verify.
CVE-2017-1000101
Bug: https://curl.haxx.se/docs/adv_20170809A.html
Reported-by: Brian Carpenter
Upstream-commit: 453e7a7a03a2cec749abd3878a48e728c515cca7
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/tool_urlglob.c | 5 ++++-
tests/data/Makefile.inc | 2 +-
tests/data/test1289 | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 2 deletions(-)
create mode 100644 tests/data/test1289
diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c
index d002f27..caf2385 100644
--- a/src/tool_urlglob.c
+++ b/src/tool_urlglob.c
@@ -269,7 +269,10 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
}
errno = 0;
max_n = strtoul(pattern, &endp, 10);
- if(errno || (*endp == ':')) {
+ if(errno)
+ /* overflow */
+ endp = NULL;
+ else if(*endp == ':') {
pattern = endp+1;
errno = 0;
step_n = strtoul(pattern, &endp, 10);
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index ecfedc9..be69e7c 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -128,7 +128,7 @@ test1220 test1221 test1222 test1223 test1224 test1225 test1226 test1227 \
test1228 test1229 test1230 test1231 test1232 test1233 test1234 test1235 \
test1236 test1237 test1238 test1239 test1240 test1241 test1242 test1243 \
test1244 test1245 test1246 \
-\
+test1289 \
test1300 test1301 test1302 test1303 test1304 test1305 test1306 test1307 \
test1308 test1309 test1310 test1311 test1312 test1313 test1314 test1315 \
test1316 test1317 test1318 test1319 test1320 test1321 test1322 \
diff --git a/tests/data/test1289 b/tests/data/test1289
new file mode 100644
index 0000000..d679cc0
--- /dev/null
+++ b/tests/data/test1289
@@ -0,0 +1,35 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+globbing
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+<name>
+globbing with overflow and bad syntxx
+</name>
+<command>
+http://ur%20[0-60000000000000000000
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+# curl: (3) [globbing] bad range in column
+<errorcode>
+3
+</errorcode>
+</verify>
+</testcase>
--
2.9.4

View File

@ -0,0 +1,49 @@
From d30858296331b3ab1dc57043eef66fddf87637c3 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Tue, 1 Aug 2017 17:16:46 +0200
Subject: [PATCH] tftp: reject file name lengths that don't fit
... and thereby avoid telling send() to send off more bytes than the
size of the buffer!
CVE-2017-1000100
Bug: https://curl.haxx.se/docs/adv_20170809B.html
Reported-by: Even Rouault
Credit to OSS-Fuzz for the discovery
Upstream-commit: 358b2b131ad6c095696f20dcfa62b8305263f898
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/tftp.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/tftp.c b/lib/tftp.c
index f2f8347..92b3edf 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -490,6 +490,11 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
if(result)
return result;
+ if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
+ failf(data, "TFTP file name too long\n");
+ return CURLE_TFTP_ILLEGAL; /* too long file name field */
+ }
+
snprintf((char *)state->spacket.data+2,
state->blksize,
"%s%c%s%c", filename, '\0', mode, '\0');
--
2.9.4

View File

@ -1,7 +1,7 @@
Summary: A utility for getting files from remote servers (FTP, HTTP, and others)
Name: curl
Version: 7.51.0
Release: 3%{?dist}
Release: 9%{?dist}
License: MIT
Group: Applications/Internet
Source: http://curl.haxx.se/download/%{name}-%{version}.tar.lzma
@ -15,6 +15,24 @@ Patch2: 0002-curl-7.51.0-file-host.patch
# map CURL_SSLVERSION_DEFAULT to NSS default, add support for TLS 1.3 (#1396719)
Patch3: 0003-curl-7.51.0-tls-version.patch
# fix floating point buffer overflow issues (CVE-2016-9586)
Patch4: 0004-curl-7.51.0-CVE-2016-9586.patch
# fix out of bounds read in curl --write-out (CVE-2017-7407)
Patch5: 0005-curl-7.51.0-CVE-2017-7407.patch
# fix links to documentation of TLS cipher-suites (#1463532)
Patch6: 0006-curl-7.51.0-ciphers-man-page.patch
# nss: fix a possible use-after-free in SelectClientCert() (#1436158)
Patch7: 0007-curl-7.54.1-nss-cc-use-after-free.patch
# do not continue parsing of glob after range overflow (CVE-2017-1000101)
Patch9: 0009-curl-7.54.1-CVE-2017-1000101.patch
# tftp: reject file name lengths that do not fit buffer (CVE-2017-1000100)
Patch10: 0010-curl-7.54.1-CVE-2017-1000100.patch
# patch making libcurl multilib ready
Patch101: 0101-curl-7.32.0-multilib.patch
@ -27,6 +45,7 @@ Patch104: 0104-curl-7.19.7-localhost6.patch
Provides: webclient
URL: http://curl.haxx.se/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -nu)
BuildRequires: automake
BuildRequires: groff
BuildRequires: krb5-devel
BuildRequires: libidn2-devel
@ -93,7 +112,7 @@ Requires: libssh2%{?_isa} >= %{libssh2_version}
# libnsspem.so is no longer included in the nss package (#1347336)
BuildRequires: nss-pem
Requires: nss-pem
Requires: nss-pem%{?_isa}
%description -n libcurl
libcurl is a free and easy-to-use client-side URL transfer library, supporting
@ -134,12 +153,22 @@ documentation of the library, too.
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch9 -p1
%patch10 -p1
# Fedora patches
%patch101 -p1
%patch102 -p1
%patch104 -p1
# regenerate Makefile.in files
aclocal -I m4
automake
# disable test 1112 (#565305) and test 1801
# <https://github.com/bagder/curl/commit/21e82bd6#commitcomment-12226582>
printf "1112\n1801\n" >> tests/data/DISABLED
@ -241,6 +270,25 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/aclocal/libcurl.m4
%changelog
* Wed Aug 09 2017 Kamil Dudka <kdudka@redhat.com> 7.51.0-9
- tftp: reject file name lengths that do not fit buffer (CVE-2017-1000100)
- do not continue parsing of glob after range overflow (CVE-2017-1000101)
* Thu Jul 20 2017 Kamil Dudka <kdudka@redhat.com> 7.51.0-8
- nss: fix a possible use-after-free in SelectClientCert() (#1436158)
* Wed Jun 21 2017 Kamil Dudka <kdudka@redhat.com> 7.51.0-7
- fix links to documentation of TLS cipher-suites (#1463532)
* Fri Apr 07 2017 Kamil Dudka <kdudka@redhat.com> 7.51.0-6
- fix out of bounds read in curl --write-out (CVE-2017-7407)
* Tue Apr 04 2017 Kamil Dudka <kdudka@redhat.com> 7.51.0-5
- make the dependency on nss-pem arch-specific (#1428550)
* Fri Dec 23 2016 Kamil Dudka <kdudka@redhat.com> 7.51.0-4
- fix floating point buffer overflow issues (CVE-2016-9586)
* Mon Nov 21 2016 Kamil Dudka <kdudka@redhat.com> 7.51.0-3
- map CURL_SSLVERSION_DEFAULT to NSS default, add support for TLS 1.3 (#1396719)