From 20879e824851a7a188eac50fd34aac04113d7432 Mon Sep 17 00:00:00 2001
From: Niels Baggesen <nba@users.sourceforge.net>
Date: Thu, 1 Jun 2023 11:12:34 +0200
Subject: [PATCH] snmplib: Handle two oldEngineID lines in snmpd.conf. Fixes
 #578

Conflict:NA
Reference:https://github.com/net-snmp/net-snmp/commit/20879e824851a7a188eac50fd34aac04113d7432

diff --git a/snmplib/snmpv3.c b/snmplib/snmpv3.c
index 2dd527544f..be9256fa11 100644
--- a/snmplib/snmpv3.c
+++ b/snmplib/snmpv3.c
@@ -862,6 +862,11 @@ version_conf(const char *word, char *cptr)
 void
 oldengineID_conf(const char *word, char *cptr)
 {
+    if (oldEngineID) {
+        free(oldEngineID);
+        oldEngineID = NULL;
+        oldEngineIDLength = 0;
+    }
     read_config_read_octet_string(cptr, &oldEngineID, &oldEngineIDLength);
 }
 
-- 
2.33.0

