[libvirt] [PATCH] addrToString: give better error message

Eric Blake eblake at redhat.com
Wed Apr 21 14:43:28 UTC 2010

On 04/20/2010 10:13 AM, Eric Blake wrote:
> The user probably doesn't care what the gai error numbers are, as
> much as what the failed conversion IP address was.
> +        char ip[INET6_ADDRSTRLEN];
> +
> +        if (inet_ntop(sa->sa_family, sa->sa_data, ip, sizeof ip)) {

This is wrong.  Given typical layout, sa->sa_data is not the same
address as ((sockaddr_in*)sa)->sin_addr or
((sockaddr_in6*)sa)->in6_addr, and since those are at different offsets,
the code needs to be conditional on the value of sa->sa_family.  I'll
post a respin soon.

Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100421/a5779653/attachment-0001.sig>

More information about the libvir-list mailing list