[Pkg-gnupg-commit] [gpgme] 08/10: cherry-pick bugfixes from upstream

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Dec 4 23:19:09 UTC 2017


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

dkg pushed a commit to branch master
in repository gpgme.

commit e58062dad1429c744c19dbfdcf66a36d15892cb1
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date:   Mon Dec 4 17:46:19 2017 -0500

    cherry-pick bugfixes from upstream
---
 ...-qt-Fix-IODeviceDataProvider-with-Process.patch |  33 ++++
 ...-missing-variable-to-gpgsm-tests-Makefile.patch |  28 ++++
 .../0053-Fix-uid-parsing-for-ldap-keyserver.patch  |  52 ++++++
 ...ault-whence-argument-for-Data-to-SEEK_SET.patch |  54 +++++++
 ...heck-for-a-failed-selftest-in-gpgm_data_n.patch | 176 +++++++++++++++++++++
 debian/patches/series                              |   5 +
 6 files changed, 348 insertions(+)

diff --git a/debian/patches/0051-qt-Fix-IODeviceDataProvider-with-Process.patch b/debian/patches/0051-qt-Fix-IODeviceDataProvider-with-Process.patch
new file mode 100644
index 0000000..e2681b2
--- /dev/null
+++ b/debian/patches/0051-qt-Fix-IODeviceDataProvider-with-Process.patch
@@ -0,0 +1,33 @@
+From: Andre Heinecke <aheinecke at intevation.de>
+Date: Tue, 14 Nov 2017 14:28:32 +0100
+Subject: qt: Fix IODeviceDataProvider with Process
+
+* lang/qt/src/dataprovider.cpp (blocking_read): Keep
+reading if process is not atEnd.
+
+--
+This fixes a regression in Kleopatra that uses this dataprovider
+to chain the gpgtar process to the encryption / signing.
+
+(cherry picked from commit 56b27b21d5f8dd95b9d6415c5e98b821774f3093)
+---
+ lang/qt/src/dataprovider.cpp | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/lang/qt/src/dataprovider.cpp b/lang/qt/src/dataprovider.cpp
+index 8385686..124f591 100644
+--- a/lang/qt/src/dataprovider.cpp
++++ b/lang/qt/src/dataprovider.cpp
+@@ -184,7 +184,11 @@ static qint64 blocking_read(const std::shared_ptr<QIODevice> &io, char *buffer,
+                 if (p->error() == QProcess::UnknownError &&
+                         p->exitStatus() == QProcess::NormalExit &&
+                         p->exitCode() == 0) {
+-                    return 0;
++                    if (io->atEnd()) {
++                        // EOF
++                        return 0;
++                    } // continue reading even if process ended to ensure
++                      // everything is read.
+                 } else {
+                     Error::setSystemError(GPG_ERR_EIO);
+                     return -1;
diff --git a/debian/patches/0052-tests-Add-missing-variable-to-gpgsm-tests-Makefile.patch b/debian/patches/0052-tests-Add-missing-variable-to-gpgsm-tests-Makefile.patch
new file mode 100644
index 0000000..b1250a4
--- /dev/null
+++ b/debian/patches/0052-tests-Add-missing-variable-to-gpgsm-tests-Makefile.patch
@@ -0,0 +1,28 @@
+From: Werner Koch <wk at gnupg.org>
+Date: Thu, 30 Nov 2017 09:49:38 +0100
+Subject: tests: Add missing variable to gpgsm tests Makefile
+
+* tests/gpgsm/Makefile.am (GPG_AGENT): Set var.  It is used later.
+--
+
+Note that the var is used by the gpgsm.conf target.
+
+Reported-by: Alon Bar-Lev <alon.barlev at gmail.com>
+Signed-off-by: Werner Koch <wk at gnupg.org>
+(cherry picked from commit f43016500774ab82f222249202bda6c463aaf63f)
+---
+ tests/gpgsm/Makefile.am | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/tests/gpgsm/Makefile.am b/tests/gpgsm/Makefile.am
+index 274ba9d..02983b9 100644
+--- a/tests/gpgsm/Makefile.am
++++ b/tests/gpgsm/Makefile.am
+@@ -20,6 +20,7 @@
+ ## Process this file with automake to produce Makefile.in
+ 
+ GPGSM = gpgsm
++GPG_AGENT = gpg-agent
+ 
+ TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) LC_ALL=C GPG_AGENT_INFO= \
+                     top_srcdir=$(top_srcdir)
diff --git a/debian/patches/0053-Fix-uid-parsing-for-ldap-keyserver.patch b/debian/patches/0053-Fix-uid-parsing-for-ldap-keyserver.patch
new file mode 100644
index 0000000..b6b8061
--- /dev/null
+++ b/debian/patches/0053-Fix-uid-parsing-for-ldap-keyserver.patch
@@ -0,0 +1,52 @@
+From: Andre Heinecke <aheinecke at intevation.de>
+Date: Fri, 1 Dec 2017 09:44:47 +0100
+Subject: Fix uid parsing for ldap keyserver
+
+* src/engine-gpg.c (gpg_keylist_preprocess): Check field count
+for uid and add fallback.
+
+--
+This fixes accessing unintialized memory and resulting
+crashes in gpgrt_asprintf.
+
+GnuPG-Bug-Id: T3550
+(cherry picked from commit 651b3d8207cc7d85699f89fc4c21cb1243453aa8)
+---
+ src/engine-gpg.c | 17 ++++++++++++++---
+ 1 file changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/src/engine-gpg.c b/src/engine-gpg.c
+index 0c3a63e..2bdf611 100644
+--- a/src/engine-gpg.c
++++ b/src/engine-gpg.c
+@@ -2585,6 +2585,9 @@ gpg_keylist_preprocess (char *line, char **r_line)
+ 	 as defined in 5.2. Machine Readable Indexes of the OpenPGP
+ 	 HTTP Keyserver Protocol (draft).
+ 
++         For an ldap keyserver the format is:
++         uid:<escaped uid string>
++
+ 	 We want:
+ 	 uid:o<flags>::::<creatdate>:<expdate>:::<c-coded uid>:
+       */
+@@ -2626,9 +2629,17 @@ gpg_keylist_preprocess (char *line, char **r_line)
+ 	  }
+ 	*dst = '\0';
+ 
+-	if (gpgrt_asprintf (r_line, "uid:o%s::::%s:%s:::%s:",
+-		      field[4], field[2], field[3], uid) < 0)
+-	  return gpg_error_from_syserror ();
++        if (fields < 4)
++          {
++            if (gpgrt_asprintf (r_line, "uid:o::::::::%s:", uid) < 0)
++              return gpg_error_from_syserror ();
++          }
++        else
++          {
++            if (gpgrt_asprintf (r_line, "uid:o%s::::%s:%s:::%s:",
++                                field[4], field[2], field[3], uid) < 0)
++              return gpg_error_from_syserror ();
++          }
+       }
+       return 0;
+ 
diff --git a/debian/patches/0054-python-Default-whence-argument-for-Data-to-SEEK_SET.patch b/debian/patches/0054-python-Default-whence-argument-for-Data-to-SEEK_SET.patch
new file mode 100644
index 0000000..cc1836d
--- /dev/null
+++ b/debian/patches/0054-python-Default-whence-argument-for-Data-to-SEEK_SET.patch
@@ -0,0 +1,54 @@
+From: Tobias Mueller <muelli at cryptobitch.de>
+Date: Tue, 22 Aug 2017 17:48:25 +0200
+Subject: python: Default whence argument for Data() to SEEK_SET.
+
+* lang/python/gpgme.i: copied signature from gpgme.h and defaulted the
+value to SEEK_SET.
+* lang/python/tests/t-data.py: Added a test for no second argument
+--
+
+Having to import the os package when wanting to read a Data object is a
+slight annoyance. With SWIG, we can define default parameters. This
+change defaults the whence argument to SEEK_SET which is how StringIO
+and BytesIO behave.
+
+Signed-off-by: Tobias Mueller <muelli at cryptobitch.de>
+(cherry picked from commit 3cf9aedc92b6c65d2cb34037e52b9a299637d03b)
+---
+ lang/python/gpgme.i         | 5 +++++
+ lang/python/tests/t-data.py | 6 ++++++
+ 2 files changed, 11 insertions(+)
+
+diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
+index 610b3d9..492326b 100644
+--- a/lang/python/gpgme.i
++++ b/lang/python/gpgme.i
+@@ -557,6 +557,11 @@ gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx,
+                       const char *pattern="",
+                       int secret_only=0);
+ 
++/* The whence argument is surprising in Python-land,
++   because BytesIO or StringIO objects do not require it.
++   It defaults to SEEK_SET. Let's do that for Data objects, too */
++off_t gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence=SEEK_SET);
++
+ /* Include the unmodified <gpgme.h> for cc, and the cleaned-up local
+    version for SWIG.  We do, however, want to hide certain fields on
+    some structs, which we provide prior to including the version for
+diff --git a/lang/python/tests/t-data.py b/lang/python/tests/t-data.py
+index d1facd4..700ab40 100755
+--- a/lang/python/tests/t-data.py
++++ b/lang/python/tests/t-data.py
+@@ -49,6 +49,12 @@ data.write(b'Hello world!')
+ data.seek(0, os.SEEK_SET)
+ assert data.read() == b'Hello world!'
+ 
++data = gpg.Data()
++data.write(b'Hello world!')
++# We expect the second argument to default to SEEK_SET
++data.seek(0)
++assert data.read() == b'Hello world!'
++
+ binjunk = bytes(range(256))
+ data = gpg.Data()
+ data.write(binjunk)
diff --git a/debian/patches/0055-core-Also-check-for-a-failed-selftest-in-gpgm_data_n.patch b/debian/patches/0055-core-Also-check-for-a-failed-selftest-in-gpgm_data_n.patch
new file mode 100644
index 0000000..54b8db6
--- /dev/null
+++ b/debian/patches/0055-core-Also-check-for-a-failed-selftest-in-gpgm_data_n.patch
@@ -0,0 +1,176 @@
+From: Werner Koch <wk at gnupg.org>
+Date: Mon, 4 Dec 2017 12:08:31 +0100
+Subject: core: Also check for a failed selftest in gpgm_data_new.
+
+* src/data.c (_gpgme_data_new): Check for failed selftest.
+* tests/run-support.h (make_filename): Print a message on mallooc
+failure.
+(init_gpgme_basic): New.
+* tests/run-identify.c (main): Call init_gpgme_basic becuase we do not
+need to setup a protocol.
+* tests/t-data.c: Define PGM and include run-support.h.
+(make_filename): Remove.
+(main): Call init_gpgme_basic.
+--
+
+Note: This patch may break applications which used gpgme_data but no
+gpgme_new without having called the required gpgme_check_version.
+
+GPGME can be used without a protocol for example to work with the data
+object abstraction.  Thus a call to gpgme_data_new also needs to check
+the result of the core selftests - including on whether
+gpgme_check_version has been called.
+
+Signed-off-by: Werner Koch <wk at gnupg.org>
+(cherry picked from commit 0c1244a2b7e30ab0610ae70166e1b5d0219782c3)
+---
+ doc/gpgme.texi       |  7 ++++---
+ src/data.c           |  4 ++++
+ tests/run-identify.c |  2 +-
+ tests/run-support.h  | 18 ++++++++++++++----
+ tests/t-data.c       | 27 +++++----------------------
+ 5 files changed, 28 insertions(+), 30 deletions(-)
+
+diff --git a/doc/gpgme.texi b/doc/gpgme.texi
+index 4829426..fe4d80c 100644
+--- a/doc/gpgme.texi
++++ b/doc/gpgme.texi
+@@ -678,9 +678,10 @@ uses, this function provides a run-time check if the necessary
+ features are provided by the installed version of the library.
+ 
+ If a selftest fails, the function may still succeed.  Selftest errors
+-are returned later when invoking @code{gpgme_new}, so that a detailed
+-error code can be returned (historically, @code{gpgme_check_version}
+-does not return a detailed error code).
++are returned later when invoking @code{gpgme_new} or
++ at code{gpgme-data_new}, so that a detailed error code can be returned
++(historically, @code{gpgme_check_version} does not return a detailed
++error code).
+ @end deftypefun
+ 
+ 
+diff --git a/src/data.c b/src/data.c
+index e4e9ee3..7ae5b32 100644
+--- a/src/data.c
++++ b/src/data.c
+@@ -46,6 +46,10 @@ _gpgme_data_new (gpgme_data_t *r_dh, struct _gpgme_data_cbs *cbs)
+     return gpg_error (GPG_ERR_INV_VALUE);
+ 
+   *r_dh = NULL;
++
++  if (_gpgme_selftest)
++    return _gpgme_selftest;
++
+   dh = calloc (1, sizeof (*dh));
+   if (!dh)
+     return gpg_error_from_syserror ();
+diff --git a/tests/run-identify.c b/tests/run-identify.c
+index 01e9671..9361fa2 100644
+--- a/tests/run-identify.c
++++ b/tests/run-identify.c
+@@ -102,7 +102,7 @@ main (int argc, char **argv)
+ 
+     }
+ 
+-  init_gpgme (GPGME_PROTOCOL_OpenPGP);
++  init_gpgme_basic ();
+ 
+   for (; argc; argc--, argv++)
+     {
+diff --git a/tests/run-support.h b/tests/run-support.h
+index 841b223..6a2170b 100644
+--- a/tests/run-support.h
++++ b/tests/run-support.h
+@@ -107,7 +107,11 @@ make_filename (const char *fname)
+     srcdir = ".";
+   buf = malloc (strlen(srcdir) + strlen(fname) + 2);
+   if (!buf)
+-    exit (8);
++    {
++      fprintf (stderr, "%s:%d: could not allocate string: %s\n",
++	       __FILE__, __LINE__, strerror (errno));
++      exit (8);
++    }
+   strcpy (buf, srcdir);
+   strcat (buf, "/");
+   strcat (buf, fname);
+@@ -116,17 +120,23 @@ make_filename (const char *fname)
+ 
+ 
+ void
+-init_gpgme (gpgme_protocol_t proto)
++init_gpgme_basic (void)
+ {
+-  gpgme_error_t err;
+-
+   gpgme_check_version (NULL);
+   setlocale (LC_ALL, "");
+   gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
+ #ifndef HAVE_W32_SYSTEM
+   gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));
+ #endif
++}
++
++
++void
++init_gpgme (gpgme_protocol_t proto)
++{
++  gpg_error_t err;
+ 
++  init_gpgme_basic ();
+   err = gpgme_engine_check_version (proto);
+   fail_if_err (err);
+ }
+diff --git a/tests/t-data.c b/tests/t-data.c
+index fe2d59e..c214de7 100644
+--- a/tests/t-data.c
++++ b/tests/t-data.c
+@@ -30,8 +30,10 @@
+ #include <string.h>
+ #include <errno.h>
+ 
+-#include <gpgme.h>
++#define PGM "t-data"
++#include "run-support.h"
+ 
++#undef fail_if_err
+ #define fail_if_err(a) do { if(a) {                                          \
+                                fprintf (stderr, "%s:%d: (%i) gpgme_error_t " \
+                                 "%s\n", __FILE__, __LINE__, round,           \
+@@ -39,27 +41,6 @@
+                                 exit (1); }                                  \
+                              } while(0)
+ 
+-static char *
+-make_filename (const char *fname)
+-{
+-  const char *srcdir = getenv ("srcdir");
+-  char *buf;
+-
+-  if (!srcdir)
+-    srcdir = ".";
+-  buf = malloc (strlen(srcdir) + strlen(fname) + 2 );
+-  if (!buf)
+-    {
+-      fprintf (stderr, "%s:%d: could not allocate string: %s\n",
+-	       __FILE__, __LINE__, strerror (errno));
+-      exit (1);
+-    }
+-  strcpy (buf, srcdir);
+-  strcat (buf, "/");
+-  strcat (buf, fname);
+-  return buf;
+-}
+-
+ typedef enum
+   {
+     TEST_INITIALIZER,
+@@ -203,6 +184,8 @@ main (void)
+   gpgme_error_t err = 0;
+   gpgme_data_t data;
+ 
++  init_gpgme_basic ();
++
+   while (++round)
+     {
+       switch (round)
diff --git a/debian/patches/series b/debian/patches/series
index ea00533..6702520 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -48,3 +48,8 @@
 0049-core-Restore-get_max_fds-optimization-on-Linux.patch
 0050-core-Allow-disabling-the-use-of-SYS_getdents-for-Lin.patch
 0051-core-use-getdents64-syscall-on-linux-instead-of-getd.patch
+0051-qt-Fix-IODeviceDataProvider-with-Process.patch
+0052-tests-Add-missing-variable-to-gpgsm-tests-Makefile.patch
+0053-Fix-uid-parsing-for-ldap-keyserver.patch
+0054-python-Default-whence-argument-for-Data-to-SEEK_SET.patch
+0055-core-Also-check-for-a-failed-selftest-in-gpgm_data_n.patch

-- 
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