Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 700b71e92a1ca1f03e32cb7365b98abb93eeffe4
Ticket: 3069278fffffffffffffffffffffffffffffffff
breakage on head Windows triggered by install-tzdata
User & Date: nijtmans on 2010-09-21 18:47:32
Changes

  1. icomment:
    I worked through the code, trying to find locations where UNICODE
    strings were appended to a buffer, trying to let is end with a double
    null-byte. In most places, this is done by using
    Tcl_DStringSetLength(.... , len+1);
    Tcl_DStringSetLength(.... , len);
    The first call allocates enough space to accomodate for the extra
    null byte, The second call sets the length correctly, and puts
    the principal null-byte there.
    
    However, there were two places where it was done differently.
    In tclWinFCmd.c, line 1307:
     nativeSource[oldSourceLen + 1] = '\0';
    If oldSourceLen is the string length in bytes, and
    nativeSource is a WCHAR array, this will set two
    null-bytes in the string, but at a double index
    of the intended location. The UNICODE string
    will not be null-terminated, which explains
    exactly Andreas' stack trace.
    
    Another location was at tclWinPipe.c, line 3136:
     *(WCHAR *)(namePtr + Tcl_DStringLength(&buf) + 1) = '\0';
    Not that bad, but casting a char * to a WCHAR *, while
    not even being sure that the pointer is aligned to
    a two-byte boundry, is clearly not correct.
    
    Here is the patch, which changed both locations to
    use the double Tcl_DStringSetLength method. This
    should - once and for all - fix this.
    
    Andreas  (or Jeff), could you please confirm that this
    fixes the bug? Thanks!
    
    Originally, I intended to modify tclUtil.c such that
    on Windows two null-bytes are always guaranteed.
    However, there is a lot of code which assumes
    insertion of a single null-byte, so this lead to
    test failures.
    
    
  2. login: "nijtmans"
  3. mimetype: "text/plain"
  4. username: "nijtmans"