More overflow fixes from Dmitry V. Levin.

This commit is contained in:
Andrey Kiselev 2004-09-24 08:10:18 +00:00
parent 79cf6661ca
commit 9f1423f91f
2 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $Id: tif_dirread.c,v 1.38 2004-09-23 08:58:11 dron Exp $ */ /* $Id: tif_dirread.c,v 1.39 2004-09-24 08:10:18 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -64,8 +64,8 @@ static void ChopUpSingleUncompressedStrip(TIFF*);
static char * static char *
CheckMalloc(TIFF* tif, size_t nmemb, size_t elem_size, const char* what) CheckMalloc(TIFF* tif, size_t nmemb, size_t elem_size, const char* what)
{ {
char *cp = NULL; char *cp = NULL;
size_t bytes = nmemb * elem_size; tsize_t bytes = nmemb * elem_size;
/* /*
* XXX: Check for integer overflow. * XXX: Check for integer overflow.

View File

@ -1,4 +1,4 @@
/* $Id: tiffiop.h,v 1.26 2004-09-22 13:48:20 dron Exp $ */ /* $Id: tiffiop.h,v 1.27 2004-09-24 08:10:18 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -206,8 +206,9 @@ struct tiff {
(TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) (TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size)
#endif #endif
#define TIFFhowmany(x, y) (((x)+((y)-1))/(y)) /* NB: the uint32 casts are to silence certain ANSI-C compilers */
#define TIFFhowmany8(x) (((x)&0x07)?((x)>>3)+1:(x)>>3) #define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y)))
#define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3)
#define TIFFroundup(x, y) (TIFFhowmany(x,y)*(y)) #define TIFFroundup(x, y) (TIFFhowmany(x,y)*(y))
#define TIFFmax(A,B) ((A)>(B)?(A):(B)) #define TIFFmax(A,B) ((A)>(B)?(A):(B))