diff options
author | Jean-Baptiste Maillet <jean-baptiste.maillet@parrot.com> | 2014-11-24 11:04:44 +0100 |
---|---|---|
committer | Jean-Baptiste Maillet <jean-baptiste.maillet@parrot.com> | 2014-11-24 11:04:44 +0100 |
commit | de5f2b55126af3fc898398dab46bbab5371824f1 (patch) | |
tree | d604968f62891b751616f486f280d9af5d64e2ef /examples/simple_talker | |
parent | 146b3e0c5df87dcdd010b1e1a72e23bc166bec54 (diff) | |
download | Open-AVB-de5f2b55126af3fc898398dab46bbab5371824f1.tar.gz |
Fix for Coverity CID71731 - Buffer not null terminated
Diffstat (limited to 'examples/simple_talker')
-rwxr-xr-x | examples/simple_talker/simple_talker.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/examples/simple_talker/simple_talker.c b/examples/simple_talker/simple_talker.c index 37bf6d6c..2e5fc716 100755 --- a/examples/simple_talker/simple_talker.c +++ b/examples/simple_talker/simple_talker.c @@ -433,16 +433,19 @@ int get_mac_address(char *interface) struct ifreq if_request; int lsock; int rc; + lsock = socket(PF_PACKET, SOCK_RAW, htons(0x800)); if (lsock < 0) return -1; + memset(&if_request, 0, sizeof(if_request)); - strncpy(if_request.ifr_name, interface, sizeof(if_request.ifr_name)); + strncpy(if_request.ifr_name, interface, sizeof(if_request.ifr_name) - 1); rc = ioctl(lsock, SIOCGIFHWADDR, &if_request); if (rc < 0) { close(lsock); return -1; } + memcpy(STATION_ADDR, if_request.ifr_hwaddr.sa_data, sizeof(STATION_ADDR)); close(lsock); |