diff options
Diffstat (limited to 'src/microhttpd/basicauth.c')
-rw-r--r-- | src/microhttpd/basicauth.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/microhttpd/basicauth.c b/src/microhttpd/basicauth.c index 0d1309f2..24bafc31 100644 --- a/src/microhttpd/basicauth.c +++ b/src/microhttpd/basicauth.c | |||
@@ -119,15 +119,25 @@ MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, | |||
119 | { | 119 | { |
120 | int ret; | 120 | int ret; |
121 | size_t hlen = strlen(realm) + strlen("Basic realm=\"\"") + 1; | 121 | size_t hlen = strlen(realm) + strlen("Basic realm=\"\"") + 1; |
122 | char header[hlen]; | 122 | char *header; |
123 | 123 | ||
124 | header = (char*)malloc(hlen); | ||
125 | if (NULL == header) | ||
126 | { | ||
127 | #if HAVE_MESSAGES | ||
128 | MHD_DLOG(connection->daemon, | ||
129 | "Failed to allocate memory for auth header\n"); | ||
130 | #endif /* HAVE_MESSAGES */ | ||
131 | return MHD_NO; | ||
132 | } | ||
124 | MHD_snprintf_ (header, | 133 | MHD_snprintf_ (header, |
125 | sizeof (header), | 134 | hlen, |
126 | "Basic realm=\"%s\"", | 135 | "Basic realm=\"%s\"", |
127 | realm); | 136 | realm); |
128 | ret = MHD_add_response_header (response, | 137 | ret = MHD_add_response_header (response, |
129 | MHD_HTTP_HEADER_WWW_AUTHENTICATE, | 138 | MHD_HTTP_HEADER_WWW_AUTHENTICATE, |
130 | header); | 139 | header); |
140 | free(header); | ||
131 | if (MHD_YES == ret) | 141 | if (MHD_YES == ret) |
132 | ret = MHD_queue_response (connection, | 142 | ret = MHD_queue_response (connection, |
133 | MHD_HTTP_UNAUTHORIZED, | 143 | MHD_HTTP_UNAUTHORIZED, |