Commit fdbe649c3 for imagemagick.org
commit fdbe649c3d305d266ebe3935ba8e0416cce0c9af
Author: Cristy <urban-warrior@imagemagick.org>
Date: Sat Jun 27 11:59:34 2026 -0400
https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-cvxf-g9w2-7mcx
diff --git a/coders/cals.c b/coders/cals.c
index d99559c0e..544d1a195 100644
--- a/coders/cals.c
+++ b/coders/cals.c
@@ -261,8 +261,6 @@ static Image *ReadCALSImage(const ImageInfo *image_info,
while ((c=ReadBlobByte(image)) != EOF)
if (fputc(c,file) != c)
break;
- if (fflush(file) != 0)
- ThrowImageException(FileOpenError,"UnableToCreateTemporaryFile");
if (fseek(file,0,SEEK_SET) != 0)
ThrowImageException(FileOpenError,"UnableToCreateTemporaryFile");
(void) CloseBlob(image);
diff --git a/coders/dcm.c b/coders/dcm.c
index ec6855795..8f68f7e97 100644
--- a/coders/dcm.c
+++ b/coders/dcm.c
@@ -3989,7 +3989,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
file=(FILE *) NULL;
unique_file=AcquireUniqueFileResource(filename);
if (unique_file != -1)
- file=fdopen(unique_file,"wb");
+ file=fdopen(unique_file,"rb+");
if (file == (FILE *) NULL)
{
(void) RelinquishUniqueFileResource(filename);
@@ -4009,15 +4009,18 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (fputc(c,file) != c)
break;
}
- (void) fclose(file);
if (c == EOF)
break;
+ if (fseek(file,0,SEEK_SET) != 0)
+ ThrowDCMException(FileOpenError,"UnableToCreateTemporaryFile");
(void) FormatLocaleString(read_info->filename,MagickPathExtent,
"jpeg:%s",filename);
if (image->compression == JPEG2000Compression)
(void) FormatLocaleString(read_info->filename,MagickPathExtent,
"j2k:%s",filename);
+ read_info->file=file;
jpeg_image=ReadImage(read_info,exception);
+ read_info->file=(FILE *) NULL;
if (jpeg_image != (Image *) NULL)
{
ResetImagePropertyIterator(image);