Tcl Source Code

View Ticket
Login
Ticket UUID: 1602539
Title: [glob] adds stray NUL to end of mounted VFS directory names
Type: Bug Created on: 2006-11-25 00:53:29
Submitter: andygoth Assigned to: vincentdarley
Subsystem: 37. File System Severity:
Priority: 8 Last modified: 2007-12-15 06:36:55
Status: Closed Closed by: hobbs
Resolution: Fixed Closed on: 2007-12-14 23:36:55
Version: obsolete: 8.5a6
Description:
% binary scan [glob -type d tclkit] c* out; set out
116 99 108 107 105 116
% binary scan [glob -type d *] c* out; set out
116 99 108 107 105 116 0

On Windows this has the effect of truncating the string if passed to puts.  I haven't seen this in Linux.

% puts <[glob -type d *]>
<tclkit.exe%

(the % is the next prompt; the newline never printed)
User Comments:
dgp added on 2006-11-27 22:31:56:
Logged In: YES 
user_id=80530
Originator: NO


I tried to duplicate this
with trofs to gather more
data, and [glob -type d $pattern]
doesn't work at all with it.

Don't know yet where that
places the flaw(s).

dgp added on 2006-11-28 21:57:36:
Logged In: YES 
user_id=80530
Originator: NO


Is this flaw seen only in
the 8.5 development sources,
or is it present in 8.4.14
as well?

hobbs added on 2006-11-29 00:51:16:
Logged In: YES 
user_id=72656
Originator: NO

It repros for me in 8.5 head, but not 8.4.14 head.

dgp added on 2006-11-29 00:54:41:
Logged In: YES 
user_id=80530
Originator: NO


looks like I'm on the trail
of a different (possibly
related) bug then.  When I know
more I'll open a separate report.

andygoth added on 2006-12-01 07:08:05:
Logged In: YES 
user_id=8653
Originator: YES

"I haven't seen this in Linux."  I refer to the truncation, not the bug as a whole.

In plain terms, the NUL happens regardless of operating system.  I tested on both Windows and Linux operating systems and on both x86 and x86_64 architectures.

The bug does not appear to be present in 8.4.

hobbs added on 2007-12-15 05:37:34:
Logged In: YES 
user_id=72656
Originator: NO

I'm not reproducing this on 8.5.0-rc and tclvfs head on XP:

C:\build\vfs>make shell
% package require vfs::zip
1.0
% vfs::zip::Mount C:/temp/lame.zip t
filea2d970
% cd t
% glob -type d *
ACM misc html
% puts <[glob -type d *]>
<ACM misc html>
% binary scan [glob -type d *] c* out ; set out
65 67 77 32 109 105 115 99 32 104 116 109 108
% info patch
8.5.0

mpc_janssen added on 2007-12-15 05:54:18:
Logged In: YES 
user_id=1463011
Originator: NO

I still can reproduce on XP with Tcl HEAD

% info pa
8.5.0
% package require vfs::zip
1.0
% vfs::zip::Mount svn-win32-1.4.5.zip svnab
filea13da8
% binary scan [glob -type d *] c* out; set out
68 105 103 101 115 116 45 80 101 114 108 45 77 68 53 45 49 46 56 32 116 99 108 1
16 99 99 32 115 118 110 97 98 0
% parray tcl_platform
tcl_platform(byteOrder)   = littleEndian
tcl_platform(machine)     = intel
tcl_platform(os)          = Windows NT
tcl_platform(osVersion)   = 5.1
tcl_platform(platform)    = windows
tcl_platform(pointerSize) = 4
tcl_platform(user)        = mjanssen
tcl_platform(wordSize)    = 4

hobbs added on 2007-12-15 05:56:57:
Logged In: YES 
user_id=72656
Originator: NO

OK, specifically it is the glob on the mounted dir itself.

% vfs::zip::Mount C:/temp/lame.zip t
filea2d970
% glob -type d *
t
% puts <[glob -type d *]>
<t >
% binary scan [glob -type d *] c* out ; set out
116 0

hobbs added on 2007-12-15 06:15:28:
Logged In: YES 
user_id=72656
Originator: NO

The bug is in bug in tclIOUtil.c:FsAddMountsToGlobResult at 1261 where the call to TclNewFSPathObj passes in the wrong size.

hobbs added on 2007-12-15 06:36:55:
Logged In: YES 
user_id=72656
Originator: NO

* generic/tclIOUtil.c (FsAddMountsToGlobResult): fix the tail
conversion of vfs mounts. [Bug 1602539]

The '/' handling wasn't done right on the length part.