]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
image-sgi: Return early if sgiOpenFile fails 647/head
authorGünther Noack <gnoack@google.com>
Fri, 4 Jul 2025 14:15:42 +0000 (16:15 +0200)
committerGünther Noack <gnoack@google.com>
Tue, 8 Jul 2025 17:18:03 +0000 (19:18 +0200)
sgiOpenFile can fail when passing an image that both has large
dimensions and which also uses RLE compression.  In that case,
sgiOpenFile attempts to allocate space for compression-related tables
and these allocations may fail due to the requested size, causing
sgiOpenFile to return NULL.  Without this fix, the NULL pointer gets
dereferenced, which crashes the filter process.

Compare https://en.wikipedia.org/wiki/Silicon_Graphics_Image#Header
for an overview of the SGI image headere.

cupsfilters/image-sgi.c

index 9bdb121b2cd87f32b6ab0790b7a7a68ea9607224..77629ac8f9f69bc621736e6180b4a1321a295b6c 100644 (file)
@@ -56,6 +56,9 @@ _cupsImageReadSGI(
 
   sgip = sgiOpenFile(fp, SGI_READ, 0, 0, 0, 0, 0);
 
+  if (!sgip)
+    return (1);
+
  /*
   * Get the image dimensions and load the output image...
   */