summaryrefslogtreecommitdiffstats
path: root/userspace/arptables/arptables.c
diff options
context:
space:
mode:
authorJaromír Končický <jkoncick@redhat.com>2013-10-15 21:55:52 +0200
committerBart De Schuymer <bdschuym@pandora.be>2013-10-15 21:55:52 +0200
commitfea55b0930d7cb67a3359185e53ef6b856b7721d (patch)
tree23b969532667985017b53affce37584b1f66d098 /userspace/arptables/arptables.c
parent461c0674967504fafe7feb7631c51e7fceb67753 (diff)
fix potential buffer overflows reported by static analysis
Diffstat (limited to 'userspace/arptables/arptables.c')
-rw-r--r--userspace/arptables/arptables.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/userspace/arptables/arptables.c b/userspace/arptables/arptables.c
index 8ef445a..4da6fea 100644
--- a/userspace/arptables/arptables.c
+++ b/userspace/arptables/arptables.c
@@ -1270,7 +1270,7 @@ print_firewall(const struct arpt_entry *fw,
sprintf(buf, "%s", addr_to_dotted(&(fw->arp.src)));
else
sprintf(buf, "%s", addr_to_anyname(&(fw->arp.src)));
- strcat(buf, mask_to_dotted(&(fw->arp.smsk)));
+ strncat(buf, mask_to_dotted(&(fw->arp.smsk)), sizeof(buf) - strlen(buf) -1);
printf("-s %s ", buf);
}
@@ -1294,7 +1294,7 @@ after_devsrc:
sprintf(buf, "%s", addr_to_dotted(&(fw->arp.tgt)));
else
sprintf(buf, "%s", addr_to_anyname(&(fw->arp.tgt)));
- strcat(buf, mask_to_dotted(&(fw->arp.tmsk)));
+ strncat(buf, mask_to_dotted(&(fw->arp.tmsk)), sizeof(buf) - strlen(buf) -1);
printf("-d %s ", buf);
}
@@ -1796,7 +1796,7 @@ int do_command(int argc, char *argv[], char **table, arptc_handle_t *handle)
*table, arptc_strerror(errno));
}
}
- }
+ }
memset(&fw, 0, sizeof(fw));
opts = original_opts;
@@ -2064,7 +2064,8 @@ int do_command(int argc, char *argv[], char **table, arptc_handle_t *handle)
target->t = fw_calloc(1, size);
target->t->u.target_size = size;
- strcpy(target->t->u.user.name, jumpto);
+ strncpy(target->t->u.user.name, jumpto, sizeof(target->t->u.user.name));
+ target->t->u.user.name[sizeof(target->t->u.user.name)-1] = '\0';
/*
target->init(target->t, &fw.nfcache);
*/