Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b87fa89ec03e7c8e61cfbb07399b6d9a69c5a27bc298c4370f6d43af335ed9ba
Ticket: 9ee9f4d7be4615e04f62fe22885dadce13ca4d01
zlib push/pop corrupts underlying channel
User & Date: aku on 2020-06-19 20:03:43
Changes

  1. comment changed to:
    In the following script, the $src gains two new characters at the end each
    time a zlib transform is pushed and then popped:
    
    <code><pre>
    #! /usr/bin/env tclsh
    
    set data hello
    set src [file tempfile]
    puts -nonewline $src $data
    flush $src
    chan configure $src -translation binary
    
    set dst [file tempfile]
    chan configure $dst -translation binary
    
    for {set i 0} {$i < 10} {incr i} {
        # Determine size of src channel
        seek $src 0 end
        set size [chan tell $src]
        seek $src 0 start
        # Determine size of content in src channel
        set data [read $src]
        set size2 [string length $data]
        seek $src 0 start
        # Copy src over to dst, keep dst empty
        zlib push deflate $src -level 6
        chan truncate $dst 0
        chan copy $src $dst
        chan pop $src
        # Show sizes
        puts [list $size $size2]
    }
    close $src
    close $dst
    
    </pre></code>
    
  2. login: "aku"
  3. mimetype: "text/plain"