trap receiver is special in that the OID is optional. Make sure that we
authormartijn <martijn@openbsd.org>
Tue, 20 Feb 2024 12:32:48 +0000 (12:32 +0000)
committermartijn <martijn@openbsd.org>
Tue, 20 Feb 2024 12:32:48 +0000 (12:32 +0000)
accept a NULL descriptor, which results in an OID length of 0.

Found by and OK sthen@

usr.sbin/snmpd/parse.y

index f3b0925..541a65f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: parse.y,v 1.89 2024/02/06 15:36:11 martijn Exp $      */
+/*     $OpenBSD: parse.y,v 1.90 2024/02/20 12:32:48 martijn Exp $      */
 
 /*
  * Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -1759,9 +1759,13 @@ resolve_oids(void)
        free(trapcmds);
 
        for (i = 0; i < ntrapaddresses; i++) {
-               if (resolve_oid(
-                   &trapaddresses[i].tr->ta_oid, &trapaddresses[i].oid) == -1)
-                       return -1;
+               if (trapaddresses[i].oid.descriptor == NULL)
+                       trapaddresses[i].tr->ta_oid.bo_n = 0;
+               else {
+                       if (resolve_oid(&trapaddresses[i].tr->ta_oid,
+                           &trapaddresses[i].oid) == -1)
+                               return -1;
+               }
                TAILQ_INSERT_TAIL(&conf->sc_trapreceivers,
                    trapaddresses[i].tr, entry);
        }