From 86269a8b3485ab6d71c108e3e7ae4269ad8b2007 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 27 Jun 2010 21:44:17 +1200 Subject: [PATCH] Author: Henrik Nordstrom Fix free memory corruption and off-by-on error when comparing SNMP OIDs Both introduced by the polishing of the SNMP tree generator. --- src/snmp_core.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/snmp_core.cc b/src/snmp_core.cc index b301fe6993..b45ee0c0c7 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -934,7 +934,7 @@ snmpLookupNodeStr(mib_tree_entry *root, const char *str) } int i, r = 1; - while (r <= namelen) { + while (r < namelen) { /* Find the child node which matches this */ for (i = 0; i < e->children && e->leaves[i]->name[r] != name[r]; i++) ; // seek-loop @@ -962,9 +962,10 @@ snmpCreateOidFromStr(const char *str, oid **name, int *nl) *name = NULL; *nl = 0; char *s = xstrdup(str); + char *s_ = s; /* Parse the OID string into oid bits */ - while ( (p = strsep(&s, delim)) != NULL) { + while ( (p = strsep(&s_, delim)) != NULL) { *name = (oid*)xrealloc(*name, sizeof(oid) * ((*nl) + 1)); (*name)[*nl] = atoi(p); (*nl)++; -- 2.47.3