changeset 1049:c2317cfb99ec

Fix parsing of long FastCGI lengths
author Adam Chlipala <adamc@hcoop.net>
date Thu, 26 Nov 2009 10:35:57 -0500
parents 38411c2cd363
children 93315ac00394
files src/c/fastcgi.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/c/fastcgi.c	Wed Nov 25 09:48:23 2009 -0500
+++ b/src/c/fastcgi.c	Thu Nov 26 10:35:57 2009 -0500
@@ -223,7 +223,7 @@
   else if (*len < 4)
     return -1;
   else {
-    int r = (((*buf)[3] & 0x7f) << 24) + ((*buf)[2] << 16) + ((*buf)[1] << 8) + (*buf)[0];
+    int r = (((*buf)[0] & 0x7f) << 24) + ((*buf)[1] << 16) + ((*buf)[2] << 8) + (*buf)[3];
     *buf += 4;
     *len -= 4;
     return r;
@@ -236,9 +236,9 @@
   if ((nameLength = read_funny_len(buf, &len)) < 0)
     return -1;
   if ((valueLength = read_funny_len(buf, &len)) < 0)
-    return -1;
+    return -2;
   if (len < nameLength + valueLength)
-    return -1;
+    return -3;
 
   if (nameLength+1 > nv->name_len) {
     nv->name_len = nameLength+1;
@@ -374,7 +374,7 @@
           goto done;
         }
 
-        write_stderr(out, "PARAM: %s -> %s\n", hs.nvps[used_nvps].name, hs.nvps[used_nvps].value);
+        //write_stderr(out, "PARAM: %s -> %s\n", hs.nvps[used_nvps].name, hs.nvps[used_nvps].value);
 
         ++used_nvps;
       }