The traphandler currently relies on some false assumptions.

1) A pdu has 3 leading elements to the varbind list, not 4.
2) The first element of a trap varbind as 2 elements, not 3
3) The varbind list is optional.

The final point also causes "trap handle" in snmpd to print the
trap oid twice if no additional elements are send.

OK?

martijn@

Index: traphandler.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/traphandler.c,v
retrieving revision 1.13
diff -u -p -r1.13 traphandler.c
--- traphandler.c       11 May 2019 17:46:02 -0000      1.13
+++ traphandler.c       13 Aug 2019 14:49:11 -0000
@@ -239,10 +239,11 @@ traphandler_parse(char *buf, size_t n, s
                break;
 
        case SNMP_V2:
-               if (ber_scanf_elements(elm, "{SSSS{e}}", &elm) == -1 ||
-                   ber_scanf_elements(elm, "{SdS}{So}e",
-                   uptime, trapoid, vbinds) == -1)
+               if (ber_scanf_elements(elm, "{SSS{e}}", &elm) == -1 ||
+                   ber_scanf_elements(elm, "{Sd}{So}",
+                   uptime, trapoid) == -1)
                        goto done;
+               *vbinds = elm->be_next->be_next;
                break;
 
        default:

Reply via email to