Diff

Differences From Artifact [f8be70e066]:

To Artifact [8fe7ed4f05]:


   349    349   	    #           ; # a buffer boundary, nor the header itself
   350    350   	} else {
   351    351   	    break
   352    352   	}
   353    353       }
   354    354   
   355    355       set hdr [string range $hdr [expr $pos + 4] [expr $pos + 21]]
   356         -    set pos [expr [tell $fd] + $pos - 512]
          356  +
          357  +    set seekstart [expr {[tell $fd] - 512}]
          358  +    if {$seekstart < 0} {
          359  +        set seekstart 0
          360  +    }
          361  +    set pos [expr {$seekstart + $pos}]
   357    362   
   358    363       binary scan $hdr ssssiis \
   359    364   	cb(ndisk) cb(cdisk) \
   360    365   	cb(nitems) cb(ntotal) \
   361    366   	cb(csize) cb(coff) \
   362    367   	cb(comment)
   363    368   
................................................................................
   364    369       set cb(ndisk)	[u_short $cb(ndisk)]
   365    370       set cb(nitems)	[u_short $cb(nitems)]
   366    371       set cb(ntotal)	[u_short $cb(ntotal)]
   367    372       set cb(comment)	[u_short $cb(comment)]
   368    373   
   369    374       # Compute base for situations where ZIP file
   370    375       # has been appended to another media (e.g. EXE)
   371         -    set cb(base)	[expr { $pos - $cb(csize) - $cb(coff) }]
          376  +    set base            [expr { $pos - $cb(csize) - $cb(coff) }]
          377  +    if {$base < 0} {
          378  +        set base 0
          379  +    }
          380  +    set cb(base)	$base
   372    381   }
   373    382   
   374    383   proc zip::TOC {fd arr} {
   375    384       upvar #0 zip::$fd cb
   376    385       upvar 1 $arr sb
   377    386   
   378    387       set buf [read $fd 46]