From 8a2105078b5845e31768da06b360676352b1f3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 2 May 2017 12:28:23 +0200 Subject: [PATCH] substitute: Validate substitute URLs. Reported by Maxim Cournoyer at . * guix/scripts/substitute.scm (validate-uri): New procedure. (guix-substitute): Use it. --- guix/scripts/substitute.scm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 748c334e3c..b4e913a880 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -980,6 +980,10 @@ (define (client-terminal-columns) (and number (max 20 (- number 1)))))) 80)) +(define (validate-uri uri) + (unless (string->uri uri) + (leave (_ "~a: invalid URI~%") uri))) + (define (guix-substitute . args) "Implement the build daemon's substituter protocol." (mkdir-p %narinfo-cache-directory) @@ -1001,6 +1005,9 @@ (define (guix-substitute . args) (newline) (force-output (current-output-port)) + ;; Sanity-check %CACHE-URLS so we can provide a meaningful error message. + (for-each validate-uri %cache-urls) + ;; Attempt to install the client's locale, mostly so that messages are ;; suitably translated. (match (or (find-daemon-option "untrusted-locale")