diff options
| author | Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in> | 2025-12-12 20:29:43 +0530 |
|---|---|---|
| committer | Gyorgy Sarvari <skandigraun@gmail.com> | 2025-12-12 22:06:52 +0100 |
| commit | f978eae8fcef63c5c25b9f37ac34080948fac42e (patch) | |
| tree | 10f4dc1e2f0964b8581fddc1112f56dcb131f380 | |
| parent | 222e1b635ec3c906523c18889f84023fcaae3347 (diff) | |
| download | meta-openembedded-f978eae8fcef63c5c25b9f37ac34080948fac42e.tar.gz | |
ImageMagick: Fix CVE-2025-57803
Backport the fix for CVE-2025-57803
Upstream-Status: Backport [https://github.com/ImageMagick/ImageMagick/commit/61f444e5457e4e506c73f18460133c80c235ebb6]
Add below patch to fix
0007-ImageMagick-Fix-CVE-2025-57803.patch
Add below support patch to fix
0007-ImageMagick-Add-support-patch-to-fix-CVE-2025-57803.patch
Signed-off-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
3 files changed, 125 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/imagemagick/files/0007-ImageMagick-Add-support-patch-to-fix-CVE-2025-57803.patch b/meta-oe/recipes-support/imagemagick/files/0007-ImageMagick-Add-support-patch-to-fix-CVE-2025-57803.patch new file mode 100644 index 0000000000..ef570a496a --- /dev/null +++ b/meta-oe/recipes-support/imagemagick/files/0007-ImageMagick-Add-support-patch-to-fix-CVE-2025-57803.patch | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | From 558a3a71c2b107483d8e88cd2d20242358b6633d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in> | ||
| 3 | Date: Fri, 5 Dec 2025 13:43:17 +0530 | ||
| 4 | Subject: [PATCH 1/1] ImageMagick: Add support patch to fix CVE-2025-57803 | ||
| 5 | |||
| 6 | Upstream-Status: Backport [https://github.com/ImageMagick/ImageMagick/commit/61f444e5457e4e506c73f18460133c80c235ebb6] | ||
| 7 | |||
| 8 | Comment: Refreshed hunk to match latest kirkstone | ||
| 9 | |||
| 10 | Signed-off-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in> | ||
| 11 | --- | ||
| 12 | coders/bmp.c | 17 ++++++----------- | ||
| 13 | 1 file changed, 6 insertions(+), 11 deletions(-) | ||
| 14 | |||
| 15 | diff --git a/coders/bmp.c b/coders/bmp.c | ||
| 16 | index a46448a95..703ad0483 100644 | ||
| 17 | --- a/coders/bmp.c | ||
| 18 | +++ b/coders/bmp.c | ||
| 19 | @@ -968,18 +968,18 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception) | ||
| 20 | ThrowReaderException(CorruptImageError,"ImproperImageHeader"); | ||
| 21 | if (bmp_info.compression == BI_RLE4) | ||
| 22 | bmp_info.bits_per_pixel<<=1; | ||
| 23 | - bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32); | ||
| 24 | + bytes_per_line=image->columns*(4*(bmp_info.bits_per_pixel+31)/32); | ||
| 25 | length=(size_t) bytes_per_line*image->rows; | ||
| 26 | if ((MagickSizeType) (length/256) > blob_size) | ||
| 27 | ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); | ||
| 28 | + pixel_info=AcquireVirtualMemory(image->rows, | ||
| 29 | + MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels)); | ||
| 30 | + if (pixel_info == (MemoryInfo *) NULL) | ||
| 31 | + ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); | ||
| 32 | + pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info); | ||
| 33 | if ((bmp_info.compression == BI_RGB) || | ||
| 34 | (bmp_info.compression == BI_BITFIELDS)) | ||
| 35 | { | ||
| 36 | - pixel_info=AcquireVirtualMemory(image->rows, | ||
| 37 | - MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels)); | ||
| 38 | - if (pixel_info == (MemoryInfo *) NULL) | ||
| 39 | - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); | ||
| 40 | - pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info); | ||
| 41 | if (image->debug != MagickFalse) | ||
| 42 | (void) LogMagickEvent(CoderEvent,GetMagickModule(), | ||
| 43 | " Reading pixels (%.20g bytes)",(double) length); | ||
| 44 | @@ -996,11 +996,6 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception) | ||
| 45 | /* | ||
| 46 | Convert run-length encoded raster pixels. | ||
| 47 | */ | ||
| 48 | - pixel_info=AcquireVirtualMemory(image->rows, | ||
| 49 | - MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels)); | ||
| 50 | - if (pixel_info == (MemoryInfo *) NULL) | ||
| 51 | - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); | ||
| 52 | - pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info); | ||
| 53 | status=DecodeImage(image,bmp_info.compression,pixels, | ||
| 54 | image->columns*image->rows); | ||
| 55 | if (status == MagickFalse) | ||
| 56 | -- | ||
| 57 | 2.34.1 | ||
| 58 | |||
diff --git a/meta-oe/recipes-support/imagemagick/files/0007-ImageMagick-Fix-CVE-2025-57803.patch b/meta-oe/recipes-support/imagemagick/files/0007-ImageMagick-Fix-CVE-2025-57803.patch new file mode 100644 index 0000000000..9a26aa6892 --- /dev/null +++ b/meta-oe/recipes-support/imagemagick/files/0007-ImageMagick-Fix-CVE-2025-57803.patch | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | From 9624a36f5c77d81cfdce20d0978850fa0db1543c Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in> | ||
| 3 | Date: Thu, 23 Oct 2025 23:41:32 +0530 | ||
| 4 | Subject: [PATCH 07/18] ImageMagick: Fix CVE-2025-57803 | ||
| 5 | |||
| 6 | CVE: CVE-2025-57803 | ||
| 7 | |||
| 8 | Upstream-Status: Backport [https://github.com/ImageMagick/ImageMagick/commit/2c55221f4d38193adcb51056c14cf238fbcc35d7.patch] | ||
| 9 | |||
| 10 | Comment: Refreshed hunk to match latest kirkstone | ||
| 11 | |||
| 12 | Signed-off-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in> | ||
| 13 | --- | ||
| 14 | coders/bmp.c | 31 +++++++++++++++++++------------ | ||
| 15 | 1 file changed, 19 insertions(+), 12 deletions(-) | ||
| 16 | |||
| 17 | diff --git a/coders/bmp.c b/coders/bmp.c | ||
| 18 | index a46448a95..beff10bb5 100644 | ||
| 19 | --- a/coders/bmp.c | ||
| 20 | +++ b/coders/bmp.c | ||
| 21 | @@ -506,6 +506,10 @@ static MagickBooleanType IsBMP(const unsigned char *magick,const size_t length) | ||
| 22 | % o exception: return any errors or warnings in this structure. | ||
| 23 | % | ||
| 24 | */ | ||
| 25 | +static inline MagickBooleanType BMPOverflowCheck(size_t x,size_t y) | ||
| 26 | +{ | ||
| 27 | + return((y != 0) && (x > 4294967295UL/y) ? MagickTrue : MagickFalse); | ||
| 28 | +} | ||
| 29 | |||
| 30 | static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception) | ||
| 31 | { | ||
| 32 | @@ -546,6 +550,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception) | ||
| 33 | size_t | ||
| 34 | bit, | ||
| 35 | bytes_per_line, | ||
| 36 | + extent, | ||
| 37 | length; | ||
| 38 | |||
| 39 | ssize_t | ||
| 40 | @@ -968,12 +973,18 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception) | ||
| 41 | ThrowReaderException(CorruptImageError,"ImproperImageHeader"); | ||
| 42 | if (bmp_info.compression == BI_RLE4) | ||
| 43 | bmp_info.bits_per_pixel<<=1; | ||
| 44 | - bytes_per_line=image->columns*(4*(bmp_info.bits_per_pixel+31)/32); | ||
| 45 | - length=(size_t) bytes_per_line*image->rows; | ||
| 46 | + extent=image->columns*bmp_info.bits_per_pixel; | ||
| 47 | + bytes_per_line=4*((extent+31)/32); | ||
| 48 | + if (BMPOverflowCheck(bytes_per_line,image->rows) != MagickFalse) | ||
| 49 | + ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); | ||
| 50 | + length=bytes_per_line*image->rows; | ||
| 51 | if ((MagickSizeType) (length/256) > blob_size) | ||
| 52 | ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); | ||
| 53 | - pixel_info=AcquireVirtualMemory(image->rows, | ||
| 54 | - MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels)); | ||
| 55 | + extent=MagickMax(bytes_per_line,image->columns+1UL); | ||
| 56 | + if ((BMPOverflowCheck(image->rows,extent) != MagickFalse) || | ||
| 57 | + (BMPOverflowCheck(extent,sizeof(*pixels)) != MagickFalse)) | ||
| 58 | + ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); | ||
| 59 | + pixel_info=AcquireVirtualMemory(image->rows,extent*sizeof(*pixels)); | ||
| 60 | if (pixel_info == (MemoryInfo *) NULL) | ||
| 61 | ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); | ||
| 62 | pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info); | ||
| 63 | -- | ||
| 64 | 2.34.1 | ||
| 65 | |||
diff --git a/meta-oe/recipes-support/imagemagick/imagemagick_7.0.10.bb b/meta-oe/recipes-support/imagemagick/imagemagick_7.0.10.bb index 3185df9adc..7b06272e2a 100644 --- a/meta-oe/recipes-support/imagemagick/imagemagick_7.0.10.bb +++ b/meta-oe/recipes-support/imagemagick/imagemagick_7.0.10.bb | |||
| @@ -32,6 +32,8 @@ SRC_URI = "git://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=htt | |||
| 32 | file://0004-ImageMagick-Fix-CVE-2025-55005.patch \ | 32 | file://0004-ImageMagick-Fix-CVE-2025-55005.patch \ |
| 33 | file://0005-ImageMagick-Fix-CVE-2025-53019.patch \ | 33 | file://0005-ImageMagick-Fix-CVE-2025-53019.patch \ |
| 34 | file://0006-ImageMagick-Fix-CVE-2025-55004.patch \ | 34 | file://0006-ImageMagick-Fix-CVE-2025-55004.patch \ |
| 35 | file://0007-ImageMagick-Add-support-patch-to-fix-CVE-2025-57803.patch \ | ||
| 36 | file://0007-ImageMagick-Fix-CVE-2025-57803.patch \ | ||
| 35 | " | 37 | " |
| 36 | 38 | ||
| 37 | SRCREV = "35b4991eb0939a327f3489988c366e21068b0178" | 39 | SRCREV = "35b4991eb0939a327f3489988c366e21068b0178" |
