-fix html detection
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Tue, 12 Jun 2012 16:37:56 +0000 (16:37 +0000)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Tue, 12 Jun 2012 16:37:56 +0000 (16:37 +0000)
src/gns/gnunet-gns-proxy.c

index 65139beb4cb0f966a857c3e3907a9d63e600358b..c99010dc44d9b6b459feb7408af1d8ee3e6723e0 100644 (file)
@@ -40,7 +40,7 @@
 /* MHD/cURL defines */
 #define BUF_WAIT_FOR_CURL 0
 #define BUF_WAIT_FOR_MHD 1
-#define HTML_HDR_CONTENT "Content-Type: text/html\r\n"
+#define HTML_HDR_CONTENT "Content-Type: text/html"
 
 /* regexp */
 //#define RE_DOTPLUS "<a href=\"http://(([A-Za-z]+[.])+)([+])"
@@ -373,10 +373,14 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
 {
   size_t bytes = size * nmemb;
   struct ProxyCurlTask *ctask = cls;
-  char hdr[bytes+1];
+  int len = strlen (HTML_HDR_CONTENT);
+  char hdr[len+1];
+  
+  if ( (len+1) > bytes)
+    return bytes;
 
-  memcpy (hdr, buffer, bytes);
-  hdr[bytes] = '\0';
+  memcpy (hdr, buffer, len);
+  hdr[len] = '\0';
 
   if (0 == strcmp (hdr, HTML_HDR_CONTENT))
   {