Skip to content

Commit 6f9ad51

Browse files
committed
Fix possible buffer size problem (CWE-120)
Calling strncpy with a maximum size argument of 16 bytes on destination array "iwr.ifr_ifrn.ifrn_name" of size 16 bytes might leave the destination string unterminated.
1 parent 22a1b67 commit 6f9ad51

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

python-ethtool/ethtool.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ static PyObject *get_wireless_protocol (PyObject *self __unused, PyObject *args)
666666

667667
/* Setup our request structure. */
668668
memset(&iwr, 0, sizeof(iwr));
669-
strncpy(iwr.ifr_name, devname, IFNAMSIZ);
669+
strncpy(iwr.ifr_name, devname, IFNAMSIZ-1);
670+
iwr.ifr_name[IFNAMSIZ-1] = 0;
670671

671672
/* Open control socket. */
672673
fd = socket(AF_INET, SOCK_DGRAM, 0);

0 commit comments

Comments
 (0)