diff options
author | Disconnect3d <dominik.b.czarnota@gmail.com> | 2019-07-11 21:13:08 +0200 |
---|---|---|
committer | Reiner Herrmann <reiner@reiner-h.de> | 2019-07-11 19:13:08 +0000 |
commit | d3d0d74465a2d6eb4fdda5634cb9aa8ba7a1c5ec (patch) | |
tree | ad32590031d4fe332b4e6e895b53e56ca9fcbcc7 | |
parent | Support media on other drives in youtube-dl.profile (diff) | |
download | firejail-d3d0d74465a2d6eb4fdda5634cb9aa8ba7a1c5ec.tar.gz firejail-d3d0d74465a2d6eb4fdda5634cb9aa8ba7a1c5ec.tar.zst firejail-d3d0d74465a2d6eb4fdda5634cb9aa8ba7a1c5ec.zip |
Update libpostexecseccomp.c (#2851)
* Update libpostexecseccomp.c
Remove `if (size != 0)` condition, which is always true as there is a `if (size <= 0)` condition before.
Also note that if the `if (size <= 0)` condition wouldn't be there and `size` would be 0, there would have been an undefined behavior in due to division by zero in `(unsigned short) size / (unsigned short) sizeof(struct sock_filter);`.
Found with LGTM: https://lgtm.com/projects/g/netblue30/firejail/snapshot/961c4ca00425b60a7bc8543460031a8ebf3d8aa6/files/src/libpostexecseccomp/libpostexecseccomp.c#x838c24f710410160:1
-rw-r--r-- | src/libpostexecseccomp/libpostexecseccomp.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/libpostexecseccomp/libpostexecseccomp.c b/src/libpostexecseccomp/libpostexecseccomp.c index 3983510ec..b2f64f18e 100644 --- a/src/libpostexecseccomp/libpostexecseccomp.c +++ b/src/libpostexecseccomp/libpostexecseccomp.c | |||
@@ -40,9 +40,7 @@ static void load_seccomp(void) { | |||
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | unsigned short entries = (unsigned short) size / (unsigned short) sizeof(struct sock_filter); | 42 | unsigned short entries = (unsigned short) size / (unsigned short) sizeof(struct sock_filter); |
43 | struct sock_filter *filter = MAP_FAILED; | 43 | struct sock_filter *filter = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); |
44 | if (size != 0) | ||
45 | filter = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); | ||
46 | close(fd); | 44 | close(fd); |
47 | 45 | ||
48 | if (filter == MAP_FAILED) { | 46 | if (filter == MAP_FAILED) { |