Skip to content

Commit

Permalink
* libtiff/tif_dirread.c: fix needless tag ordering warning
Browse files Browse the repository at this point in the history
  • Loading branch information
redder86 committed Dec 14, 2010
1 parent 9036804 commit 975703d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2010-12-13 Lee Howard <faxguy@howardsilvan.com>

* libtiff/tif_dirread.c: fix needless tag ordering warning
http://bugzilla.maptools.org/show_bug.cgi?id=2210

2010-12-13 Lee Howard <faxguy@howardsilvan.com>

* libtiff/tif_color.c: prevent crash in handling bad TIFFs
Expand Down
12 changes: 7 additions & 5 deletions libtiff/tif_dirread.c
@@ -1,4 +1,4 @@
/* $Id: tif_dirread.c,v 1.92.2.12 2010-12-11 22:32:32 faxguy Exp $ */
/* $Id: tif_dirread.c,v 1.92.2.13 2010-12-14 02:40:31 faxguy Exp $ */

/*
* Copyright (c) 1988-1997 Sam Leffler
Expand Down Expand Up @@ -83,6 +83,7 @@ TIFFReadDirectory(TIFF* tif)
const TIFFFieldInfo* fip;
size_t fix;
uint16 dircount;
uint16 previous_tag = 0;
int diroutoforderwarning = 0, compressionknown = 0;
int haveunknowntags = 0;

Expand Down Expand Up @@ -176,23 +177,24 @@ TIFFReadDirectory(TIFF* tif)

if (dp->tdir_tag == IGNORE)
continue;
if (fix >= tif->tif_nfields)
fix = 0;

/*
* Silicon Beach (at least) writes unordered
* directory tags (violating the spec). Handle
* it here, but be obnoxious (maybe they'll fix it?).
*/
if (dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) {
if (dp->tdir_tag < previous_tag) {
if (!diroutoforderwarning) {
TIFFWarningExt(tif->tif_clientdata, module,
"%s: invalid TIFF directory; tags are not sorted in ascending order",
tif->tif_name);
diroutoforderwarning = 1;
}
fix = 0; /* O(n^2) */
}
previous_tag = dp->tdir_tag;
if (fix >= tif->tif_nfields ||
dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag)
fix = 0; /* O(n^2) */
while (fix < tif->tif_nfields &&
tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag)
fix++;
Expand Down

0 comments on commit 975703d

Please sign in to comment.