diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-06-15 13:37:49 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-06-15 13:37:49 +0200 |
commit | 16e12faa29c0b86ea44956a193db4675fbf83ecb (patch) | |
tree | f694ee7adbf247ff2100a9ccd1bd52f89e65f656 | |
parent | 721fb0de29e78a1cfd5d759758c69830333d7699 (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.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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)); |