Skip to content

Commit 3d89349

Browse files
committed
More robust checks for sane tarballs.
1 parent 6eaad6f commit 3d89349

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

utils.lisp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,20 @@ template pathname."
181181
while line collect line)))
182182

183183
(defun tarball-prefix (file)
184+
"For a tarball that unpacks into a subdirectory (e.g. 'foo/foo.asd',
185+
'foo/package.asd', etc), extract the subdirectory string. Errors if
186+
the subdirectory is absent or inconsistent."
184187
(let ((contents (tarball-contents file)))
185-
(let ((prefix (subseq (first contents) 0
186-
(1+ (position #\/ (first contents))))))
187-
(dolist (entry contents prefix)
188-
(unless (and (<= (length prefix) (length entry))
189-
(string= prefix entry :end2 (length prefix)))
190-
(error "Tarball ~A lacks consistent prefix output directory"
191-
file))))))
188+
(let ((first-slash (position #\/ (first contents))))
189+
(unless first-slash
190+
(error "No slash in first entry of tarball -- ~A" (first contents)))
191+
(let ((prefix (subseq (first contents) 0
192+
(1+ first-slash))))
193+
(dolist (entry contents prefix)
194+
(unless (and (<= (length prefix) (length entry))
195+
(string= prefix entry :end2 (length prefix)))
196+
(error "Tarball ~A lacks consistent prefix output directory"
197+
file)))))))
192198

193199
(defun tarball-canonical-name (file)
194200
(string-right-trim "/" (tarball-prefix file)))

0 commit comments

Comments
 (0)