diff options
Diffstat (limited to 'src/testcurl/test_head.c')
-rw-r--r-- | src/testcurl/test_head.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/testcurl/test_head.c b/src/testcurl/test_head.c index 3c984125..066688b6 100644 --- a/src/testcurl/test_head.c +++ b/src/testcurl/test_head.c | |||
@@ -274,10 +274,13 @@ lcurl_hdr_callback (char *buffer, size_t size, size_t nitems, | |||
274 | int res; | 274 | int res; |
275 | const unsigned int numbers_pos = | 275 | const unsigned int numbers_pos = |
276 | MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": "); | 276 | MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": "); |
277 | res = snprintf (cmpbuf, sizeof(cmpbuf), "%u\r\n", check_res->expected_size); | 277 | res = snprintf (cmpbuf, sizeof(cmpbuf), "%u", check_res->expected_size); |
278 | if ((res <= 0) || (res > ((int) (sizeof(cmpbuf) - 1)))) | 278 | if ((res <= 0) || (res > ((int) (sizeof(cmpbuf) - 1)))) |
279 | externalErrorExit (); | 279 | externalErrorExit (); |
280 | if (0 != strcmp (buffer + numbers_pos, cmpbuf)) | 280 | if (data_size - numbers_pos <= 2) |
281 | mhdErrorExitDesc ("Broken Content-Length"); | ||
282 | else if ((((size_t) res + 2) != data_size - numbers_pos) || | ||
283 | (0 != memcmp (buffer + numbers_pos, cmpbuf, (size_t) res))) | ||
281 | { | 284 | { |
282 | fprintf (stderr, "Wrong Content-Length.\n" | 285 | fprintf (stderr, "Wrong Content-Length.\n" |
283 | "Expected:\n%u\n" | 286 | "Expected:\n%u\n" |
@@ -285,6 +288,11 @@ lcurl_hdr_callback (char *buffer, size_t size, size_t nitems, | |||
285 | buffer + numbers_pos); | 288 | buffer + numbers_pos); |
286 | mhdErrorExitDesc ("Wrong Content-Length"); | 289 | mhdErrorExitDesc ("Wrong Content-Length"); |
287 | } | 290 | } |
291 | else if (0 != memcmp ("\r\n", buffer + data_size - 2, 2)) | ||
292 | { | ||
293 | mhdErrorExitDesc ("The Content-Length header is not " \ | ||
294 | "terminated by CRLF"); | ||
295 | } | ||
288 | check_res->size_found++; | 296 | check_res->size_found++; |
289 | } | 297 | } |
290 | 298 | ||