Skip to content
Snippets Groups Projects
Commit f9ce26c5 authored by Kees Cook's avatar Kees Cook Committed by Jonathan Corbet
Browse files

docs: networking: Replace strncpy() with strscpy()

parent 709dedfd
No related branches found
No related tags found
No related merge requests found
...@@ -263,7 +263,7 @@ possible overrun should the name be too long:: ...@@ -263,7 +263,7 @@ possible overrun should the name be too long::
char name[128]; char name[128];
if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0) if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0)
strncpy(name, "Unknown", sizeof(name)); strscpy(name, "Unknown", sizeof(name));
printf("Name: %s\n", name); printf("Name: %s\n", name);
......
...@@ -153,7 +153,7 @@ As capture, each frame contains two parts:: ...@@ -153,7 +153,7 @@ As capture, each frame contains two parts::
struct ifreq s_ifr; struct ifreq s_ifr;
... ...
strncpy (s_ifr.ifr_name, "eth0", sizeof(s_ifr.ifr_name)); strscpy_pad (s_ifr.ifr_name, "eth0", sizeof(s_ifr.ifr_name));
/* get interface index of eth0 */ /* get interface index of eth0 */
ioctl(this->socket, SIOCGIFINDEX, &s_ifr); ioctl(this->socket, SIOCGIFINDEX, &s_ifr);
......
...@@ -107,7 +107,7 @@ Note that the character pointer becomes overwritten with the real device name ...@@ -107,7 +107,7 @@ Note that the character pointer becomes overwritten with the real device name
*/ */
ifr.ifr_flags = IFF_TUN; ifr.ifr_flags = IFF_TUN;
if( *dev ) if( *dev )
strncpy(ifr.ifr_name, dev, IFNAMSIZ); strscpy_pad(ifr.ifr_name, dev, IFNAMSIZ);
if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){ if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
close(fd); close(fd);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment