From 8b6b975659dfa431bbf0dbcc68d5144bfe8cd403 Mon Sep 17 00:00:00 2001 From: Frank Warmerdam Date: Sat, 30 Sep 2000 04:18:55 +0000 Subject: [PATCH] don't allow open of compressed files for r+ --- ChangeLog | 8 ++++++++ libtiff/tif_open.c | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6065e96c..7ebf09c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2000-09-30 Frank Warmerdam + + * Modified TIFFClientOpen() to emit an error on an attempt to + open a comperessed file for update (O_RDWR/r+) access. This is + because the compressor/decompressor code gets very confused when + the mode is O_RDWR, assuming this means writing only. See + bug http://bugzilla.remotesensing.org/show_bug.cgi?id=13 + 2000-09-27 Frank Warmerdam * Added GNULDdso target and switched linux and freebsd to use it. diff --git a/libtiff/tif_open.c b/libtiff/tif_open.c index 1010b0aa..b36d5930 100644 --- a/libtiff/tif_open.c +++ b/libtiff/tif_open.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_open.c,v 1.4 2000-08-14 18:10:43 warmerda Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_open.c,v 1.5 2000-09-30 04:18:55 warmerda Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -349,6 +349,14 @@ TIFFClientOpen( !TIFFMapFileContents(tif, (tdata_t*) &tif->tif_base, &tif->tif_size)) tif->tif_flags &= ~TIFF_MAPPED; if (TIFFReadDirectory(tif)) { + if( m != O_RDONLY + && tif->tif_dir.td_compression != COMPRESSION_NONE ) + { + TIFFError( name, + "Can't open a compressed TIFF file" + " with compression for update." ); + goto bad; + } tif->tif_rawcc = -1; tif->tif_flags |= TIFF_BUFFERSETUP; return (tif);