Date: Mon, 9 Jan 2017 05:51:38 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311750 - head/contrib/bsnmp/gensnmpdef Message-ID: <201701090551.v095pcOl002221@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Mon Jan 9 05:51:38 2017 New Revision: 311750 URL: https://svnweb.freebsd.org/changeset/base/311750 Log: Check result from smiGetFirstNode and smiGetNodeByOID This avoids a segfault with malformed or unanticipated files, like IPV6-TC.txt (a file containing just TEXTUAL-CONVENTIONS). MFC after: 5 days Found with: gensnmpdef /usr/local/share/snmp/mibs/IPV6-TC.txt Modified: head/contrib/bsnmp/gensnmpdef/gensnmpdef.c Modified: head/contrib/bsnmp/gensnmpdef/gensnmpdef.c ============================================================================== --- head/contrib/bsnmp/gensnmpdef/gensnmpdef.c Mon Jan 9 05:50:52 2017 (r311749) +++ head/contrib/bsnmp/gensnmpdef/gensnmpdef.c Mon Jan 9 05:51:38 2017 (r311750) @@ -126,9 +126,11 @@ open_node(const SmiNode *n, u_int level, while (level < n->oidlen - 1) { if (level >= cut) { + n1 = smiGetNodeByOID(level + 1, n->oid); + if (n1 == NULL) + continue; pindent(level); printf("(%u", n->oid[level]); - n1 = smiGetNodeByOID(level + 1, n->oid); printf(" "); print_name(n1); printf("\n"); @@ -560,6 +562,8 @@ main(int argc, char *argv[]) last = NULL; for (opt = 0; opt < argc; opt++) { n = smiGetFirstNode(mods[opt], SMI_NODEKIND_ANY); + if (n == NULL) + continue; for (;;) { if (do_typedef == 0) { level = open_node(n, level, &last);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701090551.v095pcOl002221>