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);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to