summaryrefslogtreecommitdiff
path: root/nix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-12-31 11:15:24 +0100
committerLudovic Courtès <ludo@gnu.org>2017-12-31 11:18:30 +0100
commit091191c3dcbfb9f01070d26bf15cb2c4dd07b1b5 (patch)
treef77c3bf5986dd80bd0adce92b9ad8726d30f5fed /nix/scripts
parent1c27f72fc2770d68243dd95b7c05adc3b2b02ea4 (diff)
list-runtime-root: Fix off-by-one in 'strip-drop' call.
Fixes <https://bugs.gnu.org/29862>. Reported by Danny Milosavljevic <dannym@scratchpost.org>. * nix/scripts/list-runtime-roots.in (canonicalize-store-item): Define 'store' with a trailing "/". Have the 'string-prefix?' call match the 'string-drop' call.
Diffstat (limited to 'nix/scripts')
-rw-r--r--nix/scripts/list-runtime-roots.in7
1 files changed, 4 insertions, 3 deletions
diff --git a/nix/scripts/list-runtime-roots.in b/nix/scripts/list-runtime-roots.in
index 48a07edf5fd..5f2660fb5e6 100644
--- a/nix/scripts/list-runtime-roots.in
+++ b/nix/scripts/list-runtime-roots.in
@@ -130,12 +130,13 @@ or the empty list."
130 (< (string->number a) (string->number b)))))) 130 (< (string->number a) (string->number b))))))
131 131
132(define canonicalize-store-item 132(define canonicalize-store-item
133 (let ((prefix (+ 1 (string-length %store-directory)))) 133 (let* ((store (string-append %store-directory "/"))
134 (prefix (string-length store)))
134 (lambda (file) 135 (lambda (file)
135 "Return #f if FILE is not a store item; otherwise, return the store file 136 "Return #f if FILE is not a store item; otherwise, return the store file
136name without any sub-directory components." 137name without any sub-directory components."
137 (and (string-prefix? %store-directory file) 138 (and (string-prefix? store file)
138 (string-append %store-directory "/" 139 (string-append store
139 (let ((base (string-drop file prefix))) 140 (let ((base (string-drop file prefix)))
140 (match (string-index base #\/) 141 (match (string-index base #\/)
141 (#f base) 142 (#f base)