[erlang-patches] httpc crashing on particular urls

Antti Siponen antti.siponen@REDACTED
Tue Sep 29 23:29:59 CEST 2015


Hello everybody, it is my first appearance on this mailing list so feel
free to remind me of all the rules I possibly break...

I noticed that in one specific case the inets:httpc request function fails
to return a meaningful error and silently crashes instead. This seems to
happen when the provided URL scheme is not http or https. I am just an
Erlang beginner so I don't expect to be able to provide a good patch, but I
have written up a mockup patch that does solve the issue, although the
error message it produces is very likely not in line with the conventions
used and the code itself is ugly and based only on guesswork from the
surrouding code without any real understanding of what I am doing.

Anyway to reproduce the bug you might try to execute the following request
on httpc: httpc:request(get, {"broken://erlang.org:80", []}, [],
[{sync,false}, {stream, self}, {receiver,fun(X)-> io:format("~p",[X])end}]).

Instead of an error I get {ok, #Ref} and in the background a httpc crash.
The same happens on sync requests as well and the erl shell hangs.

The mock fix that I wrote is available here:
https://github.com/lantti/otp/commit/8872f1ca2986757a670f386eba022481f126febc

The main points there to notice are that the function socket_type() fails
with a missing clause when an unrecognized URL scheme is introduced and
that we are inside the httpc:init where failing is not allowed. So I fixed
that by returning an error tuple instead and pattern matching against that
tuple at the calling side.

Maybe somebody here would like to take the time to actually write that fix
properly.

Thank you,

Antti Siponen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20150929/a8d7b350/attachment.htm>


More information about the erlang-patches mailing list