Skip to content

Commit 2b10db8

Browse files
committed
fix potentially missing NUL termination
1 parent 706aefb commit 2b10db8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

main/network.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize)
989989
buf = estrdup(errstr);
990990
} else {
991991
strncpy(buf, errstr, bufsize);
992+
buf[bufsize?(bufsize-1):0] = 0;
992993
}
993994
return buf;
994995
#else
@@ -1013,6 +1014,7 @@ PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize)
10131014
buf = estrdup(sysbuf);
10141015
} else {
10151016
strncpy(buf, sysbuf, bufsize);
1017+
buf[bufsize?(bufsize-1):0] = 0;
10161018
}
10171019

10181020
if (free_it) {

0 commit comments

Comments
 (0)