diff options
author | Paul Moore <paul@paul-moore.com> | 2017-02-17 12:15:20 -0500 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2017-02-17 14:18:43 -0500 |
commit | e3addce3794ddb6dc174d429da055296282df0e6 (patch) | |
tree | ec9e3b37017df9bc6832a9a6f503d77bdc86e2e7 /src/arch-s390.c | |
parent | 390b4b2f37b8790c3ba762578d5b610304fdb64d (diff) | |
download | libseccomp-e3addce3794ddb6dc174d429da055296282df0e6.tar.gz |
db: include the arguments in the db_api_rule_list struct
Instead of dynamically allocating a variable number of arguments,
include an array of ARG_COUNT_MAX elements directly in the struct.
Also perform a number of simplifications to the code with the
understanding that ARG_COUNT_MAX is an ABI independent value that
isn't variable.
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'src/arch-s390.c')
-rw-r--r-- | src/arch-s390.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/arch-s390.c b/src/arch-s390.c index 2e79670..0d83e97 100644 --- a/src/arch-s390.c +++ b/src/arch-s390.c @@ -209,7 +209,6 @@ int s390_rule_add(struct db_filter_col *col, struct db_filter *db, bool strict, { int rc; unsigned int iter; - size_t args_size; int sys = rule->syscall; int sys_a, sys_b; struct db_api_rule_list *rule_a, *rule_b; @@ -219,7 +218,7 @@ int s390_rule_add(struct db_filter_col *col, struct db_filter *db, bool strict, (359 to 373) : direct socket syscalls, Linux 4.3+ */ /* strict check for the multiplexed socket syscalls */ - for (iter = 0; iter < rule->args_cnt; iter++) { + for (iter = 0; iter < ARG_COUNT_MAX; iter++) { if ((rule->args[iter].valid != 0) && (strict)) return -EINVAL; } @@ -249,19 +248,9 @@ int s390_rule_add(struct db_filter_col *col, struct db_filter *db, bool strict, } else { /* need two rules, dup the first and link together */ rule_a = rule; - rule_b = malloc(sizeof(*rule_b)); + rule_b = db_rule_dup(rule_a); if (rule_b == NULL) return -ENOMEM; - args_size = sizeof(*rule_b->args) * rule_a->args_cnt; - rule_b->args = malloc(args_size); - if (rule_b->args == NULL) { - free(rule_b); - return -ENOMEM; - } - rule_b->action = rule_a->action; - rule_b->syscall = rule_a->syscall; - rule_b->args_cnt = rule_a->args_cnt; - memcpy(rule_b->args, rule_a->args, args_size); rule_b->prev = rule_a; rule_b->next = NULL; rule_a->next = rule_b; |