@@ -351,11 +351,16 @@ break } } set hdr [string range $hdr [expr $pos + 4] [expr $pos + 21]] - set pos [expr [tell $fd] + $pos - 512] + + set seekstart [expr {[tell $fd] - 512}] + if {$seekstart < 0} { + set seekstart 0 + } + set pos [expr {$seekstart + $pos}] binary scan $hdr ssssiis \ cb(ndisk) cb(cdisk) \ cb(nitems) cb(ntotal) \ cb(csize) cb(coff) \ @@ -366,11 +371,15 @@ set cb(ntotal) [u_short $cb(ntotal)] set cb(comment) [u_short $cb(comment)] # Compute base for situations where ZIP file # has been appended to another media (e.g. EXE) - set cb(base) [expr { $pos - $cb(csize) - $cb(coff) }] + set base [expr { $pos - $cb(csize) - $cb(coff) }] + if {$base < 0} { + set base 0 + } + set cb(base) $base } proc zip::TOC {fd arr} { upvar #0 zip::$fd cb upvar 1 $arr sb