summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerouault <erouault>2015-08-30 21:07:44 +0000
committererouault <erouault>2015-08-30 21:07:44 +0000
commit9c7d8588ea4e6acb621f9789c4ac14fb3654e5f7 (patch)
tree7c6cdc694e82ae5d26b1cd35a33a53541091c0fd
parentcf82832e3e1f174697126f968a49e262de41621a (diff)
downloadlibtiff-9c7d8588ea4e6acb621f9789c4ac14fb3654e5f7.tar.gz
* libtiff/tif_lzw.c: make nextdata a unsigned type to avoid
undefined behaviour with shifts (gcc -fsanitize=shift)
-rw-r--r--ChangeLog4
-rw-r--r--libtiff/tif_lzw.c12
2 files changed, 11 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index aee767cb..c2a47066 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2015-08-30 Even Rouault <even.rouault at spatialys.com>
+ * libtiff/tif_lzw.c: make nextdata a unsigned type to avoid
+ undefined behaviour with shifts (gcc -fsanitize=shift)
+
+2015-08-30 Even Rouault <even.rouault at spatialys.com>
* libtiff/tif_fax3.c, libtiff/tif_lzw.c, libtiff/tif_predict.c:
add explicit masking with 0xff before casting
to unsigned char (make icc -check=conversions happy)
diff --git a/libtiff/tif_lzw.c b/libtiff/tif_lzw.c
index ab04bbaa..9b76dd03 100644
--- a/libtiff/tif_lzw.c
+++ b/libtiff/tif_lzw.c
@@ -1,4 +1,4 @@
-/* $Id: tif_lzw.c,v 1.48 2015-08-30 20:49:55 erouault Exp $ */
+/* $Id: tif_lzw.c,v 1.49 2015-08-30 21:07:44 erouault Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -94,7 +94,7 @@ typedef struct {
unsigned short nbits; /* # of bits/code */
unsigned short maxcode; /* maximum code for lzw_nbits */
unsigned short free_ent; /* next free entry in hash table */
- long nextdata; /* next bits of i/o */
+ unsigned long nextdata; /* next bits of i/o */
long nextbits; /* # of valid bits in lzw_nextdata */
int rw_mode; /* preserve rw_mode from init */
@@ -367,7 +367,8 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
unsigned char *bp;
hcode_t code;
int len;
- long nbits, nextbits, nextdata, nbitsmask;
+ long nbits, nextbits, nbitsmask;
+ unsigned long nextdata;
code_t *codep, *free_entp, *maxcodep, *oldcodep;
(void) s;
@@ -874,7 +875,8 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
hcode_t ent;
long disp;
long incount, outcount, checkpoint;
- long nextdata, nextbits;
+ unsigned long nextdata;
+ long nextbits;
int free_ent, maxcode, nbits;
uint8* op;
uint8* limit;
@@ -1036,7 +1038,7 @@ LZWPostEncode(TIFF* tif)
register LZWCodecState *sp = EncoderState(tif);
uint8* op = tif->tif_rawcp;
long nextbits = sp->lzw_nextbits;
- long nextdata = sp->lzw_nextdata;
+ unsigned long nextdata = sp->lzw_nextdata;
long outcount = sp->enc_outcount;
int nbits = sp->lzw_nbits;