~ubuntu-branches/ubuntu/quantal/libseccomp/quantal-backports

« back to all changes in this revision

Viewing changes to tests/07-db-bug-looping.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2013-11-07 16:35:12 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131107163512-gdgfu5c3kuxfpxvg
Tags: 1.0.1-2~ubuntu12.10.1
No-change backport to quantal (LP: #1244340)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
{
30
30
        int rc;
31
31
        struct util_options opts;
 
32
        scmp_filter_ctx ctx;
32
33
 
33
34
        rc = util_getopt(argc, argv, &opts);
34
35
        if (rc < 0)
35
36
                goto out;
36
37
 
37
 
        rc = seccomp_init(SCMP_ACT_KILL);
38
 
        if (rc != 0)
 
38
        ctx = seccomp_init(SCMP_ACT_KILL);
 
39
        if (ctx == NULL)
39
40
                goto out;
40
41
 
41
42
        /* The next three seccomp_rule_add_exact() calls for read must
42
43
         * go together in this order to catch an infinite loop. */
43
44
 
44
 
        rc = seccomp_rule_add_exact(SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
 
45
        rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
45
46
                                    SCMP_A0(SCMP_CMP_EQ, STDOUT_FILENO));
46
47
        if (rc != 0)
47
48
                goto out;
48
49
 
49
 
        rc = seccomp_rule_add_exact(SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
 
50
        rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
50
51
                                    SCMP_A1(SCMP_CMP_EQ, 0x0));
51
52
        if (rc != 0)
52
53
                goto out;
53
54
 
54
 
        rc = seccomp_rule_add_exact(SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
 
55
        rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
55
56
                                    SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO));
56
57
        if (rc != 0)
57
58
                goto out;
58
59
 
59
 
        rc = util_filter_output(&opts);
 
60
        rc = util_filter_output(&opts, ctx);
60
61
        if (rc)
61
62
                goto out;
62
63
 
63
64
out:
64
 
        seccomp_release();
 
65
        seccomp_release(ctx);
65
66
        return (rc < 0 ? -rc : rc);
66
67
}