From e19acd514853b81f5a515b2abcd74c59034647e0 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 5 May 2021 17:29:50 +0100 Subject: [PATCH] fix load of large PPM images from a pipe large PPM images loaded over pipes could cause a crash, thanks ewelot see https://github.com/libvips/libvips/issues/2240 --- ChangeLog | 1 + libvips/foreign/ppmload.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3cd3234b..7ac84db3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 30/4/21 start 8.10.7 - better vips7 PNG load compatibility [SkyDiverCool] +- fix load of large PPM images from a pipe [ewelot] 22/12/20 start 8.10.6 - don't seek on bad file descriptors [kleisauke] diff --git a/libvips/foreign/ppmload.c b/libvips/foreign/ppmload.c index 7f16cb65..083b2a56 100644 --- a/libvips/foreign/ppmload.c +++ b/libvips/foreign/ppmload.c @@ -506,8 +506,8 @@ vips_foreign_load_ppm_generate_binary( VipsRegion *or, while( n_bytes > 0 ) { gint64 bytes_read; - bytes_read = vips_source_read( ppm->source, - q, sizeof_line ); + bytes_read = + vips_source_read( ppm->source, q, n_bytes ); if( bytes_read < 0 ) return( -1 ); if( bytes_read == 0 ) { @@ -516,8 +516,8 @@ vips_foreign_load_ppm_generate_binary( VipsRegion *or, return( -1 ); } - n_bytes -= bytes_read; q += bytes_read; + n_bytes -= bytes_read; } }