diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-04-22 01:36:31 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-04-22 01:39:31 +0200 |
commit | 6030d8493e13af81be63c3cee530d44b4dff1ad6 (patch) | |
tree | 2d0760d036839dd31647d35517c80040be4fabcb /guix/pk-crypto.scm | |
parent | 50db7d82b3f3ab8ec382132b06a1400c0044b89e (diff) | |
download | gnu-guix-6030d8493e13af81be63c3cee530d44b4dff1ad6.tar gnu-guix-6030d8493e13af81be63c3cee530d44b4dff1ad6.tar.gz |
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.
Diffstat (limited to 'guix/pk-crypto.scm')
-rw-r--r-- | guix/pk-crypto.scm | 7 |
1 files changed, 6 insertions, 1 deletions
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)))))) |