clip coding and interpretation on image read

They could be out of bounds enums. This used not to matter, but we use
them more now, so out of bounds values can cause coredumps.
This commit is contained in:
John Cupitt 2019-08-24 11:20:45 +01:00
parent 4b677fb16a
commit 038409093f
2 changed files with 4 additions and 1 deletions

View File

@ -10,6 +10,7 @@
- fix a problem with shinkv tail processing [angelmixu]
- fix a read one byte beyond buffer bug in jpegload
- make GIF parsing less strict
- clip coding and interpretation on vips image read
24/5/19 started 8.8.1
- improve realpath() use on older libc

View File

@ -382,8 +382,10 @@ vips__read_header_bytes( VipsImage *im, unsigned char *from )
im->Ysize = VIPS_CLIP( 1, im->Ysize, VIPS_MAX_COORD );
im->Bands = VIPS_CLIP( 1, im->Bands, VIPS_MAX_COORD );
im->BandFmt = VIPS_CLIP( 0, im->BandFmt, VIPS_FORMAT_LAST - 1 );
im->Type = VIPS_CLIP( 0, im->Type, VIPS_INTERPRETATION_LAST - 1 );
im->Coding = VIPS_CLIP( 0, im->Coding, VIPS_CODING_LAST - 1 );
/* Type, Coding, Offset, Res, etc. don't affect vips file layout, just
/* Offset, Res, etc. don't affect vips file layout, just
* pixel interpretation, don't clip them.
*/