smidump perl output module naive about backslashes

The "perl" output module in smidump seems to be a little naive about backslashes. (Given the output language, I can understand a little difficulty in getting all the special characters escaped correctly.) Rather than trust the offending string to a mailer, I've included it as an attachment. It's taken from CISCO-SLB-EXT-MIB.my, which is part of the CISCO MIB collection. The perl output won't compile, and the problem seems to be that '' gets rendered as '\' (the backslash in the middle isn't being doubled).
This problem was found with version 0.4.3, running on Linux/x86.
[I may wind up fixing this one myself while fixing another problem. Look for a post about the joys :-) of HP-UX in a few days.]
SlbRegularExpression ::= TEXTUAL-CONVENTION DISPLAY-HINT "255a" STATUS current DESCRIPTION "A regular expression of length 0 to 255. Regular expressions are typically used for matching fields in Layer 7 data streams, such as URLs or Cookies in HTTP. The following syntax is based on the file name matching algorithm commonly employed in UNIX : '*' matches zero or more characters; '?' matches exactly one character; '' means escaped character, e.g., '*' matches the character '*'; a bracketed range matches any single character from the range, e.g. [0-9] matches '0', '2', and '9', but not 'a'; a leading ^ in a range means don't match any in the range; '+' matches any sequence of one or more characters; '.' matches any single character; All other characters represent themselves. '\a' matches alert (ASCII 7); '\b' matches backspace (ASCII 8); '\f' matches form-feed (ASCII 12); '\n' matches newline (ASCII 10); '\r' matches carriage return (ASCII 13); '\t' matches tab (ASCII 9); '\v' matches vertical tab (ASCII 11); '\0' matches null (ASCII 0); '\' matches backslash; '\x##' matches the ASCII character whose hexadecimal representation is ##. " SYNTAX OCTET STRING (SIZE (0..255))

The "perl" output module in smidump seems to be a little naive about backslashes. [I may wind up fixing this one myself ...
Indeed. Patch attached.
*** dump-perl.c.ori 2005-04-22 17:45:16.000000000 -0400 --- dump-perl.c 2005-04-21 21:18:54.000000000 -0400 *************** *** 47,52 **** --- 47,53 ----
static PerlEscape perlEscapes [] = { { ''', "\'" }, + { '\', "\\" }, { 0, NULL } };

On Fri, Apr 22, 2005 at 05:51:19PM -0400, Allen McIntosh wrote:
The "perl" output module in smidump seems to be a little naive about backslashes. [I may wind up fixing this one myself ...
Indeed. Patch attached.
Thanks. I have committed the patch to the svn.
/js

Setup:
Redhat Linux 9 x86 libsmi 0.4.3 gcc 3.2.2
To trigger problem: smidump --format=mosy CISCO-IETF-FRR-CAPABILITY.my
File CISCO-IETF-FRR-CAPABILITY.my attached. Cisco does not provide a copy of the CISCO-IETF-FRR-MIB referenced in CISCO-IETF-FRR-CAPABILITY.my. Segmentation fault is a bit cryptic as a diagnostic, though :-).
I had to compile without -O2 in order to get a reasonable looking stack trace, which is as follows:
Program received signal SIGSEGV, Segmentation fault. 0x4001f0cb in findObjectByModuleAndNode (modulePtr=0x80981f0, nodePtr=0x0) at data.c:2084 2084 for (objectPtr = nodePtr->firstObjectPtr; objectPtr; (gdb) where #0 0x4001f0cb in findObjectByModuleAndNode (modulePtr=0x80981f0, nodePtr=0x0) at data.c:2084 #1 0x40027336 in smiGetParentNode (smiNodePtr=0x8098928) at smi.c:1090 #2 0x080555d8 in getOidString (smiNode=0x8098928, importedParent=0) at dump-mosy.c:101 #3 0x0805628f in dumpMosy (modc=1, modv=0x8093330, flags=0, output=0x0) at dump-mosy.c:499 #4 0x0804a74c in main (argc=2, argv=0xbffff824) at smidump.c:378 #5 0x4009fa67 in __libc_start_main () from /lib/i686/libc.so.6
-- ***************************************************************** -- CISCO-IETF-FRR-CAPABILITY.my: Capability statement for Cisco's -- implementation of the IETF's MPLS Traffic Engineering Fast -- Reroute MIB (CISCO-IETF-FRR-MIB.my) -- -- April 25, 2003 - Adrien Grise -- -- Copyright (c) 2003 by cisco Systems, Inc. -- All rights reserved.

On Mon, Apr 25, 2005 at 09:54:13AM -0400, Allen McIntosh wrote:
To trigger problem: smidump --format=mosy CISCO-IETF-FRR-CAPABILITY.my
File CISCO-IETF-FRR-CAPABILITY.my attached. Cisco does not provide a copy of the CISCO-IETF-FRR-MIB referenced in CISCO-IETF-FRR-CAPABILITY.my. Segmentation fault is a bit cryptic as a diagnostic, though :-).
Below is a patch which seems to cure the problem.
/js
Index: smi.c =================================================================== --- smi.c (revision 2127) +++ smi.c (working copy) @@ -994,9 +994,9 @@ nodePtr = nodePtr->nextPtr; } else { for (nodePtr = nodePtr->parentPtr; - (nodePtr->parentPtr) && (!nodePtr->nextPtr); + nodePtr && (nodePtr->parentPtr) && (!nodePtr->nextPtr); nodePtr = nodePtr->parentPtr); - nodePtr = nodePtr->nextPtr; + if (nodePtr) nodePtr = nodePtr->nextPtr; } } while (nodePtr);
@@ -1081,6 +1081,9 @@ }
nodePtr = nodePtr->parentPtr; + if (! nodePtr) { + return NULL; + }
/* * First, try to find a definition in the same module.
participants (2)
-
Allen McIntosh
-
Juergen Schoenwaelder