]> git.puffer.fish Git - mirror/frr.git/commitdiff
nhrpd: offset value not checked for min size 5590/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 26 Dec 2019 11:58:02 +0000 (06:58 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 14 Jan 2020 23:42:12 +0000 (18:42 -0500)
If the extension offset points to a location within the packet header,
we end up with an integer underflow leading to heap buffer read
overflow.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
nhrpd/nhrp_peer.c

index 3a74b756961b9ee943ba2894b55af84d3eaf1bfc..c5e985cdacad37b1167fda62996b3908ffa07996 100644 (file)
@@ -896,8 +896,10 @@ void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb)
 
        extoff = htons(hdr->extension_offset);
        if (extoff) {
-               if (extoff >= realsize) {
-                       info = "extoff larger than packet";
+               assert(zb->head > zb->buf);
+               uint32_t header_offset = zb->head - zb->buf;
+               if ((extoff >= realsize) || (extoff < (header_offset))) {
+                       info = "extoff larger than packet, or smaller than header";
                        goto drop;
                }
                paylen = extoff - (zb->head - zb->buf);