aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-08-18 09:07:12 +0000
committerChristian Grothoff <christian@grothoff.org>2007-08-18 09:07:12 +0000
commitef59dec2cab29b3c9679f55eeb490e2e265b066e (patch)
tree9822ac2410e917f5c320928367750f8bfb75282d
parentebbcd54678a786c61207cab8e00c55bfb123e1c7 (diff)
downloadlibmicrohttpd-ef59dec2cab29b3c9679f55eeb490e2e265b066e.tar.gz
libmicrohttpd-ef59dec2cab29b3c9679f55eeb490e2e265b066e.zip
extra error checking
-rw-r--r--ChangeLog5
-rw-r--r--src/daemon/response.c14
2 files changed, 19 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index cbdbc0e3..c362ed3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
1Sat Aug 18 03:06:09 MDT 2007
2 Check for out of memory when adding headers to
3 responses. Check for NULL key when looking
4 for headers. - CG
5
1Wed Aug 15 01:46:44 MDT 2007 6Wed Aug 15 01:46:44 MDT 2007
2 Extending API to allow timeout of connections. 7 Extending API to allow timeout of connections.
3 Changed API (MHD_create_response_from_callback) to 8 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,
50 (NULL != strstr (content, "\r")) || (NULL != strstr (content, "\n"))) 50 (NULL != strstr (content, "\r")) || (NULL != strstr (content, "\n")))
51 return MHD_NO; 51 return MHD_NO;
52 hdr = malloc (sizeof (struct MHD_HTTP_Header)); 52 hdr = malloc (sizeof (struct MHD_HTTP_Header));
53 if (hdr == NULL)
54 return MHD_NO;
53 hdr->header = strdup (header); 55 hdr->header = strdup (header);
56 if (hdr->header == NULL) {
57 free(hdr);
58 return MHD_NO;
59 }
54 hdr->value = strdup (content); 60 hdr->value = strdup (content);
61 if (hdr->value == NULL) {
62 free(hdr->header);
63 free(hdr);
64 return MHD_NO;
65 }
55 hdr->kind = MHD_HEADER_KIND; 66 hdr->kind = MHD_HEADER_KIND;
56 hdr->next = response->first_header; 67 hdr->next = response->first_header;
57 response->first_header = hdr; 68 response->first_header = hdr;
@@ -132,6 +143,9 @@ const char *
132MHD_get_response_header (struct MHD_Response *response, const char *key) 143MHD_get_response_header (struct MHD_Response *response, const char *key)
133{ 144{
134 struct MHD_HTTP_Header *pos; 145 struct MHD_HTTP_Header *pos;
146
147 if (key == NULL)
148 return NULL;
135 pos = response->first_header; 149 pos = response->first_header;
136 while (pos != NULL) 150 while (pos != NULL)
137 { 151 {