summaryrefslogtreecommitdiff
path: root/extra/gnome-keyring/gpg-agent-fix-encoding.patch
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2012-08-03 00:01:47 +0000
committerroot <root@rshg054.dnsready.net>2012-08-03 00:01:47 +0000
commit92bafb5f0efc526b1f83cd5fb9460443c4b13dca (patch)
treea762a2b1551bff9d77cf7a44a75f915fb074c1a2 /extra/gnome-keyring/gpg-agent-fix-encoding.patch
parentf003ac1c96d76f4e3a2b93f988e1effce6771052 (diff)
Fri Aug 3 00:01:47 UTC 2012
Diffstat (limited to 'extra/gnome-keyring/gpg-agent-fix-encoding.patch')
-rw-r--r--extra/gnome-keyring/gpg-agent-fix-encoding.patch86
1 files changed, 86 insertions, 0 deletions
diff --git a/extra/gnome-keyring/gpg-agent-fix-encoding.patch b/extra/gnome-keyring/gpg-agent-fix-encoding.patch
new file mode 100644
index 000000000..e6a7412b3
--- /dev/null
+++ b/extra/gnome-keyring/gpg-agent-fix-encoding.patch
@@ -0,0 +1,86 @@
+From d31a26df7ce8d9c084b9c66fe00458683dde9864 Mon Sep 17 00:00:00 2001
+From: Stef Walter <stefw@gnome.org>
+Date: Thu, 28 Jun 2012 15:51:54 +0200
+Subject: [PATCH] gpg-agent: Encode passwords when --data was requested
+
+ * Use URI encoding to return passwords when gnupg calls us with
+ a --data argument.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=678771
+---
+ daemon/gpg-agent/gkd-gpg-agent-ops.c | 41 ++++++++++++++++++++++++++++++----
+ 1 file changed, 37 insertions(+), 4 deletions(-)
+
+diff --git a/daemon/gpg-agent/gkd-gpg-agent-ops.c b/daemon/gpg-agent/gkd-gpg-agent-ops.c
+index be6c4d3..a1a21ff 100644
+--- a/daemon/gpg-agent/gkd-gpg-agent-ops.c
++++ b/daemon/gpg-agent/gkd-gpg-agent-ops.c
+@@ -632,11 +632,12 @@ command_has_option (gchar *command, gchar *option)
+ return has_option;
+ }
+
++static const char HEXC[] = "0123456789abcdef";
++
+ /* Encode a password in hex */
+ static gchar*
+-encode_password (const gchar *pass)
++hex_encode_password (const gchar *pass)
+ {
+- static const char HEXC[] = "0123456789abcdef";
+ int j, c;
+ gchar *enc, *k;
+
+@@ -656,6 +657,36 @@ encode_password (const gchar *pass)
+ return enc;
+ }
+
++static gchar*
++uri_encode_password (const gchar *value)
++{
++ gchar *p;
++ gchar *result;
++
++ /* Just allocate for worst case */
++ result = egg_secure_alloc ((strlen (value) * 3) + 1);
++
++ /* Now loop through looking for escapes */
++ p = result;
++ while (*value) {
++
++ /* These characters we let through verbatim */
++ if (*value && (g_ascii_isalnum (*value) || strchr ("_-.", *value) != NULL)) {
++ *(p++) = *(value++);
++
++ /* All others get encoded */
++ } else {
++ *(p++) = '%';
++ *(p++) = HEXC[((unsigned char)*value) >> 4];
++ *(p++) = HEXC[((unsigned char)*value) & 0x0F];
++ ++value;
++ }
++ }
++
++ *p = 0;
++ return result;
++}
++
+ /* ----------------------------------------------------------------------------------
+ * OPERATIONS
+ */
+@@ -737,10 +768,12 @@ gkd_gpg_agent_ops_getpass (GkdGpgAgentCall *call, gchar *args)
+ if (password == NULL) {
+ gkd_gpg_agent_send_reply (call, FALSE, "111 cancelled");
+ } else if (flags & GKD_GPG_AGENT_PASS_AS_DATA) {
+- gkd_gpg_agent_send_data (call, password);
++ encoded = uri_encode_password (password);
++ gkd_gpg_agent_send_data (call, encoded);
+ gkd_gpg_agent_send_reply (call, TRUE, NULL);
++ egg_secure_strfree (encoded);
+ } else {
+- encoded = encode_password (password);
++ encoded = hex_encode_password (password);
+ gkd_gpg_agent_send_reply (call, TRUE, encoded);
+ egg_secure_strfree (encoded);
+ }
+--
+1.7.10.2 \ No newline at end of file