Skip to content

Commit

Permalink
fix potentially missing NUL termination
Browse files Browse the repository at this point in the history
  • Loading branch information
smalyshev authored and Tyrael committed Aug 27, 2014
1 parent 2c27515 commit 7325578
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main/network.c
Expand Up @@ -992,6 +992,7 @@ PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize)
buf = estrdup(errstr);
} else {
strncpy(buf, errstr, bufsize);
buf[bufsize?(bufsize-1):0] = 0;
}
return buf;
#else
Expand All @@ -1016,6 +1017,7 @@ PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize)
buf = estrdup(sysbuf);
} else {
strncpy(buf, sysbuf, bufsize);
buf[bufsize?(bufsize-1):0] = 0;
}

if (free_it) {
Expand Down

0 comments on commit 7325578

Please sign in to comment.