Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2020-12-31
16:03 • Closed ticket [5af0b88de8]: Remove redundant code from ::safe::AliasGlob plu... artifact: 162bbff0c1 user: kjnash
2020-07-18
12:57 • Ticket [5af0b88de8]: 3 changes artifact: aac1abd991 user: kjnash
12:57 • New ticket [5af0b88de8]. artifact: 7b9b069cb3 user: kjnash

Remove redundant code from ::safe::AliasGlob

Closed / Fixed5af0b88de82204d112f1d4966d9814d63a3fe6d9Created 6 years agoUpdated 6 years ago
Descriptionwiki2020-07-18 12:57:09
In command ::safe::AliasGlob, the following code block in the [switch] command that parses command options fulfils no useful purpose and should be removed:
	    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"
	    }
::safe::AliasGlob was added in:
  • 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,

  1. 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.
  2. 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].

kjnash Ticket [5af0b88de8]: 3 changes [History diff]2020-07-18 12:57:52
kjnash Closed ticket [5af0b88de8]. [History diff]2020-12-31 16:03:26
Log in (anonymous is fine) to add a comment.