summaryrefslogtreecommitdiff
path: root/src/arch-x86.c
diff options
context:
space:
mode:
authorPaul Moore <paul@paul-moore.com>2017-02-17 12:15:20 -0500
committerPaul Moore <paul@paul-moore.com>2017-02-17 14:18:43 -0500
commite3addce3794ddb6dc174d429da055296282df0e6 (patch)
treeec9e3b37017df9bc6832a9a6f503d77bdc86e2e7 /src/arch-x86.c
parent390b4b2f37b8790c3ba762578d5b610304fdb64d (diff)
downloadlibseccomp-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-x86.c')
-rw-r--r--src/arch-x86.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/arch-x86.c b/src/arch-x86.c
index 8542079..39c2f09 100644
--- a/src/arch-x86.c
+++ b/src/arch-x86.c
@@ -225,7 +225,6 @@ int x86_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;
@@ -235,7 +234,7 @@ int x86_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;
}
@@ -265,19 +264,9 @@ int x86_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;