diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-06-21 21:13:13 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-06-23 13:34:07 +0200 |
commit | ed2f11bbe3ead86611afbef011d9c6ac72c376ff (patch) | |
tree | ad90fb0163047474994fd61f40a06debdf3309f1 /lib | |
parent | 072505f4ede34bc533396dd48275c117529bd5b9 (diff) | |
download | barebox-ed2f11bbe3ead86611afbef011d9c6ac72c376ff.tar.gz barebox-ed2f11bbe3ead86611afbef011d9c6ac72c376ff.tar.xz |
ratp: fix data presence check
Looking at the "data length" and SO flag isn't enough to declare a
packet with or without data, because SYN flagged packets will also use
the "data length" field to define MDL.
So, improve the check to match against SYN|RST|FIN flagged packets,
which can never have data.
This commit fixed a segfault in barebox when an unexpected SYN packet
was sent in the middle of a connection; barebox thought the packet had
data because the "data length" in the SYN packet was different than 0.
Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ratp.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ratp.c b/lib/ratp.c index d3c252047a..c946bea1a5 100644 --- a/lib/ratp.c +++ b/lib/ratp.c @@ -165,7 +165,7 @@ static bool ratp_has_data(struct ratp_header *hdr) { if (hdr->control & RATP_CONTROL_SO) return 1; - if (hdr->data_length) + if (!(hdr->control & (RATP_CONTROL_SYN | RATP_CONTROL_RST | RATP_CONTROL_FIN)) && hdr->data_length) return 1; return 0; } @@ -1338,7 +1338,7 @@ static int ratp_behaviour_i1(struct ratp_internal *ri, void *pkt) struct ratp_header *hdr = pkt; uint8_t control = 0; - if (!hdr->data_length && !(hdr->control & RATP_CONTROL_SO)) + if (!ratp_has_data (hdr)) return 1; pr_vdebug("%s **received** %d\n", __func__, hdr->data_length); |