From 2e21d851e9195a741e9c26d6d69cb22cf8d267d2 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 4 Oct 2002 06:02:14 +0000 Subject: [PATCH] =?UTF-8?q?*=20passphrase.c=20(agent=5Fget=5Fpassphrase):?= =?UTF-8?q?=20Fixed=20signed/unsigned=20char=20problem=20in=20%-escaping.?= =?UTF-8?q?=20=20Noted=20by=20Ingo=20Kl=EF=BF=BDcker.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g10/ChangeLog | 5 +++++ g10/passphrase.c | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 1d566d221..0662a412a 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,8 @@ +2002-10-04 Werner Koch + + * passphrase.c (agent_get_passphrase): Fixed signed/unsigned char + problem in %-escaping. Noted by Ingo Klöcker. + 2002-10-03 David Shaw * keylist.c (print_capabilities): Secret-parts-missing keys should diff --git a/g10/passphrase.c b/g10/passphrase.c index 0da40e3c0..d84d6e88b 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -732,6 +732,7 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text ) else { /* The new Assuan protocol */ char *line, *p; + const unsigned char *s; int i; if (!tryagain_text) @@ -751,33 +752,33 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text ) else *p++ = 'X'; /* no caching */ *p++ = ' '; - for (i=0; tryagain_text[i]; i++) + for (i=0, s=tryagain_text; *s; s++) { - if (tryagain_text[i] < ' ' || tryagain_text[i] == '+') + if (*s < ' ' || *s == '+') { - sprintf (p, "%%%02X", tryagain_text[i]); + sprintf (p, "%%%02X", *s); p += 3; } - else if (tryagain_text[i] == ' ') + else if (*s == ' ') *p++ = '+'; else - *p++ = tryagain_text[i]; + *p++ = *s; } *p++ = ' '; *p++ = 'X'; /* Use the standard prompt */ *p++ = ' '; /* copy description */ - for (i=0; atext[i]; i++) + for (i=0, s= atext; *s; s++) { - if (atext[i] < ' ' || atext[i] == '+') + if (*s < ' ' || *s == '+') { - sprintf (p, "%%%02X", atext[i]); + sprintf (p, "%%%02X", *s); p += 3; } - else if (atext[i] == ' ') + else if (*s == ' ') *p++ = '+'; else - *p++ = atext[i]; + *p++ = *s; } *p++ = '\n'; i = writen (fd, line, p - line);