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