Check: can db be read back before writing to disk? - pee - Pee a password manag… | |
git clone git://vernunftzentrum.de/pee.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 88416143f5476e68425e91b6f9dca81f74f837f4 | |
parent 1b06ec6f3c1ccdfb4c3bee842a122b22bdce556c | |
Author: Christian Kellermann <[email protected]> | |
Date: Tue, 12 Jan 2016 13:12:12 +0100 | |
Check: can db be read back before writing to disk? | |
This at least protects the db from being destroyed should we | |
accidentally serialise an object that cannot be read in by read, such | |
as #<unspecified>. | |
Diffstat: | |
pee.scm | 9 +++++++++ | |
1 file changed, 9 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/pee.scm b/pee.scm | |
@@ -123,7 +123,16 @@ | |
(let ((content (with-input-from-file file read-all))) | |
(enc/dec-file content passphrase symmetric-unbox))) | |
+(define (check-content content) | |
+ (condition-case | |
+ (with-input-from-string | |
+ (with-output-to-string | |
+ (lambda () (pp content))) | |
+ read) | |
+ (e () (error "Internal error: Writing of unserialisable object detected."))… | |
+ | |
(define (encrypt-file file content passphrase) | |
+ (check-content content) | |
(let ((cyphertext (enc/dec-file | |
(with-output-to-string (lambda () (pp content))) | |
passphrase |