diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2014-12-22 19:42:31 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2014-12-22 19:42:31 +0000 |
commit | 001c1fdad596c41a67f08653ada5d46401dd9792 (patch) | |
tree | c22cef00de9a00664607e9be18af3127b7a403fe /src/microhttpd/basicauth.c | |
parent | 03af50116d05118c328eb8910b9c512948414ca7 (diff) | |
download | libmicrohttpd-001c1fdad596c41a67f08653ada5d46401dd9792.tar.gz libmicrohttpd-001c1fdad596c41a67f08653ada5d46401dd9792.zip |
Replace char variable size arrays with malloc'ed buffers
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, |