Package: gnupg2 / 2.0.26-6+deb8u2

0002-gpg-Allow-for-positional-parameters-in-the-passphras.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From c45b9819e8f4b35681c91ffb67abdc38dcc32a2a Mon Sep 17 00:00:00 2001
From: Werner Koch <wk@gnupg.org>
Date: Tue, 26 Aug 2014 10:16:04 +0200
Subject: [PATCH 02/31] gpg: Allow for positional parameters in the passphrase
 prompt.

* g10/passphrase.c (passphrase_get): Replace sprintf by xasprintf.
--

Without that at least the French translation does not always work
because it requires positional parameters.  Windows for example does
not support them as they are not defined by C99 but by POSIX.
---
 g10/passphrase.c | 35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/g10/passphrase.c b/g10/passphrase.c
index 9752718..54caf72 100644
--- a/g10/passphrase.c
+++ b/g10/passphrase.c
@@ -341,38 +341,27 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid, int repeat,
       if ( !algo_name )
         algo_name = "?";
 
-#define KEYIDSTRING _(" (main key ID %s)")
-
-      maink = xmalloc ( strlen (KEYIDSTRING) + keystrlen() + 20 );
-      if( keyid[2] && keyid[3] && keyid[0] != keyid[2]
+      if (keyid[2] && keyid[3]
+          && keyid[0] != keyid[2]
           && keyid[1] != keyid[3] )
-        sprintf( maink, KEYIDSTRING, keystr(&keyid[2]) );
+        maink = xasprintf (_(" (main key ID %s)"), keystr (&keyid[2]));
       else
-        *maink = 0;
+        maink = xstrdup ("");
 
       uid = get_user_id ( keyid, &uidlen );
       timestr = strtimestamp (pk->timestamp);
 
-#undef KEYIDSTRING
-
-#define PROMPTSTRING _("Please enter the passphrase to unlock the" \
-		       " secret key for the OpenPGP certificate:\n" \
-		       "\"%.*s\"\n" \
-		       "%u-bit %s key, ID %s,\n" \
-                       "created %s%s.\n" )
-
-      atext = xmalloc ( 100 + strlen (PROMPTSTRING)
-                        + uidlen + 15 + strlen(algo_name) + keystrlen()
-                        + strlen (timestr) + strlen (maink) );
-      sprintf (atext, PROMPTSTRING,
-               (int)uidlen, uid,
-               nbits_from_pk (pk), algo_name, keystr(&keyid[0]), timestr,
-               maink  );
+      atext = xasprintf (_("Please enter the passphrase to unlock the"
+                           " secret key for the OpenPGP certificate:\n"
+                           "\"%.*s\"\n"
+                           "%u-bit %s key, ID %s,\n"
+                           "created %s%s.\n"),
+                         (int)uidlen, uid,
+                         nbits_from_pk (pk), algo_name, keystr(&keyid[0]),
+                         timestr, maink);
       xfree (uid);
       xfree (maink);
 
-#undef PROMPTSTRING
-
       {
         size_t dummy;
         fingerprint_from_pk( pk, fpr, &dummy );
-- 
2.1.4