Skip to content

Commit

Permalink
Network routines: fix a Coverity warning
Browse files Browse the repository at this point in the history
The warning was:
CID 602256 (luigirizzo#1 of 2): Buffer not null terminated (BUFFER_SIZE_WARNING)
CID 602256 (luigirizzo#2 of 2): Buffer not null terminated (BUFFER_SIZE_WARNING)
buffer_size_warning: Calling strncpy with a maximum size argument of 16 bytes
on destination array ifr.ifr_ifrn.ifrn_name of size 16 bytes might leave
the destination string unterminated.
  • Loading branch information
fxlb committed Jan 16, 2015
1 parent 20f5296 commit 0d9b1ce
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ pcap_lookupnet(device, netp, maskp, errbuf)
/* XXX Work around Linux kernel bug */
ifr.ifr_addr.sa_family = AF_INET;
#endif
(void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
(void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) {
if (errno == EADDRNOTAVAIL) {
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
Expand All @@ -925,7 +925,7 @@ pcap_lookupnet(device, netp, maskp, errbuf)
/* XXX Work around Linux kernel bug */
ifr.ifr_addr.sa_family = AF_INET;
#endif
(void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
(void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) {
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFNETMASK: %s: %s", device, pcap_strerror(errno));
Expand Down

0 comments on commit 0d9b1ce

Please sign in to comment.