Skip to content

Commit a43e9d3

Browse files
committed
Merge branch '8.10'
2 parents 64e384d + 98641ba commit a43e9d3

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- hide info messages you could get with some older glibs [kleisauke]
2020
- fix --no-strip on dzsave with icc-profiles [altert]
2121
- better GraphicsMagick image write [bfriesen]
22-
- Add missing read loops to spng, heif and ppm load [kleisauke]
22+
- Add missing read loops to spng, heif, giflib and ppm load [kleisauke]
2323

2424
6/9/20 started 8.10.2
2525
- update magicksave/load profile handling [kelilevi]

libvips/foreign/gifload.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,20 +351,34 @@ vips_foreign_load_gif_close_giflib( VipsForeignLoadGif *gif )
351351

352352
/* Callback from the gif loader.
353353
*
354-
* Read up to len bytes into buffer, return number of bytes read, 0 for EOF.
354+
* Read up to len bytes into buffer, return number of bytes read. This is
355+
* called by giflib exactly as fread, so it does not distinguish between EOF
356+
* and read error.
355357
*/
356358
static int
357359
vips_giflib_read( GifFileType *file, GifByteType *buf, int n )
358360
{
359361
VipsForeignLoadGif *gif = (VipsForeignLoadGif *) file->UserData;
360362

361-
gint64 read;
363+
int to_read;
362364

363-
read = vips_source_read( gif->source, buf, n );
364-
if( read == 0 )
365-
gif->eof = TRUE;
365+
to_read = n;
366+
while( to_read > 0 ) {
367+
gint64 bytes_read;
366368

367-
return( (int) read );
369+
bytes_read = vips_source_read( gif->source, buf, n );
370+
if( bytes_read == 0 )
371+
gif->eof = TRUE;
372+
if( bytes_read <= 0 )
373+
return( -1 );
374+
if( bytes_read > INT_MAX )
375+
return( -1 );
376+
377+
to_read -= bytes_read;
378+
buf += bytes_read;
379+
}
380+
381+
return( (int) n );
368382
}
369383

370384
/* Open any underlying file resource, then giflib.

libvips/foreign/heifload.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -988,13 +988,14 @@ vips_foreign_load_heif_read( void *data, size_t size, void *userdata )
988988
VipsForeignLoadHeif *heif = (VipsForeignLoadHeif *) userdata;
989989

990990
while( size > 0 ) {
991-
gint64 result;
991+
gint64 bytes_read;
992992

993-
result = vips_source_read( heif->source, data, size );
994-
if( result <= 0 )
993+
bytes_read = vips_source_read( heif->source, data, size );
994+
if( bytes_read <= 0 )
995995
return( -1 );
996996

997-
size -= result;
997+
size -= bytes_read;
998+
data += bytes_read;
998999
}
9991000

10001001
return( 0 );

libvips/foreign/ppmload.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,20 @@ vips_foreign_load_ppm_generate_binary( VipsRegion *or,
462462

463463
n_bytes = sizeof_line;
464464
while( n_bytes > 0 ) {
465-
size_t bytes_read;
465+
gint64 bytes_read;
466466

467467
bytes_read = vips_source_read( ppm->source,
468468
q, sizeof_line );
469+
if( bytes_read < 0 )
470+
return( -1 );
469471
if( bytes_read == 0 ) {
470472
vips_error( class->nickname,
471473
"%s", _( "file truncated" ) );
472474
return( -1 );
473475
}
474476

475477
n_bytes -= bytes_read;
478+
q += bytes_read;
476479
}
477480
}
478481

0 commit comments

Comments
 (0)