Package: snmptrapfmt
Version: 1.11
Severity: important
Tags: patch

I have a lot of switches sending traps on linkup/down and other events
which I receive using snmptrapd and log using snmptrapfmt (or at least
try to).  Everytime I receive a trap however snmptrapfmt segfaults.

I tracked the segfault down to trying to call sprintf with a null
pointer input as an argument since the trap messages do not contain an
enterprise value and the log format has $e in it to print the enterprise
value for every log entry.

The following patch prints out '(null)' instead whenever the enterprise
value is non existant.

diff -u snmptrapfmt-1.11/snmptrapfmt.c snmptrapfmt-1.11.new/snmptrapfmt.c
--- snmptrapfmt-1.11/snmptrapfmt.c      2006-03-22 15:39:19.000000000 -0500
+++ snmptrapfmt-1.11.new/snmptrapfmt.c  2007-09-13 13:26:22.000000000 -0400
@@ -858,11 +858,11 @@
   switch (oidFmt)
   {
     case OIDFMT_TEXT:          /* use textual format for the oid */
-      sprintf(lbuf, "%s", oidP);
+      sprintf(lbuf, "%s", oidP ? oidP : "(null)");
       break;
     case OIDFMT_OID:           /* usenumerical format for the oid */
     default:                   /* shouldn't happen */
-      sprintf(lbuf, "%s", oidP);
+      sprintf(lbuf, "%s", oidP ? oidP : "(null)");
       break;
   }
 
@@ -1105,7 +1105,7 @@
             lg_sprint_oid(var->v_oid, cfg_oidfmt, cPPtr, bRemP);
             break;
           case 't':            /* the type */
-            logging(0, "Type info not available - using ASN_OCTET_STR");
+            logging(1, "Type info not available - using ASN_OCTET_STR");
             lg_sprint_ASNtype(ASN_OCTET_STR, cPPtr, bRemP);
             break;
           case 'v':            /* the value */


It also changes one call to logging since it was causing the program to
complain about an already existing snmptrapfmt.trc file.  Perhaps the
real answer is that the trc file should be recreated each time, rather
than complain that the file already exists (which is the current
behaviour).

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'proposed-updates')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-1-686-smp
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages snmptrapfmt depends on:
ii  libsnmp9                      5.2.3-7    NET SNMP (Simple Network Managemen
ii  snmpd                         5.2.3-7    NET SNMP (Simple Network Managemen

snmptrapfmt recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to