aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2023-04-26 07:39:27 -0300
committerLibravatar Topi Miettinen <topimiettinen@users.noreply.github.com>2023-05-01 20:19:34 +0000
commit1e3e43e12322825e7d5ca70771ed9ecb26f6403d (patch)
tree92a044ec11de9aeadbcf1790e30f256be42de093 /src
parentbuild(deps): bump github/codeql-action from 2.3.0 to 2.3.2 (diff)
downloadfirejail-1e3e43e12322825e7d5ca70771ed9ecb26f6403d.tar.gz
firejail-1e3e43e12322825e7d5ca70771ed9ecb26f6403d.tar.zst
firejail-1e3e43e12322825e7d5ca70771ed9ecb26f6403d.zip
arp.c: ensure positive timeout on select(2)
Log from build_and_test[1]: TESTING: network scan (net_scan.exp) [...] firejail /bin/bash Child process initialized in 1704.83 ms spawn /bin/bash firejail --net=br0 --ip=10.10.20.60 runner@fv-az576-472:~/work/firejail/firejail/test/network$ <l/test/network$ firejail --net=br0 --ip=10.10.20.60 Reading profile /etc/firejail/default.profile Reading profile /etc/firejail/disable-common.inc Reading profile /etc/firejail/disable-programs.inc ** Note: you can use --noprofile to disable default.profile ** Error select: arp.c:202 arp_check: Invalid argument runner@fv-az576-472:~/work/firejail/firejail/test/network$ TESTING ERROR 4 This "Invalid argument" error does not always happen, so I assume that it may be due to a negative integer value in `ts` when calling select. Misc: Found in #5805. [1] https://github.com/netblue30/firejail/actions/runs/4806275219/jobs/8553597462
Diffstat (limited to 'src')
-rw-r--r--src/firejail/arp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/firejail/arp.c b/src/firejail/arp.c
index d4288b29e..ed14eb171 100644
--- a/src/firejail/arp.c
+++ b/src/firejail/arp.c
@@ -197,7 +197,11 @@ int arp_check(const char *dev, uint32_t destaddr) {
197 double timeout = timerend - now; 197 double timeout = timerend - now;
198 ts.tv_sec = timeout; 198 ts.tv_sec = timeout;
199 ts.tv_usec = (timeout - ts.tv_sec) * 1000000; 199 ts.tv_usec = (timeout - ts.tv_sec) * 1000000;
200 int nready = select(maxfd + 1, &fds, (fd_set *) 0, (fd_set *) 0, &ts); 200 if (ts.tv_sec < 0)
201 ts.tv_sec = 0;
202 if (ts.tv_usec < 0)
203 ts.tv_usec = 0;
204 int nready = select(maxfd + 1, &fds, (fd_set *) 0, (fd_set *) 0, &ts);
201 if (nready < 0) 205 if (nready < 0)
202 errExit("select"); 206 errExit("select");
203 else if (nready == 0) { // timeout 207 else if (nready == 0) { // timeout