Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libheif for openSUSE:Factory checked 
in at 2024-01-04 15:55:15
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libheif (Old)
 and      /work/SRC/openSUSE:Factory/.libheif.new.28375 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libheif"

Thu Jan  4 15:55:15 2024 rev:29 rq:1136786 version:1.17.6

Changes:
--------
--- /work/SRC/openSUSE:Factory/libheif/libheif.changes  2023-12-15 
21:46:20.220083653 +0100
+++ /work/SRC/openSUSE:Factory/.libheif.new.28375/libheif.changes       
2024-01-04 15:56:27.142447351 +0100
@@ -1,0 +2,28 @@
+Wed Jan  3 09:26:08 UTC 2024 - Dirk Müller <dmuel...@suse.com>
+
+- update to 1.17.6:
+  * A couple of build fixes and bug fixes detected by fuzzing.
+
+  * Corrects these issues:
+  * CVE-2023-49462 - #1043
+  * CVE-2023-49463 - #1042
+- drop libheif-CVE-2023-49462.patch,
+  libheif-CVE-2023-49464.patch,
+  libheif-CVE-2023-49460.patch: upstream
+
+-------------------------------------------------------------------
+Tue Dec 19 10:40:25 UTC 2023 - pgaj...@suse.com
+
+- security update
+- added patches
+  fix CVE-2023-49460 [bsc#1217902], segmentation violation in 
decode_uncompressed_image()
+  + libheif-CVE-2023-49460.patch
+
+-------------------------------------------------------------------
+Mon Dec 18 18:18:18 UTC 2023 - o...@aepfle.de
+
+- sync ExclusiveArch with SVT-AV1
+- move HEIF plugins from examples to separate package
+- make sure all subpackages use the same libheif1 ABI
+
+-------------------------------------------------------------------

Old:
----
  libheif-1.17.5.tar.gz
  libheif-CVE-2023-49462.patch
  libheif-CVE-2023-49464.patch

New:
----
  libheif-1.17.6.tar.gz

BETA DEBUG BEGIN:
  Old:  * CVE-2023-49463 - #1042
- drop libheif-CVE-2023-49462.patch,
  libheif-CVE-2023-49464.patch,
  Old:- drop libheif-CVE-2023-49462.patch,
  libheif-CVE-2023-49464.patch,
  libheif-CVE-2023-49460.patch: upstream
BETA DEBUG END:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libheif.spec ++++++
--- /var/tmp/diff_new_pack.I3EWGF/_old  2024-01-04 15:56:29.530534589 +0100
+++ /var/tmp/diff_new_pack.I3EWGF/_new  2024-01-04 15:56:29.534534736 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package libheif
 #
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -21,13 +21,13 @@
 %bcond_with kvazaar
 %bcond_with svtenc
 %if 0%{?suse_version} > 1500
-%ifarch x86_64
+%ifarch aarch64 riscv64 x86_64
 %bcond_without svtenc
 %endif
 %endif
 
 Name:           libheif
-Version:        1.17.5
+Version:        1.17.6
 Release:        0
 Summary:        HEIF/AVIF file format decoder and encoder
 License:        GPL-2.0-or-later
@@ -35,10 +35,6 @@
 URL:            https://github.com/strukturag/libheif
 Source0:        %{url}/releases/download/v%{version}/%{name}-%{version}.tar.gz
 Source99:       baselibs.conf
-# CVE-2023-49462 [bsc#1217898], read16 segv
-Patch0:         libheif-CVE-2023-49462.patch
-# CVE-2023-49464 [bsc#1217900], UAF
-Patch1:         libheif-CVE-2023-49464.patch
 BuildRequires:  chrpath
 BuildRequires:  cmake
 BuildRequires:  fdupes
@@ -89,6 +85,7 @@
 Summary:        Plugin AOM encoder and decoder for AVIF
 Group:          System/Libraries
 Supplements:    libheif1
+Requires:       libheif1 = %{version}-%{release}
 
 %description aom
 This plugin provides the AOM encoder and decoder for AVIF to libheif. Packaged 
separately
@@ -98,6 +95,7 @@
 Summary:        Plugin dav1d decoder for AVIF
 Group:          System/Libraries
 Supplements:    libheif1
+Requires:       libheif1 = %{version}-%{release}
 
 %description dav1d
 This plugin provides the dav1d encoder for AVIF to libheif. Packaged separately
@@ -107,6 +105,7 @@
 Summary:        Plugin FFMPEG decoder (HW acc) for HEIC
 Group:          System/Libraries
 Supplements:    libheif1
+Requires:       libheif1 = %{version}-%{release}
 
 %description ffmpeg
 This plugin provides the FFMPEG decoder (HW acc) for HEIC to libheif. Packaged 
separately
@@ -116,6 +115,7 @@
 Summary:        Plugin encoder and decoder for JPEG in HEIF
 Group:          System/Libraries
 Supplements:    libheif1
+Requires:       libheif1 = %{version}-%{release}
 
 %description jpeg
 This plugin provides the encoder and decoder for JPEG in HEIF to libheif. 
Packaged separately
@@ -126,6 +126,7 @@
 Summary:        Plugin kvazaar encoder for HEIC
 Group:          System/Libraries
 Supplements:    libheif1
+Requires:       libheif1 = %{version}-%{release}
 
 %description kvazaar
 This plugin provides the kvazaar encoder for HEIC to libheif. Packaged 
separately
@@ -136,6 +137,7 @@
 Summary:        Plugin OpenJPEG J2K encoder and decoder for JPEG-2000 in HEIF
 Group:          System/Libraries
 Supplements:    libheif1
+Requires:       libheif1 = %{version}-%{release}
 
 %description openjpeg
 This plugin provides the OpenJPEG J2K encoder and decoder for JPEG to libheif. 
Packaged separately
@@ -145,6 +147,7 @@
 Summary:        Plugin rav1e encoder for AVIF
 Group:          System/Libraries
 Supplements:    libheif1
+Requires:       libheif1 = %{version}-%{release}
 
 %description rav1e
 This plugin provides the rav1e encoder for AVIF to libheif. Packaged separately
@@ -155,12 +158,25 @@
 Summary:        Plugin SVT-AV1 encoder for AVIF
 Group:          System/Libraries
 Supplements:    libheif1
+Requires:       libheif1 = %{version}-%{release}
 
 %description svtenc
 This plugin provides the SVT-AV1 encoder for AVIF to libheif. Packaged 
separately
 so that the libraries it requires are not pulled in by default by libheif.
 %endif
 
+%if %{with x265}
+%package HEIF
+Summary:        Plugin for HEIF decoder and encoder
+Group:          System/Libraries
+Supplements:    libheif1
+Requires:       libheif1 = %{version}-%{release}
+
+%description HEIF
+This plugin provides an decoder and encoder for HEIF to libheif. Packaged 
separately
+so that the libraries it requires are not pulled in by default by libheif.
+%endif
+
 %package devel
 Summary:        Devel Package for %{name}
 Group:          Development/Libraries/C and C++
@@ -174,6 +190,7 @@
 Summary:        GDK PixBuf Loader for %{name}
 Group:          System/Libraries
 Supplements:    (libheif1 and libgdk_pixbuf-2_0-0)
+Requires:       libheif1 = %{version}-%{release}
 
 %description -n gdk-pixbuf-loader-libheif
 A ISO/IEC 23008-12:2017 HEIF file format decoder and encoder.
@@ -184,6 +201,7 @@
 %package -n heif-examples
 Summary:        Example binary programs for %{name}
 Group:          Productivity/Graphics/Other
+Requires:       libheif1 = %{version}-%{release}
 
 %description -n heif-examples
 A ISO/IEC 23008-12:2017 HEIF file format decoder and encoder.
@@ -194,6 +212,7 @@
 Summary:        Thumbnailer for HEIF/AVIF image files
 Group:          Productivity/Graphics/Other
 Supplements:    libheif1
+Requires:       libheif1 = %{version}-%{release}
 
 %description -n heif-thumbnailer
 Allows to show thumbnail previews of HEIF and AVIF images using %{name}.
@@ -325,6 +344,12 @@
 %{_libexecdir}/libheif/libheif-svtenc.so
 %endif
 
+%if %{with x265}
+%files HEIF
+%{_libexecdir}/libheif/libheif-libde265.so
+%{_libexecdir}/libheif/libheif-x265.so
+%endif
+
 %files devel
 %doc README.md
 %{_includedir}/libheif
@@ -343,8 +368,6 @@
 %{_mandir}/man1/heif-convert.1%{?ext_man}
 %{_mandir}/man1/heif-enc.1%{?ext_man}
 %{_mandir}/man1/heif-info.1%{?ext_man}
-%{_libexecdir}/libheif/libheif-libde265.so
-%{_libexecdir}/libheif/libheif-x265.so
 
 %files -n heif-thumbnailer
 %{_bindir}/heif-thumbnailer

++++++ libheif-1.17.5.tar.gz -> libheif-1.17.6.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/CMakeLists.txt 
new/libheif-1.17.6/CMakeLists.txt
--- old/libheif-1.17.5/CMakeLists.txt   2023-11-21 10:35:24.000000000 +0100
+++ new/libheif-1.17.6/CMakeLists.txt   2023-12-20 11:31:30.000000000 +0100
@@ -1,6 +1,6 @@
 cmake_minimum_required (VERSION 3.16.3) # Oldest Ubuntu LTS (20.04 currently)
 
-project(libheif LANGUAGES C CXX VERSION 1.17.5)
+project(libheif LANGUAGES C CXX VERSION 1.17.6)
 
 # compatibility_version is never allowed to be decreased for any specific 
SONAME.
 # Libtool in the libheif-1.15.1 release had set it to 17.0.0, so we have to 
use this for the v1.x.y versions.
@@ -259,6 +259,10 @@
 if (LIBSHARPYUV_FOUND)
     list(APPEND REQUIRES_PRIVATE "libsharpyuv")
 endif()
+if (WITH_DEFLATE_HEADER_COMPRESSION)
+    list(APPEND REQUIRES_PRIVATE "zlib")
+endif()
+
 list(JOIN REQUIRES_PRIVATE " " REQUIRES_PRIVATE)
 
 include(CheckCXXSymbolExists)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/README.md new/libheif-1.17.6/README.md
--- old/libheif-1.17.5/README.md        2023-11-21 10:35:24.000000000 +0100
+++ new/libheif-1.17.6/README.md        2023-12-20 11:31:30.000000000 +0100
@@ -155,7 +155,7 @@
 * `WITH_{codec}_PLUGIN`: when enabled, the codec is compiled as a separate 
plugin.
 
 In order to use dynamic plugins, also make sure that `ENABLE_PLUGIN_LOADING` 
is enabled.
-The placeholder `{codec}` can have these values: `LIBDE265`, `X265`, 
`AOM_DECODER`, `AOM_ENCODER`, `SvtEnc`, `DAV1D`, `FFMPEG_HEVC_DECODER`, 
`JPEG_DECODER`, `JPEG_ENCODER`, `KVAZAAR`, `OpenJPEG_DECODER`, 
`OpenJPEG_ENCODER`.
+The placeholder `{codec}` can have these values: `LIBDE265`, `X265`, 
`AOM_DECODER`, `AOM_ENCODER`, `SvtEnc`, `DAV1D`, `FFMPEG_DECODER`, 
`JPEG_DECODER`, `JPEG_ENCODER`, `KVAZAAR`, `OpenJPEG_DECODER`, 
`OpenJPEG_ENCODER`.
 
 Further options are:
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/examples/encoder_jpeg.cc 
new/libheif-1.17.6/examples/encoder_jpeg.cc
--- old/libheif-1.17.5/examples/encoder_jpeg.cc 2023-11-21 10:35:24.000000000 
+0100
+++ new/libheif-1.17.6/examples/encoder_jpeg.cc 2023-12-20 11:31:30.000000000 
+0100
@@ -29,6 +29,7 @@
 #include <string.h>
 
 #include <vector>
+#include <limits>
 
 #include "encoder_jpeg.h"
 #include "libheif/exif.h"
@@ -176,13 +177,24 @@
       static const uint8_t kExifMarker = JPEG_APP0 + 1;
 
       uint32_t skip = (exifdata[0]<<24) | (exifdata[1]<<16) | (exifdata[2]<<8) 
| exifdata[3];
+      if (skip > (exifsize - 4)) {
+        fprintf(stderr, "Invalid EXIF data (offset too large)\n");
+        return false;
+      }
       skip += 4;
 
       uint8_t* ptr = exifdata + skip;
       size_t size = exifsize - skip;
 
+      if (size > std::numeric_limits<uint32_t>::max()) {
+        fprintf(stderr, "EXIF larger than 4GB is not supported");
+        return false;
+      }
+
+      auto size32 = static_cast<uint32_t>(size);
+
       // libheif by default normalizes the image orientation, so that we have 
to set the EXIF Orientation to "Horizontal (normal)"
-      modify_exif_orientation_tag_if_it_exists(ptr, (int)size, 1);
+      modify_exif_orientation_tag_if_it_exists(ptr, size32, 1);
 
       // We have to limit the size for the memcpy, otherwise GCC warns that we 
exceed the maximum size.
       if (size>0x1000000) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/examples/encoder_png.cc 
new/libheif-1.17.6/examples/encoder_png.cc
--- old/libheif-1.17.5/examples/encoder_png.cc  2023-11-21 10:35:24.000000000 
+0100
+++ new/libheif-1.17.6/examples/encoder_png.cc  2023-12-20 11:31:30.000000000 
+0100
@@ -117,15 +117,16 @@
   if (exifdata) {
     if (exifsize > 4) {
       uint32_t skip = (exifdata[0]<<24) | (exifdata[1]<<16) | (exifdata[2]<<8) 
| exifdata[3];
-      skip += 4;
+      if (skip < (exifsize - 4)) {
+        skip += 4;
+        uint8_t* ptr = exifdata + skip;
+        size_t size = exifsize - skip;
 
-      uint8_t* ptr = exifdata + skip;
-      size_t size = exifsize - skip;
+        // libheif by default normalizes the image orientation, so that we 
have to set the EXIF Orientation to "Horizontal (normal)"
+        modify_exif_orientation_tag_if_it_exists(ptr, (int)size, 1);
 
-      // libheif by default normalizes the image orientation, so that we have 
to set the EXIF Orientation to "Horizontal (normal)"
-      modify_exif_orientation_tag_if_it_exists(ptr, (int)size, 1);
-
-      png_set_eXIf_1(png_ptr, info_ptr, (png_uint_32)size, ptr);
+        png_set_eXIf_1(png_ptr, info_ptr, (png_uint_32)size, ptr);
+      }
     }
 
     free(exifdata);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/extra/getopt_long.c 
new/libheif-1.17.6/extra/getopt_long.c
--- old/libheif-1.17.5/extra/getopt_long.c      2023-11-21 10:35:24.000000000 
+0100
+++ new/libheif-1.17.6/extra/getopt_long.c      2023-12-20 11:31:30.000000000 
+0100
@@ -73,7 +73,7 @@
  *     Parse argc/argv argument vector.
  */
 int
-getopt_internal(int nargc, char ** nargv, const char *ostr)
+getopt_internal(int nargc, char * const* nargv, const char *ostr)
 {
        static char *place = EMSG;              /* option letter processing */
        const char *oli;                                /* option letter list 
index */
@@ -142,7 +142,7 @@
 
        if ((retval = getopt_internal(nargc, nargv, ostr)) == -2) {
                retval = -1;
-               ++optind; 
+               ++optind;
        }
        return(retval);
 }
@@ -175,11 +175,11 @@
                } else
                        current_argv_len = strlen(current_argv);
 
-               for (i = 0; long_options[i].name; i++) { 
+               for (i = 0; long_options[i].name; i++) {
                        if (strncmp(current_argv, long_options[i].name, 
current_argv_len))
                                continue;
 
-                       if (strlen(long_options[i].name) == 
(unsigned)current_argv_len) { 
+                       if (strlen(long_options[i].name) == 
(unsigned)current_argv_len) {
                                match = i;
                                break;
                        }
@@ -215,7 +215,7 @@
                if (long_options[match].flag) {
                        *long_options[match].flag = long_options[match].val;
                        retval = 0;
-               } else 
+               } else
                        retval = long_options[match].val;
                if (index)
                        *index = match;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/libheif/box.cc 
new/libheif-1.17.6/libheif/box.cc
--- old/libheif-1.17.5/libheif/box.cc   2023-11-21 10:35:24.000000000 +0100
+++ new/libheif-1.17.6/libheif/box.cc   2023-12-20 11:31:30.000000000 +0100
@@ -2854,7 +2854,11 @@
   std::ostringstream sstr;
   sstr << Box::dump(indent);
 
-  sstr << indent << "number of data bytes: " << get_box_size() - 
get_header_size() << "\n";
+  if (get_box_size() >= get_header_size()) {
+    sstr << indent << "number of data bytes: " << get_box_size() - 
get_header_size() << "\n";
+  } else {
+     sstr << indent << "number of data bytes is invalid\n";
+  }
 
   return sstr.str();
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/libheif/context.cc 
new/libheif-1.17.6/libheif/context.cc
--- old/libheif-1.17.5/libheif/context.cc       2023-11-21 10:35:24.000000000 
+0100
+++ new/libheif-1.17.6/libheif/context.cc       2023-12-20 11:31:30.000000000 
+0100
@@ -2411,7 +2411,7 @@
     image_nclx = std::make_shared<color_profile_nclx>();
   }
 
-  if (image_nclx->get_full_range_flag() != spec_nclx->full_range_flag) {
+  if (image_nclx->get_full_range_flag() != ( spec_nclx->full_range_flag == 0 ? 
false : true ) ) {
     return false;
   }
 
@@ -2938,9 +2938,9 @@
   for (;;) {
     uint8_t* data;
     int size;
-    
+
     encoder->plugin->get_compressed_data(encoder->encoder, &data, &size, 
nullptr);
-    
+
     if (data == NULL) {
       break;
     }
@@ -2954,7 +2954,7 @@
 
 
 
-  //Add 'ispe' Property 
+  //Add 'ispe' Property
   m_heif_file->add_ispe_property(image_id, image->get_width(), 
image->get_height());
 
   //Add 'colr' Property
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/libheif/exif.cc 
new/libheif-1.17.6/libheif/exif.cc
--- old/libheif-1.17.5/libheif/exif.cc  2023-11-21 10:35:24.000000000 +0100
+++ new/libheif-1.17.6/libheif/exif.cc  2023-12-20 11:31:30.000000000 +0100
@@ -25,12 +25,12 @@
 #define DEFAULT_EXIF_ORIENTATION 1
 #define EXIF_TAG_ORIENTATION 0x112
 
+// Note: As far as I can see, it is not defined in the EXIF standard whether 
the offsets and counts of the IFD is signed or unsigned.
+// We assume that these are all unsigned.
 
-static int32_t read32(const uint8_t* data, int size, int pos, bool 
littleEndian)
+static uint32_t read32(const uint8_t* data, uint32_t size, uint32_t pos, bool 
littleEndian)
 {
-  if (pos + 4 > size) {
-    return -1;
-  }
+  assert(pos <= size - 4);
 
   const uint8_t* p = data + pos;
 
@@ -43,28 +43,24 @@
 }
 
 
-static int32_t read16(const uint8_t* data, int size, int pos, bool 
littleEndian)
+static uint16_t read16(const uint8_t* data, uint32_t size, uint32_t pos, bool 
littleEndian)
 {
-  if (pos + 2 > size) {
-    return -1;
-  }
+  assert(pos <= size - 2);
 
   const uint8_t* p = data + pos;
 
   if (littleEndian) {
-    return (p[1] << 8) | p[0];
+    return static_cast<uint16_t>((p[1] << 8) | p[0]);
   }
   else {
-    return (p[0] << 8) | p[1];
+    return static_cast<uint16_t>((p[0] << 8) | p[1]);
   }
 }
 
 
-static void write16(uint8_t* data, int size, int pos, uint16_t value, bool 
littleEndian)
+static void write16(uint8_t* data, uint32_t size, uint32_t pos, uint16_t 
value, bool littleEndian)
 {
-  if (pos + 2 > size) {
-    return;
-  }
+  assert(pos <= size - 2);
 
   uint8_t* p = data + pos;
 
@@ -78,16 +74,16 @@
   }
 }
 
-
-static int find_exif_tag(const uint8_t* exif, int  size, uint16_t query_tag, 
bool* out_littleEndian)
+// Returns 0 if the query_tag was not found.
+static uint32_t find_exif_tag(const uint8_t* exif, uint32_t size, uint16_t 
query_tag, bool* out_littleEndian)
 {
   if (size < 4) {
-    return -1;
+    return 0;
   }
 
   if ((exif[0] != 'I' && exif[0] != 'M') ||
       (exif[1] != 'I' && exif[1] != 'M')) {
-    return -1;
+    return 0;
   }
 
   bool littleEndian = (exif[0] == 'I');
@@ -95,14 +91,22 @@
   assert(out_littleEndian);
   *out_littleEndian = littleEndian;
 
-  int offset = read32(exif, size, 4, littleEndian);
-  if (offset < 0) {
-    return -1;
+  uint32_t offset = read32(exif, size, 4, littleEndian);
+
+  if (size - 2 < offset) {
+    return 0;
   }
 
-  int cnt = read16(exif, size, offset, littleEndian);
-  if (cnt < 1) {
-    return -1;
+  uint16_t cnt = read16(exif, size, offset, littleEndian);
+
+  // Does the IFD table fit into our memory range? We need this to prevent an 
underflow in the following statement.
+  if (2U + cnt * 12U > size) {
+    return 0;
+  }
+
+  // end of IFD table would exceed the end of the EXIF data
+  if (size - 2U - cnt * 12U > offset) {
+    return 0;
   }
 
   for (int i = 0; i < cnt; i++) {
@@ -114,20 +118,20 @@
 
   // TODO: do we have to also scan the next IFD table ?
 
-  return -1;
+  return 0;
 }
 
 
-void modify_exif_tag_if_it_exists(uint8_t* exif, int size, uint16_t 
modify_tag, uint16_t modify_value)
+void modify_exif_tag_if_it_exists(uint8_t* exif, uint32_t size, uint16_t 
modify_tag, uint16_t modify_value)
 {
   bool little_endian;
-  int pos = find_exif_tag(exif, size, modify_tag, &little_endian);
-  if (pos < 0) {
+  uint32_t pos = find_exif_tag(exif, size, modify_tag, &little_endian);
+  if (pos == 0) {
     return;
   }
 
-  int type = read16(exif, size, pos + 2, little_endian);
-  int count = read32(exif, size, pos + 4, little_endian);
+  uint16_t type = read16(exif, size, pos + 2, little_endian);
+  uint32_t count = read32(exif, size, pos + 4, little_endian);
 
   if (type == EXIF_TYPE_SHORT && count == 1) {
     write16(exif, size, pos + 8, modify_value, little_endian);
@@ -135,26 +139,26 @@
 }
 
 
-void modify_exif_orientation_tag_if_it_exists(uint8_t* exifData, int size, 
uint16_t orientation)
+void modify_exif_orientation_tag_if_it_exists(uint8_t* exifData, uint32_t 
size, uint16_t orientation)
 {
   modify_exif_tag_if_it_exists(exifData, size, EXIF_TAG_ORIENTATION, 
orientation);
 }
 
 
-int read_exif_orientation_tag(const uint8_t* exif, int size)
+int read_exif_orientation_tag(const uint8_t* exif, uint32_t size)
 {
   bool little_endian;
-  int pos = find_exif_tag(exif, size, EXIF_TAG_ORIENTATION, &little_endian);
-  if (pos < 0) {
+  uint32_t pos = find_exif_tag(exif, size, EXIF_TAG_ORIENTATION, 
&little_endian);
+  if (pos == 0) {
     return DEFAULT_EXIF_ORIENTATION;
   }
 
-  int type = read16(exif, size, pos + 2, little_endian);
-  int count = read32(exif, size, pos + 4, little_endian);
+  uint16_t type = read16(exif, size, pos + 2, little_endian);
+  uint32_t count = read32(exif, size, pos + 4, little_endian);
 
   if (type == EXIF_TYPE_SHORT && count == 1) {
     return read16(exif, size, pos + 8, little_endian);
   }
 
   return DEFAULT_EXIF_ORIENTATION;
-}
\ No newline at end of file
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/libheif/exif.h 
new/libheif-1.17.6/libheif/exif.h
--- old/libheif-1.17.5/libheif/exif.h   2023-11-21 10:35:24.000000000 +0100
+++ new/libheif-1.17.6/libheif/exif.h   2023-12-20 11:31:30.000000000 +0100
@@ -24,8 +24,8 @@
 #include <vector>
 #include <cinttypes>
 
-int read_exif_orientation_tag(const uint8_t* exif, int size);
+int read_exif_orientation_tag(const uint8_t* exif, uint32_t size);
 
-void modify_exif_orientation_tag_if_it_exists(uint8_t* exifData, int size, 
uint16_t orientation);
+void modify_exif_orientation_tag_if_it_exists(uint8_t* exifData, uint32_t 
size, uint16_t orientation);
 
 #endif //LIBHEIF_EXIF_H
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/libheif/mask_image.cc 
new/libheif-1.17.6/libheif/mask_image.cc
--- old/libheif-1.17.5/libheif/mask_image.cc    2023-11-21 10:35:24.000000000 
+0100
+++ new/libheif-1.17.6/libheif/mask_image.cc    2023-12-20 11:31:30.000000000 
+0100
@@ -107,6 +107,12 @@
                  "Unsupported bit depth for mask item");
   }
 
+  if (data.size() < width * height) {
+    return {heif_error_Invalid_input,
+            heif_suberror_Unspecified,
+            "Mask image data is too short"};
+  }
+
   img = std::make_shared<HeifPixelImage>();
   img->create(width, height, heif_colorspace_monochrome, 
heif_chroma_monochrome);
   img->add_plane(heif_channel_Y, width, height, mskC->get_bits_per_pixel());
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/libheif/plugins/encoder_svt.cc 
new/libheif-1.17.6/libheif/plugins/encoder_svt.cc
--- old/libheif-1.17.5/libheif/plugins/encoder_svt.cc   2023-11-21 
10:35:24.000000000 +0100
+++ new/libheif-1.17.6/libheif/plugins/encoder_svt.cc   2023-12-20 
11:31:30.000000000 +0100
@@ -674,7 +674,7 @@
   svt_config.logical_processors = encoder->threads;
 
   // disable 2-pass
-  svt_config.rc_stats_buffer = (SvtAv1FixedBuf) {nullptr, 0};
+  svt_config.rc_stats_buffer = SvtAv1FixedBuf {nullptr, 0};
 
   svt_config.rate_control_mode = 0; // constant rate factor
   //svt_config.enable_adaptive_quantization = 0;   // 2 is CRF (the default), 
0 would be CQP
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/libheif/plugins/encoder_x265.cc 
new/libheif-1.17.6/libheif/plugins/encoder_x265.cc
--- old/libheif-1.17.5/libheif/plugins/encoder_x265.cc  2023-11-21 
10:35:24.000000000 +0100
+++ new/libheif-1.17.6/libheif/plugins/encoder_x265.cc  2023-12-20 
11:31:30.000000000 +0100
@@ -299,6 +299,7 @@
 
 static void x265_cleanup_plugin()
 {
+  x265_cleanup();
 }
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/libheif/uncompressed_image.cc 
new/libheif-1.17.6/libheif/uncompressed_image.cc
--- old/libheif-1.17.5/libheif/uncompressed_image.cc    2023-11-21 
10:35:24.000000000 +0100
+++ new/libheif-1.17.6/libheif/uncompressed_image.cc    2023-12-20 
11:31:30.000000000 +0100
@@ -534,6 +534,9 @@
   int alternate_channel_bits = 0;
   for (Box_uncC::Component component : uncC_box->get_components()) {
     uint16_t component_index = component.component_index;
+    if (component_index >= cmpd_box->get_components().size()) {
+      return -1;
+    }
     auto component_type = 
cmpd_box->get_components()[component_index].component_type;
     switch (component_type) {
       case component_type_monochrome:
@@ -606,6 +609,12 @@
                                                         uint32_t 
maximum_image_height_limit,
                                                         const 
std::vector<uint8_t>& uncompressed_data)
 {
+  if (uncompressed_data.empty()) {
+    return {heif_error_Invalid_input,
+            heif_suberror_Unspecified,
+            "Uncompressed image data is empty"};
+  }
+
   // Get the properties for this item
   // We need: ispe, cmpd, uncC
   std::vector<std::shared_ptr<Box>> item_properties;
@@ -613,6 +622,7 @@
   if (error) {
     return error;
   }
+
   uint32_t width = 0;
   uint32_t height = 0;
   bool found_ispe = false;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/tests/CMakeLists.txt 
new/libheif-1.17.6/tests/CMakeLists.txt
--- old/libheif-1.17.5/tests/CMakeLists.txt     2023-11-21 10:35:24.000000000 
+0100
+++ new/libheif-1.17.6/tests/CMakeLists.txt     2023-12-20 11:31:30.000000000 
+0100
@@ -16,9 +16,10 @@
 # --- tests that require access to internal symbols
 
 if (WITH_REDUCED_VISIBILITY)
-    message(WARNING "Conversion and JPEG 2000 box unit tests can only be 
compiled with full symbol visibility (WITH_REDUCED_VISIBILITY=OFF)")
+    message(WARNING "Conversion and box unit tests can only be compiled with 
full symbol visibility (WITH_REDUCED_VISIBILITY=OFF)")
 else()
     add_libheif_test(conversion)
+    add_libheif_test(idat)
     add_libheif_test(jpeg2000)
 endif()
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libheif-1.17.5/tests/idat.cc 
new/libheif-1.17.6/tests/idat.cc
--- old/libheif-1.17.5/tests/idat.cc    1970-01-01 01:00:00.000000000 +0100
+++ new/libheif-1.17.6/tests/idat.cc    2023-12-20 11:31:30.000000000 +0100
@@ -0,0 +1,51 @@
+/*
+  libheif Item Data Box (idat) unit tests
+
+  MIT License
+
+  Copyright (c) 2023 Brad Hards <br...@frogmouth.net>
+
+  Permission is hereby granted, free of charge, to any person obtaining a copy
+  of this software and associated documentation files (the "Software"), to deal
+  in the Software without restriction, including without limitation the rights
+  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+  copies of the Software, and to permit persons to whom the Software is
+  furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included in 
all
+  copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+  SOFTWARE.
+*/
+
+#include "catch.hpp"
+#include "libheif/box.h"
+#include <cstdint>
+#include <iostream>
+
+TEST_CASE("idat bad") {
+  std::vector<uint8_t> testData{0x00, 0x00, 0x00, 0x00, 'i',
+                                'd',  'a',  't',  0x65};
+  auto reader = std::make_shared<StreamReader_memory>(testData.data(),
+                                                      testData.size(), false);
+
+  BitstreamRange range(reader, testData.size());
+  for (;;) {
+    std::shared_ptr<Box> box;
+    Error error = Box::read(range, &box);
+    if (error != Error::Ok || range.error()) {
+      break;
+    }
+
+    box->get_type();
+    box->get_type_string();
+    Indent indent;
+    box->dump(indent);
+  }
+}

Reply via email to