summaryrefslogtreecommitdiff
path: root/usr.sbin/snmpd/smi.c
diff options
context:
space:
mode:
authorMats O Jansson <maja@cvs.openbsd.org>2008-01-02 20:55:00 +0000
committerMats O Jansson <maja@cvs.openbsd.org>2008-01-02 20:55:00 +0000
commit92e9ea437ff454ade88b0d9b8b30d91891fd0136 (patch)
tree43215be3d9f513e4b9deb3c27a37a731e1086f8e /usr.sbin/snmpd/smi.c
parent91b8c21a50838d0b4d11437505790a77dd41fd9c (diff)
Make sure that a key belongs to the table before returning a match.
Change smi_odi_cmp to return int as expected by RB-tree. -moj ok reyk@
Diffstat (limited to 'usr.sbin/snmpd/smi.c')
-rw-r--r--usr.sbin/snmpd/smi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/snmpd/smi.c b/usr.sbin/snmpd/smi.c
index da20de7d414..28fc6f9cb75 100644
--- a/usr.sbin/snmpd/smi.c
+++ b/usr.sbin/snmpd/smi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smi.c,v 1.2 2007/12/29 09:24:43 reyk Exp $ */
+/* $OpenBSD: smi.c,v 1.3 2008/01/02 20:54:59 maja Exp $ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net>
@@ -212,7 +212,7 @@ smi_foreach(struct oid *oid, u_int flags)
return (oid);
}
-long
+int
smi_oid_cmp(struct oid *a, struct oid *b)
{
size_t i;
@@ -226,7 +226,8 @@ smi_oid_cmp(struct oid *a, struct oid *b)
* (it will match any sub-elements)
*/
if ((b->o_flags & OID_TABLE) &&
- (a->o_flags & OID_KEY) == 0)
+ (a->o_flags & OID_KEY) == 0 &&
+ (a->o_oidlen > b->o_oidlen))
return (0);
return (a->o_oidlen - b->o_oidlen);