From 2d3a7fefffb26949c0103429c5eb151e93c0ecef Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 14 Sep 2015 12:03:54 +0200 Subject: Fix truncation bug when comparing EOF to uint16_t values. --- source/fitz/stream-read.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/fitz/stream-read.c b/source/fitz/stream-read.c index 927addb0..80091046 100644 --- a/source/fitz/stream-read.c +++ b/source/fitz/stream-read.c @@ -188,9 +188,9 @@ fz_read_file(fz_context *ctx, const char *filename) uint16_t fz_read_uint16(fz_context *ctx, fz_stream *stm) { - uint16_t a = fz_read_byte(ctx, stm); - uint16_t b = fz_read_byte(ctx, stm); - uint16_t x = (a<<8) | (b); + uint32_t a = fz_read_byte(ctx, stm); + uint32_t b = fz_read_byte(ctx, stm); + uint32_t x = (a<<8) | (b); if (a == EOF || b == EOF) fz_throw(ctx, FZ_ERROR_GENERIC, "premature end of file in int16"); return x; @@ -237,9 +237,9 @@ uint64_t fz_read_uint64(fz_context *ctx, fz_stream *stm) uint16_t fz_read_uint16_le(fz_context *ctx, fz_stream *stm) { - uint16_t a = fz_read_byte(ctx, stm); - uint16_t b = fz_read_byte(ctx, stm); - uint16_t x = (a) | (b<<8); + uint32_t a = fz_read_byte(ctx, stm); + uint32_t b = fz_read_byte(ctx, stm); + uint32_t x = (a) | (b<<8); if (a == EOF || b == EOF) fz_throw(ctx, FZ_ERROR_GENERIC, "premature end of file in int16"); return x; -- cgit v1.2.3