gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r31762 - in libmicrohttpd/src: examples microspdy testspdy


From: gnunet
Subject: [GNUnet-SVN] r31762 - in libmicrohttpd/src: examples microspdy testspdy
Date: Sat, 28 Dec 2013 19:43:28 +0100

Author: andreyu
Date: 2013-12-28 19:43:28 +0100 (Sat, 28 Dec 2013)
New Revision: 31762

Modified:
   libmicrohttpd/src/examples/spdy_fileserver.c
   libmicrohttpd/src/microspdy/structures.c
   libmicrohttpd/src/testspdy/test_struct_namevalue.c
Log:
spdy: fixed bug when adding header with NULL value

Modified: libmicrohttpd/src/examples/spdy_fileserver.c
===================================================================
--- libmicrohttpd/src/examples/spdy_fileserver.c        2013-12-28 14:40:26 UTC 
(rev 31761)
+++ libmicrohttpd/src/examples/spdy_fileserver.c        2013-12-28 18:43:28 UTC 
(rev 31762)
@@ -44,18 +44,24 @@
        
 #define GET_MIME_TYPE(fname, mime)     do {\
                unsigned int __len = strlen(fname);\
-               if (__len < 4 || '.' != (fname)[__len - 4]) break;\
-               const char * __ext = &(fname)[__len - 3];\
-               if(0 == strcmp(__ext, "jpg")) (mime) = strdup("image/jpeg");\
-               else if(0 == strcmp(__ext, "png")) (mime) = 
strdup("image/png");\
-               else if(0 == strcmp(__ext, "css")) (mime) = strdup("text/css");\
-               else if(0 == strcmp(__ext, "gif")) (mime) = 
strdup("image/gif");\
-               else if(0 == strcmp(__ext, "htm")) (mime) = 
strdup("text/html");\
-               else \
+               if (__len < 4 || '.' != (fname)[__len - 4]) \
                {       \
                        (mime) = strdup("application/octet-stream");\
                        printf("MIME for %s is applic...\n", (fname));\
                }\
+    else {\
+      const char * __ext = &(fname)[__len - 3];\
+      if(0 == strcmp(__ext, "jpg")) (mime) = strdup("image/jpeg");\
+      else if(0 == strcmp(__ext, "png")) (mime) = strdup("image/png");\
+      else if(0 == strcmp(__ext, "css")) (mime) = strdup("text/css");\
+      else if(0 == strcmp(__ext, "gif")) (mime) = strdup("image/gif");\
+      else if(0 == strcmp(__ext, "htm")) (mime) = strdup("text/html");\
+      else \
+      {        \
+        (mime) = strdup("application/octet-stream");\
+        printf("MIME for %s is applic...\n", (fname));\
+      }\
+    }\
                if(NULL == (mime))\
                {\
                        printf("no memory\n");\

Modified: libmicrohttpd/src/microspdy/structures.c
===================================================================
--- libmicrohttpd/src/microspdy/structures.c    2013-12-28 14:40:26 UTC (rev 
31761)
+++ libmicrohttpd/src/microspdy/structures.c    2013-12-28 18:43:28 UTC (rev 
31762)
@@ -64,8 +64,10 @@
        char **temp_value;
        char *temp_string;
        
-       if(NULL == container || NULL == name || 0 == (len = strlen(name)))
+       if(NULL == container || NULL == name || NULL == value || 0 == (len = 
strlen(name)))
                return SPDY_INPUT_ERROR;
+  //TODO there is old code handling value==NULL
+  //update it to handle strlen(value)==0
                
        for(i=0; i<len; ++i)
        {
@@ -85,7 +87,9 @@
                        free(container->name);
                        return SPDY_NO;
                }
-               if (NULL == (container->value[0] = strdup (value)))
+    /*if(NULL == value)
+      container->value[0] = NULL;
+               else */if (NULL == (container->value[0] = strdup (value)))
                {
                        free(container->value);
                        free(container->name);
@@ -125,7 +129,9 @@
                        free(pair);
                        return SPDY_NO;
                }
-               if (NULL == (pair->value[0] = strdup (value)))
+    /*if(NULL == value)
+      pair->value[0] = NULL;
+               else */if (NULL == (pair->value[0] = strdup (value)))
                {
                        free(pair->value);
                        free(pair->name);
@@ -477,6 +483,8 @@
 
       for(i=0; i<iterator->num_values; ++i)
       {
+        //if(NULL == iterator->value[i])
+        //  continue;
         size += strlen(iterator->value[i]); // string
         if(i/* || !strlen(iterator->value[i])*/) ++size; //NULL separator
       }
@@ -518,8 +526,11 @@
           ++offset;
           //if(!i) continue;
         }
-        strncpy(*stream + offset, iterator->value[i], 
strlen(iterator->value[i]));
-        offset += strlen(iterator->value[i]);
+        //else if(NULL != iterator->value[i])
+        //{
+          strncpy(*stream + offset, iterator->value[i], 
strlen(iterator->value[i]));
+          offset += strlen(iterator->value[i]);
+        //}
       }
       value_size = offset - value_offset - 4;
       value_size = htonl(value_size);

Modified: libmicrohttpd/src/testspdy/test_struct_namevalue.c
===================================================================
--- libmicrohttpd/src/testspdy/test_struct_namevalue.c  2013-12-28 14:40:26 UTC 
(rev 31761)
+++ libmicrohttpd/src/testspdy/test_struct_namevalue.c  2013-12-28 18:43:28 UTC 
(rev 31762)
@@ -165,7 +165,7 @@
        SPDY_name_value_destroy(container);
        
        //check everything with NULL values
-       for(i=0; i<6; ++i)
+       for(i=0; i<7; ++i)
        {
                printf("%i ",i);
                ob1 = (i & 4) ? data : NULL;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]