- updated code to protect against null pointers and uninitialized values and threading issues

This commit is contained in:
Mark Vejvoda
2013-02-04 08:30:43 +00:00
parent d02f91d2e0
commit f87b8b6ee2
35 changed files with 332 additions and 188 deletions

View File

@@ -143,7 +143,8 @@ int connecthostport(const char * host, unsigned short port,
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = AF_UNSPEC; /* AF_INET, AF_INET6 or AF_UNSPEC */
/* hints.ai_protocol = IPPROTO_TCP; */
snprintf(port_str, sizeof(port_str), "%hu", port);
snprintf(port_str, 7, "%hu", port);
port_str[7] = '\0';
if(host[0] == '[')
{
/* literal ip v6 address */

View File

@@ -2465,7 +2465,7 @@ int UPNP_Tools::upnp_init(void *param) {
}
dev = devlist;
while (dev) {
while (dev && dev->st) {
if (strstr(dev->st, "InternetGatewayDevice")) {
break;
}

View File

@@ -297,6 +297,9 @@ int glob( char const *pattern
cbAlloc = new_cbAlloc;
}
if(buffer == NULL) {
throw exception("buffer == NULL");
}
(void)lstrcpynA(buffer + cbCurr, szRelative, 1 + (int)(file_part - effectivePattern));
(void)lstrcatA(buffer + cbCurr, sFileName.c_str());
cbCurr += cch + 1;