From 091191c3dcbfb9f01070d26bf15cb2c4dd07b1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 31 Dec 2017 11:15:24 +0100 Subject: list-runtime-root: Fix off-by-one in 'strip-drop' call. Fixes . Reported by Danny Milosavljevic . * nix/scripts/list-runtime-roots.in (canonicalize-store-item): Define 'store' with a trailing "/". Have the 'string-prefix?' call match the 'string-drop' call. --- nix/scripts/list-runtime-roots.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'nix') diff --git a/nix/scripts/list-runtime-roots.in b/nix/scripts/list-runtime-roots.in index 48a07edf5f..5f2660fb5e 100644 --- a/nix/scripts/list-runtime-roots.in +++ b/nix/scripts/list-runtime-roots.in @@ -130,12 +130,13 @@ or the empty list." (< (string->number a) (string->number b)))))) (define canonicalize-store-item - (let ((prefix (+ 1 (string-length %store-directory)))) + (let* ((store (string-append %store-directory "/")) + (prefix (string-length store))) (lambda (file) "Return #f if FILE is not a store item; otherwise, return the store file name without any sub-directory components." - (and (string-prefix? %store-directory file) - (string-append %store-directory "/" + (and (string-prefix? store file) + (string-append store (let ((base (string-drop file prefix))) (match (string-index base #\/) (#f base) -- cgit v1.2.3