summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart De Schuymer <bdschuym@pandora.be>2011-06-23 18:24:38 +0000
committerBart De Schuymer <bdschuym@pandora.be>2011-06-23 18:24:38 +0000
commitb1acc078e9c55ca5f406f76dba9a89c70c7c6bde (patch)
tree56931b746dbfca21e6421d0e595c3e173137167e
parent8a59623f5d9b8bd8f95c7c687a2312ff333872cf (diff)
downloadandroid_external_ebtables-b1acc078e9c55ca5f406f76dba9a89c70c7c6bde.tar.gz
android_external_ebtables-b1acc078e9c55ca5f406f76dba9a89c70c7c6bde.tar.bz2
android_external_ebtables-b1acc078e9c55ca5f406f76dba9a89c70c7c6bde.zip
fix possible issues found by Coverity static analysis (thanks to Jiri Popelka)
-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;