Hello,

I came across a little bug while trying to upload an image file to a Yaws server when using HTTPS/SSL connection. When the file was large enough (under a few megs), the server would crash (See end of mail for error log excerpt).

I am quite new to Yaws, so I hope I did not misunderstand some of the workings there ;-) I tried to narrow it down and I have put up a test case that makes the server crash, and a possible workaround here (ssl_multipart_bug branch):

https://github.com/jccampagne/yaws/commit/302381cca9b3cc6e62df4b75c01cc77dd95c8676


I've put up a test case in the ..../test/t2/ directory - hope it is OK to put it here.

In the test case, ibrowse is used to simulate uploading a file to the server running on port 8444 in multipart form and HTTPS. If you try to run the test with the original yaws_server.erl file, the 'test_ssl_multipart_post' test will fail as the server crashes. I believe it is caused by the client socket getting wrapped up by the function yaws_server:make_arg/5 but not getting unwrapped on successive calls to ssl:recv/3 call in yaws_server:get_client_data/4 this is happening when there is a 'get_more' in the multipart parsing.

I am calling this snippet of code a "workaround" more than a fix because I am not sure it is the most elegant way to do it :-) I've put it in a function called 'yaws_server:unwrap_clisock/1' just to make it more obvious.


Best regards, and thanks for making Yaws ;-)
Jean-Charles Campagne


------------------------------------------------------------------------
Using:
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 5.9.2
on FreeBSD 9.0-RELEASE-p3 amd64
------------------------------------------------------------------------
Error log excerpt:

Yaws process died: {function_clause,
                      [{ssl,recv,
                           [{ssl,{sslsocket,new_ssl,<0.262.0>}},10240,10000],
                           [{file,"ssl.erl"},{line,265}]},
                       {yaws,cli_recv,3,[{file,"yaws.erl"},{line,1710}]},
                       {yaws_server,get_client_data,4,
                           [{file,"yaws_server.erl"},{line,2576}]},
                       {yaws_server,get_more_post_data,2,
                           [{file,"yaws_server.erl"},{line,3680}]},
                       {yaws_server,deliver_dyn_part,8,
                           [{file,"yaws_server.erl"},{line,2645}]},
                       {yaws_server,aloop,4,
                           [{file,"yaws_server.erl"},{line,1149}]},
                       {yaws_server,acceptor0,2,
                           [{file,"yaws_server.erl"},{line,1010}]},
                       {proc_lib,init_p_do_apply,3,
                           [{file,"proc_lib.erl"},{line,227}]}]}