[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/06: substitute: Gracefully handle invalid store file names.
From: |
Ludovic Courtès |
Subject: |
04/06: substitute: Gracefully handle invalid store file names. |
Date: |
Fri, 20 May 2016 23:35:46 +0000 (UTC) |
civodul pushed a commit to branch master
in repository guix.
commit 30d4bc0434aa5d438c2d433f39c80e1f4a25bcac
Author: Ludovic Courtès <address@hidden>
Date: Fri May 20 17:18:58 2016 +0200
substitute: Gracefully handle invalid store file names.
Before, something like:
echo have /gnu/foo | ./test-env guix substitute --query
would lead to an ugly backtrace.
* guix/scripts/substitute.scm (narinfo-cache-file): Call 'leave' when
'store-hash-part' returns #f.
---
guix/scripts/substitute.scm | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm
index d46d610..5cdc55f 100755
--- a/guix/scripts/substitute.scm
+++ b/guix/scripts/substitute.scm
@@ -440,9 +440,15 @@ the cache STR originates form."
(define (narinfo-cache-file cache-url path)
"Return the name of the local file that contains an entry for PATH. The
entry is stored in a sub-directory specific to CACHE-URL."
- (string-append %narinfo-cache-directory "/"
- (bytevector->base32-string (sha256 (string->utf8 cache-url)))
- "/" (store-path-hash-part path)))
+ ;; The daemon does not sanitize its input, so PATH could be something like
+ ;; "/gnu/store/foo". Gracefully handle that.
+ (match (store-path-hash-part path)
+ (#f
+ (leave (_ "'~a' does not name a store item~%") path))
+ ((? string? hash-part)
+ (string-append %narinfo-cache-directory "/"
+ (bytevector->base32-string (sha256 (string->utf8
cache-url)))
+ "/" hash-part))))
(define (cached-narinfo cache-url path)
"Check locally if we have valid info about PATH coming from CACHE-URL.
- branch master updated (3c9a718 -> ece6864), Ludovic Courtès, 2016/05/20
- 01/06: graph: Use absolute file name canonicalization., Ludovic Courtès, 2016/05/20
- 04/06: substitute: Gracefully handle invalid store file names.,
Ludovic Courtès <=
- 03/06: graph: Allow store file names for 'derivation' and 'references' graphs., Ludovic Courtès, 2016/05/20
- 05/06: grafts: Preserve empty directories when grafting., Ludovic Courtès, 2016/05/20
- 06/06: grafts: Rename files whose name matches a graft., Ludovic Courtès, 2016/05/20
- 02/06: derivations: 'derivation' sorts items in the resulting object., Ludovic Courtès, 2016/05/20