From 038409093faa55046972f632d9c6135f11572f7a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sat, 24 Aug 2019 11:20:45 +0100 Subject: [PATCH] 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. --- ChangeLog | 1 + libvips/iofuncs/vips.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 870ff49b..e9024987 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/libvips/iofuncs/vips.c b/libvips/iofuncs/vips.c index 83988c78..4e35023b 100644 --- a/libvips/iofuncs/vips.c +++ b/libvips/iofuncs/vips.c @@ -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. */