make-pathname fails to sanitize :directory string components
Bug #1278207 reported by
Faré
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
New
|
Undecided
|
Unassigned |
Bug Description
(pathname-directory (make-pathname :directory "../../a/b/c/"))
(:ABSOLUTE "../../a/b/c/")
(namestring (make-pathname :directory "../../a/b/c/"))
"/../../a/b/c//"
I contend SBCL should throw an error instead.
To post a comment you must log in.
I'll add that the sanitization problem exists for other component parameters than :DIRECTORY:
--
* (make-pathname :name "a/b")
#P"a/b"
* (namestring (make-pathname :name "a/b"))
"a/b"
--
And it exists for characters other than slash, e.g.,
--
: initial- contents '(#\a #\nul #\b))) foo.lisp" )))
(let* ((string (make-array 3 :element-type 'character
(pathname (make-pathname :name string :defaults #p"/tmp/
(with-open-file (file pathname :direction :output :if-exists :supersede)
(write-line "foo" file)
(close file)
(probe-file file)))
#P"/tmp/a"
--
While I'm at it, PARSE-NAMESTRING also doesn't catch #\NUL:
--
* (parse-namestring (coerce '(#\a #\nul #\b) 'string))
#P"a^@b" ;; that's a rendering, it's actually "a\0b"
3
--
I'd bet, but haven't investigated, that PATTERNs don't get sanitized either, and there might be observable anomalies that could result.
Reproduced under SBCL 2.0.0.