Problem with overlapping ranges with the same minimum value

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

On Wed, Mar 23, 2011 at 09:21:56AM +0100, Göran Runfeldt wrote:
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:
[...]
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:
I decided to handle this somewhat different (r34468). The library now translates (smidump -k -f xml)
TestLabel ::= Unsigned32(16..8191|16..1048575|16..8191)
into this:
<typedef name="TestLabel" basetype="Unsigned32"> <range min="16" max="8191"/> <range min="16" max="1048575"/> <range min="16" max="8191"/> </typedef>
/js

I have tested the r34468 patch together with 0.4.8 and it works. Thanks!
//Göran
-----Original Message----- From: Juergen Schoenwaelder [mailto:j.schoenwaelder@jacobs-university.de] Sent: den 23 mars 2011 14:50 To: Göran Runfeldt Cc: libsmi@ibr.cs.tu-bs.de Subject: Re: [libsmi] Problem with overlapping ranges with the same minimum value
On Wed, Mar 23, 2011 at 09:21:56AM +0100, Göran Runfeldt wrote:
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:
[...]
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:
I decided to handle this somewhat different (r34468). The library now translates (smidump -k -f xml)
TestLabel ::= Unsigned32(16..8191|16..1048575|16..8191)
into this:
<typedef name="TestLabel" basetype="Unsigned32"> <range min="16" max="8191"/> <range min="16" max="1048575"/> <range min="16" max="8191"/> </typedef>
/js
participants (2)
-
Göran Runfeldt
-
Juergen Schoenwaelder