Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 10782d8a98846b17560e8843b4006fe2253ac9a3
Ticket: 3118489fffffffffffffffffffffffffffffffff
NUL in filenames
User & Date: jan.nijtmans on 2014-04-11 08:20:54
Changes

  1. closer changed to: "nobody"
  2. comment changed to:
    Some file commands treat NUL (\0) as a string terminator.  Others treat it as a normal character.  This inconsistency makes it possible to spoof commands that filter based on filename, particularly extension.  Example:
    
    proc access {name} {
        if {[file extension $name] eq ".secret"} {
            error denied
        } else {
            puts granted
            open $name
        }
    }
    % access file.secret
    denied
    % access file.secret\0
    granted
    file5
    
    Generally, it's the commands that talk to the operating system that treat NUL as the string terminator.  (More likely it's the operating system itself that does this!)  For example, [open] and [cd] do this:
    
    % cd .
    % cd .\0
    % cd \0.
    couldn't change working directory to "NUL.": no such file or directory
    # (in the previous line, NUL is a real NUL character; to see it, use tkcon instead of xterm)
    % file exists .
    1
    % file exists .\0
    1
    % file exists \0.
    0
    
  3. icomment:
    Fixed in trunk for Windows only [0f4597a73cae916f979f4bd22eeb9f8dc5cd467f|0f4597a73c] by translating some characters which are invalid for win32 filenames to other characters as described here: [http://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-specialchars]. (The characters ':' and '?' are not handled, because ':' is valid as drive specifier and '?' is valid in the extended path prefix.)
    
    Code inspired by fossil: [http://www.fossil-scm.org/index.html/artifact/76559aefff?ln=245-252]
    
  4. login: "jan.nijtmans"
  5. mimetype: "text/x-fossil-wiki"
  6. severity changed to: "Minor"