Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7b9b069cb3ba0e951c7def96c5a0427ccb775a273c6cfc57941a1ac219ddfd71
Ticket: 5af0b88de82204d112f1d4966d9814d63a3fe6d9
Remove redundant code from ::safe::AliasGlob
User & Date: kjnash on 2020-07-18 12:57:09
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    In command ::safe::AliasGlob, the following code block in the [switch] command that parses command options fulfils no useful purpose and should be removed:
    <verbatim>
    	    pkgIndex.tcl {
    		# Oops, this is globbing a subdirectory in regular package
    		# search. That is not wanted. Abort, handler does catch
    		# already (because glob was not defined before). See
    		# package.tcl, lines 484ff in tclPkgUnknown.
    		return -code error "unknown command glob"
    	    }
    </verbatim>
    ::safe::AliasGlob was added in:
      *  file: [ec1bb9af3f] check-in: [7f54ff3bbe] 2008-06-25 core-8-5-branch
      *  file: [e245695909] check-in: [d5216b1efd] 2008-06-25 trunk
    
      *  AliasGlob was added so Safe Base interpreters could use tcl::tm modules via ::tcl::tm::UnknownHandler.
      *  The non-module package handlers, tclPkgUnknown and tcl::MacOSXPkgUnknown, also use glob (to search subdirectories of the auto_path elements) but expected it to fail in a Safe Base interpreter.
      *  From these first commits, AliasGlob included code that raised an error if argument "pkgIndex.tcl" was the first pattern element.  Comments refer to the wish to reject usage by tclPkgUnknown.  The motivation in these early stages was presumably to craft AliasGlob for use only in the ::tcl::tm::UnknownHandler.
      *  However, examination of tclPkgUnknown and tcl::MacOSXPkgUnknown shows that, by the time the code was committed in June 2008, the calls from tclPkgUnknown and tcl::MacOSXPkgUnknown would not have triggered the error because "pkgIndex.tcl" was not the first pattern element after the options.  The code block no longer served its original purpose.
    
    Retention of this [switch] block would be justified if it prevented abuse of the AliasGlob command by untrusted code.  However,
    
      #  The AliasGlob command is strict about allowing searches only in directories that belong to the access path, and there is no harm in allowing a search for "pkgIndex.tcl" there.
      #  A search for "pkgIndex.*", or even "*", is permitted and is harmless.
    
    The code is simply a relic of the early development of AliasGlob and no longer serves any useful purpose.
    
    Fixed in branch safe-bugfixes-8-6 commit [fb0d72aad4].
    
  5. foundin changed to: "core-8-6-branch"
  6. is_private changed to: "0"
  7. login: "kjnash"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "a774b1f5653dc3360e29ea7d635a64e94c9f1dab"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "kjnash"
  14. subsystem changed to: "33. Safe Base"
  15. type changed to: "Bug"