From 16bf20fad4faa9182d633d1833756c38c72e6ff4 Mon Sep 17 00:00:00 2001 From: Cristy Date: Wed, 31 Jul 2024 09:32:35 -0400 Subject: [PATCH] read/write in chunks --- magick/blob.c | 4 ++-- magick/blob.h | 2 +- magick/cache.c | 8 ++++---- magick/distribute-cache.c | 4 ++-- magick/matrix.c | 8 ++++---- magick/string.c | 2 +- magick/xml-tree.c | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/magick/blob.c b/magick/blob.c index b961945ce..f1d149c7c 100644 --- a/magick/blob.c +++ b/magick/blob.c @@ -279,7 +279,7 @@ MagickExport MagickBooleanType BlobToFile(char *filename,const void *blob, for (i=0; i < length; i+=(size_t) count) { count=write(file,(const char *) blob+i,MagickMin(length-i,(size_t) - MAGICK_SSIZE_MAX)); + MagickMaxBufferExtent)); if (count <= 0) { count=0; @@ -1235,7 +1235,7 @@ MagickExport unsigned char *FileToBlob(const char *filename,const size_t extent, for (i=0; i < *length; i+=count) { count=read(file,blob+i,(size_t) MagickMin(*length-i,(size_t) - MAGICK_SSIZE_MAX)); + MagickMaxBufferExtent)); if (count <= 0) { count=0; diff --git a/magick/blob.h b/magick/blob.h index fc8154a27..5b845d6bd 100644 --- a/magick/blob.h +++ b/magick/blob.h @@ -25,7 +25,7 @@ extern "C" { #endif -#define MagickMaxBufferExtent 81920 +#define MagickMaxBufferExtent 524288 #define MagickMinBufferExtent 16384 typedef enum diff --git a/magick/cache.c b/magick/cache.c index afd21363d..6a0b70de4 100644 --- a/magick/cache.c +++ b/magick/cache.c @@ -3800,10 +3800,10 @@ static inline MagickOffsetType WritePixelCacheRegion( { #if !defined(MAGICKCORE_HAVE_PWRITE) count=write(cache_info->file,buffer+i,(size_t) MagickMin(length- - (MagickSizeType) i,MAGICK_SSIZE_MAX)); + (MagickSizeType) i,MagickMaxBufferExtent)); #else count=pwrite(cache_info->file,buffer+i,(size_t) MagickMin(length- - (MagickSizeType) i,MAGICK_SSIZE_MAX),offset+i); + (MagickSizeType) i,MagickMaxBufferExtent),offset+i); #endif if (count <= 0) { @@ -4629,10 +4629,10 @@ static inline MagickOffsetType ReadPixelCacheRegion( { #if !defined(MAGICKCORE_HAVE_PREAD) count=read(cache_info->file,buffer+i,(size_t) MagickMin(length- - (MagickSizeType) i,(size_t) MAGICK_SSIZE_MAX)); + (MagickSizeType) i,(size_t) MagickMaxBufferExtent)); #else count=pread(cache_info->file,buffer+i,(size_t) MagickMin(length- - (MagickSizeType) i,(size_t) MAGICK_SSIZE_MAX),offset+i); + (MagickSizeType) i,(size_t) MagickMaxBufferExtent),offset+i); #endif if (count <= 0) { diff --git a/magick/distribute-cache.c b/magick/distribute-cache.c index beda933d6..b70f16d1b 100755 --- a/magick/distribute-cache.c +++ b/magick/distribute-cache.c @@ -159,7 +159,7 @@ static inline MagickOffsetType dpc_read(int file,const MagickSizeType length, for (i=0; i < (MagickOffsetType) length; i+=count) { count=recv(file,(char *) message+i,(LENGTH_TYPE) MagickMin(length-i, - (MagickSizeType) MAGICK_SSIZE_MAX),0); + (MagickSizeType) MagickMaxBufferExtent),0); if (count <= 0) { count=0; @@ -455,7 +455,7 @@ static inline MagickOffsetType dpc_send(int file,const MagickSizeType length, for (i=0; i < (MagickOffsetType) length; i+=count) { count=(MagickOffsetType) send(file,(char *) message+i,(LENGTH_TYPE) - MagickMin(length-i,(MagickSizeType) MAGICK_SSIZE_MAX),MSG_NOSIGNAL); + MagickMin(length-i,(MagickSizeType) MagickMaxBufferExtent),MSG_NOSIGNAL); if (count <= 0) { count=0; diff --git a/magick/matrix.c b/magick/matrix.c index 7d525620d..e851284d2 100644 --- a/magick/matrix.c +++ b/magick/matrix.c @@ -150,10 +150,10 @@ static inline MagickOffsetType WriteMatrixElements( { #if !defined(MAGICKCORE_HAVE_PWRITE) count=write(matrix_info->file,buffer+i,(size_t) MagickMin(length-i, - (MagickSizeType) MAGICK_SSIZE_MAX)); + (MagickSizeType) MagickMaxBufferExtent)); #else count=pwrite(matrix_info->file,buffer+i,(size_t) MagickMin(length-i, - (MagickSizeType) MAGICK_SSIZE_MAX),(off_t) (offset+i)); + (MagickSizeType) MagickMaxBufferExtent),(off_t) (offset+i)); #endif if (count <= 0) { @@ -683,10 +683,10 @@ static inline MagickOffsetType ReadMatrixElements( { #if !defined(MAGICKCORE_HAVE_PREAD) count=read(matrix_info->file,buffer+i,(size_t) MagickMin(length-i, - (MagickSizeType) MAGICK_SSIZE_MAX)); + (MagickSizeType) MagickMaxBufferExtent)); #else count=pread(matrix_info->file,buffer+i,(size_t) MagickMin(length-i, - (MagickSizeType) MAGICK_SSIZE_MAX),(off_t) (offset+i)); + (MagickSizeType) MagickMaxBufferExtent),(off_t) (offset+i)); #endif if (count <= 0) { diff --git a/magick/string.c b/magick/string.c index ca07db4c6..6107d15fe 100644 --- a/magick/string.c +++ b/magick/string.c @@ -659,7 +659,7 @@ MagickExport StringInfo *ConfigureFileToStringInfo(const char *filename) for (i=0; i < length; i+=count) { count=read(file,string+i,(size_t) MagickMin(length-i,(size_t) - MAGICK_SSIZE_MAX)); + MagickMaxBufferExtent)); if (count <= 0) { count=0; diff --git a/magick/xml-tree.c b/magick/xml-tree.c index 75fd2db15..68eea8fff 100644 --- a/magick/xml-tree.c +++ b/magick/xml-tree.c @@ -688,7 +688,7 @@ MagickPrivate char *FileToXML(const char *filename,const size_t extent) (void) lseek(file,0,SEEK_SET); for (i=0; i < length; i+=count) { - count=read(file,xml+i,(size_t) MagickMin(length-i,(size_t) MAGICK_SSIZE_MAX)); + count=read(file,xml+i,(size_t) MagickMin(length-i,(size_t) MagickMaxBufferExtent)); if (count <= 0) { count=0;