From: Vijay Anusuri <[email protected]>

Upstream-Status: Backport 
[https://gitlab.com/libtiff/libtiff/-/commit/6e2dac5f904496d127c92ddc4e56eccfca25c2ee]

Reference: https://security-tracker.debian.org/tracker/CVE-2023-41175

Signed-off-by: Vijay Anusuri <[email protected]>
Signed-off-by: Steve Sakoman <[email protected]>
---
 .../libtiff/tiff/CVE-2023-41175.patch         | 69 +++++++++++++++++++
 meta/recipes-multimedia/libtiff/tiff_4.3.0.bb |  1 +
 2 files changed, 70 insertions(+)
 create mode 100644 meta/recipes-multimedia/libtiff/tiff/CVE-2023-41175.patch

diff --git a/meta/recipes-multimedia/libtiff/tiff/CVE-2023-41175.patch 
b/meta/recipes-multimedia/libtiff/tiff/CVE-2023-41175.patch
new file mode 100644
index 0000000000..06645bed68
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/tiff/CVE-2023-41175.patch
@@ -0,0 +1,69 @@
+From 6e2dac5f904496d127c92ddc4e56eccfca25c2ee Mon Sep 17 00:00:00 2001
+From: Arie Haenel <[email protected]>
+Date: Wed, 19 Jul 2023 19:40:01 +0000
+Subject: [PATCH] raw2tiff: fix integer overflow and bypass of the check (fixes 
#592)
+
+Upstream-Status: Backport 
[https://gitlab.com/libtiff/libtiff/-/commit/6e2dac5f904496d127c92ddc4e56eccfca25c2ee]
+CVE: CVE-2023-41175
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ tools/raw2tiff.c | 29 +++++++++++++++++++++++++++++
+ 1 file changed, 29 insertions(+)
+
+diff --git a/tools/raw2tiff.c b/tools/raw2tiff.c
+index dfee715..253c023 100644
+--- a/tools/raw2tiff.c
++++ b/tools/raw2tiff.c
+@@ -36,6 +36,7 @@
+ #include <sys/types.h>
+ #include <math.h>
+ #include <ctype.h>
++#include <limits.h>
+ 
+ #ifdef HAVE_UNISTD_H
+ # include <unistd.h>
+@@ -101,6 +102,7 @@ main(int argc, char* argv[])
+       int     fd;
+       char    *outfilename = NULL;
+       TIFF    *out;
++      uint32_t temp_limit_check = 0;     /* temp for integer overflow 
checking*/
+ 
+       uint32_t row, col, band;
+       int     c;
+@@ -212,6 +214,33 @@ main(int argc, char* argv[])
+       if (guessSize(fd, dtype, hdr_size, nbands, swab, &width, &length) < 0)
+               return EXIT_FAILURE;
+ 
++      /* check for integer overflow in */
++      /* hdr_size + (*width) * (*length) * nbands * depth */
++
++      if ((width == 0) || (length == 0) ){
++          fprintf(stderr, "Too large nbands value specified.\n");
++          return (EXIT_FAILURE);
++      }
++
++      temp_limit_check = nbands * depth;
++
++      if ( !temp_limit_check || length > ( UINT_MAX / temp_limit_check ) )  {
++          fprintf(stderr, "Too large length size specified.\n");
++          return (EXIT_FAILURE);
++      }
++      temp_limit_check = temp_limit_check * length;
++
++      if ( !temp_limit_check || width > ( UINT_MAX / temp_limit_check ) )  {
++          fprintf(stderr, "Too large width size specified.\n");
++          return (EXIT_FAILURE);
++      }
++      temp_limit_check = temp_limit_check * width;
++
++      if ( !temp_limit_check || hdr_size > ( UINT_MAX - temp_limit_check ) )  
{
++          fprintf(stderr, "Too large header size specified.\n");
++          return (EXIT_FAILURE);
++      }
++
+       if (outfilename == NULL)
+               outfilename = argv[optind+1];
+       out = TIFFOpen(outfilename, "w");
+-- 
+2.25.1
+
diff --git a/meta/recipes-multimedia/libtiff/tiff_4.3.0.bb 
b/meta/recipes-multimedia/libtiff/tiff_4.3.0.bb
index e925b7d652..11e3818c69 100644
--- a/meta/recipes-multimedia/libtiff/tiff_4.3.0.bb
+++ b/meta/recipes-multimedia/libtiff/tiff_4.3.0.bb
@@ -46,6 +46,7 @@ SRC_URI = 
"http://download.osgeo.org/libtiff/tiff-${PV}.tar.gz \
            file://CVE-2022-40090.patch \
            file://CVE-2023-1916.patch \
            file://CVE-2023-40745.patch \
+           file://CVE-2023-41175.patch \
            "
 
 SRC_URI[sha256sum] = 
"0e46e5acb087ce7d1ac53cf4f56a09b221537fc86dfc5daaad1c2e89e1b37ac8"
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#191000): 
https://lists.openembedded.org/g/openembedded-core/message/191000
Mute This Topic: https://lists.openembedded.org/mt/102742396/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to