diff options
author | Erlang/OTP <[email protected]> | 2010-03-30 09:41:26 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-03-30 09:41:26 +0000 |
commit | a1b30b8d1785bfbc86a2eb0b2397581372d290f0 (patch) | |
tree | b34b83098660dd92b1cc1fed4911fa53fa1cce4e /erts/emulator/test | |
parent | d2e9fc8ba0bb0e077a70cc4f8da9b6c0539209c6 (diff) | |
parent | 80ce0ac4458c549fd0969333dfbbf8b3233cf544 (diff) | |
download | otp-a1b30b8d1785bfbc86a2eb0b2397581372d290f0.tar.gz otp-a1b30b8d1785bfbc86a2eb0b2397581372d290f0.tar.bz2 otp-a1b30b8d1785bfbc86a2eb0b2397581372d290f0.zip |
Merge branch 'se/decode_packet' into dev
* se/decode_packet:
Fix erlang:decode_packet(httph_bin,..) to not return faulty header strings
OTP-8548 se/decode_packet
erlang:decode_packet(httph_bin,..) could return corrupt header strings or
even crash the VM. This has been fixed. It only happened on 32-bit VM if
the header name was unknown and between 16 and 20 characters long. Sockets
with simular packet option did not suffer from this bug.
Diffstat (limited to 'erts/emulator/test')
-rw-r--r-- | erts/emulator/test/decode_packet_SUITE.erl | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/erts/emulator/test/decode_packet_SUITE.erl b/erts/emulator/test/decode_packet_SUITE.erl index 13f17e972c..6cde286871 100644 --- a/erts/emulator/test/decode_packet_SUITE.erl +++ b/erts/emulator/test/decode_packet_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -24,10 +24,10 @@ -include("test_server.hrl"). -export([all/1,init_per_testcase/2,fin_per_testcase/2, - basic/1, packet_size/1, neg/1, http/1, line/1, ssl/1]). + basic/1, packet_size/1, neg/1, http/1, line/1, ssl/1, otp_8536/1]). all(suite) -> - [basic, packet_size, neg, http, line, ssl]. + [basic, packet_size, neg, http, line, ssl, otp_8536]. init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) -> Seed = {S1,S2,S3} = now(), @@ -504,6 +504,27 @@ ssl(Config) when is_list(Config) -> F(v2hello), ok. +otp_8536(doc) -> ["Corrupt sub-binary-strings from httph_bin"]; +otp_8536(Config) when is_list(Config) -> + lists:foreach(fun otp_8536_do/1, lists:seq(1,50)), + ok. + +otp_8536_do(N) -> + Data = <<"some data 123">>, + Letters = <<"bcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba">>, + <<HdrTail:N/binary,_/binary>> = Letters, + Hdr = <<$A, HdrTail/binary>>, + Bin = <<Hdr/binary, ": ", Data/binary, "\r\n\r\n">>, + + io:format("Bin='~p'\n",[Bin]), + ?line {ok,{http_header,0,Hdr2,undefined,Data2},<<"\r\n">>} = decode_pkt(httph_bin, Bin, []), + + %% Do something to trash the C-stack, how about another decode_packet: + decode_pkt(httph_bin,<<Letters/binary, ": ", Data/binary, "\r\n\r\n">>, []), + + %% Now check that we got the expected binaries + {Hdr, Data} = {Hdr2, Data2}. + decode_pkt(Type,Bin) -> decode_pkt(Type,Bin,[]). decode_pkt(Type,Bin,Opts) -> |