import gpgme-1.13.1-3.el8
This commit is contained in:
parent
10f5c47d98
commit
f3bf39d3f4
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
SOURCES/gpgme-1.10.0.tar.bz2
|
||||
SOURCES/gpgme-1.13.1.tar.bz2
|
||||
|
@ -1 +1 @@
|
||||
77d3390887da25ed70b7ac04392360efbdca501f SOURCES/gpgme-1.10.0.tar.bz2
|
||||
f87f34e695e8d74ccc7c8f42864d50630afebb0e SOURCES/gpgme-1.13.1.tar.bz2
|
||||
|
@ -1,47 +0,0 @@
|
||||
From b99502274ae5efdf6df0d967900ec3d1e64373d7 Mon Sep 17 00:00:00 2001
|
||||
From: Werner Koch <wk@gnupg.org>
|
||||
Date: Thu, 12 Apr 2018 20:36:30 +0200
|
||||
Subject: [PATCH] core: Tweak STATUS_FAILURE handling.
|
||||
|
||||
* src/op-support.c (_gpgme_parse_failure): Ignore failures with
|
||||
location "gpg-exit".
|
||||
* tests/gpg/t-verify.c (main): Adjust for the now working checking of
|
||||
the second key.
|
||||
|
||||
Signed-off-by: Werner Koch <wk@gnupg.org>
|
||||
---
|
||||
src/op-support.c | 10 +++++++++-
|
||||
tests/gpg/t-verify.c | 8 +++++---
|
||||
2 files changed, 14 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/op-support.c b/src/op-support.c
|
||||
index 43cb1c76..e55875f9 100644
|
||||
--- a/src/op-support.c
|
||||
+++ b/src/op-support.c
|
||||
@@ -400,7 +400,13 @@ _gpgme_parse_plaintext (char *args, char **filenamep)
|
||||
|
||||
|
||||
/* Parse a FAILURE status line and return the error code. ARGS is
|
||||
- modified to contain the location part. */
|
||||
+ * modified to contain the location part. Note that for now we ignore
|
||||
+ * failure codes with a location of gpg-exit; they are too trouble
|
||||
+ * some. Instead we should eventually record that error in the
|
||||
+ * context and provide a function to return a fuller error
|
||||
+ * description; this could then also show the location of the error
|
||||
+ * (e.g. "option- parser") to make it easier for the user to detect
|
||||
+ * the actual error. */
|
||||
gpgme_error_t
|
||||
_gpgme_parse_failure (char *args)
|
||||
{
|
||||
@@ -418,6 +424,8 @@ _gpgme_parse_failure (char *args)
|
||||
*where = '\0';
|
||||
|
||||
where = args;
|
||||
+ if (!strcmp (where, "gpg-exit"))
|
||||
+ return 0;
|
||||
|
||||
return atoi (which);
|
||||
}
|
||||
--
|
||||
2.14.3
|
||||
|
@ -1,901 +0,0 @@
|
||||
diff -Naur a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
|
||||
--- a/lang/cpp/src/context.cpp 2018-11-12 13:57:39.922527452 +0100
|
||||
+++ b/lang/cpp/src/context.cpp 2018-11-14 13:22:37.402101541 +0100
|
||||
@@ -222,6 +222,7 @@
|
||||
}
|
||||
break;
|
||||
default:
|
||||
+ gpgme_release(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -267,6 +268,7 @@
|
||||
}
|
||||
break;
|
||||
default:
|
||||
+ gpgme_release(ctx);
|
||||
if (error) {
|
||||
*error = Error::fromCode(GPG_ERR_INV_ARG);
|
||||
}
|
||||
diff -Naur a/lang/cpp/src/data.cpp b/lang/cpp/src/data.cpp
|
||||
--- a/lang/cpp/src/data.cpp 2018-11-12 13:57:39.925527381 +0100
|
||||
+++ b/lang/cpp/src/data.cpp 2018-11-14 13:29:09.167961419 +0100
|
||||
@@ -244,6 +244,7 @@
|
||||
}
|
||||
|
||||
if (gpgme_op_keylist_from_data_start (ctx->impl()->ctx, d->data, 0)) {
|
||||
+ delete ctx;
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff -Naur a/lang/python/gpgme.i b/lang/python/gpgme.i
|
||||
--- a/lang/python/gpgme.i 2018-11-12 13:57:39.842529333 +0100
|
||||
+++ b/lang/python/gpgme.i 2018-11-14 13:04:00.404376027 +0100
|
||||
@@ -43,7 +43,7 @@
|
||||
{
|
||||
encodedInput = PyUnicode_AsUTF8String($input);
|
||||
if (encodedInput == NULL)
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
$1 = PyBytes_AsString(encodedInput);
|
||||
}
|
||||
else if (PyBytes_Check($input))
|
||||
@@ -52,22 +52,25 @@
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"arg %d: expected str, bytes, or None, got %s",
|
||||
$argnum, $input->ob_type->tp_name);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
}
|
||||
%typemap(freearg) const char * {
|
||||
Py_XDECREF(encodedInput$argnum);
|
||||
}
|
||||
|
||||
+%typemap(arginit) const char *[] {
|
||||
+ $1 = NULL;
|
||||
+}
|
||||
+
|
||||
/* Likewise for a list of strings. */
|
||||
-%typemap(in) const char *[] (void *vector = NULL,
|
||||
- size_t size,
|
||||
+%typemap(in) const char *[] (size_t size,
|
||||
PyObject **pyVector = NULL) {
|
||||
/* Check if is a list */
|
||||
if (PyList_Check($input)) {
|
||||
size_t i, j;
|
||||
size = PyList_Size($input);
|
||||
- $1 = (char **) (vector = malloc((size+1) * sizeof(char *)));
|
||||
+ $1 = (char **) malloc((size+1) * sizeof(char *));
|
||||
pyVector = calloc(sizeof *pyVector, size);
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
@@ -76,12 +79,7 @@
|
||||
{
|
||||
pyVector[i] = PyUnicode_AsUTF8String(o);
|
||||
if (pyVector[i] == NULL)
|
||||
- {
|
||||
- free(vector);
|
||||
- for (j = 0; j < i; j++)
|
||||
- Py_XDECREF(pyVector[j]);
|
||||
- return NULL;
|
||||
- }
|
||||
+ SWIG_fail;
|
||||
$1[i] = PyBytes_AsString(pyVector[i]);
|
||||
}
|
||||
else if (PyString_Check(o))
|
||||
@@ -91,8 +89,7 @@
|
||||
"arg %d: list must contain only str or bytes, got %s "
|
||||
"at position %d",
|
||||
$argnum, o->ob_type->tp_name, i);
|
||||
- free($1);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
}
|
||||
$1[i] = NULL;
|
||||
@@ -100,14 +97,17 @@
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"arg %d: expected a list of str or bytes, got %s",
|
||||
$argnum, $input->ob_type->tp_name);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
}
|
||||
%typemap(freearg) const char *[] {
|
||||
- size_t i;
|
||||
- free(vector$argnum);
|
||||
- for (i = 0; i < size$argnum; i++)
|
||||
- Py_XDECREF(pyVector$argnum[i]);
|
||||
+ if (pyVector$argnum) {
|
||||
+ size_t i;
|
||||
+ for (i = 0; i < size$argnum; i++)
|
||||
+ Py_XDECREF(pyVector$argnum[i]);
|
||||
+ free(pyVector$argnum);
|
||||
+ }
|
||||
+ if ($1) free($1);
|
||||
}
|
||||
|
||||
/* Release returned buffers as necessary. */
|
||||
@@ -125,7 +125,7 @@
|
||||
if (!PySequence_Check($input)) {
|
||||
PyErr_Format(PyExc_ValueError, "arg %d: Expected a list of gpgme_key_t",
|
||||
$argnum);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
if((numb = PySequence_Length($input)) != 0) {
|
||||
$1 = (gpgme_key_t*)malloc((numb+1)*sizeof(gpgme_key_t));
|
||||
@@ -142,8 +142,7 @@
|
||||
"arg %d: list must contain only gpgme_key_ts, got %s "
|
||||
"at position %d",
|
||||
$argnum, pypointer->ob_type->tp_name, i);
|
||||
- free($1);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
Py_DECREF(pypointer);
|
||||
}
|
||||
@@ -169,7 +168,7 @@
|
||||
pypointer = _gpg_obj2gpgme_data_t($input, $argnum, &wrapper,
|
||||
&bytesio, &view);
|
||||
if (pypointer == NULL)
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
have_view = !! view.obj;
|
||||
|
||||
/* input = $input, 1 = $1, 1_descriptor = $1_descriptor */
|
||||
@@ -179,7 +178,7 @@
|
||||
if ((SWIG_ConvertPtr(pypointer,(void **) &$1, $1_descriptor,
|
||||
SWIG_POINTER_EXCEPTION | $disown )) == -1) {
|
||||
Py_DECREF(pypointer);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
Py_DECREF(pypointer);
|
||||
}
|
||||
@@ -336,6 +335,11 @@
|
||||
PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
|
||||
}
|
||||
|
||||
+%typemap(arginit) (void *buffer, size_t size), (char *buf, size_t buflen) {
|
||||
+ $1 = NULL;
|
||||
+ $2 = 0;
|
||||
+}
|
||||
+
|
||||
/* Those are for gpgme_data_read() and gpgme_strerror_r(). */
|
||||
%typemap(in) (void *buffer, size_t size), (char *buf, size_t buflen) {
|
||||
{
|
||||
@@ -349,12 +353,12 @@
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
|
||||
if (tmp$argnum < 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "Positive integer expected");
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
$2 = (size_t) tmp$argnum;
|
||||
$1 = ($1_ltype) malloc($2+1);
|
||||
@@ -363,11 +367,11 @@
|
||||
%typemap(argout) (void *buffer, size_t size), (char *buf, size_t buflen) {
|
||||
Py_XDECREF($result); /* Blow away any previous result */
|
||||
if (result < 0) { /* Check for I/O error */
|
||||
- free($1);
|
||||
+ if ($1) free($1);
|
||||
return PyErr_SetFromErrno(PyExc_RuntimeError);
|
||||
}
|
||||
$result = PyBytes_FromStringAndSize($1,result);
|
||||
- free($1);
|
||||
+ if ($1) free($1);
|
||||
}
|
||||
|
||||
/* For gpgme_data_write, but should be universal. */
|
||||
@@ -380,11 +384,11 @@
|
||||
{
|
||||
encodedInput = PyUnicode_AsUTF8String($input);
|
||||
if (encodedInput == NULL)
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
if (PyBytes_AsStringAndSize(encodedInput, (char **) &$1, &ssize) == -1)
|
||||
{
|
||||
Py_DECREF(encodedInput);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
}
|
||||
else if (PyBytes_Check($input))
|
||||
@@ -393,7 +397,7 @@
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"arg %d: expected str, bytes, or None, got %s",
|
||||
$argnum, $input->ob_type->tp_name);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
|
||||
if (! $1)
|
||||
@@ -422,8 +426,17 @@
|
||||
size++;
|
||||
}
|
||||
$result = PyList_New(size);
|
||||
+ if ($result == NULL)
|
||||
+ SWIG_fail;
|
||||
for (i=0,curr=$1; i<size; i++,curr=curr->next) {
|
||||
PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(curr), $1_descriptor, %newpointer_flags);
|
||||
+ if (o == NULL) {
|
||||
+ int j;
|
||||
+ for (j = 0; j < i; j++)
|
||||
+ Py_XDECREF(PyList_GetItem($result, j));
|
||||
+ Py_DECREF($result);
|
||||
+ SWIG_fail;
|
||||
+ }
|
||||
PyList_SetItem($result, i, o);
|
||||
}
|
||||
}
|
||||
@@ -436,6 +449,8 @@
|
||||
PyObject *fragile;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
+ if (fragile == NULL)
|
||||
+ SWIG_fail;
|
||||
$result = _gpg_wrap_result(fragile, name);
|
||||
Py_DECREF(fragile);
|
||||
}
|
||||
@@ -459,22 +474,28 @@
|
||||
}
|
||||
$result = PyList_New(size);
|
||||
if ($result == NULL)
|
||||
- return NULL; /* raise */
|
||||
+ SWIG_fail; /* raise */
|
||||
for (i=0,curr=$1; i<size; i++,curr=curr->next) {
|
||||
PyObject *fragile, *o;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr(curr), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
if (fragile == NULL)
|
||||
{
|
||||
+ int j;
|
||||
+ for (j = 0; j < i; j++)
|
||||
+ Py_XDECREF(PyList_GetItem($result, j));
|
||||
Py_DECREF($result);
|
||||
- return NULL; /* raise */
|
||||
+ SWIG_fail; /* raise */
|
||||
}
|
||||
o = _gpg_wrap_result(fragile, "EngineInfo");
|
||||
Py_DECREF(fragile);
|
||||
if (o == NULL)
|
||||
{
|
||||
+ int j;
|
||||
+ for (j = 0; j < i; j++)
|
||||
+ Py_XDECREF(PyList_GetItem($result, j));
|
||||
Py_DECREF($result);
|
||||
- return NULL; /* raise */
|
||||
+ SWIG_fail; /* raise */
|
||||
}
|
||||
PyList_SetItem($result, i, o);
|
||||
}
|
||||
diff -Naur a/lang/qt/tests/t-various.cpp b/lang/qt/tests/t-various.cpp
|
||||
--- a/lang/qt/tests/t-various.cpp 2018-11-12 13:57:39.907527804 +0100
|
||||
+++ b/lang/qt/tests/t-various.cpp 2018-11-14 15:22:25.475304073 +0100
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
+#include <QScopedPointer>
|
||||
#include <QDebug>
|
||||
#include <QTest>
|
||||
#include <QSignalSpy>
|
||||
@@ -103,27 +104,30 @@
|
||||
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.13") {
|
||||
return;
|
||||
}
|
||||
- KeyListJob *job = openpgp()->keyListJob(false, true, true);
|
||||
std::vector<GpgME::Key> keys;
|
||||
- GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
||||
- false, keys);
|
||||
- delete job;
|
||||
- QVERIFY (!result.error());
|
||||
- QVERIFY (keys.size() == 1);
|
||||
+ {
|
||||
+ QScopedPointer<KeyListJob> job(openpgp()->keyListJob(false, true, true));
|
||||
+ QVERIFY(!job.isNull());
|
||||
+ GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
||||
+ false, keys);
|
||||
+ QVERIFY (!result.error());
|
||||
+ QVERIFY (keys.size() == 1);
|
||||
+ }
|
||||
Key key = keys.front();
|
||||
|
||||
QVERIFY (key.numUserIDs() == 3);
|
||||
const char uid[] = "Foo Bar (with comment) <foo@bar.baz>";
|
||||
|
||||
- auto ctx = Context::createForProtocol(key.protocol());
|
||||
- QVERIFY (ctx);
|
||||
- TestPassphraseProvider provider;
|
||||
- ctx->setPassphraseProvider(&provider);
|
||||
- ctx->setPinentryMode(Context::PinentryLoopback);
|
||||
-
|
||||
- QVERIFY(!ctx->addUid(key, uid));
|
||||
- delete ctx;
|
||||
- key.update();
|
||||
+ {
|
||||
+ QScopedPointer<Context> ctx(Context::createForProtocol(key.protocol()));
|
||||
+ QVERIFY (!ctx.isNull());
|
||||
+ TestPassphraseProvider provider;
|
||||
+ ctx->setPassphraseProvider(&provider);
|
||||
+ ctx->setPinentryMode(Context::PinentryLoopback);
|
||||
+
|
||||
+ QVERIFY(!ctx->addUid(key, uid));
|
||||
+ key.update();
|
||||
+ }
|
||||
|
||||
QVERIFY (key.numUserIDs() == 4);
|
||||
bool id_found = false;;
|
||||
@@ -136,10 +140,12 @@
|
||||
}
|
||||
QVERIFY (id_found);
|
||||
|
||||
- ctx = Context::createForProtocol(key.protocol());
|
||||
- QVERIFY (!ctx->revUid(key, uid));
|
||||
- delete ctx;
|
||||
- key.update();
|
||||
+ {
|
||||
+ QScopedPointer<Context> ctx(Context::createForProtocol(key.protocol()));
|
||||
+ QVERIFY (!ctx.isNull());
|
||||
+ QVERIFY (!ctx->revUid(key, uid));
|
||||
+ key.update();
|
||||
+ }
|
||||
|
||||
bool id_revoked = false;;
|
||||
for (const auto &u: key.userIDs()) {
|
||||
diff -Naur a/src/engine.c b/src/engine.c
|
||||
--- a/src/engine.c 2018-11-12 13:57:40.081523713 +0100
|
||||
+++ b/src/engine.c 2018-11-15 15:14:49.518729792 +0100
|
||||
@@ -459,7 +459,9 @@
|
||||
if (!new_version)
|
||||
{
|
||||
free (new_file_name);
|
||||
- free (new_home_dir);
|
||||
+ if (new_home_dir)
|
||||
+ free (new_home_dir);
|
||||
+ return gpg_error_from_syserror ();
|
||||
}
|
||||
}
|
||||
|
||||
diff -Naur a/src/engine-gpg.c b/src/engine-gpg.c
|
||||
--- a/src/engine-gpg.c 2018-11-12 13:57:40.083523666 +0100
|
||||
+++ b/src/engine-gpg.c 2018-11-15 14:55:35.374077739 +0100
|
||||
@@ -968,7 +968,7 @@
|
||||
== -1)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
- free (fd_data_map);
|
||||
+ free_fd_data_map (fd_data_map);
|
||||
free_argv (argv);
|
||||
return gpg_error (saved_errno);
|
||||
}
|
||||
@@ -978,10 +978,10 @@
|
||||
close_notify_handler,
|
||||
gpg))
|
||||
{
|
||||
- /* We leak fd_data_map and the fds. This is not easy
|
||||
- to avoid and given that we reach this here only
|
||||
- after a malloc failure for a small object, it is
|
||||
- probably better not to do anything. */
|
||||
+ close (fds[0]);
|
||||
+ close (fds[1]);
|
||||
+ free_fd_data_map (fd_data_map);
|
||||
+ free_argv (argv);
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
/* If the data_type is FD, we have to do a dup2 here. */
|
||||
@@ -1024,7 +1024,7 @@
|
||||
if (!argv[argc])
|
||||
{
|
||||
int saved_err = gpg_error_from_syserror ();
|
||||
- free (fd_data_map);
|
||||
+ free_fd_data_map (fd_data_map);
|
||||
free_argv (argv);
|
||||
return saved_err;
|
||||
}
|
||||
@@ -1049,7 +1049,7 @@
|
||||
if (!argv[argc])
|
||||
{
|
||||
int saved_err = gpg_error_from_syserror ();
|
||||
- free (fd_data_map);
|
||||
+ free_fd_data_map (fd_data_map);
|
||||
free_argv (argv);
|
||||
return saved_err;
|
||||
}
|
||||
@@ -1104,6 +1104,9 @@
|
||||
buffer = realloc (buffer, bufsize);
|
||||
if (!buffer)
|
||||
return gpg_error_from_syserror ();
|
||||
+ /* Update buffer and bufsize here to prevent memory leaks. */
|
||||
+ gpg->status.buffer = buffer;
|
||||
+ gpg->status.bufsize = bufsize;
|
||||
}
|
||||
|
||||
nread = _gpgme_io_read (gpg->status.fd[0],
|
||||
@@ -1254,8 +1257,6 @@
|
||||
}
|
||||
|
||||
/* Update the gpg object. */
|
||||
- gpg->status.bufsize = bufsize;
|
||||
- gpg->status.buffer = buffer;
|
||||
gpg->status.readpos = readpos;
|
||||
return 0;
|
||||
}
|
||||
@@ -1295,6 +1296,9 @@
|
||||
buffer = realloc (buffer, bufsize);
|
||||
if (!buffer)
|
||||
return gpg_error_from_syserror ();
|
||||
+ /* Prevent memory leaks. */
|
||||
+ gpg->colon.buffer = buffer;
|
||||
+ gpg->colon.bufsize = bufsize;
|
||||
}
|
||||
|
||||
nread = _gpgme_io_read (gpg->colon.fd[0], buffer+readpos, bufsize-readpos);
|
||||
@@ -1374,8 +1378,6 @@
|
||||
}
|
||||
|
||||
/* Update the gpg object. */
|
||||
- gpg->colon.bufsize = bufsize;
|
||||
- gpg->colon.buffer = buffer;
|
||||
gpg->colon.readpos = readpos;
|
||||
return 0;
|
||||
}
|
||||
diff -Naur a/src/engine-gpgsm.c b/src/engine-gpgsm.c
|
||||
--- a/src/engine-gpgsm.c 2018-11-12 13:57:40.083523666 +0100
|
||||
+++ b/src/engine-gpgsm.c 2018-11-15 15:03:09.798301245 +0100
|
||||
@@ -1366,8 +1366,10 @@
|
||||
gpgsm->output_cb.data = keydata;
|
||||
err = gpgsm_set_fd (gpgsm, OUTPUT_FD, use_armor ? "--armor"
|
||||
: map_data_enc (gpgsm->output_cb.data));
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ free (cmd);
|
||||
return err;
|
||||
+ }
|
||||
gpgsm_clear_fd (gpgsm, INPUT_FD);
|
||||
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
|
||||
gpgsm->inline_data = NULL;
|
||||
@@ -1467,8 +1469,10 @@
|
||||
gpgsm->output_cb.data = keydata;
|
||||
err = gpgsm_set_fd (gpgsm, OUTPUT_FD, use_armor ? "--armor"
|
||||
: map_data_enc (gpgsm->output_cb.data));
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ free (line);
|
||||
return err;
|
||||
+ }
|
||||
gpgsm_clear_fd (gpgsm, INPUT_FD);
|
||||
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
|
||||
gpgsm->inline_data = NULL;
|
||||
diff -Naur a/src/gpgme-tool.c b/src/gpgme-tool.c
|
||||
--- a/src/gpgme-tool.c 2018-11-12 13:57:40.084523642 +0100
|
||||
+++ b/src/gpgme-tool.c 2018-11-15 22:02:04.913188338 +0100
|
||||
@@ -2330,8 +2330,8 @@
|
||||
char *inp_fn;
|
||||
assuan_fd_t out_fd;
|
||||
char *out_fn;
|
||||
- gpgme_data_t inp_data;
|
||||
- gpgme_data_t out_data;
|
||||
+ gpgme_data_t inp_data = NULL;
|
||||
+ gpgme_data_t out_data = NULL;
|
||||
|
||||
(void)line;
|
||||
|
||||
@@ -2346,13 +2346,18 @@
|
||||
|
||||
err = server_data_obj (inp_fd, inp_fn, 0, server->input_enc, &inp_data,
|
||||
&server->input_stream);
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ if (inp_data)
|
||||
+ gpgme_data_release (inp_data);
|
||||
return err;
|
||||
+ }
|
||||
err = server_data_obj (out_fd, out_fn, 1, server->output_enc, &out_data,
|
||||
&server->output_stream);
|
||||
if (err)
|
||||
{
|
||||
gpgme_data_release (inp_data);
|
||||
+ if (out_data)
|
||||
+ gpgme_data_release (out_data);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -2425,8 +2430,11 @@
|
||||
{
|
||||
err = server_data_obj (inp_fd, inp_fn, 0, server->input_enc, &inp_data,
|
||||
&server->input_stream);
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ if (inp_data)
|
||||
+ gpgme_data_release (inp_data);
|
||||
return err;
|
||||
+ }
|
||||
}
|
||||
if (out_fd != ASSUAN_INVALID_FD || out_fn)
|
||||
{
|
||||
@@ -2435,6 +2443,8 @@
|
||||
if (err)
|
||||
{
|
||||
gpgme_data_release (inp_data);
|
||||
+ if (out_data)
|
||||
+ gpgme_data_release (out_data);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
@@ -2499,8 +2509,8 @@
|
||||
char *inp_fn;
|
||||
assuan_fd_t out_fd;
|
||||
char *out_fn;
|
||||
- gpgme_data_t inp_data;
|
||||
- gpgme_data_t out_data;
|
||||
+ gpgme_data_t inp_data = NULL;
|
||||
+ gpgme_data_t out_data = NULL;
|
||||
gpgme_sig_mode_t mode = GPGME_SIG_MODE_NORMAL;
|
||||
|
||||
if (strstr (line, "--clear"))
|
||||
@@ -2519,13 +2529,18 @@
|
||||
|
||||
err = server_data_obj (inp_fd, inp_fn, 0, server->input_enc, &inp_data,
|
||||
&server->input_stream);
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ if (inp_data)
|
||||
+ gpgme_data_release (inp_data);
|
||||
return err;
|
||||
+ }
|
||||
err = server_data_obj (out_fd, out_fn, 1, server->output_enc, &out_data,
|
||||
&server->output_stream);
|
||||
if (err)
|
||||
{
|
||||
gpgme_data_release (inp_data);
|
||||
+ if (out_data)
|
||||
+ gpgme_data_release (out_data);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -2557,7 +2572,7 @@
|
||||
char *inp_fn;
|
||||
char *msg_fn;
|
||||
char *out_fn;
|
||||
- gpgme_data_t inp_data;
|
||||
+ gpgme_data_t inp_data = NULL;
|
||||
gpgme_data_t msg_data = NULL;
|
||||
gpgme_data_t out_data = NULL;
|
||||
|
||||
@@ -2574,8 +2589,11 @@
|
||||
|
||||
err = server_data_obj (inp_fd, inp_fn, 0, server->input_enc, &inp_data,
|
||||
&server->input_stream);
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ if (inp_data)
|
||||
+ gpgme_data_release (inp_data);
|
||||
return err;
|
||||
+ }
|
||||
if (msg_fd != ASSUAN_INVALID_FD || msg_fn)
|
||||
{
|
||||
err = server_data_obj (msg_fd, msg_fn, 0, server->message_enc, &msg_data,
|
||||
@@ -2583,6 +2601,8 @@
|
||||
if (err)
|
||||
{
|
||||
gpgme_data_release (inp_data);
|
||||
+ if (msg_data)
|
||||
+ gpgme_data_release (msg_data);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
@@ -2594,6 +2614,8 @@
|
||||
{
|
||||
gpgme_data_release (inp_data);
|
||||
gpgme_data_release (msg_data);
|
||||
+ if (out_data)
|
||||
+ gpgme_data_release (out_data);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
@@ -2634,7 +2656,7 @@
|
||||
gpg_error_t err;
|
||||
assuan_fd_t inp_fd;
|
||||
char *inp_fn;
|
||||
- gpgme_data_t inp_data;
|
||||
+ gpgme_data_t inp_data = NULL;
|
||||
|
||||
inp_fd = server->input_fd;
|
||||
inp_fn = server->input_filename;
|
||||
@@ -2643,8 +2665,11 @@
|
||||
|
||||
err = server_data_obj (inp_fd, inp_fn, 0, server->input_enc, &inp_data,
|
||||
&server->input_stream);
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ if (inp_data)
|
||||
+ gpgme_data_release (inp_data);
|
||||
return err;
|
||||
+ }
|
||||
|
||||
err = gt_import (server->gt, inp_data);
|
||||
|
||||
@@ -2668,7 +2693,7 @@
|
||||
gpg_error_t err;
|
||||
assuan_fd_t out_fd;
|
||||
char *out_fn;
|
||||
- gpgme_data_t out_data;
|
||||
+ gpgme_data_t out_data = NULL;
|
||||
gpgme_export_mode_t mode = 0;
|
||||
const char *pattern[2];
|
||||
|
||||
@@ -2678,8 +2703,11 @@
|
||||
return GPG_ERR_ASS_NO_OUTPUT;
|
||||
err = server_data_obj (out_fd, out_fn, 1, server->output_enc, &out_data,
|
||||
&server->output_stream);
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ if (out_data)
|
||||
+ gpgme_data_release (out_data);
|
||||
return err;
|
||||
+ }
|
||||
|
||||
if (has_option (line, "--extern"))
|
||||
mode |= GPGME_EXPORT_MODE_EXTERN;
|
||||
@@ -2733,7 +2761,7 @@
|
||||
char *inp_fn;
|
||||
assuan_fd_t out_fd;
|
||||
char *out_fn;
|
||||
- gpgme_data_t inp_data;
|
||||
+ gpgme_data_t inp_data = NULL;
|
||||
gpgme_data_t out_data = NULL;
|
||||
gpgme_data_t parms_data = NULL;
|
||||
const char *parms;
|
||||
@@ -2749,8 +2777,11 @@
|
||||
|
||||
err = server_data_obj (inp_fd, inp_fn, 0, server->input_enc, &inp_data,
|
||||
&server->input_stream);
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ if (inp_data)
|
||||
+ gpgme_data_release (inp_data);
|
||||
return err;
|
||||
+ }
|
||||
if (out_fd != ASSUAN_INVALID_FD || out_fn)
|
||||
{
|
||||
err = server_data_obj (out_fd, out_fn, 1, server->output_enc, &out_data,
|
||||
@@ -2758,6 +2789,8 @@
|
||||
if (err)
|
||||
{
|
||||
gpgme_data_release (inp_data);
|
||||
+ if (out_data)
|
||||
+ gpgme_data_release (out_data);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
@@ -2795,6 +2828,7 @@
|
||||
}
|
||||
|
||||
err = gt_genkey (server->gt, parms, out_data, NULL);
|
||||
+ free (parms);
|
||||
|
||||
server_reset_fds (server);
|
||||
|
||||
@@ -2968,7 +3002,7 @@
|
||||
gpg_error_t err;
|
||||
assuan_fd_t out_fd;
|
||||
char *out_fn;
|
||||
- gpgme_data_t out_data;
|
||||
+ gpgme_data_t out_data = NULL;
|
||||
unsigned int flags = 0;
|
||||
|
||||
out_fd = server->output_fd;
|
||||
@@ -2977,8 +3011,11 @@
|
||||
return GPG_ERR_ASS_NO_OUTPUT;
|
||||
err = server_data_obj (out_fd, out_fn, 1, server->output_enc, &out_data,
|
||||
&server->output_stream);
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ if (out_data)
|
||||
+ gpgme_data_release (out_data);
|
||||
return err;
|
||||
+ }
|
||||
|
||||
if (strstr (line, "--html"))
|
||||
flags |= GPGME_AUDITLOG_HTML;
|
||||
@@ -3111,7 +3148,7 @@
|
||||
gpg_error_t err;
|
||||
assuan_fd_t inp_fd;
|
||||
char *inp_fn;
|
||||
- gpgme_data_t inp_data;
|
||||
+ gpgme_data_t inp_data = NULL;
|
||||
|
||||
(void)line;
|
||||
|
||||
@@ -3122,8 +3159,11 @@
|
||||
|
||||
err = server_data_obj (inp_fd, inp_fn, 0, server->input_enc, &inp_data,
|
||||
&server->input_stream);
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ if (inp_data)
|
||||
+ gpgme_data_release (inp_data);
|
||||
return err;
|
||||
+ }
|
||||
|
||||
err = gt_identify (server->gt, inp_data);
|
||||
|
||||
@@ -3159,8 +3199,11 @@
|
||||
{
|
||||
err = server_data_obj (inp_fd, inp_fn, 0, server->input_enc, &inp_data,
|
||||
&server->input_stream);
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ if (inp_data)
|
||||
+ gpgme_data_release (inp_data);
|
||||
return err;
|
||||
+ }
|
||||
}
|
||||
if (out_fd != ASSUAN_INVALID_FD || out_fn)
|
||||
{
|
||||
@@ -3169,6 +3212,8 @@
|
||||
if (err)
|
||||
{
|
||||
gpgme_data_release (inp_data);
|
||||
+ if (out_data)
|
||||
+ gpgme_data_release (out_data);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
diff -Naur a/tests/gpg/t-import.c b/tests/gpg/t-import.c
|
||||
--- a/tests/gpg/t-import.c 2018-11-12 13:57:39.808530132 +0100
|
||||
+++ b/tests/gpg/t-import.c 2018-11-16 12:52:09.829248570 +0100
|
||||
@@ -212,7 +212,7 @@
|
||||
{
|
||||
gpgme_ctx_t ctx;
|
||||
gpgme_error_t err;
|
||||
- gpgme_data_t in;
|
||||
+ gpgme_data_t in = NULL;
|
||||
gpgme_import_result_t result;
|
||||
char *pubkey_1_asc = make_filename ("pubkey-1.asc");
|
||||
char *seckey_1_asc = make_filename ("seckey-1.asc");
|
||||
@@ -235,6 +235,7 @@
|
||||
check_result (result, "ADAB7FCC1F4DE2616ECFA402AF82244F9CD9FD55", 0);
|
||||
gpgme_data_release (in);
|
||||
|
||||
+ in = NULL; /* Make Coverity happy. */
|
||||
err = gpgme_data_new_from_file (&in, seckey_1_asc, 1);
|
||||
free (seckey_1_asc);
|
||||
fail_if_err (err);
|
||||
diff -Naur a/tests/gpg/t-trustlist.c b/tests/gpg/t-trustlist.c
|
||||
--- a/tests/gpg/t-trustlist.c 2018-11-12 13:57:39.810530085 +0100
|
||||
+++ b/tests/gpg/t-trustlist.c 2018-11-16 12:52:09.837248378 +0100
|
||||
@@ -39,7 +39,7 @@
|
||||
{
|
||||
gpgme_ctx_t ctx;
|
||||
gpgme_error_t err;
|
||||
- gpgme_trust_item_t item;
|
||||
+ gpgme_trust_item_t item = NULL;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
@@ -58,6 +58,7 @@
|
||||
item->level, item->keyid, item->type, item->owner_trust,
|
||||
item->validity, item->name);
|
||||
gpgme_trust_item_unref (item);
|
||||
+ item = NULL; /* Make Coverity happy. */
|
||||
}
|
||||
if (gpgme_err_code (err) != GPG_ERR_EOF)
|
||||
fail_if_err (err);
|
||||
diff -Naur a/tests/gpgsm/cms-keylist.c b/tests/gpgsm/cms-keylist.c
|
||||
--- a/tests/gpgsm/cms-keylist.c 2018-11-12 13:57:39.830529615 +0100
|
||||
+++ b/tests/gpgsm/cms-keylist.c 2018-11-16 12:52:09.842248259 +0100
|
||||
@@ -45,7 +45,7 @@
|
||||
{
|
||||
gpgme_error_t err;
|
||||
gpgme_ctx_t ctx;
|
||||
- gpgme_key_t key;
|
||||
+ gpgme_key_t key = NULL;
|
||||
gpgme_keylist_result_t result;
|
||||
|
||||
if (argc)
|
||||
@@ -107,6 +107,7 @@
|
||||
putchar ('\n');
|
||||
|
||||
gpgme_key_unref (key);
|
||||
+ key = NULL; /* Make Coverity happy. */
|
||||
}
|
||||
if (gpgme_err_code (err) != GPG_ERR_EOF)
|
||||
fail_if_err (err);
|
||||
diff -Naur a/tests/gpgsm/t-import.c b/tests/gpgsm/t-import.c
|
||||
--- a/tests/gpgsm/t-import.c 2018-11-12 13:57:39.829529639 +0100
|
||||
+++ b/tests/gpgsm/t-import.c 2018-11-16 12:52:07.932293971 +0100
|
||||
@@ -142,7 +142,7 @@
|
||||
{
|
||||
gpgme_ctx_t ctx;
|
||||
gpgme_error_t err;
|
||||
- gpgme_data_t in;
|
||||
+ gpgme_data_t in = NULL;
|
||||
gpgme_import_result_t result;
|
||||
char *cert_1 = make_filename ("cert_dfn_pca01.der");
|
||||
char *cert_2 = make_filename ("cert_dfn_pca15.der");
|
||||
@@ -164,6 +164,7 @@
|
||||
check_result (result, "DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD", 1, 1);
|
||||
gpgme_data_release (in);
|
||||
|
||||
+ in = NULL; /* Make Coverity happy. */
|
||||
err = gpgme_data_new_from_file (&in, cert_2, 1);
|
||||
free (cert_2);
|
||||
fail_if_err (err);
|
||||
diff -Naur a/tests/gpgsm/t-keylist.c b/tests/gpgsm/t-keylist.c
|
||||
--- a/tests/gpgsm/t-keylist.c 2018-11-12 13:57:39.829529639 +0100
|
||||
+++ b/tests/gpgsm/t-keylist.c 2018-11-16 13:20:51.685124686 +0100
|
||||
@@ -85,7 +85,7 @@
|
||||
{
|
||||
gpgme_error_t err;
|
||||
gpgme_ctx_t ctx;
|
||||
- gpgme_key_t key;
|
||||
+ gpgme_key_t key = NULL;
|
||||
gpgme_keylist_result_t result;
|
||||
int i = 0;
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
fprintf (stderr, "Warning: Skipping unknown key %s\n",
|
||||
key->subkeys->fpr);
|
||||
gpgme_key_unref (key);
|
||||
+ key = NULL; /* Make Coverity happy. */
|
||||
continue;
|
||||
}
|
||||
else
|
||||
@@ -365,6 +366,7 @@
|
||||
|
||||
|
||||
gpgme_key_unref (key);
|
||||
+ key = NULL; /* Make Coverity happy. */
|
||||
i++;
|
||||
}
|
||||
if (gpgme_err_code (err) != GPG_ERR_EOF)
|
||||
diff -Naur a/tests/run-identify.c b/tests/run-identify.c
|
||||
--- a/tests/run-identify.c 2018-11-12 13:57:39.806530179 +0100
|
||||
+++ b/tests/run-identify.c 2018-11-16 12:59:06.391278677 +0100
|
||||
@@ -77,7 +77,7 @@
|
||||
int last_argc = -1;
|
||||
gpgme_error_t err;
|
||||
int anyerr = 0;
|
||||
- gpgme_data_t data;
|
||||
+ gpgme_data_t data = NULL;
|
||||
gpgme_data_type_t dt;
|
||||
|
||||
if (argc)
|
||||
@@ -122,6 +122,7 @@
|
||||
anyerr = 1;
|
||||
printf ("%s: %s\n", *argv, data_type_to_string (dt));
|
||||
gpgme_data_release (data);
|
||||
+ data = NULL; /* Make Coverity happy. */
|
||||
}
|
||||
}
|
||||
|
||||
diff -Naur a/tests/run-import.c b/tests/run-import.c
|
||||
--- a/tests/run-import.c 2018-11-12 13:57:39.833529545 +0100
|
||||
+++ b/tests/run-import.c 2018-11-16 13:00:30.184273195 +0100
|
||||
@@ -58,7 +58,7 @@
|
||||
int url_mode = 0;
|
||||
int nul_mode = 0;
|
||||
gpgme_import_result_t impres;
|
||||
- gpgme_data_t data;
|
||||
+ gpgme_data_t data = NULL;
|
||||
|
||||
if (argc)
|
||||
{ argc--; argv++; }
|
||||
@@ -122,6 +122,7 @@
|
||||
print_import_result (impres);
|
||||
|
||||
gpgme_data_release (data);
|
||||
+ data = NULL; /* Make Coverity happy. */
|
||||
}
|
||||
|
||||
gpgme_release (ctx);
|
398
SOURCES/gpgme-1.13.1-fix-resource-leaks.patch
Normal file
398
SOURCES/gpgme-1.13.1-fix-resource-leaks.patch
Normal file
@ -0,0 +1,398 @@
|
||||
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
|
||||
index c0a1dc21..e991dbc8 100644
|
||||
--- a/lang/cpp/src/context.cpp
|
||||
+++ b/lang/cpp/src/context.cpp
|
||||
@@ -223,6 +223,7 @@ Context *Context::createForProtocol(Protocol proto)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
+ gpgme_release(ctx);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -273,6 +274,7 @@ std::unique_ptr<Context> Context::createForEngine(Engine eng, Error *error)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
+ gpgme_release(ctx);
|
||||
if (error) {
|
||||
*error = Error::fromCode(GPG_ERR_INV_ARG);
|
||||
}
|
||||
diff --git a/lang/cpp/src/data.cpp b/lang/cpp/src/data.cpp
|
||||
index 7a93cbc2..d08a29db 100644
|
||||
--- a/lang/cpp/src/data.cpp
|
||||
+++ b/lang/cpp/src/data.cpp
|
||||
@@ -249,6 +249,7 @@ std::vector<GpgME::Key> GpgME::Data::toKeys(Protocol proto) const
|
||||
}
|
||||
|
||||
if (gpgme_op_keylist_from_data_start (ctx->impl()->ctx, d->data, 0)) {
|
||||
+ delete ctx;
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
|
||||
index 87371af8..64b88d54 100644
|
||||
--- a/lang/python/gpgme.i
|
||||
+++ b/lang/python/gpgme.i
|
||||
@@ -53,7 +53,7 @@
|
||||
{
|
||||
encodedInput = PyUnicode_AsUTF8String($input);
|
||||
if (encodedInput == NULL)
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
$1 = PyBytes_AsString(encodedInput);
|
||||
}
|
||||
else if (PyBytes_Check($input))
|
||||
@@ -62,22 +62,25 @@
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"arg %d: expected str, bytes, or None, got %s",
|
||||
$argnum, $input->ob_type->tp_name);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
}
|
||||
%typemap(freearg) const char * {
|
||||
Py_XDECREF(encodedInput$argnum);
|
||||
}
|
||||
|
||||
+%typemap(arginit) const char *[] {
|
||||
+ $1 = NULL;
|
||||
+}
|
||||
+
|
||||
/* Likewise for a list of strings. */
|
||||
-%typemap(in) const char *[] (void *vector = NULL,
|
||||
- size_t size,
|
||||
+%typemap(in) const char *[] (size_t size,
|
||||
PyObject **pyVector = NULL) {
|
||||
/* Check if is a list */
|
||||
if (PyList_Check($input)) {
|
||||
size_t i, j;
|
||||
size = PyList_Size($input);
|
||||
- $1 = (char **) (vector = malloc((size+1) * sizeof(char *)));
|
||||
+ $1 = (char **) malloc((size+1) * sizeof(char *));
|
||||
pyVector = calloc(sizeof *pyVector, size);
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
@@ -86,12 +89,7 @@
|
||||
{
|
||||
pyVector[i] = PyUnicode_AsUTF8String(o);
|
||||
if (pyVector[i] == NULL)
|
||||
- {
|
||||
- free(vector);
|
||||
- for (j = 0; j < i; j++)
|
||||
- Py_XDECREF(pyVector[j]);
|
||||
- return NULL;
|
||||
- }
|
||||
+ SWIG_fail;
|
||||
$1[i] = PyBytes_AsString(pyVector[i]);
|
||||
}
|
||||
else if (PyString_Check(o))
|
||||
@@ -101,8 +99,7 @@
|
||||
"arg %d: list must contain only str or bytes, got %s "
|
||||
"at position %d",
|
||||
$argnum, o->ob_type->tp_name, i);
|
||||
- free($1);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
}
|
||||
$1[i] = NULL;
|
||||
@@ -110,14 +107,17 @@
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"arg %d: expected a list of str or bytes, got %s",
|
||||
$argnum, $input->ob_type->tp_name);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
}
|
||||
%typemap(freearg) const char *[] {
|
||||
- size_t i;
|
||||
- free(vector$argnum);
|
||||
- for (i = 0; i < size$argnum; i++)
|
||||
- Py_XDECREF(pyVector$argnum[i]);
|
||||
+ if (pyVector$argnum) {
|
||||
+ size_t i;
|
||||
+ for (i = 0; i < size$argnum; i++)
|
||||
+ Py_XDECREF(pyVector$argnum[i]);
|
||||
+ free(pyVector$argnum);
|
||||
+ }
|
||||
+ if ($1) free($1);
|
||||
}
|
||||
|
||||
/* Release returned buffers as necessary. */
|
||||
@@ -135,7 +135,7 @@
|
||||
if (!PySequence_Check($input)) {
|
||||
PyErr_Format(PyExc_ValueError, "arg %d: Expected a list of gpgme_key_t",
|
||||
$argnum);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
if((numb = PySequence_Length($input)) != 0) {
|
||||
$1 = (gpgme_key_t*)malloc((numb+1)*sizeof(gpgme_key_t));
|
||||
@@ -152,8 +152,7 @@
|
||||
"arg %d: list must contain only gpgme_key_ts, got %s "
|
||||
"at position %d",
|
||||
$argnum, pypointer->ob_type->tp_name, i);
|
||||
- free($1);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
Py_DECREF(pypointer);
|
||||
}
|
||||
@@ -179,7 +178,7 @@
|
||||
pypointer = _gpg_obj2gpgme_data_t($input, $argnum, &wrapper,
|
||||
&bytesio, &view);
|
||||
if (pypointer == NULL)
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
have_view = !! view.obj;
|
||||
|
||||
/* input = $input, 1 = $1, 1_descriptor = $1_descriptor */
|
||||
@@ -189,7 +188,7 @@
|
||||
if ((SWIG_ConvertPtr(pypointer,(void **) &$1, $1_descriptor,
|
||||
SWIG_POINTER_EXCEPTION | $disown )) == -1) {
|
||||
Py_DECREF(pypointer);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
Py_DECREF(pypointer);
|
||||
}
|
||||
@@ -346,6 +345,11 @@
|
||||
PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
|
||||
}
|
||||
|
||||
+%typemap(arginit) (void *buffer, size_t size), (char *buf, size_t buflen) {
|
||||
+ $1 = NULL;
|
||||
+ $2 = 0;
|
||||
+}
|
||||
+
|
||||
/* Those are for gpgme_data_read() and gpgme_strerror_r(). */
|
||||
%typemap(in) (void *buffer, size_t size), (char *buf, size_t buflen) {
|
||||
{
|
||||
@@ -359,12 +363,12 @@
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
|
||||
if (tmp$argnum < 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "Positive integer expected");
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
$2 = (size_t) tmp$argnum;
|
||||
$1 = ($1_ltype) malloc($2+1);
|
||||
@@ -373,11 +377,11 @@
|
||||
%typemap(argout) (void *buffer, size_t size), (char *buf, size_t buflen) {
|
||||
Py_XDECREF($result); /* Blow away any previous result */
|
||||
if (result < 0) { /* Check for I/O error */
|
||||
- free($1);
|
||||
+ if ($1) free($1);
|
||||
return PyErr_SetFromErrno(PyExc_RuntimeError);
|
||||
}
|
||||
$result = PyBytes_FromStringAndSize($1,result);
|
||||
- free($1);
|
||||
+ if ($1) free($1);
|
||||
}
|
||||
|
||||
/* For gpgme_data_write, but should be universal. */
|
||||
@@ -390,11 +394,11 @@
|
||||
{
|
||||
encodedInput = PyUnicode_AsUTF8String($input);
|
||||
if (encodedInput == NULL)
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
if (PyBytes_AsStringAndSize(encodedInput, (char **) &$1, &ssize) == -1)
|
||||
{
|
||||
Py_DECREF(encodedInput);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
}
|
||||
else if (PyBytes_Check($input))
|
||||
@@ -403,7 +407,7 @@
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"arg %d: expected str, bytes, or None, got %s",
|
||||
$argnum, $input->ob_type->tp_name);
|
||||
- return NULL;
|
||||
+ SWIG_fail;
|
||||
}
|
||||
|
||||
if (! $1)
|
||||
@@ -432,8 +436,17 @@
|
||||
size++;
|
||||
}
|
||||
$result = PyList_New(size);
|
||||
+ if ($result == NULL)
|
||||
+ SWIG_fail;
|
||||
for (i=0,curr=$1; i<size; i++,curr=curr->next) {
|
||||
PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(curr), $1_descriptor, %newpointer_flags);
|
||||
+ if (o == NULL) {
|
||||
+ int j;
|
||||
+ for (j = 0; j < i; j++)
|
||||
+ Py_XDECREF(PyList_GetItem($result, j));
|
||||
+ Py_DECREF($result);
|
||||
+ SWIG_fail;
|
||||
+ }
|
||||
PyList_SetItem($result, i, o);
|
||||
}
|
||||
}
|
||||
@@ -446,6 +459,8 @@
|
||||
PyObject *fragile;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
+ if (fragile == NULL)
|
||||
+ SWIG_fail;
|
||||
$result = _gpg_wrap_result(fragile, name);
|
||||
Py_DECREF(fragile);
|
||||
}
|
||||
@@ -469,22 +484,28 @@ wrapresult(gpgme_vfs_mount_result_t, "VFSMountResult")
|
||||
}
|
||||
$result = PyList_New(size);
|
||||
if ($result == NULL)
|
||||
- return NULL; /* raise */
|
||||
+ SWIG_fail; /* raise */
|
||||
for (i=0,curr=$1; i<size; i++,curr=curr->next) {
|
||||
PyObject *fragile, *o;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr(curr), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
if (fragile == NULL)
|
||||
{
|
||||
+ int j;
|
||||
+ for (j = 0; j < i; j++)
|
||||
+ Py_XDECREF(PyList_GetItem($result, j));
|
||||
Py_DECREF($result);
|
||||
- return NULL; /* raise */
|
||||
+ SWIG_fail; /* raise */
|
||||
}
|
||||
o = _gpg_wrap_result(fragile, "EngineInfo");
|
||||
Py_DECREF(fragile);
|
||||
if (o == NULL)
|
||||
{
|
||||
+ int j;
|
||||
+ for (j = 0; j < i; j++)
|
||||
+ Py_XDECREF(PyList_GetItem($result, j));
|
||||
Py_DECREF($result);
|
||||
- return NULL; /* raise */
|
||||
+ SWIG_fail; /* raise */
|
||||
}
|
||||
PyList_SetItem($result, i, o);
|
||||
}
|
||||
diff --git a/src/engine-gpg.c b/src/engine-gpg.c
|
||||
index dc2d9455..a1e40fe2 100644
|
||||
--- a/src/engine-gpg.c
|
||||
+++ b/src/engine-gpg.c
|
||||
@@ -1122,6 +1122,7 @@ build_argv (engine_gpg_t gpg, const char *pgmname)
|
||||
to avoid and given that we reach this here only
|
||||
after a malloc failure for a small object, it is
|
||||
probably better not to do anything. */
|
||||
+ free_argv (argv);
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
/* If the data_type is FD, we have to do a dup2 here. */
|
||||
@@ -1239,6 +1240,9 @@ read_status (engine_gpg_t gpg)
|
||||
buffer = realloc (buffer, bufsize);
|
||||
if (!buffer)
|
||||
return gpg_error_from_syserror ();
|
||||
+ /* Update buffer and bufsize here to prevent memory leaks. */
|
||||
+ gpg->status.buffer = buffer;
|
||||
+ gpg->status.bufsize = bufsize;
|
||||
}
|
||||
|
||||
nread = _gpgme_io_read (gpg->status.fd[0],
|
||||
@@ -1351,8 +1355,6 @@ read_status (engine_gpg_t gpg)
|
||||
}
|
||||
|
||||
/* Update the gpg object. */
|
||||
- gpg->status.bufsize = bufsize;
|
||||
- gpg->status.buffer = buffer;
|
||||
gpg->status.readpos = readpos;
|
||||
return 0;
|
||||
}
|
||||
@@ -1392,6 +1394,9 @@ read_colon_line (engine_gpg_t gpg)
|
||||
buffer = realloc (buffer, bufsize);
|
||||
if (!buffer)
|
||||
return gpg_error_from_syserror ();
|
||||
+ /* Prevent memory leaks. */
|
||||
+ gpg->colon.bufsize = bufsize;
|
||||
+ gpg->colon.buffer = buffer;
|
||||
}
|
||||
|
||||
nread = _gpgme_io_read (gpg->colon.fd[0], buffer+readpos, bufsize-readpos);
|
||||
@@ -1471,8 +1476,6 @@ read_colon_line (engine_gpg_t gpg)
|
||||
}
|
||||
|
||||
/* Update the gpg object. */
|
||||
- gpg->colon.bufsize = bufsize;
|
||||
- gpg->colon.buffer = buffer;
|
||||
gpg->colon.readpos = readpos;
|
||||
return 0;
|
||||
}
|
||||
diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c
|
||||
index ae5d8ef1..1f603f19 100644
|
||||
--- a/src/engine-gpgsm.c
|
||||
+++ b/src/engine-gpgsm.c
|
||||
@@ -1533,8 +1533,10 @@ gpgsm_export (void *engine, const char *pattern, gpgme_export_mode_t mode,
|
||||
gpgsm->output_cb.data = keydata;
|
||||
err = gpgsm_set_fd (gpgsm, OUTPUT_FD, use_armor ? "--armor"
|
||||
: map_data_enc (gpgsm->output_cb.data));
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ free (cmd);
|
||||
return err;
|
||||
+ }
|
||||
gpgsm_clear_fd (gpgsm, INPUT_FD);
|
||||
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
|
||||
gpgsm->inline_data = NULL;
|
||||
@@ -1634,8 +1636,10 @@ gpgsm_export_ext (void *engine, const char *pattern[], gpgme_export_mode_t mode,
|
||||
gpgsm->output_cb.data = keydata;
|
||||
err = gpgsm_set_fd (gpgsm, OUTPUT_FD, use_armor ? "--armor"
|
||||
: map_data_enc (gpgsm->output_cb.data));
|
||||
- if (err)
|
||||
+ if (err) {
|
||||
+ free (line);
|
||||
return err;
|
||||
+ }
|
||||
gpgsm_clear_fd (gpgsm, INPUT_FD);
|
||||
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
|
||||
gpgsm->inline_data = NULL;
|
||||
diff --git a/src/engine.c b/src/engine.c
|
||||
index 05979c15..7e2e3800 100644
|
||||
--- a/src/engine.c
|
||||
+++ b/src/engine.c
|
||||
@@ -460,7 +460,8 @@ _gpgme_set_engine_info (gpgme_engine_info_t info, gpgme_protocol_t proto,
|
||||
if (!new_version)
|
||||
{
|
||||
free (new_file_name);
|
||||
- free (new_home_dir);
|
||||
+ if (new_home_dir)
|
||||
+ free (new_home_dir);
|
||||
return gpg_error_from_syserror ();
|
||||
}
|
||||
}
|
||||
diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c
|
||||
index 7a0bfcb3..f4ddd83b 100644
|
||||
--- a/src/gpgme-tool.c
|
||||
+++ b/src/gpgme-tool.c
|
||||
@@ -1189,6 +1189,7 @@ gt_get_key (gpgme_tool_t gt, const char *pattern, gpgme_key_t *r_key)
|
||||
similar hack to sort out such duplicates but it can't
|
||||
do that while listing keys. */
|
||||
gpgme_key_unref (key);
|
||||
+ key = NULL;
|
||||
goto try_next_key;
|
||||
}
|
||||
if (!err)
|
||||
diff --git a/src/keylist.c b/src/keylist.c
|
||||
index cdb115fd..b7cbf3c3 100644
|
||||
--- a/src/keylist.c
|
||||
+++ b/src/keylist.c
|
||||
@@ -1321,6 +1321,7 @@ gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key,
|
||||
similar hack to sort out such duplicates but it can't
|
||||
do that while listing keys. */
|
||||
gpgme_key_unref (key);
|
||||
+ key = NULL;
|
||||
goto try_next_key;
|
||||
}
|
||||
if (!err)
|
27
SOURCES/gpgme-build-with-gnupg-2.2.19.patch
Normal file
27
SOURCES/gpgme-build-with-gnupg-2.2.19.patch
Normal file
@ -0,0 +1,27 @@
|
||||
diff -up gpgme-1.13.1/src/engine-gpg.c.build gpgme-1.13.1/src/engine-gpg.c
|
||||
--- gpgme-1.13.1/src/engine-gpg.c.build 2019-06-13 08:45:22.000000000 +0200
|
||||
+++ gpgme-1.13.1/src/engine-gpg.c 2020-04-30 14:30:35.550253558 +0200
|
||||
@@ -2920,6 +2920,12 @@ gpg_keylist_build_options (engine_gpg_t
|
||||
|
||||
err = add_arg (gpg, "--with-colons");
|
||||
|
||||
+ if (have_gpg_version (gpg, "2.2.19"))
|
||||
+ {
|
||||
+ if (!err)
|
||||
+ err = add_arg (gpg, "--with-keygrip");
|
||||
+ }
|
||||
+
|
||||
/* Since gpg 2.1.15 fingerprints are always printed, thus there is
|
||||
* no more need to explicitly request them. */
|
||||
if (!have_gpg_version (gpg, "2.1.15"))
|
||||
diff -up gpgme-1.13.1/tests/json/t-keylist-secret.out.json.build gpgme-1.13.1/tests/json/t-keylist-secret.out.json
|
||||
--- gpgme-1.13.1/tests/json/t-keylist-secret.out.json.build 2018-12-03 10:37:25.000000000 +0100
|
||||
+++ gpgme-1.13.1/tests/json/t-keylist-secret.out.json 2020-04-30 14:24:40.904707411 +0200
|
||||
@@ -91,7 +91,6 @@
|
||||
"can_sign": true,
|
||||
"can_certify": true,
|
||||
"can_authenticate": true,
|
||||
- "secret": true,
|
||||
"is_qualified": false,
|
||||
"protocol": "OpenPGP",
|
||||
"fingerprint": "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2",
|
@ -12,23 +12,18 @@
|
||||
|
||||
# STATUS_KEY_CONSIDERED has been added in 2.1.13
|
||||
%global gnupg2_min_ver 2.1.13
|
||||
# GPG_ERR_SUBKEYS_EXP_OR_REV has been added in 1.23
|
||||
%global libgpg_error_min_ver 1.23
|
||||
%global libgpg_error_min_ver 1.24
|
||||
|
||||
Name: gpgme
|
||||
Summary: GnuPG Made Easy - high level crypto API
|
||||
Version: 1.10.0
|
||||
Release: 6%{?dist}
|
||||
Version: 1.13.1
|
||||
Release: 3%{?dist}
|
||||
|
||||
License: LGPLv2+
|
||||
URL: https://gnupg.org/related_software/gpgme/
|
||||
Source0: ftp://ftp.gnupg.org/gcrypt/gpgme/gpgme-%{version}.tar.bz2
|
||||
Source0: https://gnupg.org/ftp/gcrypt/gpgme/gpgme-%{version}.tar.bz2
|
||||
Source2: gpgme-multilib.h
|
||||
|
||||
## upstream patches
|
||||
# https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gpgme.git;a=commit;h=b99502274ae5efdf6df0d967900ec3d1e64373d7
|
||||
Patch1000: 0001-core-Tweak-STATUS_FAILURE-handling.patch
|
||||
|
||||
## downstream patches
|
||||
# Don't add extra libs/cflags in gpgme-config/cmake equivalent
|
||||
Patch1001: 0001-don-t-add-extra-libraries-for-linking.patch
|
||||
@ -37,17 +32,19 @@ Patch1002: gpgme-1.3.2-largefile.patch
|
||||
# Let's fix stupid AX_PYTHON_DEVEL
|
||||
Patch1003: 0001-fix-stupid-ax_python_devel.patch
|
||||
# Fix resource leaks discovered by static code analyzer
|
||||
Patch1004: gpgme-1.10.0-fix-resource-leaks.patch
|
||||
Patch1004: gpgme-1.13.1-fix-resource-leaks.patch
|
||||
# Make the make check work with gnupg-2.2.19 and above
|
||||
Patch1005: gpgme-build-with-gnupg-2.2.19.patch
|
||||
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: automake
|
||||
#BuildRequires: autoconf
|
||||
#BuildRequires: automake
|
||||
BuildRequires: gcc
|
||||
BuildRequires: gcc-c++
|
||||
BuildRequires: gawk
|
||||
BuildRequires: gnupg2 >= %{gnupg2_min_ver}
|
||||
BuildRequires: gnupg2-smime
|
||||
BuildRequires: libgpg-error-devel >= %{libgpg_error_min_ver}
|
||||
BuildRequires: libassuan-devel >= 2.0.2
|
||||
BuildRequires: libassuan-devel >= 2.4.2
|
||||
|
||||
# For python bindings
|
||||
BuildRequires: swig
|
||||
@ -151,12 +148,10 @@ Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
|
||||
# set it to a value which we know will be suppressed.
|
||||
sed -i -e 's|^libdir=@libdir@$|libdir=@exec_prefix@/lib|g' src/gpgme-config.in
|
||||
|
||||
find -type f -name Makefile\* -exec sed -i -e 's|GPG = gpg|GPG = gpg2|' {} ';'
|
||||
|
||||
%build
|
||||
./autogen.sh
|
||||
#./autogen.sh
|
||||
%configure --disable-static --disable-silent-rules \
|
||||
--enable-languages=cpp,qt,python3
|
||||
--enable-languages=cpp,qt,python
|
||||
|
||||
%make_build
|
||||
|
||||
@ -166,6 +161,7 @@ find -type f -name Makefile\* -exec sed -i -e 's|GPG = gpg|GPG = gpg2|' {} ';'
|
||||
# unpackaged files
|
||||
rm -fv %{buildroot}%{_infodir}/dir
|
||||
rm -fv %{buildroot}%{_libdir}/lib*.la
|
||||
rm -fv %{buildroot}%{_libdir}/pkgconfig/%{name}*.pc
|
||||
|
||||
# Hack to resolve multiarch conflict (#341351)
|
||||
%ifarch %{multilib_arches}
|
||||
@ -200,6 +196,7 @@ make check
|
||||
%license COPYING*
|
||||
%doc AUTHORS ChangeLog NEWS README* THANKS TODO VERSION
|
||||
%{_libdir}/lib%{name}.so.11*
|
||||
%{_bindir}/%{name}-json
|
||||
|
||||
%post devel
|
||||
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir 2>/dev/null || :
|
||||
@ -253,6 +250,19 @@ fi
|
||||
%{python3_sitearch}/gpg/
|
||||
|
||||
%changelog
|
||||
* Tue Jun 02 2020 Jiri Kucera <jkucera@redhat.com> - 1.13.1-3
|
||||
- Fix resource leaks found by static code analysis
|
||||
Related: #1829822
|
||||
|
||||
* Mon Jun 01 2020 Jiri Kucera <jkucera@redhat.com> - 1.13.1-2
|
||||
- Remove *.pc files due to 'nothing provides pkgconfig(gpg-error)'
|
||||
and 'nothing provides pkgconfig(libassuan)' dnf errors
|
||||
Related: #1829822
|
||||
|
||||
* Mon Jun 01 2020 Jiri Kucera <jkucera@redhat.com> - 1.13.1-1
|
||||
- Update to gpgme 1.13.1
|
||||
Resolves: #1829822
|
||||
|
||||
* Mon Nov 12 2018 Jiri Kucera <jkucera@redhat.com> - 1.10.0-6
|
||||
- Fix important static scanner issues
|
||||
Resolves: #1602526
|
||||
|
Loading…
Reference in New Issue
Block a user