]> granicus.if.org Git - curl/commitdiff
fix Content-Length validation
authorYang Tse <yangsita@gmail.com>
Tue, 16 Feb 2010 11:17:00 +0000 (11:17 +0000)
committerYang Tse <yangsita@gmail.com>
Tue, 16 Feb 2010 11:17:00 +0000 (11:17 +0000)
tests/server/rtspd.c
tests/server/sws.c

index c10b829aa16a7eaab7a6aae80c5298fc63e5b6ba..56111bd262c41d2b35fa572694943e48ad8f4d09 100644 (file)
@@ -581,10 +581,12 @@ static int ProcessRequest(struct httprequest *req)
       char *endptr;
       char *ptr = line + 15;
       unsigned long clen = 0;
-      while(*ptr && (' ' == *ptr))
+      while(*ptr && ISSPACE(*ptr))
         ptr++;
+      endptr = ptr;
+      SET_ERRNO(0);
       clen = strtoul(ptr, &endptr, 10);
-      if((ptr == endptr) || ERRNO) {
+      if((ptr == endptr) || !ISSPACE(*endptr) || (ERANGE == ERRNO)) {
         /* this assumes that a zero Content-Length is valid */
         logmsg("Found invalid Content-Length: (%s) in the request", ptr);
         req->open = FALSE; /* closes connection */
index b12b670b574b739a6cc23c6b92235aa4d3c9af1a..42446a9ac206529390b7cd0dc407a886f829a792 100644 (file)
@@ -500,10 +500,12 @@ static int ProcessRequest(struct httprequest *req)
       char *endptr;
       char *ptr = line + 15;
       unsigned long clen = 0;
-      while(*ptr && (' ' == *ptr))
+      while(*ptr && ISSPACE(*ptr))
         ptr++;
+      endptr = ptr;
+      SET_ERRNO(0);
       clen = strtoul(ptr, &endptr, 10);
-      if((ptr == endptr) || ERRNO) {
+      if((ptr == endptr) || !ISSPACE(*endptr) || (ERANGE == ERRNO)) {
         /* this assumes that a zero Content-Length is valid */
         logmsg("Found invalid Content-Length: (%s) in the request", ptr);
         req->open = FALSE; /* closes connection */