Skip to content

Commit 3626397

Browse files
committed
Fix buffer overflow
When compiling, the following warning message is generated: "warning: ‘strncpy’ writing 1040 bytes into a region of size 1024 overflows the destination" This is because calloc allocates NLMSG_SPACE(MAX_PAYLOAD) space for nlh, which includes the space for the header, so the actual space available for the message is only MAX_PAYLOAD.
1 parent 35ca058 commit 3626397

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

vwifi-tool.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bool denylist_send(char *denylist)
9292
nlh->nlmsg_pid = getpid();
9393
nlh->nlmsg_flags = 0;
9494

95-
strncpy(NLMSG_DATA(nlh), denylist, NLMSG_SPACE(MAX_PAYLOAD));
95+
strncpy(NLMSG_DATA(nlh), denylist, MAX_PAYLOAD);
9696

9797
struct iovec iov = {
9898
.iov_base = (void *) nlh,

0 commit comments

Comments
 (0)