Security Advisories (3)
CVE-2026-8669 (2026-05-15)

Imager versions through 1.030 for Perl allow a heap out of bounds (OOB) write on crafted multi-frame GIF files. Imager::File::GIF's i_readgif_multi_low allocates a single per-row buffer GifRow sized for the GIF's global screen width 'SWidth' and reuses it across every image in the file. The page-match branch validates Image.Width + Image.Left > SWidth before each DGifGetLine write, but the parallel skip-image branch at imgif.c:790-805 calls DGifGetLine(GifFile, GifRow, Width) with no such check.

CVE-2026-13705 (2026-07-06)

Imager versions before 1.032 for Perl have a heap out-of-bounds read in the bundled Imager::File::SGI reader via a 16-bit RLE literal run in read_rgb_16_rle. read_rgb_16_rle guards each literal run with if (count > data_left), but count is a pixel count while every 16-bit sample consumes two bytes. The copy loop reads inp[0] * 256 + inp[1] and advances two bytes per pixel, so a run with data_left / 2 < count <= data_left passes the guard yet consumes 2 * count bytes and reads past the end of the buffer. The 8-bit path is unaffected because there one pixel is one byte. Reading a crafted SGI image through Imager->read triggers the over-read before the parser rejects the malformed image, which can crash the process.

CVE-2026-14454 (2026-07-08)

Imager versions before 1.033 for Perl treat unsigned EXIF IFD entry counts as signed. Imager mishandled large EXIF IFD entry count values, treating them as negative numbers. This could lead to an attempt to allocate a block nearly the size of the address space, which fails and kills the process. An attacker could craft an image with EXIF data that terminates a worker process.

NAME

Imager::Preprocess - simple preprocessor for handling multiple sample sizes

SYNOPSIS

/* in the source: */
#code condition true to work with 8-bit samples
... code using preprocessor types/values ...
#/code

# process and make #line directives
perl -MImager::Preprocess -epreprocess foo.im foo.c

# process and no #line directives
perl -MImager::Preprocess -epreprocess -l foo.im foo.c

DESCRIPTION

This is a simple preprocessor that aims to reduce duplication of source code when implementing an algorithm both for 8-bit samples and double samples in Imager.

Imager's Makefile.PL currently scans the MANIFEST for .im files and adds Makefile files to convert these to .c files.

The beginning of a sample-independent section of code is preceded by:

#code expression

where expression should return true if processing should be done at 8-bits/sample.

You can also use a #code block around a function definition to produce 8-bit and double sample versions of a function. In this case #code has no expression and you will need to use IM_SUFFIX() to produce different function names.

The end of a sample-independent section of code is terminated by:

#/code

#code sections cannot be nested.

#/code without a starting #code is an error.

You can also define extra sample-size dependent macros with #!define:

#define common-name eight-bit-name floating-point-name

The following types and values are defined in a #code section:

  • IM_GPIX(im, x, y, &col)

  • IM_GLIN(im, l, r, y, colors)

  • IM_PPIX(im, x, y, &col)

  • IM_PLIN(im, x, y, colors)

  • IM_GSAMP(im, l, r, y, samples, chans, chan_count)

    These correspond to the appropriate image function, eg. IM_GPIX() becomes i_gpix() or i_gpixf() as appropriate.

  • IM_ADAPT_COLORS(dest_channels, src_channels, colors, count)

    Call i_adapt_colors() or i_adapt_fcolors().

  • IM_FILL_COMBINE(fill) - retrieve the combine function from a fill object.

  • IM_FILL_FILLER(fill) - retrieve the fill_with_* function from a fill object.

  • IM_ABS(sample) - calculate the absolute value of an IM_WORK_T value.

  • IM_SAMPLE_MAX - maximum value for a sample

  • IM_SAMPLE_MAX2 - maximum value for a sample, squared

  • IM_SAMPLE_T - type of a sample (i_sample_t or i_fsample_t)

  • IM_COLOR - color type, either i_color or i_fcolor.

  • IM_WORK_T - working sample type, either int or double.

  • IM_Sf - format string for the sample type, "%d" or "%f".

  • IM_Wf - format string for the work type, "%d" or "%f".

  • IM_SUFFIX(identifier) - adds _8 or _double onto the end of identifier.

  • IM_EIGHT_BIT - this is a macro defined only in 8-bit/sample code.

Other types, functions and values may be added in the future.

AUTHOR

Tony Cook <tonyc@cpan.org>