aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-07-17 13:55:04 -0400
committerNick Mathewson <nickm@torproject.org>2016-07-17 13:55:04 -0400
commitc138c9a2be868c4d8bad4e6ae5637205f1bdcf0f (patch)
tree43baab11abc049adf6c1d266a444fdd10c4936ee /src
parent9932544297e02dc4f79d70317f214bcbb2dd8e9a (diff)
parentfbae15a856fccdecfb19ff80229b584026ae2def (diff)
downloadtor-c138c9a2be868c4d8bad4e6ae5637205f1bdcf0f.tar.gz
tor-c138c9a2be868c4d8bad4e6ae5637205f1bdcf0f.zip
Merge branch 'maint-0.2.8'
Diffstat (limited to 'src')
-rw-r--r--src/common/sandbox.c30
-rw-r--r--src/test/test_util_format.c8
2 files changed, 19 insertions, 19 deletions
diff --git a/src/common/sandbox.c b/src/common/sandbox.c
index db3054d8d0..23d97dffa1 100644
--- a/src/common/sandbox.c
+++ b/src/common/sandbox.c
@@ -587,7 +587,7 @@ static int
sb_socket(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
{
int rc = 0;
- int i;
+ int i, j;
(void) filter;
#ifdef __i386__
@@ -604,20 +604,20 @@ sb_socket(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
for (i = 0; i < 2; ++i) {
const int pf = i ? PF_INET : PF_INET6;
-
- rc = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket),
- SCMP_CMP(0, SCMP_CMP_EQ, pf),
- SCMP_CMP_MASKED(1, SOCK_CLOEXEC|SOCK_NONBLOCK, SOCK_STREAM),
- SCMP_CMP(2, SCMP_CMP_EQ, IPPROTO_TCP));
- if (rc)
- return rc;
-
- rc = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket),
- SCMP_CMP(0, SCMP_CMP_EQ, pf),
- SCMP_CMP_MASKED(1, SOCK_CLOEXEC|SOCK_NONBLOCK, SOCK_DGRAM),
- SCMP_CMP(2, SCMP_CMP_EQ, IPPROTO_IP));
- if (rc)
- return rc;
+ for (j=0; j < 3; ++j) {
+ const int type = (j == 0) ? SOCK_STREAM :
+ (j == 1) ? SOCK_DGRAM :
+ SOCK_DGRAM;
+ const int protocol = (j == 0) ? IPPROTO_TCP :
+ (j == 1) ? IPPROTO_IP :
+ IPPROTO_UDP;
+ rc = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket),
+ SCMP_CMP(0, SCMP_CMP_EQ, pf),
+ SCMP_CMP_MASKED(1, SOCK_CLOEXEC|SOCK_NONBLOCK, type),
+ SCMP_CMP(2, SCMP_CMP_EQ, protocol));
+ if (rc)
+ return rc;
+ }
}
rc = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket),
diff --git a/src/test/test_util_format.c b/src/test/test_util_format.c
index f3dcd1184c..63a668238c 100644
--- a/src/test/test_util_format.c
+++ b/src/test/test_util_format.c
@@ -106,10 +106,10 @@ test_util_format_base64_encode(void *ignored)
for (i = 0;i<50;i++) {
src[i] = 0;
}
- src[50] = 255;
- src[51] = 255;
- src[52] = 255;
- src[53] = 255;
+ src[50] = (char)255;
+ src[51] = (char)255;
+ src[52] = (char)255;
+ src[53] = (char)255;
res = base64_encode(dst, 1000, src, 54, BASE64_ENCODE_MULTILINE);
tt_int_op(res, OP_EQ, 74);