diff --git a/ChangeLog b/ChangeLog index cbdbc0e3..c362ed3a 100644 --- 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 index 56333396..648b36a2 100644 --- 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) {