fix CVE-2023-39328

This commit is contained in:
xh 2024-07-11 05:59:40 +00:00
parent 3096c56179
commit 5928ebc0ba
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From b287b27a87ecfbbd3b1206b17269d19e76a1b467 Mon Sep 17 00:00:00 2001
From: pic4xiu <40382944+pic4xiu@users.noreply.github.com>
Date: Thu, 29 Jun 2023 19:50:47 +0800
Subject: [PATCH] Update opj_malloc.c
Conflict: NA
Reference: https://github.com/uclouvain/openjpeg/commit/b287b27a87ecfbbd3b1206b17269d19e76a1b467
---
src/lib/openjp2/opj_malloc.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/lib/openjp2/opj_malloc.c b/src/lib/openjp2/opj_malloc.c
index dca91bfcb..6242614f9 100644
--- a/src/lib/openjp2/opj_malloc.c
+++ b/src/lib/openjp2/opj_malloc.c
@@ -197,6 +197,16 @@ void * opj_malloc(size_t size)
}
void * opj_calloc(size_t num, size_t size)
{
+ static unsigned long long allocated_size = 0;
+ static unsigned long long max_allocated_size = 4ULL * 1024 * 1024 * 1024;
+ /*Restrict this function can only malloc 4GB of memory*/
+
+ unsigned long long total_size = (unsigned long long)(num * size);
+ allocated_size += total_size;
+ if (allocated_size > max_allocated_size) {
+ /*Prevent excessive resource allocation*/
+ return NULL;
+ }
if (num == 0 || size == 0) {
/* prevent implementation defined behavior of realloc */
return NULL;

View File

@ -2,7 +2,7 @@
Name: openjpeg2 Name: openjpeg2
Version: 2.5.0 Version: 2.5.0
Release: 3 Release: 4
Summary: C-Library for JPEG 2000 Summary: C-Library for JPEG 2000
License: BSD and MIT License: BSD and MIT
URL: https://github.com/uclouvain/openjpeg URL: https://github.com/uclouvain/openjpeg
@ -10,6 +10,7 @@ Source0: https://github.com/uclouvain/openjpeg/archive/v%{version}/openjp
Patch0: openjpeg2_opj2.patch Patch0: openjpeg2_opj2.patch
Patch1: heap-buffer-overflow.patch Patch1: heap-buffer-overflow.patch
Patch2: backport-CVE-2023-39328.patch
BuildRequires: cmake gcc-c++ make zlib-devel libpng-devel libtiff-devel lcms2-devel doxygen java-devel BuildRequires: cmake gcc-c++ make zlib-devel libpng-devel libtiff-devel lcms2-devel doxygen java-devel
BuildRequires: jbigkit-devel libjpeg-turbo-devel BuildRequires: jbigkit-devel libjpeg-turbo-devel
@ -100,6 +101,12 @@ mv %{buildroot}%{_mandir}/man1/opj_dump.1 %{buildroot}%{_mandir}/man1/opj2_dump.
%{_bindir}/opj2_dump %{_bindir}/opj2_dump
%changelog %changelog
* Thu Jul 11 2024 xinghe <xinghe2@h-partners.com> - 2.5.0-4
- Type:cves
- ID:CVE-2023-39328
- SUG:NA
- DESC:fix CVE-2023-39328
* Mon May 29 2023 Jia Chao <jiachao2130@126.com> - 2.5.0-3 * Mon May 29 2023 Jia Chao <jiachao2130@126.com> - 2.5.0-3
- Fix: builddir contains arch info make help create different noarch pkg. - Fix: builddir contains arch info make help create different noarch pkg.