Added check for valid code lengths in LZWDecode() and LZWDecodeCompat().

Fixes http://bugzilla.remotesensing.org/show_bug.cgi?id=115
This commit is contained in:
Andrey Kiselev 2002-08-22 15:13:27 +00:00
parent ff411c24b5
commit 9b829f8c18

View File

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_lzw.c,v 1.14 2002-04-18 13:23:46 dron Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_lzw.c,v 1.15 2002-08-22 15:13:27 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -442,6 +442,13 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
break;
}
len = codep->length;
if(len == 0) {
TIFFError(tif->tif_name,
"LZWDecode: Wrong length of decoded string: "
"data probably corrupted at scanline %d",
tif->tif_row);
return (0);
}
tp = op + len;
do {
int t;
@ -616,6 +623,13 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
} while (--occ);
break;
}
if(codep->length == 0) {
TIFFError(tif->tif_name,
"LZWDecodeCompat: Wrong length of decoded "
"string: data probably corrupted at scanline %d",
tif->tif_row);
return (0);
}
op += codep->length, occ -= codep->length;
tp = op;
do {