aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2021-08-30 12:15:37 +0000
committerLibravatar GitHub <noreply@github.com>2021-08-30 12:15:37 +0000
commit76ee518742af9fcbe4a234b7cf6168868ac11864 (patch)
tree1cf660c87deee07d26a8c4837177963e0be2004e
parentupdating youtube-viewers-common.profile (#4485) (diff)
parentFix hanging arp_check (diff)
downloadfirejail-76ee518742af9fcbe4a234b7cf6168868ac11864.tar.gz
firejail-76ee518742af9fcbe4a234b7cf6168868ac11864.tar.zst
firejail-76ee518742af9fcbe4a234b7cf6168868ac11864.zip
Merge pull request #4476 from minus7/master
Fix hanging arp_check
-rw-r--r--src/firejail/arp.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/firejail/arp.c b/src/firejail/arp.c
index bbab9a6d9..c259fc0ad 100644
--- a/src/firejail/arp.c
+++ b/src/firejail/arp.c
@@ -20,6 +20,7 @@
20#include "firejail.h" 20#include "firejail.h"
21#include <sys/socket.h> 21#include <sys/socket.h>
22#include <sys/ioctl.h> 22#include <sys/ioctl.h>
23#include <sys/time.h>
23#include <linux/if_ether.h> //TCP/IP Protocol Suite for Linux 24#include <linux/if_ether.h> //TCP/IP Protocol Suite for Linux
24#include <net/if.h> 25#include <net/if.h>
25#include <netinet/in.h> 26#include <netinet/in.h>
@@ -188,9 +189,14 @@ int arp_check(const char *dev, uint32_t destaddr) {
188 FD_SET(sock, &fds); 189 FD_SET(sock, &fds);
189 int maxfd = sock; 190 int maxfd = sock;
190 struct timeval ts; 191 struct timeval ts;
191 ts.tv_sec = 0; // 0.5 seconds wait time 192 gettimeofday(&ts, NULL);
192 ts.tv_usec = 500000; 193 double timerend = ts.tv_sec + ts.tv_usec / 1000000.0 + 0.5;
193 while (1) { 194 while (1) {
195 gettimeofday(&ts, NULL);
196 double now = ts.tv_sec + ts.tv_usec / 1000000.0;
197 double timeout = timerend - now;
198 ts.tv_sec = timeout;
199 ts.tv_usec = (timeout - ts.tv_sec) * 1000000;
194 int nready = select(maxfd + 1, &fds, (fd_set *) 0, (fd_set *) 0, &ts); 200 int nready = select(maxfd + 1, &fds, (fd_set *) 0, (fd_set *) 0, &ts);
195 if (nready < 0) 201 if (nready < 0)
196 errExit("select"); 202 errExit("select");
@@ -201,8 +207,8 @@ int arp_check(const char *dev, uint32_t destaddr) {
201 } 207 }
202 if (sendto (sock, frame, 14 + sizeof(ArpHdr), 0, (struct sockaddr *) &addr, sizeof (addr)) <= 0) 208 if (sendto (sock, frame, 14 + sizeof(ArpHdr), 0, (struct sockaddr *) &addr, sizeof (addr)) <= 0)
203 errExit("send"); 209 errExit("send");
204 ts.tv_sec = 0; // 0.5 seconds wait time 210 gettimeofday(&ts, NULL);
205 ts.tv_usec = 500000; 211 timerend = ts.tv_sec + ts.tv_usec / 1000000.0 + 0.5;
206 fflush(0); 212 fflush(0);
207 } 213 }
208 else { 214 else {