[Pkg-gnupg-commit] [gpgme] 77/132: python: Fix passphrase callback wrapping.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Apr 26 01:01:27 UTC 2017


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch experimental
in repository gpgme.

commit 3bdce4aa3ddd4a3f55b24678faf978d61daa8909
Author: Justus Winter <justus at g10code.com>
Date:   Thu Feb 16 14:49:27 2017 +0100

    python: Fix passphrase callback wrapping.
    
    * lang/python/helpers.c (pyPassphraseCb): Cope with 'passphrase_info'
    being NULL.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 lang/python/helpers.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lang/python/helpers.c b/lang/python/helpers.c
index 576767c..947819d 100644
--- a/lang/python/helpers.c
+++ b/lang/python/helpers.c
@@ -377,7 +377,21 @@ static gpgme_error_t pyPassphraseCb(void *hook,
     goto leave;
   }
 
-  PyTuple_SetItem(args, 1, PyBytes_FromString(passphrase_info));
+  if (passphrase_info == NULL)
+    {
+      Py_INCREF(Py_None);
+      PyTuple_SetItem(args, 1, Py_None);
+    }
+  else
+    PyTuple_SetItem(args, 1, PyUnicode_DecodeUTF8(passphrase_info,
+                                                  strlen (passphrase_info),
+                                                  "strict"));
+  if (PyErr_Occurred()) {
+    Py_DECREF(args);
+    err_status = gpg_error(GPG_ERR_GENERAL);
+    goto leave;
+  }
+
   PyTuple_SetItem(args, 2, PyBool_FromLong((long)prev_was_bad));
   if (dataarg) {
     Py_INCREF(dataarg);		/* Because GetItem doesn't give a ref but SetItem taketh away */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git



More information about the Pkg-gnupg-commit mailing list