!58 [sync] PR-56: 【Mainline】Fix heap corruption

From: @openeuler-sync-bot 
Reviewed-by: @HuaxinLuGitee 
Signed-off-by: @HuaxinLuGitee
This commit is contained in:
openeuler-ci-bot 2024-12-23 02:09:08 +00:00 committed by Gitee
commit 362688851b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From e04a67610adeea29541078cbc9e0cf9dab659e6b Mon Sep 17 00:00:00 2001
From: Guido Kiener <guido.kiener@rohde-schwarz.com>
Date: Fri, 1 Dec 2023 16:19:27 +0100
Subject: [PATCH] Fix heap corruption
Calculation of resultlen is wrong. E.g. if server allows
only one mechanism SCRAM-SHA-256, the expected string for the
mechlist_buf is "SCRAM-SHA-256-PLUS SCRAM-SHA-256" with a required
size of 33 bytes and not 32 bytes.
Note that (strlen(mysep) * (s_conn->mech_length - 1) * 2) = 0
when s_conn->mech_length = 1.
Signed-off-by: Guido Kiener <guido.kiener@rohde-schwarz.com>
---
lib/server.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/server.c b/lib/server.c
index c69e58b8..b44155f4 100644
--- a/lib/server.c
+++ b/lib/server.c
@@ -1764,7 +1764,7 @@ int _sasl_server_listmech(sasl_conn_t *conn,
INTERROR(conn, SASL_NOMECH);
resultlen = (prefix ? strlen(prefix) : 0)
- + (strlen(mysep) * (s_conn->mech_length - 1) * 2)
+ + (strlen(mysep) * (s_conn->mech_length * 2 - 1))
+ (mech_names_len(s_conn->mech_list) * 2) /* including -PLUS variant */
+ (s_conn->mech_length * (sizeof("-PLUS") - 1))
+ (suffix ? strlen(suffix) : 0)
--
2.33.0

View File

@ -6,7 +6,7 @@
Name: cyrus-sasl Name: cyrus-sasl
Version: 2.1.28 Version: 2.1.28
Release: 4 Release: 5
Summary: The Cyrus SASL API Implementation Summary: The Cyrus SASL API Implementation
License: BSD with advertising License: BSD with advertising
@ -19,6 +19,7 @@ Patch1: backport-Fix-earlier-554-commit-to-use-fetch_errno-instead-of.patch
Patch2: backport-sample-Rename-dprint-function.patch Patch2: backport-sample-Rename-dprint-function.patch
Patch3: backport-Fix-time.h-check.patch Patch3: backport-Fix-time.h-check.patch
Patch4: backport-Use-int-instead-of-char-for-variable-c.patch Patch4: backport-Use-int-instead-of-char-for-variable-c.patch
Patch5: backport-Fix-heap-corruption.patch
BuildRequires: autoconf, automake, libtool, gdbm-devel, groff BuildRequires: autoconf, automake, libtool, gdbm-devel, groff
BuildRequires: krb5-devel >= 1.2.2, openssl-devel, pam-devel, pkgconfig BuildRequires: krb5-devel >= 1.2.2, openssl-devel, pam-devel, pkgconfig
@ -261,6 +262,9 @@ getent passwd %{username} >/dev/null || useradd -r -g %{username} -d %{homedir}
%changelog %changelog
* Thu Dec 19 2024 yixiangzhike <yixiangzhike007@163.com> - 2.1.28-5
- backport upstream patch to fix heap corruption
* Fri Oct 11 2024 yixiangzhike <yixiangzhike007@163.com> - 2.1.28-4 * Fri Oct 11 2024 yixiangzhike <yixiangzhike007@163.com> - 2.1.28-4
- backport upstream patch to fix char overflow - backport upstream patch to fix char overflow