From cdccc0290d09c35e173cdce3734e4eb9a2a47ad9 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 27 Aug 2015 10:03:22 +0200 Subject: [PATCH] minissdpc.c: avoid unix socket leak in getDevicesFromMiniSSDPD() --- miniupnpc/Changelog.txt | 3 +++ miniupnpc/minissdpc.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/miniupnpc/Changelog.txt b/miniupnpc/Changelog.txt index 16304b7..815dadb 100644 --- a/miniupnpc/Changelog.txt +++ b/miniupnpc/Changelog.txt @@ -1,6 +1,9 @@ $Id: Changelog.txt,v 1.212 2015/07/23 20:41:50 nanard Exp $ miniUPnP client Changelog. +2015/08/27: + avoid unix socket leak in getDevicesFromMiniSSDPD() + 2015/08/16: Also accept "Up" as ConnectionStatus value diff --git a/miniupnpc/minissdpc.c b/miniupnpc/minissdpc.c index 29155a4..c986291 100644 --- a/miniupnpc/minissdpc.c +++ b/miniupnpc/minissdpc.c @@ -44,7 +44,7 @@ struct sockaddr_un { struct UPNPDev * getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath, int * error) { - struct UPNPDev * devlist; + struct UPNPDev * devlist = NULL; int s; int res; @@ -58,9 +58,9 @@ getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath, int * err if (res < 0) { if (error) *error = res; - return NULL; + } else { + devlist = receiveDevicesFromMiniSSDPD(s, error); } - devlist = receiveDevicesFromMiniSSDPD(s, error); disconnectFromMiniSSDPD(s); return devlist; } @@ -145,6 +145,7 @@ connectToMiniSSDPD(const char * socketpath) if(connect(s, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) { /*syslog(LOG_WARNING, "connect(\"%s\"): %m", socketpath);*/ + close(s); return MINISSDPC_SOCKET_ERROR; } return s;