Skip to content

Commit e19acd5

Browse files
committed
fix load of large PPM images from a pipe
large PPM images loaded over pipes could cause a crash, thanks ewelot see #2240
1 parent a560d7d commit e19acd5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
30/4/21 start 8.10.7
22
- better vips7 PNG load compatibility [SkyDiverCool]
3+
- fix load of large PPM images from a pipe [ewelot]
34

45
22/12/20 start 8.10.6
56
- don't seek on bad file descriptors [kleisauke]

libvips/foreign/ppmload.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ vips_foreign_load_ppm_generate_binary( VipsRegion *or,
506506
while( n_bytes > 0 ) {
507507
gint64 bytes_read;
508508

509-
bytes_read = vips_source_read( ppm->source,
510-
q, sizeof_line );
509+
bytes_read =
510+
vips_source_read( ppm->source, q, n_bytes );
511511
if( bytes_read < 0 )
512512
return( -1 );
513513
if( bytes_read == 0 ) {
@@ -516,8 +516,8 @@ vips_foreign_load_ppm_generate_binary( VipsRegion *or,
516516
return( -1 );
517517
}
518518

519-
n_bytes -= bytes_read;
520519
q += bytes_read;
520+
n_bytes -= bytes_read;
521521
}
522522
}
523523

0 commit comments

Comments
 (0)