瀏覽代碼

[http] Accept Content-Length header with trailing whitespace

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>
tags/v1.20.1
Michael Brown 10 年之前
父節點
當前提交
e845b7da9b
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2
    1
      src/net/tcp/httpcore.c

+ 2
- 1
src/net/tcp/httpcore.c 查看文件

@@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
33 33
 #include <strings.h>
34 34
 #include <byteswap.h>
35 35
 #include <errno.h>
36
+#include <ctype.h>
36 37
 #include <assert.h>
37 38
 #include <ipxe/uri.h>
38 39
 #include <ipxe/refcnt.h>
@@ -441,7 +442,7 @@ static int http_rx_content_length ( struct http_request *http, char *value ) {
441 442
 
442 443
 	/* Parse content length */
443 444
 	content_len = strtoul ( value, &endp, 10 );
444
-	if ( *endp != '\0' ) {
445
+	if ( ! ( ( *endp == '\0' ) || isspace ( *endp ) ) ) {
445 446
 		DBGC ( http, "HTTP %p invalid Content-Length \"%s\"\n",
446 447
 		       http, value );
447 448
 		return -EINVAL_CONTENT_LENGTH;

Loading…
取消
儲存