]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[http] Accept Content-Length header with trailing whitespace
authorMichael Brown <mcb30@ipxe.org>
Tue, 25 Mar 2014 15:42:46 +0000 (15:42 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 25 Mar 2014 15:46:14 +0000 (15:46 +0000)
At least one HTTP server (Google's OCSP responder) has been observed
to generate a Content-Length header with trailing whitespace.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/tcp/httpcore.c

index aa15b11231da1a169a0d6c065a755ddca78ecec2..6552ca2bd7663de187c6f26a4a8ee0f7cbe846be 100644 (file)
@@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <strings.h>
 #include <byteswap.h>
 #include <errno.h>
+#include <ctype.h>
 #include <assert.h>
 #include <ipxe/uri.h>
 #include <ipxe/refcnt.h>
@@ -441,7 +442,7 @@ static int http_rx_content_length ( struct http_request *http, char *value ) {
 
        /* Parse content length */
        content_len = strtoul ( value, &endp, 10 );
-       if ( *endp != '\0' ) {
+       if ( ! ( ( *endp == '\0' ) || isspace ( *endp ) ) ) {
                DBGC ( http, "HTTP %p invalid Content-Length \"%s\"\n",
                       http, value );
                return -EINVAL_CONTENT_LENGTH;