libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit ef59dec2cab29b3c9679f55eeb490e2e265b066e
parent ebbcd54678a786c61207cab8e00c55bfb123e1c7
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 18 Aug 2007 09:07:12 +0000

extra error checking

Diffstat:
MChangeLog | 5+++++
Msrc/daemon/response.c | 14++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,8 @@ +Sat Aug 18 03:06:09 MDT 2007 + Check for out of memory when adding headers to + responses. Check for NULL key when looking + for headers. - CG + Wed Aug 15 01:46:44 MDT 2007 Extending API to allow timeout of connections. Changed API (MHD_create_response_from_callback) to diff --git a/src/daemon/response.c b/src/daemon/response.c @@ -50,8 +50,19 @@ MHD_add_response_header (struct MHD_Response *response, (NULL != strstr (content, "\r")) || (NULL != strstr (content, "\n"))) return MHD_NO; hdr = malloc (sizeof (struct MHD_HTTP_Header)); + if (hdr == NULL) + return MHD_NO; hdr->header = strdup (header); + if (hdr->header == NULL) { + free(hdr); + return MHD_NO; + } hdr->value = strdup (content); + if (hdr->value == NULL) { + free(hdr->header); + free(hdr); + return MHD_NO; + } hdr->kind = MHD_HEADER_KIND; hdr->next = response->first_header; response->first_header = hdr; @@ -132,6 +143,9 @@ const char * MHD_get_response_header (struct MHD_Response *response, const char *key) { struct MHD_HTTP_Header *pos; + + if (key == NULL) + return NULL; pos = response->first_header; while (pos != NULL) {