diff options
author | Tom Hromatka <tom.hromatka@oracle.com> | 2020-06-30 08:16:38 -0600 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2020-07-13 21:14:15 -0400 |
commit | 858df15ea6354b6a75979720bce057b696545fd0 (patch) | |
tree | 60a6ba7f42319ece11d57364bc0db60b19c51e0b /src/arch-x32.c | |
parent | e74831eb6679bc2ae12a7f426de0e75859032e81 (diff) | |
download | libseccomp-858df15ea6354b6a75979720bce057b696545fd0.tar.gz |
arch: Use bitwise math rather than arithmetic
The arm and x32 architecture files were using arithmetic
to set/clear bits in their syscall numbers. This could
erroneously double add or double subtract these bits.
This commit uses bitwise logic to ensure the bits are
properly set/cleared.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'src/arch-x32.c')
-rw-r--r-- | src/arch-x32.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/arch-x32.c b/src/arch-x32.c index 7b97fb3..3890968 100644 --- a/src/arch-x32.c +++ b/src/arch-x32.c @@ -43,7 +43,7 @@ int x32_syscall_resolve_name_munge(const char *name) if (sys == __NR_SCMP_ERROR) return sys; - return sys + X32_SYSCALL_BIT; + return (sys | X32_SYSCALL_BIT); } /** @@ -57,7 +57,7 @@ int x32_syscall_resolve_name_munge(const char *name) */ const char *x32_syscall_resolve_num_munge(int num) { - return x32_syscall_resolve_num(num - X32_SYSCALL_BIT); + return x32_syscall_resolve_num(num & (~X32_SYSCALL_BIT)); } const struct arch_def arch_def_x32 = { |