[PATCH] scdaemon: Fix status info encoding
David Härdeman
david at hardeman.nu
Sun Nov 13 16:50:02 CET 2016
I've been playing around a bit with private data objects using an OpenPGP
card when I noticed that writing binary data to an object and then reading
it back would sometime alter the data.
Example:
$ echo -n "%41" > binfile
$ od -tx1 binfile
0000000 25 34 31
0000003
$ gpg --card-edit
....
gpg/card> privatedo 1 < binfile
gpg/card> verify
...
Private DO 1 .....: A
Last line should have been:
Private DO 1 .....: %41
Turns out that scdaemon does not properly escape the '%' character, meaning
that gpg-agent and gpg parse the unescaped '%' character.
Signed-off-by: David Härdeman <david at hardeman.nu>
---
scd/command.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scd/command.c b/scd/command.c
index 3584593..a1fa060 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -2137,7 +2137,7 @@ send_status_info (ctrl_t ctrl, const char *keyword, ...)
}
for ( ; valuelen && n < DIM (buf)-2; n++, valuelen--, value++)
{
- if (*value < ' ' || *value == '+')
+ if (*value < ' ' || *value == '+' || *value == '%')
{
sprintf (p, "%%%02X", *value);
p += 3;
More information about the Gnupg-devel
mailing list