HTTPClient

Fork of HTTPClient by Donatien Garnier

Files at this revision

API Documentation at this revision

Comitter:
fangbao
Date:
Fri Oct 10 09:41:01 2014 +0000
Parent:
18:277279a1891e
Commit message:
Fix an issue: the server might send back "Access-Control-Allow-Credentials: true" in the Response Headers. The length of the key in that header is 33 bytes, which is larger than the size of the 'key' buffer (32 bytes).

Changed in this revision

HTTPClient.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/HTTPClient.cpp	Wed May 07 16:48:10 2014 +0000
+++ b/HTTPClient.cpp	Fri Oct 10 09:41:01 2014 +0000
@@ -41,6 +41,7 @@
 #define MAX(x,y) (((x)>(y))?(x):(y))
 
 #define CHUNK_SIZE 256
+#define KEYVALUE_SIZE 48
 
 #include <cstring>
 
@@ -364,14 +365,14 @@
 
     buf[crlfPos] = '\0';
 
-    char key[32];
-    char value[32];
+    char key[KEYVALUE_SIZE];
+    char value[KEYVALUE_SIZE];
 
     //key[31] = '\0';
     //value[31] = '\0';
 
-    memset(key, 0, 32);
-    memset(value, 0, 32);
+    memset(key, 0, KEYVALUE_SIZE);
+    memset(value, 0, KEYVALUE_SIZE);
 
     //int n = sscanf(buf, "%31[^:]: %31[^\r\n]", key, value);
     
@@ -381,14 +382,14 @@
     if(keyEnd != NULL)
     {
       *keyEnd = '\0';
-      if(strlen(buf) < 32)
+      if(strlen(buf) < KEYVALUE_SIZE)
       {
         strcpy(key, buf);
         n++;
         char* valueStart = keyEnd + 2;
         if( (valueStart - buf) < crlfPos )
         {
-          if(strlen(valueStart) < 32)
+          if(strlen(valueStart) < KEYVALUE_SIZE)
           { 
             strcpy(value, valueStart);
             n++;