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):


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

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,