Skip to content

[AutoPR- Security] Patch icu for CVE-2025-5222 [HIGH] #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: fasttrack/2.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions SPECS/icu/CVE-2025-5222.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
From c40dcd9c3caf2407506c4969ba4456d0f8434505 Mon Sep 17 00:00:00 2001
From: Frank Tang <[email protected]>
Date: Wed, 22 Jan 2025 11:50:59 -0800
Subject: [PATCH] ICU-22973 Fix buffer overflow by using CharString

Signed-off-by: Azure Linux Security Servicing Account <[email protected]>
Upstream-reference: https://github.com/unicode-org/icu/commit/2c667e31cfd0b6bb1923627a932fd3453a5bac77.patch
---
icu/icu4c/source/tools/genrb/parse.cpp | 49 +++++++++++++++-----------
1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/icu/icu4c/source/tools/genrb/parse.cpp b/icu/icu4c/source/tools/genrb/parse.cpp
index 18a8c76..b301101 100644
--- a/icu/icu4c/source/tools/genrb/parse.cpp
+++ b/icu/icu4c/source/tools/genrb/parse.cpp
@@ -818,7 +818,7 @@ addCollation(ParseState* state, TableResource *result, const char *collationTyp
struct UString *tokenValue;
struct UString comment;
enum ETokenType token;
- char subtag[1024];
+ CharString subtag;
UnicodeString rules;
UBool haveRules = FALSE;
UVersionInfo version;
@@ -854,15 +854,15 @@ addCollation(ParseState* state, TableResource *result, const char *collationTyp
return NULL;
}

- u_UCharsToChars(tokenValue->fChars, subtag, u_strlen(tokenValue->fChars) + 1);
-
+ subtag.clear();
+ subtag.appendInvariantChars(tokenValue->fChars, u_strlen(tokenValue->fChars), *status);
if (U_FAILURE(*status))
{
res_close(result);
return NULL;
}

- member = parseResource(state, subtag, NULL, status);
+ member = parseResource(state, subtag.data(), NULL, status);

if (U_FAILURE(*status))
{
@@ -873,7 +873,7 @@ addCollation(ParseState* state, TableResource *result, const char *collationTyp
{
// Ignore the parsed resources, continue parsing.
}
- else if (uprv_strcmp(subtag, "Version") == 0 && member->isString())
+ else if (uprv_strcmp(subtag.data(), "Version") == 0 && member->isString())
{
StringResource *sr = static_cast<StringResource *>(member);
char ver[40];
@@ -890,11 +890,11 @@ addCollation(ParseState* state, TableResource *result, const char *collationTyp
result->add(member, line, *status);
member = NULL;
}
- else if(uprv_strcmp(subtag, "%%CollationBin")==0)
+ else if(uprv_strcmp(subtag.data(), "%%CollationBin")==0)
{
/* discard duplicate %%CollationBin if any*/
}
- else if (uprv_strcmp(subtag, "Sequence") == 0 && member->isString())
+ else if (uprv_strcmp(subtag.data(), "Sequence") == 0 && member->isString())
{
StringResource *sr = static_cast<StringResource *>(member);
rules = sr->fString;
@@ -1047,7 +1047,7 @@ parseCollationElements(ParseState* state, char *tag, uint32_t startline, UBool n
struct UString *tokenValue;
struct UString comment;
enum ETokenType token;
- char subtag[1024], typeKeyword[1024];
+ CharString subtag, typeKeyword;
uint32_t line;

result = table_open(state->bundle, tag, NULL, status);
@@ -1089,7 +1089,8 @@ parseCollationElements(ParseState* state, char *tag, uint32_t startline, UBool n
return NULL;
}

- u_UCharsToChars(tokenValue->fChars, subtag, u_strlen(tokenValue->fChars) + 1);
+ subtag.clear();
+ subtag.appendInvariantChars(tokenValue->fChars, u_strlen(tokenValue->fChars), *status);

if (U_FAILURE(*status))
{
@@ -1097,9 +1098,9 @@ parseCollationElements(ParseState* state, char *tag, uint32_t startline, UBool n
return NULL;
}

- if (uprv_strcmp(subtag, "default") == 0)
+ if (uprv_strcmp(subtag.data(), "default") == 0)
{
- member = parseResource(state, subtag, NULL, status);
+ member = parseResource(state, subtag.data(), NULL, status);

if (U_FAILURE(*status))
{
@@ -1118,22 +1119,29 @@ parseCollationElements(ParseState* state, char *tag, uint32_t startline, UBool n
if(token == TOK_OPEN_BRACE) {
token = getToken(state, &tokenValue, &comment, &line, status);
TableResource *collationRes;
- if (keepCollationType(subtag)) {
- collationRes = table_open(state->bundle, subtag, NULL, status);
+ if (keepCollationType(subtag.data())) {
+ collationRes = table_open(state->bundle, subtag.data(), NULL, status);
} else {
collationRes = NULL;
}
// need to parse the collation data regardless
- collationRes = addCollation(state, collationRes, subtag, startline, status);
+ collationRes = addCollation(state, collationRes, subtag.data(), startline, status);
if (collationRes != NULL) {
result->add(collationRes, startline, *status);
}
} else if(token == TOK_COLON) { /* right now, we'll just try to see if we have aliases */
/* we could have a table too */
token = peekToken(state, 1, &tokenValue, &line, &comment, status);
- u_UCharsToChars(tokenValue->fChars, typeKeyword, u_strlen(tokenValue->fChars) + 1);
- if(uprv_strcmp(typeKeyword, "alias") == 0) {
- member = parseResource(state, subtag, NULL, status);
+ typeKeyword.clear();
+ typeKeyword.appendInvariantChars(tokenValue->fChars, u_strlen(tokenValue->fChars), *status);
+ if (U_FAILURE(*status))
+ {
+ res_close(result);
+ return NULL;
+ }
+
+ if(uprv_strcmp(typeKeyword.data(), "alias") == 0) {
+ member = parseResource(state, subtag.data(), NULL, status);
if (U_FAILURE(*status))
{
res_close(result);
@@ -1175,7 +1183,7 @@ realParseTable(ParseState* state, TableResource *table, char *tag, uint32_t star
struct UString *tokenValue=NULL;
struct UString comment;
enum ETokenType token;
- char subtag[1024];
+ CharString subtag;
uint32_t line;
UBool readToken = FALSE;

@@ -1214,7 +1222,8 @@ realParseTable(ParseState* state, TableResource *table, char *tag, uint32_t star
}

if(uprv_isInvariantUString(tokenValue->fChars, -1)) {
- u_UCharsToChars(tokenValue->fChars, subtag, u_strlen(tokenValue->fChars) + 1);
+ subtag.clear();
+ subtag.appendInvariantChars(tokenValue->fChars, u_strlen(tokenValue->fChars), *status);
} else {
*status = U_INVALID_FORMAT_ERROR;
error(line, "invariant characters required for table keys");
@@ -1227,7 +1236,7 @@ realParseTable(ParseState* state, TableResource *table, char *tag, uint32_t star
return NULL;
}

- member = parseResource(state, subtag, &comment, status);
+ member = parseResource(state, subtag.data(), &comment, status);

if (member == NULL || U_FAILURE(*status))
{
--
2.45.4

7 changes: 6 additions & 1 deletion SPECS/icu/icu.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
Summary: International Components for Unicode.
Name: icu
Version: 68.2.0.9
Release: 1%{?dist}
Release: 2%{?dist}
License: BSD and MIT and Public Domain and naist-2003
URL: https://github.com/microsoft/icu
Group: System Environment/Libraries
Vendor: Microsoft Corporation
Distribution: Mariner
#Source0: %{url}/archive/v%{version}.tar.gz
Source0: %{name}-%{version}.tar.gz
Patch0: CVE-2025-5222.patch
BuildRequires: autoconf
BuildRequires: python3
BuildRequires: python3-xml
Expand All @@ -29,6 +30,7 @@ It contains the libraries and header files to create applications

%prep
%setup -q
%patch 0 -p1

%build
pushd icu/icu4c/source
Expand Down Expand Up @@ -60,6 +62,9 @@ make -C icu/icu4c/source DESTDIR=%{buildroot} install
%{_libdir}/pkgconfig/*.pc

%changelog
* Tue Aug 12 2025 Azure Linux Security Servicing Account <[email protected]> - 68.2.0.9-2
- Patch for CVE-2025-5222

* Fri May 20 2022 CBL-Mariner Service Account <[email protected]> - 68.2.0.9-1
- Update to version "68.2.0.9".

Expand Down
Loading