Blob Blame History Raw
--- greenbone-security-assistant-6.0.11.libmicrohttpd/src/gsad.c	2016-09-05 23:17:14.795923529 +0200
+++ greenbone-security-assistant-6.0.11/src/gsad.c	2016-09-05 23:33:14.846076112 +0200
@@ -170,6 +170,15 @@
  " frame-ancestors *"
 
 /**
+ * @brief Compatibility for MHD versions <= 0.9.33 as needed for EPEL7-
+ */
+#ifndef MHD_HTTP_NOT_ACCEPTABLE
+#ifdef MHD_HTTP_METHOD_NOT_ACCEPTABLE
+#define MHD_HTTP_NOT_ACCEPTABLE MHD_HTTP_METHOD_NOT_ACCEPTABLE
+#endif
+#endif
+
+/**
  * @brief Add content security headers to a MHD response.
  */
 #define ADD_CONTENT_SECURITY_HEADERS(response)                                \
@@ -3210,8 +3219,8 @@
   size_t size = (content_length ? content_length : strlen (content));
   int ret;
 
-  response = MHD_create_response_from_data (size, (void *) content,
-                                            MHD_NO, MHD_YES);
+  response = MHD_create_response_from_buffer (size, (void *) content,
+                                            MHD_RESPMEM_MUST_COPY);
   gsad_add_content_type_header (response, &content_type);
 
   if (content_disposition)
@@ -3267,8 +3276,7 @@
   body = g_strdup_printf ("<html><body>Code 303 - Redirecting to"
                           " <a href=\"%s\">%s<a/></body></html>\n",
                           uri, uri);
-  response = MHD_create_response_from_data (strlen (body), body, MHD_NO,
-                                            MHD_YES);
+  response = MHD_create_response_from_buffer (strlen (body), body, MHD_RESPMEM_MUST_COPY);
   g_free (body);
 
   if (!response)
@@ -3388,7 +3396,7 @@
   /* Only accept GET and POST methods and send ERROR_PAGE in other cases. */
   if (strcmp (method, "GET") && strcmp (method, "POST"))
     {
-      send_response (connection, ERROR_PAGE, MHD_HTTP_METHOD_NOT_ACCEPTABLE,
+      send_response (connection, ERROR_PAGE, MHD_HTTP_NOT_ACCEPTABLE,
                      NULL, GSAD_CONTENT_TYPE_TEXT_HTML, NULL, 0);
       return MHD_YES;
     }
@@ -3518,8 +3526,8 @@
           g_free (language);
           res = xsl_transform (xml);
         }
-      response = MHD_create_response_from_data (strlen (res), res,
-                                                MHD_NO, MHD_YES);
+      response = MHD_create_response_from_buffer (strlen (res), res,
+                                                MHD_RESPMEM_MUST_COPY);
       g_free (path);
       g_free (xml);
       g_free (res);
@@ -3534,10 +3542,9 @@
       tracef ("File %s failed, ", path);
       g_free (path);
 
-      return MHD_create_response_from_data (strlen (FILE_NOT_FOUND),
+      return MHD_create_response_from_buffer (strlen (FILE_NOT_FOUND),
                                             (void *) FILE_NOT_FOUND,
-                                            MHD_NO,
-                                            MHD_YES);
+                                            MHD_RESPMEM_MUST_COPY);
     }
 
   /* Guess content type. */
@@ -3574,8 +3581,8 @@
                                 NULL);
       g_free (path);
       fclose (file);
-      ret = MHD_create_response_from_data (strlen (res), (void *) res,
-                                           MHD_NO, MHD_YES);
+      ret = MHD_create_response_from_buffer (strlen (res), (void *) res,
+                                           MHD_RESPMEM_MUST_COPY);
       g_free (res);
       return ret;
     }
@@ -3785,7 +3792,7 @@
   /* Only accept GET and POST methods and send ERROR_PAGE in other cases. */
   if (strcmp (method, "GET") && strcmp (method, "POST"))
     {
-      send_response (connection, ERROR_PAGE, MHD_HTTP_METHOD_NOT_ACCEPTABLE,
+      send_response (connection, ERROR_PAGE, MHD_HTTP_NOT_ACCEPTABLE,
                      NULL, GSAD_CONTENT_TYPE_TEXT_HTML, NULL, 0);
       return MHD_YES;
     }
@@ -3958,8 +3965,8 @@
               res = xsl_transform (xml);
               g_free (xml);
             }
-          response = MHD_create_response_from_data (strlen (res), res,
-                                                    MHD_NO, MHD_YES);
+          response = MHD_create_response_from_buffer (strlen (res), res,
+                                                    MHD_RESPMEM_MUST_COPY);
           g_free (res);
           ADD_CONTENT_SECURITY_HEADERS (response);
           return handler_send_response (connection,
@@ -4046,8 +4053,8 @@
           g_free (full_url);
           res = xsl_transform (xml);
           g_free (xml);
-          response = MHD_create_response_from_data (strlen (res), res,
-                                                    MHD_NO, MHD_YES);
+          response = MHD_create_response_from_buffer (strlen (res), res,
+                                                    MHD_RESPMEM_MUST_COPY);
           g_free (res);
           ADD_CONTENT_SECURITY_HEADERS (response);
           return handler_send_response (connection,
@@ -4103,8 +4110,8 @@
           g_free (language);
           res = xsl_transform (xml);
           g_free (xml);
-          response = MHD_create_response_from_data (strlen (res), res,
-                                                    MHD_NO, MHD_YES);
+          response = MHD_create_response_from_buffer (strlen (res), res,
+                                                    MHD_RESPMEM_MUST_COPY);
           g_free (res);
           ADD_CONTENT_SECURITY_HEADERS (response);
           return handler_send_response (connection,
@@ -4179,9 +4186,9 @@
                 content_type = GSAD_CONTENT_TYPE_APP_XML;
             }
 
-          response = MHD_create_response_from_data (res_len,
+          response = MHD_create_response_from_buffer (res_len,
                                                     (void *) res,
-                                                    MHD_NO, MHD_YES);
+                                                    MHD_RESPMEM_MUST_COPY);
           if (content_type_string)
             {
               MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE,
@@ -4227,8 +4234,8 @@
               credentials_free (credentials);
               return MHD_NO;
             }
-          response = MHD_create_response_from_data ((unsigned int) res_len,
-                                                    res, MHD_NO, MHD_YES);
+          response = MHD_create_response_from_buffer ((unsigned int) res_len,
+                                                    res, MHD_RESPMEM_MUST_COPY);
           g_free (res);
         }
       else if (!strncmp (&url[0], "/help/",
@@ -4327,8 +4334,8 @@
                                 "Invalid request", __FUNCTION__, __LINE__,
                                 "Error generating help page.",
                                 "/help/contents.html");
-          response = MHD_create_response_from_data (strlen (res), res,
-                                                    MHD_NO, MHD_YES);
+          response = MHD_create_response_from_buffer (strlen (res), res,
+                                                    MHD_RESPMEM_MUST_COPY);
           g_free (res);
         }
       else