From af021b53f367a1419d41437ac349082945cbae52 Mon Sep 17 00:00:00 2001 From: martijn Date: Fri, 2 Dec 2022 10:57:12 +0000 Subject: [PATCH] When checking if we're implied we must also check if we're working on a string or an oid, else we can generate invalid OIDs. Found by bluhm@ on powerpc64 OK bluhm@ --- lib/libagentx/agentx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/libagentx/agentx.c b/lib/libagentx/agentx.c index 6c929588db1..da74dc9d006 100644 --- a/lib/libagentx/agentx.c +++ b/lib/libagentx/agentx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agentx.c,v 1.20 2022/11/01 13:34:44 martijn Exp $ */ +/* $OpenBSD: agentx.c,v 1.21 2022/12/02 10:57:12 martijn Exp $ */ /* * Copyright (c) 2019 Martijn van Duren * @@ -2515,10 +2515,16 @@ agentx_object_implied(struct agentx_object *axo, struct agentx_index *axi) { size_t i = 0; + struct ax_varbind *vb; for (i = 0; i < axo->axo_indexlen; i++) { if (axo->axo_index[i] == axi) { - if (axi->axi_vb.avb_data.avb_ostring.aos_slen != 0) + vb = &axi->axi_vb; + if (vb->avb_type == AX_DATA_TYPE_OCTETSTRING && + vb->avb_data.avb_ostring.aos_slen != 0) + return 1; + else if (vb->avb_type == AX_DATA_TYPE_OID && + vb->avb_data.avb_oid.aoi_idlen != 0) return 1; else if (i == axo->axo_indexlen - 1) return axo->axo_implied; -- 2.20.1