diff --git a/ChangeLog b/ChangeLog index 842106a..1d6f4da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,29 @@ Version 1.8.0 ******************************************************************************* +2010-03-15 Marcelo Jimenez + * SF Patch Tracker [ 2964685 ] patch for avoiding inet_ntoa (1.8.0) + + Seems like SF's tracker won't let me add a patch to someone else's issue ?! + This refers to https://sourceforge.net/support/tracker.php?aid=2724578 + + The calls to inet_ntoa are in getlocalhostname(), which is called from + UpnpInit when it is returning the bound IP address. + UpnpInit/getlocalhostname hasn't been updated to IPv6, I presume this is + deliberate so that it doesn't start returning IPv6 addresses and + overwriting the caller's IPv4-sized allocation. + + The attached patch just updates getlocalhostname to use inet_ntop instead + of inet_ntoa, and also documents the fact that UpnpInit is IPv4 only whilst + UpnpInnit2 is both IPv4 and IPv6. + + A fuller solution might be to change UpnpInit to use some variant on + UpnpGetIfInfo. UpnpInit could still be left as IPv4 only if desired - + perhaps UpnpGetIfInfo could take an option for the desired address family. + getlocalhostname and its own copy of the interface scanning code would then + be redundant. I don't have IPv6 capability here though so I'm reluctant to + change the IPv6 code, as I have no way to test it. + 2010-03-15 Marcelo Jimenez * SF Patch Tracker [ 2724578 ] patch for avoiding memory leaks when add devices diff --git a/upnp/inc/upnp.h b/upnp/inc/upnp.h index 8d5a2d8..058e3e5 100644 --- a/upnp/inc/upnp.h +++ b/upnp/inc/upnp.h @@ -685,22 +685,22 @@ extern "C" { /*! - * \brief Initializes the Linux SDK for UPnP Devices. + * \brief Initializes the Linux SDK for UPnP Devices (IPv4 only). * * \deprecated Kept for backwards compatibility. Use UpnpInit2 for new - * implementations. + * implementations or where IPv6 is required. * * This function must be called before any other API function can be called. * It should be called only once. Subsequent calls to this API return a * \c UPNP_E_INIT error code. * - * Optionally, the application can specify a host IP address (in the + * Optionally, the application can specify a host IPv4 address (in the * case of a multi-homed configuration) and a port number to use for * all UPnP operations. Since a port number can be used only by one * process, multiple processes using the SDK must specify * different port numbers. * - * If unspecified, the SDK will use the first adapter's IP address + * If unspecified, the SDK will use the first IPv4-capable adapter's IP address * and an arbitrary port. * * This call is synchronous. @@ -718,8 +718,8 @@ extern "C" { * \li \c UPNP_E_INTERNAL_ERROR: An internal error ocurred. */ EXPORT_SPEC int UpnpInit( - /*! The host local IP address to use, in string format, for example - * "192.168.0.1", or \c NULL to use the first adapter's IP address. */ + /*! The host local IPv4 address to use, in string format, for example + * "192.168.0.1", or \c NULL to use the first IPv4 adapter's IP address. */ const char *HostIP, /*! Local Port to listen for incoming connections * \c NULL will pick an arbitrary free port. */ @@ -727,7 +727,7 @@ EXPORT_SPEC int UpnpInit( /*! - * \brief Initializes the Linux SDK for UPnP Devices. + * \brief Initializes the Linux SDK for UPnP Devices (IPv4 or IPv6). * * This function must be called before any other API function can be called. * It should be called only once. Subsequent calls to this API return a diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index d9f200c..245da18 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -3485,9 +3485,13 @@ int getlocalhostname(char *out, const int out_len) if (p) { strncpy(out, p, out_len); } else { + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "getlocalhostname: inet_ntop returned error\n" ); ret = UPNP_E_INIT; } } else { + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "getlocalhostname: gethostbyname returned error\n" ); ret = UPNP_E_INIT; } @@ -3520,6 +3524,8 @@ int getlocalhostname(char *out, const int out_len) if (p) { strncpy(out, p, out_len); } else { + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "getlocalhostname: inet_ntop returned error\n" ); ret = UPNP_E_INIT; } UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, @@ -3597,6 +3603,8 @@ int getlocalhostname(char *out, const int out_len) if (p) { strncpy(out, p, out_len); } else { + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "getlocalhostname: inet_ntop returned error\n" ); ret = UPNP_E_INIT; } UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,