summaryrefslogtreecommitdiffstats
path: root/userspace
diff options
context:
space:
mode:
Diffstat (limited to 'userspace')
-rw-r--r--userspace/ebtables2/communication.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/userspace/ebtables2/communication.c b/userspace/ebtables2/communication.c
index 4b89a65..3311358 100644
--- a/userspace/ebtables2/communication.c
+++ b/userspace/ebtables2/communication.c
@@ -66,7 +66,9 @@ static struct ebt_replace *translate_user2kernel(struct ebt_u_replace *u_repl)
new->nentries = u_repl->nentries;
new->num_counters = u_repl->num_counters;
new->counters = sparc_cast u_repl->counters;
- chain_offsets = (unsigned int *)malloc(u_repl->num_chains * sizeof(unsigned int));
+ chain_offsets = (unsigned int *)calloc(u_repl->num_chains, sizeof(unsigned int));
+ if (!chain_offsets)
+ ebt_print_memory();
/* Determine size */
for (i = 0; i < u_repl->num_chains; i++) {
if (!(entries = u_repl->chains[i]))
@@ -313,6 +315,8 @@ void ebt_deliver_counters(struct ebt_u_replace *u_repl)
if (chainnr == u_repl->num_chains)
break;
}
+ if (next == NULL)
+ ebt_print_bug("next == NULL");
if (cc->type == CNT_NORM) {
/* 'Normal' rule, meaning we didn't do anything to it
* So, we just copy */
@@ -640,9 +644,9 @@ static int retrieve_from_file(char *filename, struct ebt_replace *repl,
!= repl->entries_size ||
fseek(file, sizeof(struct ebt_replace) + repl->entries_size,
SEEK_SET)
- || fread((char *)repl->counters, sizeof(char),
+ || (repl->counters && fread((char *)repl->counters, sizeof(char),
repl->nentries * sizeof(struct ebt_counter), file)
- != repl->nentries * sizeof(struct ebt_counter)) {
+ != repl->nentries * sizeof(struct ebt_counter))) {
ebt_print_error("File %s is corrupt", filename);
free(entries);
repl->entries = NULL;