BUG/MINOR: http_fetch: fix possible uninit sockaddr in fetch_url_ip/port
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 10 May 2021 09:23:34 +0000 (11:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 11 May 2021 13:29:06 +0000 (15:29 +0200)
commit6e5795d610be8491525b781b53ef474fbe4a0341
tree61d5494b7b88413c88e4f2ca7a4c9f9dd3ded790
parentfed5db84ee8ce8ca50eeb7e79335b082434924a3
BUG/MINOR: http_fetch: fix possible uninit sockaddr in fetch_url_ip/port

Check the return value of url2sa in smp_fetch_url_ip/port. If negative,
the address result is uninitialized and the sample fetch is aborted.
Also, the sockaddr is prelimiary zero'ed before calling url2sa to ensure
that it is not used by upper functions even if the sample returns 0.

Without the check, the value returned by the url_ip/url_port fetches is
unspecified. This can be triggered with the following curl :
$ curl -iv --request-target "xxx://127.0.0.1:20080/" http://127.0.0.1:20080/

This should be backported to all stable branches. However, note that
between the 1.8 and 2.0, the targetted functions have been extracted
from proto_http.c to http_fetch.c.

This should fix in part coverity report from the github issue #1244.

(cherry picked from commit c89d5337ee5064091ceab7b2d967f99071dc39eb)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/http_fetch.c