fix potentially missing NUL termination

This commit is contained in:
Stanislav Malyshev 2014-08-18 23:04:24 -07:00
parent 706aefb781
commit 2b10db8e10

View file

@ -989,6 +989,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
@ -1013,6 +1014,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) {