From: martijn Date: Mon, 27 Jun 2022 10:25:32 +0000 (+0000) Subject: Initialize oidbuf and regionbuf when registering a region in appl_region. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=002d07d7257242147ab6f3cd45990b0c17cc6d1e;p=openbsd Initialize oidbuf and regionbuf when registering a region in appl_region. This prevents us from spewing garbage on error. regionbuf case pointed out by tb@ OK deraadt@ tb@ --- diff --git a/usr.sbin/snmpd/application.c b/usr.sbin/snmpd/application.c index 48ab925ae5f..7940280aa54 100644 --- a/usr.sbin/snmpd/application.c +++ b/usr.sbin/snmpd/application.c @@ -1,4 +1,4 @@ -/* $OpenBSD: application.c,v 1.3 2022/02/22 15:59:13 martijn Exp $ */ +/* $OpenBSD: application.c,v 1.4 2022/06/27 10:25:32 martijn Exp $ */ /* * Copyright (c) 2021 Martijn van Duren @@ -224,6 +224,7 @@ appl_region(struct appl_context *ctx, uint32_t timeout, uint8_t priority, 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)); @@ -272,6 +273,7 @@ appl_region(struct appl_context *ctx, uint32_t timeout, uint8_t priority, backend->ab_name, oidbuf, priority); return APPL_ERROR_DUPLICATEREGISTRATION; overlap: + regionbuf[0] = '\0'; for (i = 0; i < region->ar_oid.bo_n; i++) { if (i != 0) strlcat(regionbuf, ".", sizeof(regionbuf));