From 891b0b0c9eb5cd6aabf7954f0667c84433a65981 Mon Sep 17 00:00:00 2001 From: Mico Micic Date: Mon, 12 Feb 2024 16:00:53 +0100 Subject: [PATCH] SNMP octet scring has a defined length and does not need a null separator --- apps/snmp/snmp_lib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/snmp/snmp_lib.c b/apps/snmp/snmp_lib.c index 4a4fd628..c7d97b05 100644 --- a/apps/snmp/snmp_lib.c +++ b/apps/snmp/snmp_lib.c @@ -917,11 +917,12 @@ type_xml2snmp(char *snmpstr, break; } case ASN_OCTET_STR: // 4 - *snmplen = strlen(snmpstr)+1; - if ((*snmpval = (u_char*)strdup((snmpstr))) == NULL){ - clixon_err(OE_UNIX, errno, "strdup"); + *snmplen = strlen(snmpstr); + if ((*snmpval = malloc(*snmplen)) == NULL){ + clixon_err(OE_UNIX, errno, "malloc"); goto done; } + memcpy(*snmpval, snmpstr, *snmplen); break; case ASN_COUNTER64:{ // 0x46 / 70 uint64_t u64;