upnphttp: ParseHttpHeaders() checks atoi() return

atoi() can return a negative value, and that can lead to problems
later
This commit is contained in:
Thomas Bernard 2013-01-27 21:07:40 +01:00
parent 60d1db157a
commit 3b5eacb3ae
1 changed files with 4 additions and 0 deletions

View File

@ -92,6 +92,10 @@ ParseHttpHeaders(struct upnphttp * h)
while(*p < '0' || *p > '9')
p++;
h->req_contentlen = atoi(p);
if(h->req_contentlen < 0) {
syslog(LOG_WARNING, "ParseHttpHeaders() invalid Content-Length %d", h->req_contentlen);
h->req_contentlen = 0;
}
/*printf("*** Content-Lenght = %d ***\n", h->req_contentlen);
printf(" readbufflen=%d contentoff = %d\n",
h->req_buflen, h->req_contentoff);*/