!108 [sync] PR-104: fix CVE-2024-45491, CVE-2024-45492

From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
This commit is contained in:
openeuler-ci-bot 2024-09-05 10:13:01 +00:00 committed by Gitee
commit 323f716435
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 70 additions and 9 deletions

View File

@ -0,0 +1,31 @@
From 8e439a9947e9dc80a395c0c7456545d8d9d9e421 Mon Sep 17 00:00:00 2001
From: Sebastian Pipping <sebastian@pipping.org>
Date: Mon, 19 Aug 2024 22:34:13 +0200
Subject: [PATCH] lib: Detect integer overflow in dtdCopy
Reported by TaiYou
---
expat/lib/xmlparse.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/xmlparse.c b/expat/lib/xmlparse.c
index 91682c188..e2327bdcf 100644
--- a/lib/xmlparse.c
+++ b/lib/xmlparse.c
@@ -7016,6 +7016,16 @@ dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd,
if (! newE)
return 0;
if (oldE->nDefaultAtts) {
+ /* Detect and prevent integer overflow.
+ * The preprocessor guard addresses the "always false" warning
+ * from -Wtype-limits on platforms where
+ * sizeof(int) < sizeof(size_t), e.g. on x86_64. */
+#if UINT_MAX >= SIZE_MAX
+ if ((size_t)oldE->nDefaultAtts
+ > ((size_t)(-1) / sizeof(DEFAULT_ATTRIBUTE))) {
+ return 0;
+ }
+#endif
newE->defaultAtts
= ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
if (! newE->defaultAtts) {

View File

@ -0,0 +1,30 @@
From 9bf0f2c16ee86f644dd1432507edff94c08dc232 Mon Sep 17 00:00:00 2001
From: Sebastian Pipping <sebastian@pipping.org>
Date: Mon, 19 Aug 2024 22:37:16 +0200
Subject: [PATCH] lib: Detect integer overflow in function nextScaffoldPart
Reported by TaiYou
---
expat/lib/xmlparse.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
index 91682c188..f737575ea 100644
--- a/lib/xmlparse.c
+++ b/lib/xmlparse.c
@@ -7558,6 +7558,15 @@ nextScaffoldPart(XML_Parser parser) {
int next;
if (! dtd->scaffIndex) {
+ /* Detect and prevent integer overflow.
+ * The preprocessor guard addresses the "always false" warning
+ * from -Wtype-limits on platforms where
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
+#if UINT_MAX >= SIZE_MAX
+ if (parser->m_groupSize > ((size_t)(-1) / sizeof(int))) {
+ return -1;
+ }
+#endif
dtd->scaffIndex = (int *)MALLOC(parser, parser->m_groupSize * sizeof(int));
if (! dtd->scaffIndex)
return -1;

View File

@ -1,7 +1,7 @@
%define Rversion %(echo %{version} | sed -e 's/\\./_/g' -e 's/^/R_/') %define Rversion %(echo %{version} | sed -e 's/\\./_/g' -e 's/^/R_/')
Name: expat Name: expat
Version: 2.5.0 Version: 2.5.0
Release: 4 Release: 5
Summary: An XML parser library Summary: An XML parser library
License: MIT License: MIT
URL: https://libexpat.github.io/ URL: https://libexpat.github.io/
@ -27,6 +27,8 @@ Patch17: backport-009-CVE-2023-52425.patch
Patch18: backport-001-CVE-2024-45490.patch Patch18: backport-001-CVE-2024-45490.patch
Patch19: backport-002-CVE-2024-45490.patch Patch19: backport-002-CVE-2024-45490.patch
Patch20: backport-003-CVE-2024-45490.patch Patch20: backport-003-CVE-2024-45490.patch
Patch21: backport-CVE-2024-45491.patch
Patch22: backport-CVE-2024-45492.patch
BuildRequires: sed,autoconf,automake,gcc-c++,libtool,xmlto BuildRequires: sed,autoconf,automake,gcc-c++,libtool,xmlto
@ -52,36 +54,34 @@ autoreconf -fiv
%make_build %make_build
%install %install
%makeinstall %make_install
find %{buildroot} -type f -name changelog -delete find %{buildroot} -type f -name changelog -delete
%check %check
make check %make_build check
%ldconfig_scriptlets
%files %files
%defattr(-,root,root)
%license COPYING AUTHORS %license COPYING AUTHORS
%{_bindir}/* %{_bindir}/*
%{_libdir}/libexpat.so.1* %{_libdir}/libexpat.so.1*
%exclude %{_docdir}/%{name}/AUTHORS %exclude %{_docdir}/%{name}/AUTHORS
%files devel %files devel
%defattr(-,root,root)
%{_includedir}/* %{_includedir}/*
%{_libdir}/{libexpat.*a,libexpat.so} %{_libdir}/{libexpat.*a,libexpat.so}
%{_libdir}/cmake/expat-%{version} %{_libdir}/cmake/expat-%{version}
%{_libdir}/pkgconfig/expat.pc %{_libdir}/pkgconfig/expat.pc
%files help %files help
%defattr(-,root,root)
%doc README.md %doc README.md
%{_mandir}/man1/* %{_mandir}/man1/*
%changelog %changelog
* Wed Sep 04 2024 Funda Wang <fundawang@yeah.net> - 2.5.0-5
- fix CVE-2024-45491, CVE-2024-45492
* Mon Sep 2 2024 caixiaomeng <caixiaomeng2@huawei.com> - 2.5.0-4 * Mon Sep 2 2024 caixiaomeng <caixiaomeng2@huawei.com> - 2.5.0-4
- fix CVE-2024-45491 - fix CVE-2024-45490
* Wed Jun 12 2024 wangjiang <wangjiang37@h-partners.com> - 2.5.0-3 * Wed Jun 12 2024 wangjiang <wangjiang37@h-partners.com> - 2.5.0-3
- fix CVE-2023-52425 - fix CVE-2023-52425