aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Pinto <danielpinto52@gmail.com>2018-04-17 01:31:49 +0100
committerNick Mathewson <nickm@torproject.org>2018-08-08 09:21:29 -0400
commita350f216b30c5841b8eb0303c9c3fd32a2b2245b (patch)
tree05d8210d6a9431b57c000f3cfb0f8b42b2042cbd /src
parent42c6ebda1626371cc6b0fff0cc0710b841936bef (diff)
downloadtor-a350f216b30c5841b8eb0303c9c3fd32a2b2245b.tar.gz
tor-a350f216b30c5841b8eb0303c9c3fd32a2b2245b.zip
Fix crash when calling openat with sandbox enabled #25440
The seccomp rule for the openat syscall checks for the AT_FDCWD constant. Because this constant is usually a negative value, a cast to unsigned int is necessary to make sure it does not get converted to uint64_t used by seccomp. More info on: https://github.com/seccomp/libseccomp/issues/69#issuecomment-273805980
Diffstat (limited to 'src')
-rw-r--r--src/common/sandbox.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/common/sandbox.c b/src/common/sandbox.c
index 3d27ea66b5..0a972d496b 100644
--- a/src/common/sandbox.c
+++ b/src/common/sandbox.c
@@ -469,7 +469,7 @@ allow_file_open(scmp_filter_ctx ctx, int use_openat, const char *file)
{
if (use_openat) {
return seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(openat),
- SCMP_CMP_STR(0, SCMP_CMP_EQ, AT_FDCWD),
+ SCMP_CMP(0, SCMP_CMP_EQ, (unsigned int)AT_FDCWD),
SCMP_CMP_STR(1, SCMP_CMP_EQ, file));
} else {
return seccomp_rule_add_1(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open),