[erlang-bugs] [BUG] erlang:decode_packet/3 generates corrupt header names with httph_bin
Sverker Eriksson
sverker@REDACTED
Mon Mar 29 10:48:38 CEST 2010
Fix included in pu branch:
http://github.com/erlang/otp/commit/e7ab3b456ad489bc284153ed79105d3a8d17cafd
Seems like the necessary conditions for provoking the bug are:
erlang:decode_packet (not packet option for sockets), httph_bin, an
unknown header string of length 16 to 20 characters and a 32-bit emulator.
Thanks for reporting Will.
/Sverker, Erlang/OTP Ericsson
Will wrote:
> Hello,
>
> erlang:decode_packet/3 generates strange corrupted header names for
> unknown header types when using the httph_bin option. The cause seems
> related to the length of the header name, short ones work fine.
>
> Test Case:
>
> test() ->
> B = <<
> "X-Transaction: 1269062039-39495-905\r\n"
> "X-RateLimit-Limit: 150\r\n"
> "Content-Type: application/json; charset=utf-8\r\n"
> "X-Foo: bar\r\n"
> "\r\n"
> >>,
> {ok, Headers, Rest} = decode_headers(B, []),
> io:format("HEADERS:~n~p~n", [Headers]),
> io:format("REST:~n~p~n", [Rest]).
>
> decode_headers(Bin, Acc) ->
> case erlang:decode_packet(httph_bin, Bin, []) of
> {ok, {http_header, _N, _Name, _, _V} = H, Rest} ->
> decode_headers(Rest, [H | Acc]);
> {ok, http_eoh, Rest} ->
> {ok, Acc, Rest}
> end.
>
> Result:
>
> Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0]
> [hipe] [kernel-poll:false]
>
> HEADERS:
> [{http_header,0,<<"X-Foo">>,undefined,<<"bar">>},
> {http_header,42,'Content-Type',undefined,
> <<"application/json; charset=utf-8">>},
> {http_header,0,
> <<88,45,70,111,111,50,14,0,64,190,14,1,10,0,0,0,14>>,
> undefined,<<"150">>},
> {http_header,0,
> <<88,45,70,111,111,50,14,0,64,190,14,1,10>>,
> undefined,<<"1269062039-39495-905">>}]
> REST:
> <<>>
>
> ________________________________________________________________
> erlang-bugs (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-bugs-unsubscribe@REDACTED
>
>
More information about the erlang-bugs
mailing list