miniupnpc: Fix CVE-2017-8798

Thanks to tin/Team OSTStrom
This commit is contained in:
Thomas Bernard 2017-05-09 12:00:47 +02:00
parent 086c387924
commit f0f1f4b22d
2 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,9 @@
$Id: Changelog.txt,v 1.226 2016/12/16 08:57:19 nanard Exp $ $Id: Changelog.txt,v 1.226 2016/12/16 08:57:19 nanard Exp $
miniUPnP client Changelog. miniUPnP client Changelog.
2017/05/05:
Fix CVE-2017-8798 Thanks to tin/Team OSTStrom
2016/11/11: 2016/11/11:
check strlen before memcmp in XML parsing portlistingparse.c check strlen before memcmp in XML parsing portlistingparse.c
fix build under SOLARIS and CYGWIN fix build under SOLARIS and CYGWIN

View File

@ -284,11 +284,12 @@ getHTTPResponse(int s, int * size, int * status_code)
goto end_of_stream; goto end_of_stream;
} }
} }
bytestocopy = ((int)chunksize < (n - i))?chunksize:(unsigned int)(n - i); /* it is guaranteed that (n >= i) */
bytestocopy = (chunksize < (unsigned int)(n - i))?chunksize:(unsigned int)(n - i);
if((content_buf_used + bytestocopy) > content_buf_len) if((content_buf_used + bytestocopy) > content_buf_len)
{ {
char * tmp; char * tmp;
if(content_length >= (int)(content_buf_used + bytestocopy)) { if((content_length >= 0) && ((unsigned int)content_length >= (content_buf_used + bytestocopy))) {
content_buf_len = content_length; content_buf_len = content_length;
} else { } else {
content_buf_len = content_buf_used + bytestocopy; content_buf_len = content_buf_used + bytestocopy;
@ -313,14 +314,15 @@ getHTTPResponse(int s, int * size, int * status_code)
{ {
/* not chunked */ /* not chunked */
if(content_length > 0 if(content_length > 0
&& (int)(content_buf_used + n) > content_length) { && (content_buf_used + n) > (unsigned int)content_length) {
/* skipping additional bytes */ /* skipping additional bytes */
n = content_length - content_buf_used; n = content_length - content_buf_used;
} }
if(content_buf_used + n > content_buf_len) if(content_buf_used + n > content_buf_len)
{ {
char * tmp; char * tmp;
if(content_length >= (int)(content_buf_used + n)) { if(content_length >= 0
&& (unsigned int)content_length >= (content_buf_used + n)) {
content_buf_len = content_length; content_buf_len = content_length;
} else { } else {
content_buf_len = content_buf_used + n; content_buf_len = content_buf_used + n;
@ -340,7 +342,7 @@ getHTTPResponse(int s, int * size, int * status_code)
} }
} }
/* use the Content-Length header value if available */ /* use the Content-Length header value if available */
if(content_length > 0 && (int)content_buf_used >= content_length) if(content_length > 0 && content_buf_used >= (unsigned int)content_length)
{ {
#ifdef DEBUG #ifdef DEBUG
printf("End of HTTP content\n"); printf("End of HTTP content\n");