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>
#include <strings.h>
#include <byteswap.h>
#include <errno.h>
+#include <ctype.h>
#include <assert.h>
#include <ipxe/uri.h>
#include <ipxe/refcnt.h>
/* 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;