Fix potential underflow when printing STP data.
authormbuhl <mbuhl@openbsd.org>
Mon, 13 Mar 2023 14:58:01 +0000 (14:58 +0000)
committermbuhl <mbuhl@openbsd.org>
Mon, 13 Mar 2023 14:58:01 +0000 (14:58 +0000)
Reported by Peter J. Philipp
ok claudio

usr.sbin/tcpdump/print-stp.c

index d9087c7..07a4b8f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: print-stp.c,v 1.10 2021/12/01 18:28:46 deraadt Exp $  */
+/*     $OpenBSD: print-stp.c,v 1.11 2023/03/13 14:58:01 mbuhl Exp $    */
 
 /*
  * Copyright (c) 2000 Jason L. Wright (jason@thought.net)
@@ -99,6 +99,8 @@ stp_print(p, len)
        else if (p[0] == LLCSAP_SNAP && p[1] == LLCSAP_SNAP && p[2] == LLC_UI) {
                proto = STP_PROTO_SSTP;
                printf("SSTP");
+               if (len < 8)
+                       goto truncated;
                p += 5;
                len -= 5;
        } else {