diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2016-07-16 12:39:43 +0300 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2016-07-18 14:43:45 +0200 |
commit | 9ad5ccd66e89778e33cd1be3cd8887ec4a03d177 (patch) | |
tree | c4e804dd8f4f6795ca505ccd0b0ee69acf1dfe7c /trafgen_proto.c | |
parent | c11d67bf8ce5666b454ba34c004c264d5cfae24a (diff) |
trafgen: ipv4: Do not use user-provided 'ihl' field to calculate csum
It is potentially dangerous to use the user specified IHL field for
csum calculation, as it might lead to read buffer overflows.
Instead introduce and use the len field in struct proto_hdr which is
calculated automatically after the header is built.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[tk: reword commit message]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_proto.c')
-rw-r--r-- | trafgen_proto.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/trafgen_proto.c b/trafgen_proto.c index 1babba5..cb0c6ae 100644 --- a/trafgen_proto.c +++ b/trafgen_proto.c @@ -100,8 +100,10 @@ void proto_header_fields_add(struct proto_hdr *hdr, f->mask = fields[i].mask; f->pkt_offset = hdr->pkt_offset + fields[i].offset; - if (f->pkt_offset + f->len > pkt->len) + if (f->pkt_offset + f->len > pkt->len) { + hdr->len += f->len; set_fill(0, (f->pkt_offset + f->len) - pkt->len); + } } } |