Re: snmpd(8): make sure oidbuf is properly initialized on overlapping regions

2022-08-29 Thread Theo Buehler
On Mon, Aug 29, 2022 at 07:32:25PM +0200, Martijn van Duren wrote:
> I think the subject speaks for itself.
> 
> Not a really big problem, since non of the available software that we
> currently have in base/ports have overlapping regions, but definitely
> worth fixing.
> 
> OK?

ok tb



snmpd(8): make sure oidbuf is properly initialized on overlapping regions

2022-08-29 Thread Martijn van Duren
I think the subject speaks for itself.

Not a really big problem, since non of the available software that we
currently have in base/ports have overlapping regions, but definitely
worth fixing.

OK?

martijn@

Index: application.c
===
RCS file: /cvs/src/usr.sbin/snmpd/application.c,v
retrieving revision 1.10
diff -u -p -r1.10 application.c
--- application.c   29 Aug 2022 13:25:18 -  1.10
+++ application.c   29 Aug 2022 17:30:44 -
@@ -218,6 +218,16 @@ appl_region(struct appl_context *ctx, ui
char oidbuf[1024], regionbuf[1024], subidbuf[11];
size_t i;
 
+   /* Don't use smi_oid2string, because appl_register can't use it */
+   oidbuf[0] = '\0';
+   for (i = 0; i < oid->bo_n; i++) {
+   if (i != 0)
+   strlcat(oidbuf, ".", sizeof(oidbuf));
+   snprintf(subidbuf, sizeof(subidbuf), "%"PRIu32,
+   oid->bo_id[i]);
+   strlcat(oidbuf, subidbuf, sizeof(oidbuf));
+   }
+
/*
 * Don't allow overlap when subtree flag is set.
 * This allows us to keep control of certain regions like system.
@@ -233,15 +243,6 @@ appl_region(struct appl_context *ctx, ui
appl_region_cmp(, region) == -2))
goto overlap;
 
-   /* Don't use smi_oid2string, because appl_register can't use it */
-   oidbuf[0] = '\0';
-   for (i = 0; i < oid->bo_n; i++) {
-   if (i != 0)
-   strlcat(oidbuf, ".", sizeof(oidbuf));
-   snprintf(subidbuf, sizeof(subidbuf), "%"PRIu32,
-   oid->bo_id[i]);
-   strlcat(oidbuf, subidbuf, sizeof(oidbuf));
-   }
if ((nregion = malloc(sizeof(*nregion))) == NULL) {
log_warn("%s: Can't register %s: Processing error",
backend->ab_name, oidbuf);