diff options
author | Xie He <xie.he.0141@gmail.com> | 2020-10-31 11:10:42 -0700 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2020-11-03 15:19:14 -0800 |
commit | 77124c4463d45083e69b7284415467737f31f76b (patch) | |
tree | dd5a3fe0330d867c74251a8518ae0db4c3ccd1cf /drivers/net/wan/hdlc_fr.c | |
parent | efc790394f8ac7645d80c44f9cc110779428fe7b (diff) |
net: hdlc_fr: Improve the initial checks when we receive an skb
1.
Change the skb->len check from "<= 4" to "< 4".
At first we only need to ensure a 4-byte header is present. We indeed
normally need the 5th byte, too, but it'd be more logical and cleaner
to check its existence when we actually need it.
2.
Add an fh->ea2 check to the initial checks in fr_rx. fh->ea2 == 1 means
the second address byte is the final address byte. We only support the
case where the address length is 2 bytes.
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: Xie He <xie.he.0141@gmail.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/wan/hdlc_fr.c')
-rw-r--r-- | drivers/net/wan/hdlc_fr.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index eb83116aa9df..98444f1d8cc3 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -882,7 +882,7 @@ static int fr_rx(struct sk_buff *skb) struct pvc_device *pvc; struct net_device *dev; - if (skb->len <= 4 || fh->ea1 || data[2] != FR_UI) + if (skb->len < 4 || fh->ea1 || !fh->ea2 || data[2] != FR_UI) goto rx_error; dlci = q922_to_dlci(skb->data); |