From 46b8aadbd6f4673aad27f6425f48a3b3ac5c88dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 7 Feb 2015 23:05:23 +0100 Subject: serialization: Check for EOF and incomplete input conditions. Fixes . Reported by . * guix/serialization.scm (currently-restored-file): New variable. (get-bytevector-n*): New procedure. (read-int, read-long-long, read-string, read-latin1-string, read-contents): Use it instead of 'get-bytevector-n'. (restore-file): Parameterize 'currently-restored-file' and set it. * tests/nar.scm ("restore-file with incomplete input"): New test. --- tests/nar.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/nar.scm') diff --git a/tests/nar.scm b/tests/nar.scm index 38b2482c92..4ccd364861 100644 --- a/tests/nar.scm +++ b/tests/nar.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014 Ludovic Courtès +;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -201,6 +201,15 @@ (lambda () (rm-rf input))))) +(test-equal "restore-file with incomplete input" + (string-append %test-dir "/foo") + (let ((port (open-bytevector-input-port #vu8(1 2 3)))) + (guard (c ((nar-error? c) + (and (eq? port (nar-error-port c)) + (nar-error-file c)))) + (restore-file port (string-append %test-dir "/foo")) + #f))) + (test-assert "write-file + restore-file" (let* ((input (string-append (dirname (search-path %load-path "guix.scm")) "/guix")) -- cgit v1.2.3