Re: [tkined] mib unpack returns invalid value

From: Juergen Schoenwaelder (
Date: Wed Dec 06 2000 - 23:48:07 MET

>>>>> Tim Westbrook writes:

Tim> I have a mib object that is indexed by ATM address (
Tim> 20bytes). something like...

Tim> AtmAddr ::= OCTET STRING (SIZE(0..20))

Tim> When I do a [ Tnm::mib unpack $oid], the value returned is a
Tim> hexadecimal concatenation of the MIB octets from the PDU. Which
Tim> is what you would expect! But the bytes are all truncated that
Tim> is, what should be 0x0F comes out as 0xF. I was able to make a
Tim> change to the formatOctetTC function so that case 'x' triggers a
Tim> %.2lx format command instead of just %lx ( i may not have all the
Tim> code right I dont have it in front of me). This works for now.
Tim> But, I am fairly new to c and I am wondering what kind of
Tim> problems this may introduce?

I agree that there is a bug. It actually took some time to reproduce
the bug since the description was not very precise (since the problem
is the interpretation of the "1x" display hint). In fact, the easiest
way to reproduce this problem is "Tnm::mib format AtmAddr 01:02:03". I
think I have a better patch to solve the problem:

Index: tnmMibUtil.c
RCS file: /usr/home/schoenw/CVS/scotty/tnm/snmp/tnmMibUtil.c,v
retrieving revision 1.19
diff -u -r1.19 tnmMibUtil.c
--- tnmMibUtil.c 2000/02/04 21:32:17 1.19
+++ tnmMibUtil.c 2000/12/06 22:24:29
@@ -488,6 +488,7 @@
             char buf[80];
             long vv = 0;
+ int xlen = pfx * 2;
             /* collect octets to format */
@@ -505,7 +506,7 @@
                 sprintf(buf, "%lo", vv);
             case 'x':
- sprintf(buf, "%lX", vv);
+ sprintf(buf, "%.*lX", xlen, vv);
             case 'b': {
                 int i, j;


Juergen Schoenwaelder      Technical University Braunschweig
<>  Dept. Operating Systems & Computer Networks
Phone: +49 531 391 3289    Bueltenweg 74/75, 38106 Braunschweig, Germany
Fax:   +49 531 391 5936    <URL:>

-- !! This message is brought to you via the `tkined & scotty' mailing list. !! Please do not reply to this message to unsubscribe. To subscribe or !! unsubscribe, send a mail message to <>. !! See for more information.

This archive was generated by hypermail 2b29 : Mon Jan 08 2001 - 15:27:58 MET