Commit graph

10619 commits

Author SHA1 Message Date
Alx Sa
f52ae69532 plug-ins: Small code style updates to prior commit 2026-03-25 03:29:55 +00:00
Frank Teklote
0de2a56176 file-psd: scan 'ImageSourceData' for 'Layr' block before parsing layers
When loading layer metadata from TIFF 'ImageSourceData' Tag, don't assume
'Layr' is the first 8BIM block. Iterate over 8BIM/MIB8 blocks, skip non
'Layr' blocks, and rewind 4 bytes before calling read_layer_block() so it
can read the length field as expected. Limit mask_layer_len to the
selected block (including padding).
2026-03-24 23:52:50 +00:00
Alx Sa
3f17f528d1 plug-ins: Load more multichannel PSD channels
Multichannel PSD images reuse their first channel as the
main grayscale "layer". Our PSD plug-in did not take this
into account, resulting in the channels being off-by-one and
mislabeled.

This patch prevents chn_a[0].data from being freed after
it is used to load the layer, and then resets the counts so that
it is reused as the first imported channel.
2026-03-24 20:58:29 +00:00
Alx Sa
680ebede22 plug-ins: Read full channel data for PSP selection
968cf06a only loaded the rectangle area that the
selection was contained in, rather than the actual
channel data. This patch extended the code to
also read in the PSP_CHANNEL_BLOCK data, add
it to the selection GeglBuffer, and then shift it over
into the correct location.
2026-03-23 15:07:33 +00:00
Alx Sa
51f1de8844 plug-ins: Add bounds checks to JIF loading
Resolves #16076
As reported by chamal, it is possible to craft a
Jeff's Image Format image with header values that
are larger than the file size. This can lead to buffer
overflows when loading the data. This patch adds
bounding checks based on the size of the stream.
2026-03-21 17:33:39 +00:00
Alx Sa
ccb3cc3ae8 plug-ins: Add bounds check for SFW plug-in
Resolves #16075
As noted by chamal, it is possible to cause a buffer overflow
in a crafted SFW file. This patch adds bounds checks to prevent
this from occurring.
2026-03-21 15:57:01 +00:00
Alx Sa
7612363d8c plug-ins: Clean up PVR import
Resolves #16058

Per mzfr's observations, this patch adds more
safeguards to PVR import. Memory for data and pixels
is allocated and checked rather than using arrays.
Twiddled patterns are increased to 2048 and we
verify the dimensions are in that range before trying
to access. If users share an image that is larger than
that, we can increase this limit further.
2026-03-20 23:33:19 +00:00
Alx Sa
3264a67112 plug-ins: Clean up ICNS file loading
Resolves #16056
Per mzfr, we should check if the cursor exceeds the
icon total size in icns_slurp () (per OSX icons) as we
do already in icns_decompress ().

Additionally, we were not deleting the temp_image created
to load each icon, and in fact we were making an unnecessary
blank temp_image before receiving the one from the PNG &
JPEG2000 procedures. This patch fixes both problems.
2026-03-20 14:10:15 +00:00
Alx Sa
bb3bf0ae5b plug-ins: Allocate memory in PAA plug-in
Per mzfr, we should dynamically allocate memory
for the PAA plug-in pixel data rather than rely on the image
being small enough for an array to store its information.
2026-03-20 12:24:47 +00:00
Alx Sa
b6d43ec0fe plug-ins: Allocate more space for 4bpp TIM textures
Resolves #16052
Per mzfr, the pixel array for 4bpp TIM textures needs to
be allocated twice as large since each byte in the file
stores two pixel indexes when opened.
2026-03-19 12:39:06 +00:00
Alx Sa
e0bd82f290 plug-ins: Protect against too-large FITS images
Resolves #16051
As reported by mzfr, it is possible to crash the FITS plug-in
if a large enough image is read in. This patch implements their
suggestions of using g_try_malloc () over malloc () (and checking
if it returns NULL), as well as verifying the width & height are
within GIMP's image range.
2026-03-19 12:05:47 +00:00
Alx Sa
337cfb6a31 plug-ins: Remove unneeded gegl_buffer_iterator_add()
Resolves #5553
As noted by Massimo, in the Sparkle plug-in there is an
extra gegl_buffer_iterator_add () that is not used in the following
gegl_buffer_iterator_next (iter) loop. Since this adds dest_buffer
which is also written to in the loop in the fspike () functions,
it can cause data to be overwritten. This patch removes the
unneeded extra function call.
2026-03-19 04:07:58 +00:00
Bruno Lopes
a00a227f54 plug-ins: Comment some unused functions on file-dds
To fix GNU Clang warnings
2026-03-18 18:04:11 -03:00
Bruno Lopes
23a17ee000 plug-ins: Comment unused function on sphere-designer
This fixes a warning from GNU CLang
2026-03-18 18:04:11 -03:00
Bruno Lopes
487ee4f5da plug-ins: Clean unused srcrow and src_bytes variables on warp
It was causing warnings on GNU CLang
2026-03-18 18:04:11 -03:00
Jehan
85ad553b09 plug-ins: localize a string. 2026-03-18 17:18:08 +01:00
Bruno Lopes
71c3f29df8 plug-ins: Fix warnings about unused profile_label and cmyk_profile in file-jp2 2026-03-17 22:30:47 -03:00
Sabri Ünal
3a60f800d4 i18n: Mark "Mask image" as translatable
Mark the "Mask image" string as translatable.
2026-03-17 19:10:33 -03:00
Bruno Lopes
9fb127f684 meson: Add explicit build option to build 32-bit TWAIN
It is long-time unmaintained on our repo, with no issues being fixed. Now that
32-bit binaries are not distributed, we can safely move to unmaintained section.
2026-03-17 09:56:20 -03:00
Alx Sa
60d3caa2e2 plug-ins: Copy profile with Tile plug-in
If the user chooses to make a new image when
running the Tile plug-in, the color profile is not
carried over. This can result in the tiled image
looking different. This patch adds calls to
gimp_image_get_color_profile () and
gimp_image_set_color_profile () to ensure the
profile is carried over.
2026-03-15 23:13:14 +00:00
Anders Jonsson
f33200fe8d plug-ins: show default text for licensor_phone_type2 in metadata-editor 2026-03-12 20:04:54 +01:00
Frank Teklote
4576f5a2f1 file-jpeg: fix loading of photoshop path split across multiple segments
Some JPEGs contain large Photoshop path metadata split across multiple APP13 markers. Collect all APP13 payloads and skip the repeated "Photoshop 3.0\0" identifier for subsequent segments so the metadata can be parsed as a single stream.
2026-03-12 15:08:39 +01:00
Alx Sa
f64c9c23ba plug-ins: Mitigate ZDI-CAN-28863
Resolves #15969

It is possible to set the number of color components
in the JPEG 2000 file separate from the color space,
and OpenJPEG reports that value as-is. This can result
in a buffer overflow if the num_components variable is
larger than the number of channels in the color space.

This patch adds a check to make sure num_components
is within range. If it's larger, then we clamp it to the maximum
value for that color model.
2026-03-12 13:48:45 +00:00
Frank Teklote
ee0f2ab8bf file-psd: fix 'path_flatness' being read with wrong type leading to incorrect values 2026-03-12 04:17:02 +00:00
Frank Teklote
a8d1135110 file-psd: fix integer overflow when reading path anchor points
The variable 'cntr' represents the index of all control points of a Photoshop path. It was declared too small, which caused problems with detailed path objects. 'num_rec' is of type 'gint16', but the number of control points is 'num_rec * 6', so 'cntr' must be able to cover that range
2026-03-12 03:25:24 +00:00
Alx Sa
aa8f06db95 plug-ins: Don't show TIFF Reduced Image toggle...
...when there is only one page.
The TIFF load dialog appears when either there are
multiple pages, or we need to make a decision about
how to render the alpha channel.

The "Show reduced images" was shown in both situations,
even though it is not applicable when we only have one page.
This patch modes that code inside the "if (pages->n_pages > 1)"
condition to prevent it from showing when it's not needed.
2026-03-12 03:16:22 +00:00
Frank Teklote
9be00cd3df file-psd: fix invalid layer selection caused by an uninitialized variable: 'layer_state'
Error message:
Calling error for procedure 'gimp-image-set-selected-layers':
Procedure 'gimp-image-set-selected-layers' has been called with value '<not transformable to string>' for argument 'layers' (#2, type GimpCoreObjectArray). This value is out of range.
2026-03-12 02:10:42 +00:00
Jacob Boerema
dbfc7d5b9c tests: fix typo psp has extension psp not psd 2026-03-11 09:28:39 -04:00
Jehan
a50255871c Issue #13066: Opening XPM crashes XPM plugin.
Determining whether we are on X11 or not is a runtime test, not
build-time.
2026-03-10 16:38:21 +00:00
Jacob Boerema
aabce89271 plug-ins:: fix #15960 PCX buffer overflow
A buffer overflow in the PCX reader was reported.

The +1 was added in commit da217088d0
to allow loading where the images have an off by 1 value. However,
this leaves the problem that allocated buffers may be 1 byte too small.

Because we prefer to keep loading as many images as possible, we choose
not to return an error. Instead we allocate 1 extra byte for the
line buffers.
In addition to that, we add check for valid values of bpp and error
out early when invalid.
If the bytesperline value is off by more than 1, we output a warning
message and use the manually computed value instead.

Additionally add a comment that we need to fix a British English
word in a string after string freeze.
2026-03-08 15:18:44 -04:00
Alx Sa
36f594f396 plug-ins: Free temp images in file-dcx-load
Per Jacob Boerema, the DCX loading plug-in left
behind stray images. This is because we load each
PCX image inside the DCX as a separate image and then
copy it as a layer into the first one. However, we were
not deleting the temporary image afterwards.
This patch adds a call to gimp_image_delete () to do
the clean-up work after copying the layer from the
temporary image.
2026-03-08 18:06:38 +00:00
Alx Sa
b4d41182dd plug-ins: Fix ZDI-CAN-28405 for IFF plug-in
Resolves #15289
This patch replaces the initial allocation of pixel_row
with a per-format allocation. This should resolve issues
where the allocation was too small for certain formats,
without requiring a large allocation for all formats regardless
of need.
2026-03-08 14:16:44 +00:00
Alx Sa
edc2b1736b plug-ins: Correct GUI and CMYK logic for JPEG export
Resolves #9545
When exporting a JPEG as CMYK, it is possible for the
"Save Profile" metadata option to be unchecked. This causes
the image to be saved without its CMYK profile, resulting in an
incorrect image rendering.

As this is almost never the desired case, this patch changes the
export logic to always save the profile IF the user has requested
CMYK export and a CMYK profile is attached.

Additionally, this patch fixes an issue in the export dialog where
the DCT options are shown as a radio frame instead of a combobox
as in GIMP 2.10.
2026-03-08 03:45:33 +00:00
Ondřej Míchal
cacccbaf05 plug-ins/gfig: Fix value updates after port from GimpScaleEntry to GimpSpinScale
The new widget is not a subclass of GimpLabelSpin.

Fallout from c3fcbd0019.

Helps with https://gitlab.gnome.org/Teams/GIMP/Design/gimp-ux/-/issues/503.
2026-03-08 03:15:31 +02:00
Jacob Boerema
98cb1371fd plug-ins: fix #15970 buffer overflow in file-psp
Reported as ZDI-CAN-28874.

For psp images with bit depth 1 or 4 bits and small widths, it was
possible to overflow the buffer because these bit depths are stored
in multiples of 4 bytes per line.
Because these formats are converted to regular RGB, this means that for
small widths, more bytes are needed than expected when we are upscaling
to 8-bit.

To fix this, we compute the line size when depth < 8, and adjust
line width if that value is larger.
2026-03-07 15:55:40 -05:00
Jehan
635da347cd plug-ins: improve describing enum and choice arguments.
* Also print the default value for both types of args.
* Display choice values with quotes since they are technically strings.
2026-03-06 22:49:14 +01:00
Jacob Boerema
7e1241f751 plug-ins: fix #15967 integer overflow in psd-load
Reported as ZDI-CAN-28807
With large row and column sizes 32-bit int values are not large
enough to hold the product and thus can cause overflow.

While we are at it, we not only fix the location from the report, but
also other occurrences that could overflow.
- We change certain variables to gsize to make sure they can hold a
64-bit value.
- Other intermediate results are promoted to (gsize) to make sure that
the product is computed as gsize.
- Move some i,j variables to the loops where they are used.
2026-03-06 10:01:09 -05:00
Alx Sa
2e7ed91793 plug-in: Resolve ZDI-CAN-28901 for file-xpm
Resolves #15971
It was possible to set a XPM image to have a width and/or height
that is larger than what GIMP can create an image for. In addition to
causing gimp_image_new () to fail, it can also lead to buffer overflow
when allocating space to read in the image.

This patch adds a GError parameter to parse_image (), then uses it to
pass up an error for either oversized images or buffer overflows.
2026-03-06 13:54:44 +00:00
Alx Sa
09e5459de9 plug-ins: Resolve ZDI-CAN-28813 in ANI loading
Resolves #15968
It is possible to cause a buffer overflow in our ANI
loading code by setting the Name or Artist metadata
files to 0xFFFFFFFF. This patch changes our allocation
code to use g_try_new0 () instead of g_new0 (), and
verifies if it is NULL before trying to read data into it.
2026-03-05 23:58:45 +00:00
Alx Sa
7e63e661f0 plug-ins: Show correct cursor in Windows Screenshot
Resolves #14966
When "Include mouse pointer" is checked in the Windows
version of the Create Screenshot plug-in, we used the
GetCursor () Win32 API to get the cursor icon. However,
this just returns a generic cursor rather than the current one
used.
This patch changes the code to use the hCursor property of
the CursorInfo struct that was already retrieved, which contains
the current cursor's icon instead of the generic one.
2026-03-05 15:54:34 +00:00
Jehan
8407793320 plug-ins: fix newline format with dos2unix. 2026-03-03 10:57:05 +01:00
Jehan
9ae9976732 plug-ins: let's have the same label for import and export.
While listing the file formats, I could not find the format, because it
was labelled differently.
This doesn't break the strings since the longer string already existed.
2026-03-03 10:51:20 +01:00
Waris
ed72b7d5df plug-ins: Import YUV OpenEXR chroma channels as RGB 2026-02-28 14:19:27 +00:00
Bruno Lopes
b7d89728c4 app, libgimpthumb, plug-ins, tools: Fix POSIX namespace warnings on MSVC 2026-02-28 10:06:46 -03:00
Jehan
b602a63778 plug-ins: also introspect libgimpui enum values into Script-Fu.
Since libgimpui also use GIMP_ as prefix in C, we won't ever have name
clashing with libgimp, so I also remove this prefix in Script-Fu.

E.g. GIMP_ASPECT_SQUARE is ASPECT-SQUARE in Script-Fu.
2026-02-25 14:49:23 +01:00
Alx Sa
6755fa8b8d plug-ins: Fix warning in Qbist dialog_save ()
It is possible for qbist_info.path to be NULL, which
makes gtk_file_chooser_set_filename () throw a warning
about a NULL filename in save_dialog ().
This patch adds the same guard to that call as QBist
already has in load_dialog (), to make sure we have
an existing file name before trying to set it.
2026-02-23 15:40:12 +00:00
Jehan
06fafe6f71 plug-ins: change to Unix newlines with dos2unix. 2026-02-21 12:22:56 +01:00
Jehan
3b9b300252 plug-ins: make GimpUi global when imported from a local scope.
This fixes Spyro Plus not running interactively after commit a7f02d4ee1.
Note that this seems to be the only plug-in which got broken by this
commit AFAICS.
2026-02-21 12:21:32 +01:00
Jacob Boerema
04f3030371 plug-ins: fix #15274 Imagemap create guides dialog is too wide
The create guides dialog of the imagemap plug-in shows up very wide
due to the hint text not being wrapped.

To fix this we enclose the hint box inside a scrolled window and set
horizontal policy to GTK_POLICY_EXTERNAL and a minimum vertical size
of 100, based on how we do this in the export procedure dialog for
the comment field.
2026-02-18 11:23:56 -05:00
Bruno Lopes
a7f02d4ee1 plug-ins: Fix some Python plug-ins query in headless environments
This fixes this unharmful message we were getting on macOS CI:

Gdk-WARNING **: 18:06:23.048: Failed to initialize CVDisplayLink!

The hard ones (spyro-plus.py, histogram-export.py and python-console.py)
were not touched for now, just the ProcedureDialog plugins were fixed.
2026-02-16 13:13:23 -03:00