[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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 redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]