getnameinfo() 2nd arg is socklen_t

fixes #350

also fix ressource leak
This commit is contained in:
Thomas Bernard 2019-02-12 14:23:36 +01:00
parent 3e32ea04c8
commit 61a18d6b02
1 changed files with 3 additions and 3 deletions

View File

@ -472,7 +472,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
int searchalltypes) int searchalltypes)
{ {
struct UPNPDev * tmp; struct UPNPDev * tmp;
struct UPNPDev * devlist = 0; struct UPNPDev * devlist = NULL;
unsigned int scope_id = 0; unsigned int scope_id = 0;
int opt = 1; int opt = 1;
static const char MSearchMsgFmt[] = static const char MSearchMsgFmt[] =
@ -641,7 +641,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
if(error) if(error)
*error = MINISSDPC_SOCKET_ERROR; *error = MINISSDPC_SOCKET_ERROR;
PRINT_SOCKET_ERROR("setsockopt(SO_REUSEADDR,...)"); PRINT_SOCKET_ERROR("setsockopt(SO_REUSEADDR,...)");
return NULL; goto error;
} }
if(ipv6) { if(ipv6) {
@ -823,7 +823,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
if (n < 0) { if (n < 0) {
#ifdef DEBUG #ifdef DEBUG
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
if (getnameinfo(p->ai_addr, p->ai_addrlen, hbuf, sizeof(hbuf), sbuf, if (getnameinfo(p->ai_addr, (socklen_t)p->ai_addrlen, hbuf, sizeof(hbuf), sbuf,
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0) { sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0) {
fprintf(stderr, "host:%s port:%s\n", hbuf, sbuf); fprintf(stderr, "host:%s port:%s\n", hbuf, sbuf);
} }