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
This commit is contained in:
parent
c7af73f3fb
commit
c5f8d75113
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311750
@ -126,9 +126,11 @@ open_node(const SmiNode *n, u_int level, SmiNode **last)
|
|||||||
|
|
||||||
while (level < n->oidlen - 1) {
|
while (level < n->oidlen - 1) {
|
||||||
if (level >= cut) {
|
if (level >= cut) {
|
||||||
|
n1 = smiGetNodeByOID(level + 1, n->oid);
|
||||||
|
if (n1 == NULL)
|
||||||
|
continue;
|
||||||
pindent(level);
|
pindent(level);
|
||||||
printf("(%u", n->oid[level]);
|
printf("(%u", n->oid[level]);
|
||||||
n1 = smiGetNodeByOID(level + 1, n->oid);
|
|
||||||
printf(" ");
|
printf(" ");
|
||||||
print_name(n1);
|
print_name(n1);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@ -560,6 +562,8 @@ main(int argc, char *argv[])
|
|||||||
last = NULL;
|
last = NULL;
|
||||||
for (opt = 0; opt < argc; opt++) {
|
for (opt = 0; opt < argc; opt++) {
|
||||||
n = smiGetFirstNode(mods[opt], SMI_NODEKIND_ANY);
|
n = smiGetFirstNode(mods[opt], SMI_NODEKIND_ANY);
|
||||||
|
if (n == NULL)
|
||||||
|
continue;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (do_typedef == 0) {
|
if (do_typedef == 0) {
|
||||||
level = open_node(n, level, &last);
|
level = open_node(n, level, &last);
|
||||||
|
Loading…
Reference in New Issue
Block a user