* libtiff/tif_lzw.c: make nextdata a unsigned type to avoid
undefined behaviour with shifts (gcc -fsanitize=shift)
This commit is contained in:
parent
6dc8110cee
commit
42bfc7006a
@ -1,5 +1,9 @@
|
|||||||
2015-08-30 Even Rouault <even.rouault at spatialys.com>
|
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:
|
* libtiff/tif_fax3.c, libtiff/tif_lzw.c, libtiff/tif_predict.c:
|
||||||
add explicit masking with 0xff before casting
|
add explicit masking with 0xff before casting
|
||||||
to unsigned char (make icc -check=conversions happy)
|
to unsigned char (make icc -check=conversions happy)
|
||||||
|
@ -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
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@ -94,7 +94,7 @@ typedef struct {
|
|||||||
unsigned short nbits; /* # of bits/code */
|
unsigned short nbits; /* # of bits/code */
|
||||||
unsigned short maxcode; /* maximum code for lzw_nbits */
|
unsigned short maxcode; /* maximum code for lzw_nbits */
|
||||||
unsigned short free_ent; /* next free entry in hash table */
|
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 */
|
long nextbits; /* # of valid bits in lzw_nextdata */
|
||||||
|
|
||||||
int rw_mode; /* preserve rw_mode from init */
|
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;
|
unsigned char *bp;
|
||||||
hcode_t code;
|
hcode_t code;
|
||||||
int len;
|
int len;
|
||||||
long nbits, nextbits, nextdata, nbitsmask;
|
long nbits, nextbits, nbitsmask;
|
||||||
|
unsigned long nextdata;
|
||||||
code_t *codep, *free_entp, *maxcodep, *oldcodep;
|
code_t *codep, *free_entp, *maxcodep, *oldcodep;
|
||||||
|
|
||||||
(void) s;
|
(void) s;
|
||||||
@ -874,7 +875,8 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
|||||||
hcode_t ent;
|
hcode_t ent;
|
||||||
long disp;
|
long disp;
|
||||||
long incount, outcount, checkpoint;
|
long incount, outcount, checkpoint;
|
||||||
long nextdata, nextbits;
|
unsigned long nextdata;
|
||||||
|
long nextbits;
|
||||||
int free_ent, maxcode, nbits;
|
int free_ent, maxcode, nbits;
|
||||||
uint8* op;
|
uint8* op;
|
||||||
uint8* limit;
|
uint8* limit;
|
||||||
@ -1036,7 +1038,7 @@ LZWPostEncode(TIFF* tif)
|
|||||||
register LZWCodecState *sp = EncoderState(tif);
|
register LZWCodecState *sp = EncoderState(tif);
|
||||||
uint8* op = tif->tif_rawcp;
|
uint8* op = tif->tif_rawcp;
|
||||||
long nextbits = sp->lzw_nextbits;
|
long nextbits = sp->lzw_nextbits;
|
||||||
long nextdata = sp->lzw_nextdata;
|
unsigned long nextdata = sp->lzw_nextdata;
|
||||||
long outcount = sp->enc_outcount;
|
long outcount = sp->enc_outcount;
|
||||||
int nbits = sp->lzw_nbits;
|
int nbits = sp->lzw_nbits;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user