Skip to content

Commit

Permalink
Merge pull request #186 from flaviojs/fix-buffer-overflow-lnx_eth_get…
Browse files Browse the repository at this point in the history
…_dev_index

Fix buffer overflow in lnx_eth_get_dev_index.
  • Loading branch information
grossmj authored Mar 24, 2024
2 parents 2bac780 + 7356141 commit ebe67ce
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 ebe67ce

Please sign in to comment.