fix off-by-one in bounds check

found by "buffer overflow 'ContextVarbind' 3 <= 3" smatch error
ok miod@ stsp@
This commit is contained in:
jsg 2024-02-03 00:20:21 +00:00
parent 470fe335ce
commit f8f19b6820
1 changed files with 2 additions and 2 deletions

View File

@ -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;