diff options
author | Bart De Schuymer <bdschuym@pandora.be> | 2011-06-23 18:24:38 +0000 |
---|---|---|
committer | Bart De Schuymer <bdschuym@pandora.be> | 2011-06-23 18:24:38 +0000 |
commit | caf30a4b77b49c02f2d824969e7398b89627e811 (patch) | |
tree | 37a91a049bdfd8ef58db2295802228780ea3c925 /communication.c | |
parent | 192b91d540aa8c68ab4c0d04b04cbf6651565043 (diff) | |
download | ebtables-caf30a4b77b49c02f2d824969e7398b89627e811.tar.gz |
fix possible issues found by Coverity static analysis (thanks to Jiri Popelka)
Diffstat (limited to 'communication.c')
-rw-r--r-- | communication.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/communication.c b/communication.c index 4b89a65..3311358 100644 --- a/communication.c +++ b/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; |