[vlc-devel] UPnP module on Windows has been broken

Naohiro KORIYAMA nkoriyama at gmail.com
Sat Dec 3 03:48:31 CET 2011


2011/12/2 Naohiro KORIYAMA <nkoriyama at gmail.com>:
> Anyway, on Windows, if  inet_ntop()/inet_ntop() is called with
> AF_INET6, the function always returns error value.

This is still true, but this is not real cause of the UPnP problem.

inet_ntop() in compat/inet_pton.c has a bug.

iconst char *inet_ntop (int af, const void *src, char *dst, int len)
{
    const unsigned char *b = src;

    switch (af)
    {
        case AF_INET:
            if (snprintf (dst, len, "%hhu.%hhu.%hhu.%hhu",
                          b[0], b[1], b[2], b[3]) <= len)
            {
                errno = ENOSPC;
                return NULL;
            }
            return dst;
    }
    errno = EAFNOSUPPORT;
    return NULL;
}

If af is AF_INET, len is 16(INET_ADDRSTRLEN).
snprintf's result(stored length of dst) can be from 7 to 15. (dst:
0.0.0.0, 255.255.255.255).
snprintf's result is always smaller than size.
So, this funciton always returns NULL and set ENOSPC to errno.

I attached the patch for this problem.
I'm very very sorry for libupnp.

BTW, Should we add implementation to inet_ntop/inet_pton for
AF_INET6(IPv6) in the future?
-- 
KORIYAMA, Naohiro
nkoriyama at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-inet_ntop-always-returns-NULL-on-Windows.patch
Type: application/octet-stream
Size: 816 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20111203/d9944c5c/attachment.obj>


More information about the vlc-devel mailing list