[miniupnpc] fix heap-buffer-overflow reported by ASAN (on read)
This commit is contained in:
parent
78c7dd2a37
commit
e3abcf2808
|
@ -46,7 +46,7 @@ getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath)
|
||||||
unsigned char * p;
|
unsigned char * p;
|
||||||
unsigned char * url;
|
unsigned char * url;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int urlsize, stsize, usnsize, l;
|
unsigned int urlsize, stsize, usnsize, l, plen;
|
||||||
int s;
|
int s;
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
|
|
||||||
|
@ -58,7 +58,12 @@ getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
memcpy(addr.sun_path, socketpath, sizeof(addr.sun_path));
|
plen = strlen(socketpath);
|
||||||
|
if (plen + 1 > sizeof(addr.sun_path)) {
|
||||||
|
plen = sizeof(addr.sun_path) - 1;
|
||||||
|
}
|
||||||
|
memset(addr.sun_path, 0, sizeof(addr.sun_path));
|
||||||
|
memcpy(addr.sun_path, socketpath, plen);
|
||||||
if(connect(s, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0)
|
if(connect(s, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0)
|
||||||
{
|
{
|
||||||
/*syslog(LOG_WARNING, "connect(\"%s\"): %m", socketpath);*/
|
/*syslog(LOG_WARNING, "connect(\"%s\"): %m", socketpath);*/
|
||||||
|
|
Loading…
Reference in New Issue