summaryrefslogtreecommitdiff
path: root/guix/serialization.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-01-10 21:38:08 +0100
committerLudovic Courtès <ludo@gnu.org>2018-01-11 00:00:02 +0100
commit39d1e9654c102339f3d99b0e52a49639182f972b (patch)
tree17158d104e6c2031d36b6b5157abecc1d5707ba0 /guix/serialization.scm
parent17af5d51de7c40756a4a39d336f81681de2ba447 (diff)
downloadgnu-guix-39d1e9654c102339f3d99b0e52a49639182f972b.tar
gnu-guix-39d1e9654c102339f3d99b0e52a49639182f972b.tar.gz
store: Fix potential over-reads in 'import-paths'.
Previously 'process-stderr' would always pass a bytevector of MAX-LEN to then daemon in the %stderr-read case (i.e., 'import-paths'), instead of LEN (where LEN <= MAX-LEN). In practice the extra bytes didn't cause a protocol violation or anything because they happen at the end of the stream, which typically contains the canonical sexp of the signature, and the extra zeros were just ignored. * guix/serialization.scm (write-bytevector): Add optional 'l' parameter and honor it. * guix/store.scm (process-stderr): Pass LEN to 'write-bytevector'.
Diffstat (limited to 'guix/serialization.scm')
-rw-r--r--guix/serialization.scm8
1 files changed, 4 insertions, 4 deletions
diff --git a/guix/serialization.scm b/guix/serialization.scm
index e6ae2fc307..b41a0a09d1 100644
--- a/guix/serialization.scm
+++ b/guix/serialization.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -102,9 +102,9 @@
(or (zero? m)
(put-bytevector p zero 0 (- 8 m)))))))
-(define (write-bytevector s p)
- (let* ((l (bytevector-length s))
- (m (modulo l 8))
+(define* (write-bytevector s p
+ #:optional (l (bytevector-length s)))
+ (let* ((m (modulo l 8))
(b (make-bytevector (+ 8 l (if (zero? m) 0 (- 8 m))))))
(bytevector-u32-set! b 0 l (endianness little))
(bytevector-copy! s 0 b 8 l)