Skip to content

Commit 15b9925

Browse files
committed
Append null terminator after string copying
The buffer length passed to the callback is the actual length minus 1, so 'buflen' is not out-of-bounds but exactly the last byte of the buffer. Change-Id: I63a2bb1928c80f5c78dac7133133ad2c89f82e5f
1 parent a3539f1 commit 15b9925

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

web.c

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ int web_eventmux(char *buf, size_t buflen)
260260
char *buffer = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n";
261261
web_send(web_connfd, buffer);
262262
strncpy(buf, p, buflen);
263+
buf[buflen] = '\0';
263264
free(p);
264265
close(web_connfd);
265266
return strlen(buf);

0 commit comments

Comments
 (0)