From: martijn Date: Mon, 29 Aug 2022 18:02:37 +0000 (+0000) Subject: Make sure oidbuf is initialized when we hit the overlap case. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0e097521587e9d0232903c13e2806111871c875a;p=openbsd Make sure oidbuf is initialized when we hit the overlap case. OK tb@ --- diff --git a/usr.sbin/snmpd/application.c b/usr.sbin/snmpd/application.c index 79e09b18970..820d5aaa02f 100644 --- a/usr.sbin/snmpd/application.c +++ b/usr.sbin/snmpd/application.c @@ -1,4 +1,4 @@ -/* $OpenBSD: application.c,v 1.10 2022/08/29 13:25:18 martijn Exp $ */ +/* $OpenBSD: application.c,v 1.11 2022/08/29 18:02:37 martijn Exp $ */ /* * Copyright (c) 2021 Martijn van Duren @@ -218,6 +218,16 @@ appl_region(struct appl_context *ctx, uint32_t timeout, uint8_t priority, 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, uint32_t timeout, uint8_t priority, appl_region_cmp(&search, 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);