From 6030d8493e13af81be63c3cee530d44b4dff1ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 22 Apr 2014 01:36:31 +0200 Subject: pk-crypto: Use ISO-8859-1 for strings passed to 'gcry_sexp_new'. * guix/pk-crypto.scm (string->canonical-sexp): Pass "ISO-8859-1" as the 2nd argument to 'string->pointer'. * tests/pk-crypto.scm ("version"): New test. ("hash corrupt due to restrictive locale encoding"): New test. --- guix/pk-crypto.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/pk-crypto.scm b/guix/pk-crypto.scm index 481d3f2463..351bf929c5 100644 --- a/guix/pk-crypto.scm +++ b/guix/pk-crypto.scm @@ -134,8 +134,13 @@ thrown along with 'gcry-error'." (proc (pointer->procedure int ptr `(* * ,size_t ,int)))) (lambda (str) "Parse STR and return the corresponding gcrypt s-expression." + + ;; When STR comes from 'canonical-sexp->string', it may contain + ;; characters that are really meant to be interpreted as bytes as in a C + ;; 'char *'. Thus, convert STR to ISO-8859-1 so the byte values of the + ;; characters are preserved. (let* ((sexp (bytevector->pointer (make-bytevector (sizeof '*)))) - (err (proc sexp (string->pointer str) 0 1))) + (err (proc sexp (string->pointer str "ISO-8859-1") 0 1))) (if (= 0 err) (pointer->canonical-sexp (dereference-pointer sexp)) (throw 'gcry-error err)))))) -- cgit v1.2.3