aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-01-31 14:05:10 +0100
committerLudovic Courtès <ludo@gnu.org>2013-01-31 17:49:54 +0100
commitbbdb3ffaf33cbeb8178457f4c2988aa6f960976c (patch)
treed207b7fa625690f7d8d14aeea0d77c5d251c3952
parent1f73d3b49529df15493061dd9d1e8868666c48f3 (diff)
downloadpatches-bbdb3ffaf33cbeb8178457f4c2988aa6f960976c.tar
patches-bbdb3ffaf33cbeb8178457f4c2988aa6f960976c.tar.gz
store: Don't expect build logs to be UTF-8-encoded.
* guix/store.scm (read-latin1-string): New procedure. (process-stderr): Use it instead of `read-string'. Reported by Andreas Enge <andreas@enge.fr>.
-rw-r--r--guix/store.scm22
1 files changed, 17 insertions, 5 deletions
diff --git a/guix/store.scm b/guix/store.scm
index 668bc9a019..560e5675ec 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -175,6 +175,14 @@
(get-bytevector-n p (- 8 m)))
str))
+(define (read-latin1-string p)
+ (let* ((len (read-int p))
+ (m (modulo len 8))
+ (str (get-string-n p len)))
+ (or (zero? m)
+ (get-bytevector-n p (- 8 m)))
+ str))
+
(define (write-string-list l p)
(write-int (length l) p)
(for-each (cut write-string <> p) l))
@@ -362,7 +370,11 @@ operate, should the disk become full. Return a server object."
"Read standard output and standard error from SERVER, writing it to
CURRENT-BUILD-OUTPUT-PORT. Return #t when SERVER is done sending data, and
#f otherwise; in the latter case, the caller should call `process-stderr'
-again until #t is returned or an error is raised."
+again until #t is returned or an error is raised.
+
+Since the build process's output cannot be assumed to be UTF-8, we
+conservatively consider it to be Latin-1, thereby avoiding possible
+encoding conversion errors."
(define p
(nix-server-socket server))
@@ -375,18 +387,18 @@ again until #t is returned or an error is raised."
(let ((k (read-int p)))
(cond ((= k %stderr-write)
- (read-string p)
+ (read-latin1-string p)
#f)
((= k %stderr-read)
(let ((len (read-int p)))
- (read-string p) ; FIXME: what to do?
+ (read-latin1-string p) ; FIXME: what to do?
#f))
((= k %stderr-next)
- (let ((s (read-string p)))
+ (let ((s (read-latin1-string p)))
(display s (current-build-output-port))
#f))
((= k %stderr-error)
- (let ((error (read-string p))
+ (let ((error (read-latin1-string p))
(status (if (>= (nix-server-minor-version server) 8)
(read-int p)
1)))