Skip to content

bad argument error if there is a white space at first header. #11605

@junsik

Description

@junsik

I did this

curl 8.2.0 tells bad argument error if there is a white space at first header.

* processing: http://www.w4c.go.kr/intro/introFcltMainSttus.do
*   Trying 27.101.219.129:80...
* Connected to www.w4c.go.kr (27.101.219.129) port 80
> GET /intro/introFcltMainSttus.do HTTP/1.1
Host: www.w4c.go.kr
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
Accept: */*
Accept-Encoding: deflate, gzip

< HTTP/1.1 200 OK
<  X-Content-Type-Options: nosniff
* Closing connection

XHR Error: (43) A libcurl function was given a bad argument

this might be related with folded header patch: b7baa78

A header name cannot have any whitespace at RFC.

      message-header = field-name ":" [ field-value ]
       field-name     = token
       field-value    = *( field-content | LWS )
       field-content  = <the OCTETs making up the field-value
                        and consisting of either *TEXT or combinations
                        of token, separators, and quoted-string>


  token          = 1*tchar

  tchar          = "!" / "#" / "$" / "%" / "&" / "'" / "*"
                 / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
                 / DIGIT / ALPHA
                 ; any VCHAR, except delimiters

But I am not sure strict manger is right or not.
For fixing it, following code could be considered:

if((header[0] == ' ') || (header[0] == '\t')) {
    if(data->state.prevhead)
      /* line folding, append value to the previous header's value */
      return unfold_value(data, header, hlen);
  }

I expected the following

curl 7.68.0

$ curl http://www.w4c.go.kr -v
*   Trying 27.101.219.129:80...
* TCP_NODELAY set
* Connected to www.w4c.go.kr (27.101.219.129) port 80 (#0)
> GET / HTTP/1.1
> Host: www.w4c.go.kr
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
<  X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Date: Mon, 07 Aug 2023 06:10:26 GMT
< Connection: close
< Location: /server_busy
< Content-Type: text/html
< Content-Length: 140

curl/libcurl version

curl 8.2.0

operating system

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions