1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-05-24 16:43:28 +02:00

* passphrase.c (ask_passphrase): Unescape the description string.

* cardglue.c (unescape_status_string): Removed.  Changed all
caller to use ...
* misc.c (unescape_percent_string): New.
This commit is contained in:
Werner Koch 2005-05-24 12:39:42 +00:00
parent 2ab2a874a0
commit d0f5655d19
7 changed files with 66 additions and 51 deletions

14
NEWS
View File

@ -8,13 +8,13 @@ Noteworthy changes in version 1.4.2
allows displayin the Private-DO-4 with the "list" command. allows displayin the Private-DO-4 with the "list" command.
* Rewrote large parts of the card code to optionally make use of a * Rewrote large parts of the card code to optionally make use of a
running gpg-agent. If --use-agent is beeing used and a running gpg-agent. If --use-agent is being used and a gpg-agent
gpg-agent with enabled scdaemon is active, gpg will now divert with enabled scdaemon is active, gpg will now divert all card
all card operations to that daemon. This is required because operations to that daemon. This is required because bot,
bot, scdaemon and gpg require exclusive access to the card scdaemon and gpg require exclusive access to the card reader. By
reader. By delegating the work to scdaemon, both can peacefully delegating the work to scdaemon, both can peacefully coexist and
coexist and scdaemon is able to control the use of the reader. scdaemon is able to control the use of the reader. Note that
Note that this requires at least gnupg 1.9.17. this requires at least gnupg 1.9.17.
* Fixed a couple of problems with the card reader. * Fixed a couple of problems with the card reader.

View File

@ -1,5 +1,10 @@
2005-05-24 Werner Koch <wk@g10code.com> 2005-05-24 Werner Koch <wk@g10code.com>
* passphrase.c (ask_passphrase): Unescape the description string.
* cardglue.c (unescape_status_string): Removed. Changed all
caller to use ...
* misc.c (unescape_percent_string): New.
* g10.c (add_notation_data): Check number of at-signs. * g10.c (add_notation_data): Check number of at-signs.
2005-05-23 Werner Koch <wk@g10code.com> 2005-05-23 Werner Koch <wk@g10code.com>

View File

@ -1528,7 +1528,7 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr, int reset_mode,
/* Check whether a key already exists. KEYIDX is the index of the key /* Check whether a key already exists. KEYIDX is the index of the key
(0..2). If FORCE is TRUE a diagnositivc will be printed but no (0..2). If FORCE is TRUE a diagnositic will be printed but no
error returned if the key already exists. */ error returned if the key already exists. */
static gpg_error_t static gpg_error_t
does_key_exist (app_t app, int keyidx, int force) does_key_exist (app_t app, int keyidx, int force)
@ -2134,7 +2134,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo,
{ {
char *prompt; char *prompt;
#define PROMPTSTRING _("PIN [sigs done: %lu]") #define PROMPTSTRING _("||Please enter the PIN%%0A[sigs done: %lu]")
prompt = malloc (strlen (PROMPTSTRING) + 50); prompt = malloc (strlen (PROMPTSTRING) + 50);
if (!prompt) if (!prompt)

View File

@ -540,40 +540,6 @@ check_card_serialno (app_t app, const char *serialno)
} }
/* Return a new malloced string by unescaping the string S. Escaping
is percent escaping and '+'/space mapping. A binary nul will
silently be replaced by a 0xFF. Function returns NULL to indicate
an out of memory status. */
static char *
unescape_status_string (const unsigned char *s)
{
char *buffer, *d;
buffer = d = xmalloc (strlen (s)+1);
while (*s)
{
if (*s == '%' && s[1] && s[2])
{
s++;
*d = xtoi_2 (s);
if (!*d)
*d = '\xff';
d++;
s += 2;
}
else if (*s == '+')
{
*d++ = ' ';
s++;
}
else
*d++ = *s++;
}
*d = 0;
return buffer;
}
/* Take a 20 byte hexencoded string and put it into the the provided /* Take a 20 byte hexencoded string and put it into the the provided
20 byte buffer FPR in binary format. */ 20 byte buffer FPR in binary format. */
static int static int
@ -633,12 +599,12 @@ learn_status_cb (void *opaque, const char *line)
else if (keywordlen == 9 && !memcmp (keyword, "DISP-NAME", keywordlen)) else if (keywordlen == 9 && !memcmp (keyword, "DISP-NAME", keywordlen))
{ {
xfree (parm->disp_name); xfree (parm->disp_name);
parm->disp_name = unescape_status_string (line); parm->disp_name = unescape_percent_string (line);
} }
else if (keywordlen == 9 && !memcmp (keyword, "DISP-LANG", keywordlen)) else if (keywordlen == 9 && !memcmp (keyword, "DISP-LANG", keywordlen))
{ {
xfree (parm->disp_lang); xfree (parm->disp_lang);
parm->disp_lang = unescape_status_string (line); parm->disp_lang = unescape_percent_string (line);
} }
else if (keywordlen == 8 && !memcmp (keyword, "DISP-SEX", keywordlen)) else if (keywordlen == 8 && !memcmp (keyword, "DISP-SEX", keywordlen))
{ {
@ -647,12 +613,12 @@ learn_status_cb (void *opaque, const char *line)
else if (keywordlen == 10 && !memcmp (keyword, "PUBKEY-URL", keywordlen)) else if (keywordlen == 10 && !memcmp (keyword, "PUBKEY-URL", keywordlen))
{ {
xfree (parm->pubkey_url); xfree (parm->pubkey_url);
parm->pubkey_url = unescape_status_string (line); parm->pubkey_url = unescape_percent_string (line);
} }
else if (keywordlen == 10 && !memcmp (keyword, "LOGIN-DATA", keywordlen)) else if (keywordlen == 10 && !memcmp (keyword, "LOGIN-DATA", keywordlen))
{ {
xfree (parm->login_data); xfree (parm->login_data);
parm->login_data = unescape_status_string (line); parm->login_data = unescape_percent_string (line);
} }
else if (keywordlen == 11 && !memcmp (keyword, "SIG-COUNTER", keywordlen)) else if (keywordlen == 11 && !memcmp (keyword, "SIG-COUNTER", keywordlen))
{ {
@ -662,7 +628,7 @@ learn_status_cb (void *opaque, const char *line)
{ {
char *p, *buf; char *p, *buf;
buf = p = unescape_status_string (line); buf = p = unescape_percent_string (line);
if (buf) if (buf)
{ {
while (spacep (p)) while (spacep (p))
@ -739,7 +705,7 @@ learn_status_cb (void *opaque, const char *line)
int no = keyword[11] - '1'; int no = keyword[11] - '1';
assert (no >= 0 && no <= 3); assert (no >= 0 && no <= 3);
xfree (parm->private_do[no]); xfree (parm->private_do[no]);
parm->private_do[no] = unescape_status_string (line); parm->private_do[no] = unescape_percent_string (line);
} }
return 0; return 0;

View File

@ -123,7 +123,7 @@ char *optsep(char **stringp);
char *argsplit(char *string); char *argsplit(char *string);
int parse_options(char *str,unsigned int *options, int parse_options(char *str,unsigned int *options,
struct parse_options *opts,int noisy); struct parse_options *opts,int noisy);
char *unescape_percent_string (const unsigned char *s);
char *default_homedir (void); char *default_homedir (void);

View File

@ -1029,6 +1029,41 @@ parse_options(char *str,unsigned int *options,
} }
/* Return a new malloced string by unescaping the string S. Escaping
is percent escaping and '+'/space mapping. A binary nul will
silently be replaced by a 0xFF. */
char *
unescape_percent_string (const unsigned char *s)
{
char *buffer, *d;
buffer = d = xmalloc (strlen (s)+1);
while (*s)
{
if (*s == '%' && s[1] && s[2])
{
s++;
*d = xtoi_2 (s);
if (!*d)
*d = '\xff';
d++;
s += 2;
}
else if (*s == '+')
{
*d++ = ' ';
s++;
}
else
*d++ = *s++;
}
*d = 0;
return buffer;
}
/* This is a helper function to load a Windows function from either of /* This is a helper function to load a Windows function from either of
one DLLs. */ one DLLs. */
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM

View File

@ -746,7 +746,16 @@ ask_passphrase (const char *description,
*canceled = 0; *canceled = 0;
if (!opt.batch && description) if (!opt.batch && description)
{
if (strchr (description, '%'))
{
char *tmp = unescape_percent_string (description);
tty_printf ("\n%s\n", tmp);
xfree (tmp);
}
else
tty_printf ("\n%s\n",description); tty_printf ("\n%s\n",description);
}
agent_died: agent_died:
if ( opt.use_agent ) if ( opt.use_agent )