diff options
author | 2018-09-04 08:28:14 -0400 | |
---|---|---|
committer | 2018-09-04 08:28:14 -0400 | |
commit | e8989dc95bc55644661ded3c2b68212e296d19bd (patch) | |
tree | 7ecdf9603d4bd354902db65d8bd7ca944f993447 /src/fnet | |
parent | mainline merges (diff) | |
download | firejail-e8989dc95bc55644661ded3c2b68212e296d19bd.tar.gz firejail-e8989dc95bc55644661ded3c2b68212e296d19bd.tar.zst firejail-e8989dc95bc55644661ded3c2b68212e296d19bd.zip |
mainline merge
Diffstat (limited to 'src/fnet')
-rw-r--r-- | src/fnet/arp.c | 2 | ||||
-rw-r--r-- | src/fnet/interface.c | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/fnet/arp.c b/src/fnet/arp.c index 2b6df6945..794f6c8c8 100644 --- a/src/fnet/arp.c +++ b/src/fnet/arp.c | |||
@@ -60,7 +60,7 @@ void arp_scan(const char *dev, uint32_t ifip, uint32_t ifmask) { | |||
60 | errExit("socket"); | 60 | errExit("socket"); |
61 | struct ifreq ifr; | 61 | struct ifreq ifr; |
62 | memset(&ifr, 0, sizeof (ifr)); | 62 | memset(&ifr, 0, sizeof (ifr)); |
63 | strncpy(ifr.ifr_name, dev, IFNAMSIZ); | 63 | strncpy(ifr.ifr_name, dev, IFNAMSIZ - 1); |
64 | if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) | 64 | if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) |
65 | errExit("ioctl"); | 65 | errExit("ioctl"); |
66 | close(sock); | 66 | close(sock); |
diff --git a/src/fnet/interface.c b/src/fnet/interface.c index f3e9a8993..283c6d312 100644 --- a/src/fnet/interface.c +++ b/src/fnet/interface.c | |||
@@ -58,7 +58,7 @@ void net_bridge_add_interface(const char *bridge, const char *dev) { | |||
58 | errExit("socket"); | 58 | errExit("socket"); |
59 | 59 | ||
60 | memset(&ifr, 0, sizeof(ifr)); | 60 | memset(&ifr, 0, sizeof(ifr)); |
61 | strncpy(ifr.ifr_name, bridge, IFNAMSIZ); | 61 | strncpy(ifr.ifr_name, bridge, IFNAMSIZ - 1); |
62 | #ifdef SIOCBRADDIF | 62 | #ifdef SIOCBRADDIF |
63 | ifr.ifr_ifindex = ifindex; | 63 | ifr.ifr_ifindex = ifindex; |
64 | err = ioctl(sock, SIOCBRADDIF, &ifr); | 64 | err = ioctl(sock, SIOCBRADDIF, &ifr); |
@@ -90,7 +90,7 @@ void net_if_up(const char *ifname) { | |||
90 | // get the existing interface flags | 90 | // get the existing interface flags |
91 | struct ifreq ifr; | 91 | struct ifreq ifr; |
92 | memset(&ifr, 0, sizeof(ifr)); | 92 | memset(&ifr, 0, sizeof(ifr)); |
93 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ); | 93 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); |
94 | ifr.ifr_addr.sa_family = AF_INET; | 94 | ifr.ifr_addr.sa_family = AF_INET; |
95 | 95 | ||
96 | // read the existing flags | 96 | // read the existing flags |
@@ -135,7 +135,7 @@ int net_get_mtu(const char *ifname) { | |||
135 | 135 | ||
136 | memset(&ifr, 0, sizeof(ifr)); | 136 | memset(&ifr, 0, sizeof(ifr)); |
137 | ifr.ifr_addr.sa_family = AF_INET; | 137 | ifr.ifr_addr.sa_family = AF_INET; |
138 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ); | 138 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); |
139 | if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) == 0) | 139 | if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) == 0) |
140 | mtu = ifr.ifr_mtu; | 140 | mtu = ifr.ifr_mtu; |
141 | close(s); | 141 | close(s); |
@@ -154,7 +154,7 @@ void net_set_mtu(const char *ifname, int mtu) { | |||
154 | 154 | ||
155 | memset(&ifr, 0, sizeof(ifr)); | 155 | memset(&ifr, 0, sizeof(ifr)); |
156 | ifr.ifr_addr.sa_family = AF_INET; | 156 | ifr.ifr_addr.sa_family = AF_INET; |
157 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ); | 157 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); |
158 | ifr.ifr_mtu = mtu; | 158 | ifr.ifr_mtu = mtu; |
159 | if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) != 0) { | 159 | if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) != 0) { |
160 | if (!arg_quiet) | 160 | if (!arg_quiet) |
@@ -238,7 +238,7 @@ int net_get_mac(const char *ifname, unsigned char mac[6]) { | |||
238 | errExit("socket"); | 238 | errExit("socket"); |
239 | 239 | ||
240 | memset(&ifr, 0, sizeof(ifr)); | 240 | memset(&ifr, 0, sizeof(ifr)); |
241 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ); | 241 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); |
242 | ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; | 242 | ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; |
243 | 243 | ||
244 | if (ioctl(sock, SIOCGIFHWADDR, &ifr) == -1) | 244 | if (ioctl(sock, SIOCGIFHWADDR, &ifr) == -1) |
@@ -258,7 +258,7 @@ void net_if_ip(const char *ifname, uint32_t ip, uint32_t mask, int mtu) { | |||
258 | 258 | ||
259 | struct ifreq ifr; | 259 | struct ifreq ifr; |
260 | memset(&ifr, 0, sizeof(ifr)); | 260 | memset(&ifr, 0, sizeof(ifr)); |
261 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ); | 261 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); |
262 | ifr.ifr_addr.sa_family = AF_INET; | 262 | ifr.ifr_addr.sa_family = AF_INET; |
263 | 263 | ||
264 | ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr = htonl(ip); | 264 | ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr = htonl(ip); |
@@ -292,7 +292,7 @@ int net_if_mac(const char *ifname, const unsigned char mac[6]) { | |||
292 | errExit("socket"); | 292 | errExit("socket"); |
293 | 293 | ||
294 | memset(&ifr, 0, sizeof(ifr)); | 294 | memset(&ifr, 0, sizeof(ifr)); |
295 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ); | 295 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); |
296 | ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; | 296 | ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; |
297 | memcpy(ifr.ifr_hwaddr.sa_data, mac, 6); | 297 | memcpy(ifr.ifr_hwaddr.sa_data, mac, 6); |
298 | 298 | ||
@@ -350,7 +350,7 @@ void net_if_ip6(const char *ifname, const char *addr6) { | |||
350 | // find interface index | 350 | // find interface index |
351 | struct ifreq ifr; | 351 | struct ifreq ifr; |
352 | memset(&ifr, 0, sizeof(ifr)); | 352 | memset(&ifr, 0, sizeof(ifr)); |
353 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ); | 353 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); |
354 | ifr.ifr_addr.sa_family = AF_INET; | 354 | ifr.ifr_addr.sa_family = AF_INET; |
355 | if (ioctl(sock, SIOGIFINDEX, &ifr) < 0) { | 355 | if (ioctl(sock, SIOGIFINDEX, &ifr) < 0) { |
356 | perror("ioctl SIOGIFINDEX"); | 356 | perror("ioctl SIOGIFINDEX"); |