Check-in [acdc36a7e0]
Overview
Comment:Updated to support a limit on how much seeking is done looking for a zip header
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:acdc36a7e0c97877f7bbe12d299de448ecceb96d
User & Date: rkeene on 2010-10-02 03:02:12
Other Links: manifest | tags
Context
2010-10-02
04:02
Updated to rename Win32 libraries to more windows-specific names check-in: 491345c1fd user: rkeene tags: trunk
03:02
Updated to support a limit on how much seeking is done looking for a zip header check-in: acdc36a7e0 user: rkeene tags: trunk
2010-10-01
23:46
Renamed library built by KitDLL to include version number by default check-in: fe17341989 user: rkeene tags: trunk
Changes

Modified kitdll/buildsrc/kitdll-0.0/boot.tcl from [31a964e643] to [2b2126d5c0].

    71     71   	# This loads everything needed for "clock scan" to work
    72     72   	# "clock scan" is used within "vfs::zip", which may be
    73     73   	# loaded before this is run causing the root VFS to break
    74     74   	catch { clock scan }
    75     75   
    76     76   	# Load these, the original Tclkit does so it should be safe.
    77     77   	uplevel #0 [list source [file join $tcl_mountpoint lib vfs vfsUtils.tcl]]
           78  +
           79  +	# Set a maximum seek to avoid reading the entire DLL looking for a
           80  +	# zip header
           81  +	catch {
           82  +		package require vfs::zip
           83  +		set ::zip::max_header_seek 8192
           84  +	}
    78     85   
    79     86   	# Now that the initialization is complete, mount the user VFS if needed
    80     87   	## Mount the VFS from the Shared Object
    81     88   	if {[info exists ::initVFS] && [info exists ::tclKitFilename]} {
    82     89   		catch {
    83         -			package require vfs::zip
    84         -
    85     90   			vfs::zip::Mount $::tclKitFilename "/.KITDLL_USER"
    86     91   
    87     92   			lappend auto_path [file normalize "/.KITDLL_USER/lib"]
    88     93   		}
    89     94   	}
    90     95   
    91     96   	## Mount the VFS from executable
    92     97   	if {[info exists ::initVFS]} {
    93     98   		catch {
    94         -			package require vfs::zip
    95         -
    96     99   			vfs::zip::Mount [info nameofexecutable] "/.KITDLL_APP"
    97    100   
    98    101   			lappend auto_path [file normalize "/.KITDLL_APP/lib"]
    99    102   		}
   100    103   	}
   101    104   
          105  +	# Clean up
          106  +	unset -nocomplain ::zip::max_header_seek
          107  +
   102    108   	# Clean up after the kitInit.c:preInitCmd
   103    109   	unset -nocomplain ::initVFS ::tclKitFilename
   104    110   }

Modified kitsh/buildsrc/kitsh-0.0/zipvfs.tcl from [8fe7ed4f05] to [9ed60c581d].

   328    328       # comments the chunk may start at an arbitrary distance from the
   329    329       # end of the file. So if we do not find the header immediately
   330    330       # we have to extend the range of our search, possibly until we
   331    331       # have a large part of the archive in memory. We can fail only
   332    332       # after the whole file has been searched.
   333    333   
   334    334       set sz  [tell $fd]
          335  +    if {[info exists ::zip::max_header_seek]} {
          336  +        if {$::zip::max_header_seek < $sz} {
          337  +            set sz $::zip::max_header_seek
          338  +        }
          339  +    } 
   335    340       set len 512
   336    341       set at  512
   337    342       while {1} {
   338    343   	if {$sz < $at} {set n -$sz} else {set n -$at}
   339    344   
   340    345   	seek $fd $n end
   341    346   	set hdr [read $fd $len]

Modified tclvfs/patches/all/tclvfs-20080503-zipvfs.diff from [b70e607501] to [f1ca9abb3e].

     1      1   diff -uNr tclvfs-20080503.orig/library/zipvfs.tcl tclvfs-20080503-1rsk/library/zipvfs.tcl
     2      2   --- tclvfs-20080503.orig/library/zipvfs.tcl	2008-04-15 16:11:53.000000000 -0500
     3         -+++ tclvfs-20080503-1rsk/library/zipvfs.tcl	2010-09-28 16:43:12.000000000 -0500
            3  ++++ tclvfs-20080503-1rsk/library/zipvfs.tcl	2010-10-01 21:48:38.000000000 -0500
     4      4   @@ -107,6 +107,10 @@
     5      5    	    
     6      6    	    ::zip::stat $zipfd $name sb
     7      7    
     8      8   +            if {$sb(ino) == -1} {
     9      9   +                vfs::filesystem posixerror $::vfs::posix(EISDIR)
    10     10   +            }
................................................................................
    40     40   -	# Only mday can be wrong, at end of month
    41     41   -	incr mday -1
    42     42        }
    43     43   +
    44     44        return $res
    45     45    }
    46     46    
    47         -@@ -381,7 +385,12 @@
           47  +@@ -360,6 +364,11 @@
           48  +     # after the whole file has been searched.
           49  + 
           50  +     set sz  [tell $fd]
           51  ++    if {[info exists ::zip::max_header_seek]} {
           52  ++        if {$::zip::max_header_seek < $sz} {
           53  ++            set sz $::zip::max_header_seek
           54  ++        }
           55  ++    }
           56  +     set len 512
           57  +     set at  512
           58  +     while {1} {
           59  +@@ -381,7 +390,12 @@
    48     60        }
    49     61    
    50     62        set hdr [string range $hdr [expr $pos + 4] [expr $pos + 21]]
    51     63   -    set pos [expr [tell $fd] + $pos - 512]
    52     64   +
    53     65   +    set seekstart [expr {[tell $fd] - 512}]
    54     66   +    if {$seekstart < 0} {
    55     67   +        set seekstart 0
    56     68   +    }
    57     69   +    set pos [expr {$seekstart + $pos}]
    58     70    
    59     71        binary scan $hdr ssssiis \
    60     72    	cb(ndisk) cb(cdisk) \
    61         -@@ -396,10 +405,15 @@
           73  +@@ -396,10 +410,15 @@
    62     74    
    63     75        # Compute base for situations where ZIP file
    64     76        # has been appended to another media (e.g. EXE)
    65     77   -    set cb(base)	[expr { $pos - $cb(csize) - $cb(coff) }]
    66     78   +    set base            [expr { $pos - $cb(csize) - $cb(coff) }]
    67     79   +    if {$base < 0} {
    68     80   +        set base 0
................................................................................
    71     83    }
    72     84    
    73     85    proc zip::TOC {fd arr} {
    74     86   +    upvar #0 zip::$fd cb
    75     87        upvar 1 $arr sb
    76     88    
    77     89        set buf [read $fd 46]
    78         -@@ -410,6 +424,8 @@
           90  +@@ -410,6 +429,8 @@
    79     91          flen elen clen sb(disk) sb(attr) \
    80     92          sb(atx) sb(ino)
    81     93    
    82     94   +    set sb(ino) [expr {$cb(base) + $sb(ino)}]
    83     95   +
    84     96        if { ![string equal "PK\01\02" $hdr] } {
    85     97    	binary scan $hdr H* x
    86     98    	error "bad central header: $x"
    87         -@@ -442,7 +458,7 @@
           99  +@@ -442,7 +463,7 @@
    88    100    	
    89    101    	zip::EndOfArchive $fd cb
    90    102    
    91    103   -	seek $fd $cb(coff) start
    92    104   +	seek $fd [expr {$cb(base) + $cb(coff)}] start
    93    105    
    94    106    	set toc(_) 0; unset toc(_); #MakeArray
    95    107