summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-15 13:37:49 +0200
committerDaniel Borkmann <dborkman@redhat.com>2013-06-15 13:37:49 +0200
commit16e12faa29c0b86ea44956a193db4675fbf83ecb (patch)
treef694ee7adbf247ff2100a9ccd1bd52f89e65f656
parent721fb0de29e78a1cfd5d759758c69830333d7699 (diff)
trafgen: check offsets for all kind of csums
It seems not critical at this point, but lets check it for all offsets here as well, and mark this check as unlikely to happen. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r--trafgen.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/trafgen.c b/trafgen.c
index 3b2f471..ce2967d 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -342,11 +342,11 @@ static void apply_csum16(int csum_id)
struct csum16 *csum = &packet_dyn[i].csum[j];
fmemset(&packets[i].payload[csum->off], 0, sizeof(sum));
+ if (unlikely(csum->to >= packets[i].len))
+ csum->to = packets[i].len - 1;
switch (csum->which) {
case CSUM_IP:
- if (csum->to >= packets[i].len)
- csum->to = packets[i].len - 1;
sum = calc_csum(packets[i].payload + csum->from,
csum->to - csum->from + 1, 0);
break;
@@ -362,6 +362,9 @@ static void apply_csum16(int csum_id)
(packets[i].len - csum->to),
IPPROTO_TCP);
break;
+ default:
+ bug();
+ break;
}
fmemcpy(&packets[i].payload[csum->off], &sum, sizeof(sum));