Skip to content

Commit

Permalink
Fix buffer overflow in lnx_eth_get_dev_index.
Browse files Browse the repository at this point in the history
If the name was longer than IFNAMSIZ then it would corrupt data.
  • Loading branch information
flaviojs committed Mar 24, 2024
1 parent 2bac780 commit 7356141
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/linux_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ int lnx_eth_get_dev_index(char *name)
}

memset((void *)&if_req,0,sizeof(if_req));
strcpy(if_req.ifr_name,name);
strncpy(if_req.ifr_name,name,IFNAMSIZ-1);
if_req.ifr_name[IFNAMSIZ-1] = '\0';

if (ioctl(fd,SIOCGIFINDEX,&if_req) < 0) {
fprintf(stderr,"eth_get_dev_index: SIOCGIFINDEX: %s\n",strerror(errno));
Expand Down

0 comments on commit 7356141

Please sign in to comment.