!27 fix CVE-2021-32490 CVE-2021-32491 CVE-2021-32492

From: @programmer12
Reviewed-by: @small_leek
Signed-off-by: @small_leek
This commit is contained in:
openeuler-ci-bot 2021-07-01 07:42:50 +00:00 committed by Gitee
commit 8bd8b54beb
4 changed files with 59 additions and 1 deletions

16
CVE-2021-32490.patch Normal file
View File

@ -0,0 +1,16 @@
diff --git a/libdjvu/IW44Image.cpp b/libdjvu/IW44Image.cpp
index e8d4b44..aa3d554 100644
--- a/libdjvu/IW44Image.cpp
+++ b/libdjvu/IW44Image.cpp
@@ -678,7 +678,11 @@ IW44Image::Map::image(signed char *img8, int rowsize, int pixsep, int fast)
size_t sz = bw * bh;
if (sz / (size_t)bw != (size_t)bh) // multiplication overflow
G_THROW("IW44Image: image size exceeds maximum (corrupted file?)");
+ if (sz == 0)
+ G_THROW("IW44Image: zero size image (corrupted file?)");
GPBuffer<short> gdata16(data16,sz);
+ if (data16 == NULL)
+ G_THROW("IW44Image: unable to allocate image data");
// Copy coefficients
int i;
short *p = data16;

23
CVE-2021-32491.patch Normal file
View File

@ -0,0 +1,23 @@
diff --git a/tools/ddjvu.cpp b/tools/ddjvu.cpp
index 7109952..b41f7d2 100644
--- a/tools/ddjvu.cpp
+++ b/tools/ddjvu.cpp
@@ -70,6 +70,7 @@
#include <locale.h>
#include <fcntl.h>
#include <errno.h>
+#include <cstdint>
#ifdef UNIX
# include <sys/time.h>
@@ -394,7 +395,9 @@ render(ddjvu_page_t *page, int pageno)
rowsize = rrect.w;
else
rowsize = rrect.w * 3;
- if (! (image = (char*)malloc(rowsize * rrect.h)))
+ if ((size_t) rowsize > SIZE_MAX / rrect.h)
+ die(i18n("Integer overflow when allocating image buffer for page %d"), pageno);
+ if (! (image = (char*)malloc((size_t) rowsize * rrect.h)))
die(i18n("Cannot allocate image buffer for page %d"), pageno);
/* Render */

13
CVE-2021-32492.patch Normal file
View File

@ -0,0 +1,13 @@
diff --git a/libdjvu/DataPool.cpp b/libdjvu/DataPool.cpp
index 5fcbedf..4c2eaf0 100644
--- a/libdjvu/DataPool.cpp
+++ b/libdjvu/DataPool.cpp
@@ -791,6 +791,8 @@ DataPool::create(const GP<DataPool> & pool, int start, int length)
DEBUG_MSG("DataPool::DataPool: pool=" << (void *)((DataPool *)pool) << " start=" << start << " length= " << length << "\n");
DEBUG_MAKE_INDENT(3);
+ if (!pool) G_THROW( ERR_MSG("DataPool.zero_DataPool") );
+
DataPool *xpool=new DataPool();
GP<DataPool> retval=xpool;
xpool->init();

View File

@ -1,7 +1,7 @@
Name: djvulibre
Summary: An open source (GPL'ed) implementation of DjVu
Version: 3.5.27
Release: 16
Release: 17
License: GPLv2+
URL: http://djvu.sourceforge.net/
Source0: http://downloads.sourceforge.net/djvu/djvulibre-%{version}.tar.gz
@ -14,6 +14,9 @@ Patch5: CVE-2019-18804.patch
Patch6: update-any2djvu-server-hostname.patch
Patch7: CVE-2021-32493.patch
Patch8: CVE-2021-3500.patch
Patch9: CVE-2021-32490.patch
Patch10: CVE-2021-32491.patch
Patch11: CVE-2021-32492.patch
Requires(post): xdg-utils
Requires(preun): xdg-utils
BuildRequires: libjpeg-turbo-devel libtiff-devel xdg-utils chrpath hicolor-icon-theme gcc-c++
@ -96,6 +99,9 @@ rm -f %{_datadir}/icons/hicolor/32x32/apps/djvulibre-djview3.png || :
%{_mandir}/man1/*
%changelog
* Wed Jun 30 2021 liwu <liwu13@huawei.com> - 3.5.27-17
- Fix CVE-2021-32490 CVE-2021-32491 CVE-2021-32492
* Wen Jun 30 2021 houyingchao <houyingchao@huawei.com> - 3.5.27-16
- Fix CVE-2021-32493 CVE-2021-3500