missing hexstrint->plaintext conversion
Kiss Gabor (Bitman)
kissg at ssg.ki.iif.hu
Tue Aug 26 17:48:50 CEST 2008
Dear Werner et al.,
At 2006-07-29 (svn revision 4209) gpg-preset-passphrases was changed
in order to send passphrases as hexstring.
Unfortunately the receiver side did not follow this change well.
Received hexstring is cached without converting back to plaintext.
This patch below fixes the problem.
Regards
Gabor
--- command.c-orig 2008-08-26 14:43:16.037456000 +0200
+++ command.c 2008-08-26 17:44:36.935945453 +0200
@@ -263,6 +263,28 @@
return 0;
}
+/* Convert (in place) an already parsed hexstring of
+ * 'len' digits to native bytes. */
+#define fromhex(h) ( (h)<='9' ? (h)-'0' : ((h)|0x20)-'a'+10 )
+static char *
+decode_hexstring (char *string, int len)
+{
+ unsigned char *from, *to;
+
+ for (from=to=(unsigned char*)string; len>0; to++)
+ {
+ unsigned char value;
+ value = fromhex(*from);
+ from++;
+ value <<= 4;
+ value |= fromhex(*from);
+ from++;
+ *to = value;
+ len -= 2;
+ }
+ return string;
+}
+
/* Parse the keygrip in STRING into the provided buffer BUF. BUF must
provide space for 20 bytes. BUF is not changed if the function
returns an error. */
@@ -1135,7 +1157,10 @@
/* If there is a passphrase, use it. Currently, a passphrase is
required. */
if (*line)
- passphrase = line;
+ {
+ passphrase = decode_hexstring(line, len);
+ passphrase[len/2] = '\0';
+ }
else
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
More information about the Gnupg-devel
mailing list