cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH 10/11] libcurl: add UNIX domain sockets support

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 3 Dec 2014 03:42:31 +0100 (CET)

On Thu, 27 Nov 2014, Peter Wu wrote:

> This patch considers support for UNIX domain sockets at the same level as
> HTTP proxies / IPv6, it acts as an intermediate socket provider and not as a
> separate protocol. Since this feature affects network operations, a new
> feature flag was added ("unix-sockets") with a corresponding
> CURL_VERSION_UNIX_SOCKETS macro.

Lovely! I'm very close to landing this (I have the series merged and only
edited in slightly in a local branch of mine) but I ran into a little issue I
wanted to bounce with you. It get valgrind warnings:

==18775== Conditional jump or move depends on uninitialised value(s)
==18775== at 0x4C2C1A9: strlen (vg_replace_strmem.c:412)
==18775== by 0x422A0A: dprintf_formatf (mprintf.c:810)
==18775== by 0x4231CC: curl_mvsnprintf (mprintf.c:976)
==18775== by 0x4232A8: curl_msnprintf (mprintf.c:993)
==18775== by 0x426BF2: getaddressinfo (connect.c:643)
==18775== by 0x426E0E: Curl_updateconninfo (connect.c:698)
==18775== by 0x4271BB: Curl_is_connected (connect.c:802)
==18775== by 0x429D44: multi_runsingle (multi.c:1187)
==18775== by 0x42B124: curl_multi_perform (multi.c:1805)

The culprit is this:

The Curl_updateconninfo() function in lib/connect.c calls getsockname() on the
socket which seems to not get a proper sun_path filled in (getpeername() seems
to get the path though) so when getaddressinfo() is called to show the current
"local address" it tries to snprintf() su->sun_path on line 643 and that is
uninitialized data apparently. I guess a unix domain socket doesn't really
have a "local address".

I haven't decided the best course of action to fix this but I wanted to hear
with you if you have any good idea.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2014-12-03