From: jsg Date: Sat, 3 Feb 2024 00:20:21 +0000 (+0000) Subject: fix off-by-one in bounds check X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f8f19b68202e3ba771edc4bb569b4da7ff2ddcf2;p=openbsd fix off-by-one in bounds check found by "buffer overflow 'ContextVarbind' 3 <= 3" smatch error ok miod@ stsp@ --- diff --git a/usr.sbin/tcpdump/print-snmp.c b/usr.sbin/tcpdump/print-snmp.c index 01c2f9957a9..4458287b590 100644 --- a/usr.sbin/tcpdump/print-snmp.c +++ b/usr.sbin/tcpdump/print-snmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-snmp.c,v 1.28 2021/10/23 10:47:50 martijn Exp $ */ +/* $OpenBSD: print-snmp.c,v 1.29 2024/02/03 00:20:21 jsg Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 @@ -746,7 +746,7 @@ asn1_print(struct be *elem) Class[CONTEXT].Id[elem->id], elem->asnlen); break; case BE_VB: - if (elem->id > sizeof(ContextVarbind)/sizeof(ContextVarbind[0])) + if (elem->id >= sizeof(ContextVarbind)/sizeof(ContextVarbind[0])) break; printf("%s", ContextVarbind[elem->id]); break;