diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2011-08-12 09:55:32 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2011-08-12 09:55:32 (GMT) |
commit | 799b962aea1e21eb1d360a56a574b4bb57dd2853 (patch) | |
tree | 981d43d20fbf998c03ac000feca35fab23a0d6e4 | |
parent | ba9424ed9813043dd8948d59a0fd5aa83b0cd0ca (diff) | |
download | tcl-799b962aea1e21eb1d360a56a574b4bb57dd2853.zip tcl-799b962aea1e21eb1d360a56a574b4bb57dd2853.tar.gz tcl-799b962aea1e21eb1d360a56a574b4bb57dd2853.tar.bz2 |
[Bug 3390073]: Return the correct length of written data for a compressing
transform, ensuring that buffers are written exactly once instead of multiple
times or not at all (producing an invalid file).
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | generic/tclZlib.c | 2 | ||||
-rw-r--r-- | tests/zlib.test | 32 |
3 files changed, 43 insertions, 6 deletions
@@ -1,24 +1,29 @@ +2011-08-12 Donal K. Fellows <dkf@users.sf.net> + + * generic/tclZlib.c (ZlibTransformOutput): [Bug 3390073]: Return the + correct length of written data for a compressing transform. + 2011-08-10 Alexandre Ferrieux <ferrieux@users.sourceforge.net> - * generic/tclTestObj.c: [Bug 3386721] Allow multiple [load]ing of - the Tcltest package + * generic/tclTestObj.c: [Bug 3386721]: Allow multiple [load]ing of the + Tcltest package. 2011-08-09 Alexandre Ferrieux <ferrieux@users.sourceforge.net> - * generic/tclBasic.c: [Bug 2919042] Restore "valgrindability" of Tcl + * generic/tclBasic.c: [Bug 2919042]: Restore "valgrindability" of Tcl * generic/tclEvent.c: that was lost by the streamlining of [exit], by * generic/tclExecute.c: conditionally forcing a full Finalize: * generic/tclInt.h: use -DPURIFY or ::env(TCL_FINALIZE_ON_EXIT) 2011-08-09 Alexandre Ferrieux <ferrieux@users.sourceforge.net> - * generic/tclCompCmds.c: [Bug 3386417] avoid a reference loop between + * generic/tclCompCmds.c: [Bug 3386417]: Avoid a reference loop between * generic/tclInt.h: the bytecode and its companion errostack * generic/tclResult.c: when compiling a syntax error. 2011-08-09 Jan Nijtmans <nijtmans@users.sf.net> - * win/tclWinConsole.c: [Bug 3388350] mingw64 compiler warnings + * win/tclWinConsole.c: [Bug 3388350]: mingw64 compiler warnings * win/tclWinDde.c * win/tclWinPipe.c * win/tclWinSerial.c diff --git a/generic/tclZlib.c b/generic/tclZlib.c index be91365..81012dc 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -2460,7 +2460,7 @@ ZlibTransformOutput( return -1; } - return toWrite - cd->outStream.avail_out; + return toWrite - cd->outStream.avail_in; } static int diff --git a/tests/zlib.test b/tests/zlib.test index 47eeab8..dac11e4 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -156,6 +156,7 @@ test zlib-8.3 {zlib transformation and fileevent} -constraints zlib -setup { close $srv removeFile $file } -result 81920-->81920 + test zlib-9.1 "check fcopy with push" -constraints zlib -setup { set sfile [makeFile {} testsrc.gz] set file [makeFile {} test.gz] @@ -569,6 +570,37 @@ test zlib-10.2 "bug #2818131 (mismatch gets)" -constraints { rename bgerror {} rename zlibRead {} } -result {error {invalid block type}} + +test zlib-11.1 "Bug #3390073: mis-appled gzip filtering" -setup { + set file [makeFile {} test.input] +} -constraints zlib -body { + set f [open $file wb] + puts -nonewline [zlib push gzip $f] [string repeat "hello" 1000] + close $f + set f [open $file rb] + set d [read $f] + close $f + set d [zlib gunzip $d] + list [regexp -all "hello" $d] [string length [regsub -all "hello" $d {}]] +} -cleanup { + removeFile $file +} -result {1000 0} +test zlib-11.2 "Bug #3390073: mis-appled gzip filtering" -setup { + set file [makeFile {} test.input] +} -constraints zlib -body { + set f [open $file wb] + puts -nonewline [zlib push gzip $f -header {filename /foo/bar}] \ + [string repeat "hello" 1000] + close $f + set f [open $file rb] + set d [read $f] + close $f + set d [zlib gunzip $d -header h] + list [regexp -all "hello" $d] [dict get $h filename] \ + [string length [regsub -all "hello" $d {}]] +} -cleanup { + removeFile $file +} -result {1000 /foo/bar 0} ::tcltest::cleanupTests return |