From 7a9f8809f787363bdd31c4b12316ad4f4bd7022a Mon Sep 17 00:00:00 2001 From: Super User Date: Thu, 5 Dec 2024 10:50:31 +0800 Subject: [PATCH] Sync upstream patches to fix memory leaks --- ...ry-leaks-in-the-parse_enumlist-error.patch | 61 +++++++++++++++++++ net-snmp.spec | 9 ++- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 backport-snmplib-Fix-memory-leaks-in-the-parse_enumlist-error.patch diff --git a/backport-snmplib-Fix-memory-leaks-in-the-parse_enumlist-error.patch b/backport-snmplib-Fix-memory-leaks-in-the-parse_enumlist-error.patch new file mode 100644 index 0000000..cb4bee0 --- /dev/null +++ b/backport-snmplib-Fix-memory-leaks-in-the-parse_enumlist-error.patch @@ -0,0 +1,61 @@ +From b8ec69597c9031d75f5b1602be350833fda882de Mon Sep 17 00:00:00 2001 +From: Maxim Korotkov +Date: Wed, 14 Dec 2022 12:46:49 +0300 +Subject: [PATCH] snmplib: Fix memory leaks in the parse_enumlist() error path + +Found by RASU JSC with ISP RAS Svace + +Signed-off-by: Maxim Korotkov +[ bvanassche: renamed error label, fixed indentation and a potential null pointer + dereference ] +--- + snmplib/parse.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +diff --git a/snmplib/parse.c b/snmplib/parse.c +index 3fd1104c38..ba2e3aac95 100644 +--- a/snmplib/parse.c ++++ b/snmplib/parse.c +@@ -2204,28 +2204,35 @@ parse_enumlist(FILE * fp, struct enum_list **retp) + type = get_token(fp, token, MAXTOKEN); + if (type != LEFTPAREN) { + print_error("Expected \"(\"", token, type); +- return NULL; ++ goto err; + } + type = get_token(fp, token, MAXTOKEN); + if (type != NUMBER) { + print_error("Expected integer", token, type); +- return NULL; ++ goto err; + } + (*epp)->value = strtol(token, NULL, 10); + type = get_token(fp, token, MAXTOKEN); + if (type != RIGHTPAREN) { + print_error("Expected \")\"", token, type); +- return NULL; ++ goto err; + } + epp = &(*epp)->next; + } + } + if (type == ENDOFFILE) { + print_error("Expected \"}\"", token, type); +- return NULL; ++ goto err; + } + *retp = ep; + return ep; ++ ++err: ++ if (*epp) ++ free((*epp)->label); ++ free(*epp); ++ *epp = NULL; ++ return NULL; + } + + static struct range_list * +-- +2.43.0 + diff --git a/net-snmp.spec b/net-snmp.spec index c4d83af..ad8008f 100644 --- a/net-snmp.spec +++ b/net-snmp.spec @@ -3,7 +3,7 @@ Name: net-snmp Version: 5.9.3 -Release: 5 +Release: 6 Epoch: 1 Summary: SNMP Daemon License: BSD @@ -50,6 +50,7 @@ Patch27: net-snmp-5.9.1-IdeaUI_reset_last_engineTime.patch Patch28: backport-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch Patch29: backport-snmplib-Handle-two-oldEngineID-lines-in-snmpd.conf.-.patch Patch30: backport-libsnmp-Fix-a-buffer-overflow-in-setup_engineID.patch +Patch31: backport-snmplib-Fix-memory-leaks-in-the-parse_enumlist-error.patch %{?systemd_requires} BuildRequires: systemd gcc openssl-devel bzip2-devel elfutils-devel libselinux-devel @@ -329,6 +330,12 @@ chmod 644 local/passtest %{_mandir}/man1/fixproc* %changelog +* Thu Dec 05 2024 liyunqing - 1:5.9.3-6 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:Sync upstream patches to fix memory leaks + * Tue Oct 29 2024 xingwei - 1:5.9.3-5 - Type:bugfix - CVE:NA -- Gitee