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
This commit is contained in:
John Cupitt 2021-05-05 17:29:50 +01:00
parent a560d7df50
commit e19acd5148
2 changed files with 4 additions and 3 deletions

View File

@ -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]

View File

@ -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;
}
}