From 256c87d986a63ef81c0a0039cb1245266459ba77 Mon Sep 17 00:00:00 2001 From: Rebecca Dengate Date: Tue, 29 Aug 2023 13:34:39 +1000 Subject: [PATCH 1/2] Fixes overflow when reading in large images, see issue #7664 --- CGAL_ImageIO/include/CGAL/ImageIO_impl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CGAL_ImageIO/include/CGAL/ImageIO_impl.h b/CGAL_ImageIO/include/CGAL/ImageIO_impl.h index 8dbef016b1c5..c66ae80d75e7 100644 --- a/CGAL_ImageIO/include/CGAL/ImageIO_impl.h +++ b/CGAL_ImageIO/include/CGAL/ImageIO_impl.h @@ -1242,7 +1242,7 @@ static void _swapImageData( _image *im ) Swap bytes depending on the endianness and the current architecture */ CGAL_INLINE_FUNCTION int _readImageData(_image *im) { - unsigned long size, nread; + size_t size, nread; if(im->openMode != OM_CLOSE) { size = im->xdim * im->ydim * im->zdim * im->vdim * im->wdim; @@ -1279,7 +1279,7 @@ int _readImageData(_image *im) { Swap bytes depending on the endianness and the current architecture. */ CGAL_INLINE_FUNCTION int _readNonInterlacedImageData(_image *im) { - unsigned long size, nread; + size_t size, nread; unsigned char **vp, *buf; unsigned int i, j, k, v, w; @@ -1356,7 +1356,7 @@ int _readNonInterlacedImageData(_image *im) { been read by _readImageHeader. The image buffer is interlaced. */ CGAL_INLINE_FUNCTION int _readNonInterlacedFileData(_image *im) { - unsigned long size, nread; + size_t size, nread; unsigned char *ptr1, *vp, *buf; unsigned int i, j, k, v, w; From 3527e8e8d065fcffa8140e865d4099cce2a3f14c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 29 Aug 2023 09:37:51 +0200 Subject: [PATCH 2/2] prefer std::size_t --- CGAL_ImageIO/include/CGAL/ImageIO_impl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CGAL_ImageIO/include/CGAL/ImageIO_impl.h b/CGAL_ImageIO/include/CGAL/ImageIO_impl.h index c66ae80d75e7..fefbd0d4cc8d 100644 --- a/CGAL_ImageIO/include/CGAL/ImageIO_impl.h +++ b/CGAL_ImageIO/include/CGAL/ImageIO_impl.h @@ -1242,7 +1242,7 @@ static void _swapImageData( _image *im ) Swap bytes depending on the endianness and the current architecture */ CGAL_INLINE_FUNCTION int _readImageData(_image *im) { - size_t size, nread; + std::size_t size, nread; if(im->openMode != OM_CLOSE) { size = im->xdim * im->ydim * im->zdim * im->vdim * im->wdim; @@ -1279,7 +1279,7 @@ int _readImageData(_image *im) { Swap bytes depending on the endianness and the current architecture. */ CGAL_INLINE_FUNCTION int _readNonInterlacedImageData(_image *im) { - size_t size, nread; + std::size_t size, nread; unsigned char **vp, *buf; unsigned int i, j, k, v, w; @@ -1356,7 +1356,7 @@ int _readNonInterlacedImageData(_image *im) { been read by _readImageHeader. The image buffer is interlaced. */ CGAL_INLINE_FUNCTION int _readNonInterlacedFileData(_image *im) { - size_t size, nread; + std::size_t size, nread; unsigned char *ptr1, *vp, *buf; unsigned int i, j, k, v, w;