Signed-off-by: Paul Moore <[email protected]> --- tests/01-sim-allow.c | 3 ++- tests/02-sim-basic.c | 4 ++-- tests/03-sim-basic_chains.c | 3 ++- tests/04-sim-multilevel_chains.c | 3 ++- tests/05-sim-long_jumps.c | 3 ++- tests/06-sim-actions.c | 2 +- tests/07-sim-db_bug_looping.c | 3 ++- tests/08-sim-subtree_checks.c | 3 ++- tests/09-sim-syscall_priority_pre.c | 3 ++- tests/10-sim-syscall_priority_post.c | 3 ++- tests/11-basic-basic_errors.c | 2 +- tests/12-sim-basic_masked_ops.c | 3 ++- tests/13-basic-attrs.c | 2 +- tests/14-sim-reset.c | 4 ++-- tests/15-basic-resolver.c | 1 + tests/16-sim-arch_basic.c | 4 ++-- tests/17-sim-arch_merge.c | 10 +++++++--- tests/18-sim-basic_whitelist.c | 3 ++- tests/19-sim-missing_syscalls.c | 2 +- tests/20-live-basic_die.c | 5 ++++- tests/21-live-basic_allow.c | 5 ++++- tests/22-sim-basic_chains_array.c | 3 ++- tests/23-sim-arch_all_le_basic.c | 3 ++- tests/24-live-arg_allow.c | 4 +++- tests/25-sim-multilevel_chains_adv.c | 3 ++- tests/26-sim-arch_all_be_basic.c | 3 ++- 26 files changed, 57 insertions(+), 30 deletions(-)
diff --git a/tests/01-sim-allow.c b/tests/01-sim-allow.c index 947e9d9..6de906d 100644 --- a/tests/01-sim-allow.c +++ b/tests/01-sim-allow.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_ALLOW); if (ctx == NULL) - goto out; + return ENOMEM; rc = util_filter_output(&opts, ctx); if (rc) diff --git a/tests/02-sim-basic.c b/tests/02-sim-basic.c index f902a47..c343156 100644 --- a/tests/02-sim-basic.c +++ b/tests/02-sim-basic.c @@ -24,6 +24,7 @@ * read, write, exit, and rt_sigreturn */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -42,8 +43,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; - + return ENOMEM; rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0); if (rc != 0) diff --git a/tests/03-sim-basic_chains.c b/tests/03-sim-basic_chains.c index 06a0d15..011e3b3 100644 --- a/tests/03-sim-basic_chains.c +++ b/tests/03-sim-basic_chains.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1, SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO)); diff --git a/tests/04-sim-multilevel_chains.c b/tests/04-sim-multilevel_chains.c index c504d22..83bbfd5 100644 --- a/tests/04-sim-multilevel_chains.c +++ b/tests/04-sim-multilevel_chains.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <limits.h> #include <unistd.h> @@ -38,7 +39,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), 0); if (rc != 0) diff --git a/tests/05-sim-long_jumps.c b/tests/05-sim-long_jumps.c index 0046e07..d48398c 100644 --- a/tests/05-sim-long_jumps.c +++ b/tests/05-sim-long_jumps.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <limits.h> @@ -39,7 +40,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; /* NOTE - syscalls referenced by number to make the test simpler */ diff --git a/tests/06-sim-actions.c b/tests/06-sim-actions.c index 68b037c..4dbe19f 100644 --- a/tests/06-sim-actions.c +++ b/tests/06-sim-actions.c @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0); if (rc != 0) diff --git a/tests/07-sim-db_bug_looping.c b/tests/07-sim-db_bug_looping.c index 68afbe1..e3fec81 100644 --- a/tests/07-sim-db_bug_looping.c +++ b/tests/07-sim-db_bug_looping.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; /* The next three seccomp_rule_add_exact() calls for read must * go together in this order to catch an infinite loop. */ diff --git a/tests/08-sim-subtree_checks.c b/tests/08-sim-subtree_checks.c index 42fce30..e187cee 100644 --- a/tests/08-sim-subtree_checks.c +++ b/tests/08-sim-subtree_checks.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; /* the syscall and argument numbers are all fake to make the test * simpler */ diff --git a/tests/09-sim-syscall_priority_pre.c b/tests/09-sim-syscall_priority_pre.c index c820ac8..68e35a5 100644 --- a/tests/09-sim-syscall_priority_pre.c +++ b/tests/09-sim-syscall_priority_pre.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; /* the syscall and argument numbers are all fake to make the test * simpler */ diff --git a/tests/10-sim-syscall_priority_post.c b/tests/10-sim-syscall_priority_post.c index d426e14..1e8712d 100644 --- a/tests/10-sim-syscall_priority_post.c +++ b/tests/10-sim-syscall_priority_post.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; /* the syscall and argument numbers are all fake to make the test * simpler */ diff --git a/tests/11-basic-basic_errors.c b/tests/11-basic-basic_errors.c index 4ebd43a..2b72205 100644 --- a/tests/11-basic-basic_errors.c +++ b/tests/11-basic-basic_errors.c @@ -19,8 +19,8 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ -#include <unistd.h> #include <errno.h> +#include <unistd.h> #include <seccomp.h> diff --git a/tests/12-sim-basic_masked_ops.c b/tests/12-sim-basic_masked_ops.c index 29b86d6..5c699f3 100644 --- a/tests/12-sim-basic_masked_ops.c +++ b/tests/12-sim-basic_masked_ops.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; /* the syscall and argument numbers are all fake to make the test * simpler */ diff --git a/tests/13-basic-attrs.c b/tests/13-basic-attrs.c index 091c8ed..2cd8d29 100644 --- a/tests/13-basic-attrs.c +++ b/tests/13-basic-attrs.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_ALLOW); if (ctx == NULL) - goto out; + return ENOMEM; rc = seccomp_attr_get(ctx, SCMP_FLTATR_ACT_DEFAULT, &val); if (rc != 0) diff --git a/tests/14-sim-reset.c b/tests/14-sim-reset.c index c87ba13..039974f 100644 --- a/tests/14-sim-reset.c +++ b/tests/14-sim-reset.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,8 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; - + return ENOMEM; rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0); if (rc != 0) diff --git a/tests/15-basic-resolver.c b/tests/15-basic-resolver.c index a103a1a..a8988fd 100644 --- a/tests/15-basic-resolver.c +++ b/tests/15-basic-resolver.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <string.h> #include <seccomp.h> diff --git a/tests/16-sim-arch_basic.c b/tests/16-sim-arch_basic.c index d63a1c4..8e54c0a 100644 --- a/tests/16-sim-arch_basic.c +++ b/tests/16-sim-arch_basic.c @@ -19,8 +19,8 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ -#include <unistd.h> #include <errno.h> +#include <unistd.h> #include <seccomp.h> @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; rc = seccomp_arch_remove(ctx, SCMP_ARCH_NATIVE); if (rc != 0) diff --git a/tests/17-sim-arch_merge.c b/tests/17-sim-arch_merge.c index cb0e33c..58af194 100644 --- a/tests/17-sim-arch_merge.c +++ b/tests/17-sim-arch_merge.c @@ -19,8 +19,8 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ -#include <unistd.h> #include <errno.h> +#include <unistd.h> #include <seccomp.h> @@ -37,11 +37,15 @@ int main(int argc, char *argv[]) goto out_all; ctx_32 = seccomp_init(SCMP_ACT_KILL); - if (ctx_32 == NULL) + if (ctx_32 == NULL) { + rc = -ENOMEM; goto out_all; + } ctx_64 = seccomp_init(SCMP_ACT_KILL); - if (ctx_64 == NULL) + if (ctx_64 == NULL) { + rc = -ENOMEM; goto out_all; + } rc = seccomp_arch_remove(ctx_32, SCMP_ARCH_NATIVE); if (rc != 0) diff --git a/tests/18-sim-basic_whitelist.c b/tests/18-sim-basic_whitelist.c index d312f18..d07a3b6 100644 --- a/tests/18-sim-basic_whitelist.c +++ b/tests/18-sim-basic_whitelist.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_ALLOW); if (ctx == NULL) - goto out; + return ENOMEM; rc = seccomp_rule_add_exact(ctx, SCMP_ACT_KILL, SCMP_SYS(read), 1, SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO)); diff --git a/tests/19-sim-missing_syscalls.c b/tests/19-sim-missing_syscalls.c index fec9185..50862dc 100644 --- a/tests/19-sim-missing_syscalls.c +++ b/tests/19-sim-missing_syscalls.c @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; rc = seccomp_arch_remove(ctx, SCMP_ARCH_NATIVE); if (rc != 0) diff --git a/tests/20-live-basic_die.c b/tests/20-live-basic_die.c index 1dda6d7..5e6a99b 100644 --- a/tests/20-live-basic_die.c +++ b/tests/20-live-basic_die.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -44,7 +45,8 @@ int main(int argc, char *argv[]) ctx = seccomp_init(action); if (ctx == NULL) - goto out; + return ENOMEM; + rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(rt_sigreturn), 0); if (rc != 0) @@ -53,6 +55,7 @@ int main(int argc, char *argv[]) SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0); if (rc != 0) goto out; + rc = seccomp_load(ctx); if (rc != 0) goto out; diff --git a/tests/21-live-basic_allow.c b/tests/21-live-basic_allow.c index dccc656..690f98e 100644 --- a/tests/21-live-basic_allow.c +++ b/tests/21-live-basic_allow.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -42,7 +43,8 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_TRAP); if (ctx == NULL) - goto out; + return ENOMEM; + rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), 0); if (rc != 0) goto out; @@ -60,6 +62,7 @@ int main(int argc, char *argv[]) SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0); if (rc != 0) goto out; + rc = seccomp_load(ctx); if (rc != 0) goto out; diff --git a/tests/22-sim-basic_chains_array.c b/tests/22-sim-basic_chains_array.c index e3c9613..f1be656 100644 --- a/tests/22-sim-basic_chains_array.c +++ b/tests/22-sim-basic_chains_array.c @@ -18,6 +18,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; arg_cmp = SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO); rc = seccomp_rule_add_exact_array(ctx, SCMP_ACT_ALLOW, diff --git a/tests/23-sim-arch_all_le_basic.c b/tests/23-sim-arch_all_le_basic.c index 92f5eb7..446a8d8 100644 --- a/tests/23-sim-arch_all_le_basic.c +++ b/tests/23-sim-arch_all_le_basic.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; rc = seccomp_arch_remove(ctx, SCMP_ARCH_NATIVE); if (rc != 0) diff --git a/tests/24-live-arg_allow.c b/tests/24-live-arg_allow.c index 7c50c96..2ee8377 100644 --- a/tests/24-live-arg_allow.c +++ b/tests/24-live-arg_allow.c @@ -56,7 +56,8 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_TRAP); if (ctx == NULL) - goto out; + return ENOMEM; + rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 1, SCMP_A0(SCMP_CMP_EQ, fd)); if (rc != 0) @@ -72,6 +73,7 @@ int main(int argc, char *argv[]) SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0); if (rc != 0) goto out; + rc = seccomp_load(ctx); if (rc != 0) goto out; diff --git a/tests/25-sim-multilevel_chains_adv.c b/tests/25-sim-multilevel_chains_adv.c index 0ef7f67..a284aa4 100644 --- a/tests/25-sim-multilevel_chains_adv.c +++ b/tests/25-sim-multilevel_chains_adv.c @@ -19,6 +19,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <stdlib.h> #include <seccomp.h> @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 10, 2, SCMP_A0(SCMP_CMP_EQ, 11), diff --git a/tests/26-sim-arch_all_be_basic.c b/tests/26-sim-arch_all_be_basic.c index 253138b..be892fb 100644 --- a/tests/26-sim-arch_all_be_basic.c +++ b/tests/26-sim-arch_all_be_basic.c @@ -18,6 +18,7 @@ * along with this library; if not, see <http://www.gnu.org/licenses>. */ +#include <errno.h> #include <unistd.h> #include <seccomp.h> @@ -36,7 +37,7 @@ int main(int argc, char *argv[]) ctx = seccomp_init(SCMP_ACT_KILL); if (ctx == NULL) - goto out; + return ENOMEM; rc = seccomp_arch_remove(ctx, SCMP_ARCH_NATIVE); if (rc != 0) ------------------------------------------------------------------------------ Is your legacy SCM system holding you back? Join Perforce May 7 to find out: • 3 signs your SCM is hindering your productivity • Requirements for releasing software faster • Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce _______________________________________________ libseccomp-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libseccomp-discuss
