
Hello,
I have found a problem when using smidump 0.4.8 with certain MIB files. The MIB file from this example is private, so I have extracted the part that causes the problem:
TEST-MIB DEFINITIONS ::= BEGIN
IMPORTS OBJECT-TYPE FROM RFC-1212 Unsigned32, dummyVariable FROM SNMPv2-SMI-v1 ;
TestLabel ::= Unsigned32(16..8191|16..1048575)
END
When using smidump with the SMI or XML output formats (I have not verified the other formats) the process enters an infinite loop. The XML output looks like this:
<?xml version="1.0"?>
<!-- This module has been generated by smidump 0.4.8. Do not edit. -->
<smi> <module name="TEST-MIB" language="SMIv1"> </module>
<imports> <import module="RFC-1212" name="OBJECT-TYPE"/> <import module="" name="Unsigned32"/> <import module="" name="dummyVariable"/> </imports>
<typedefs> <typedef name="TestLabel" basetype="Unsigned32"> <range min="16" max="1048575"/> <range min="16" max="8191"/> <range min="16" max="8191"/> <range min="16" max="8191"/> <range min="16" max="8191"/> <range min="16" max="8191"/> <range min="16" max="8191"/> ...
The last line is repeated infinitely.
The problem was identified to be caused by the same minimum value (16) in the two ranges. Smidump correctly warns about overlapping ranges, but this code was added to keep smidump from looping when using the -k option:
--- libsmi-0.4.8-old/lib/smi.c 2008-04-18 12:42:50.000000000 +0200 +++ libsmi-0.4.8/lib/smi.c 2011-03-22 16:18:29.000000000 +0100 @@ -867,7 +867,13 @@ if ((!listPtr) || (!listPtr->nextPtr)) { return NULL; } - + + /* Check for duplicate min values in ranges and ignore those ranges + instead of going into an infinite loop. */ + if (!memcmp(&((Range *)listPtr->nextPtr->ptr)->export.minValue, + &smiRangePtr->minValue, sizeof(struct SmiValue))) + return NULL; + return &((Range *)listPtr->nextPtr->ptr)->export; }
Any thoughts?
//Göran