public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Nils Philippsen <nils@tiptoe.de>
To: git-commits@fedoraproject.org
Subject: [rpms/gegl04] f44: Fix segfault in rgbe_rgbe_to_float()
Date: Thu, 15 Oct 2026 12:59:04 GMT	[thread overview]
Message-ID: <179206914424.1.7455223341345905733.rpms-gegl04-c71d381ea824@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/gegl04
            Branch : f44
            Commit : c71d381ea82426069f481bc7c1cd0aa8733f4f58
            Author : Nils Philippsen <nils@tiptoe.de>
            Date   : 2026-10-15T14:54:50+02:00
            Stats  : +108/-0 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/gegl04/c/c71d381ea82426069f481bc7c1cd0aa8733f4f58?branch=f44

            Log:
            Fix segfault in rgbe_rgbe_to_float()

Resolves: rhbz#2544422

Signed-off-by: Nils Philippsen <nils@tiptoe.de>

---
diff --git a/0001-libs-rgbe-fix-477-Segfault-in-rgbe_rgbe_to_float.patch b/0001-libs-rgbe-fix-477-Segfault-in-rgbe_rgbe_to_float.patch
new file mode 100644
index 0000000..30b40a3
--- /dev/null
+++ b/0001-libs-rgbe-fix-477-Segfault-in-rgbe_rgbe_to_float.patch
@@ -0,0 +1,103 @@
+From 75214d1e6893d5a6b418a62ae6953a121c371a32 Mon Sep 17 00:00:00 2001
+From: Jacob Boerema <jgboerema@gmail.com>
+Date: Wed, 30 Sep 2026 10:42:59 -0400
+Subject: [PATCH] libs/rgbe: fix #477 Segfault in rgbe_rgbe_to_float()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+A short .hdr that claims width 8 and height 11207 makes the
+uncompressed decoder read width × 4 bytes per row from the
+GMappedFile without checking how many bytes remain.
+ASan reports a READ SEGV.
+
+We use rgbe_mapped_file_remaining to make sure we are not going to
+read beyond the end of the mapped file. Also do this in a few other
+places that were also missing a safety check.
+
+In addition to that, if at least one scanline has been read, return
+the partially loaded image instead of NULL.
+---
+ libs/rgbe/rgbe.c | 22 ++++++++++++++++++----
+ 1 file changed, 18 insertions(+), 4 deletions(-)
+
+diff --git a/libs/rgbe/rgbe.c b/libs/rgbe/rgbe.c
+index c0ee66178..996afd699 100644
+--- a/libs/rgbe/rgbe.c
++++ b/libs/rgbe/rgbe.c
+@@ -134,7 +134,7 @@ rgbe_mapped_file_remaining (GMappedFile *f,
+                             const void  *data)
+ {
+   g_return_val_if_fail (f, 0);
+-  g_return_val_if_fail (GPOINTER_TO_UINT (data) >
++  g_return_val_if_fail (GPOINTER_TO_UINT (data) >=
+                         GPOINTER_TO_UINT (g_mapped_file_get_contents (f)), 0);
+ 
+   return GPOINTER_TO_UINT (data) -
+@@ -595,6 +595,9 @@ rgbe_read_uncompressed (const rgbe_file *file,
+ 
+   data = (guint8 *)g_mapped_file_get_contents (file->file) + *cursor;
+ 
++  if (rgbe_mapped_file_remaining (file->file, data) < (gsize) file->header.x_axis.size * RGBE_NUM_RGBE)
++    return FALSE;
++
+   for (i = 0; i < file->header.x_axis.size; ++i)
+     {
+       rgbe_rgbe_to_float (file, data, pixels);
+@@ -665,6 +668,8 @@ rgbe_read_new_rle (const rgbe_file *file,
+                  RGBE_NUM_RGBE * linesize, max_size);
+       return FALSE;
+     }
++  else if (rgbe_mapped_file_remaining (file->file, data) < (gsize) RGBE_NUM_RGBE * linesize)
++    return FALSE;
+ 
+   data += RGBE_NUM_RGBE;
+ 
+@@ -1032,7 +1037,7 @@ rgbe_get_size (rgbe_file *file,
+ gfloat *
+ rgbe_read_scanlines (rgbe_file *file)
+ {
+-  guint     i;
++  guint     rows    = 0;
+   gboolean  success = FALSE;
+   gfloat   *pixels  = NULL,
+            *pixel_cursor;
+@@ -1051,10 +1056,18 @@ rgbe_read_scanlines (rgbe_file *file)
+   offset = GPOINTER_TO_UINT (file->scanlines) -
+            GPOINTER_TO_UINT (g_mapped_file_get_contents (file->file));
+ 
+-  for (i = 0; i < file->header.y_axis.size; ++i)
++  for (guint i = 0; i < file->header.y_axis.size; ++i)
+     {
+       const gchar *data = g_mapped_file_get_contents (file->file);
+ 
++      if (rgbe_mapped_file_remaining (file->file, data) < offset + OFFSET_B)
++        {
++          success = FALSE;
++          g_warning ("Unable to parse rgbe scanlines, fail at row %u\n", i);
++          goto cleanup;
++        }
++      
++
+       if (data[offset + OFFSET_R] == 1 &&
+           data[offset + OFFSET_G] == 1 &&
+           data[offset + OFFSET_B] == 1)
+@@ -1070,13 +1083,14 @@ rgbe_read_scanlines (rgbe_file *file)
+           g_warning ("Unable to parse rgbe scanlines, fail at row %u\n", i);
+           goto cleanup;
+         }
++      rows++;
+       pixel_cursor += file->header.x_axis.size * RGBE_NUM_RGBE;
+     }
+ 
+   success = TRUE;
+ 
+ cleanup:
+-  if (!success)
++  if (!success && rows == 0)
+     {
+       g_free (pixels);
+       pixels = NULL;
+-- 
+2.56.0
+

diff --git a/gegl04.spec b/gegl04.spec
index af9aeb4..2ecf30c 100644
--- a/gegl04.spec
+++ b/gegl04.spec
@@ -28,6 +28,11 @@ Source0:        http://download.gimp.org/pub/gegl/%{apiver}/gegl-%{version}.tar.
 # https://gitlab.gnome.org/GNOME/gegl/-/merge_requests/284
 Patch:		0001-meson-Declare-opencl-as-a-dependency.patch
 
+# https://bugzilla.redhat.com/show_bug.cgi?id=2544422
+# https://gitlab.gnome.org/GNOME/gegl/-/issues/477
+# https://gitlab.gnome.org/GNOME/gegl/-/merge_requests/290
+Patch:		0001-libs-rgbe-fix-477-Segfault-in-rgbe_rgbe_to_float.patch
+
 BuildRequires:  chrpath
 BuildRequires:  enscript
 BuildRequires:  gcc-c++

                 reply	other threads:[~2026-10-15 12:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179206914424.1.7455223341345905733.rpms-gegl04-c71d381ea824@fedoraproject.org \
    --to=nils@tiptoe.de \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox