Package: gnupg2 / 2.1.18-8~deb9u4

Metadata

Package Version Patches format
gnupg2 2.1.18-8~deb9u4 3.0 (quilt)

Patch series

view the series file
Patch File delta Description
debian packaging/0001 avoid beta warning.patch | (download)

autogen.sh | 6 3 + 3 - 0 !
1 file changed, 3 insertions(+), 3 deletions(-)

 avoid-beta-warning

avoid self-describing as a beta

Using autoreconf against the source as distributed in tarball form
invariably results in a package that thinks it's a "beta" package,
which produces the "THIS IS A DEVELOPMENT VERSION" warning string.

since we use dh_autoreconf, i need this patch to avoid producing
builds that announce themselves as DEVELOPMENT VERSIONs.

See discussion at:

 http://lists.gnupg.org/pipermail/gnupg-devel/2014-November/029065.html

block ptrace on sensitive daemons/0002 Avoid simple memory dumps via ptrace.patch | (download)

agent/gpg-agent.c | 8 8 + 0 - 0 !
configure.ac | 1 1 + 0 - 0 !
scd/scdaemon.c | 9 9 + 0 - 0 !
3 files changed, 18 insertions(+)

 avoid simple memory dumps via ptrace

This avoids needing to setgid gpg-agent or scdaemon.  It probably
doesn't defend against all possible attacks, but it defends against
one specific (and easy) one.  If there are other protections we should
do them too.

This will make it slightly harder to debug the agent or scdaemon
because the normal user won't be able to attach gdb to it directly
while it runs.

The remaining options for debugging are:

 * launch gpg-agent or scdaemon from gdb directly
 * connect gdb to a running gpg-agent or scdaemon as the superuser

Upstream bug: https://bugs.gnupg.org/gnupg/issue1211

debian packaging/0003 avoid regenerating defsincdate use shipped file.patch | (download)

doc/Makefile.am | 7 0 + 7 - 0 !
1 file changed, 7 deletions(-)

 avoid regenerating defsincdate (use shipped file)

upstream ships doc/defsincdate in its tarballs.  but doc/Makefile.am
tries to rewrite doc/defsincdate if it notices that any of the files
have been modified more recently, and it does so assuming that we're
running from a git repo.

However, we'd rather ship the documents cleanly without regenerating
defsincdate -- we don't have a git repo available (debian builds from
upstream tarballs) and any changes to the texinfo files (e.g. from
dirmngr idling/0001 dirmngr hkp Avoid potential race condition when some.patch | (download)

dirmngr/ks-engine-hkp.c | 21 10 + 11 - 0 !
1 file changed, 10 insertions(+), 11 deletions(-)

 dirmngr: hkp: avoid potential race condition when some hosts die.

* dirmngr/ks-engine-hkp.c (select_random_host): Use atomic pass
through the host table instead of risking out-of-bounds write.

--

Multiple threads may write to hosttable[x]->dead while
select_random_host() is running.  For example, a housekeeping thread
might clear the ->dead bit on some entries, or another connection to
dirmngr might manually mark a host as alive.

If one or more hosts are resurrected between the two loops over a
given table in select_random_host(), then the allocation of tbl might
not be large enough, resulting in a write past the end of tbl on the
second loop.

This change collapses the two loops into a single loop to avoid this
discrepancy: each host's "dead" bit is now only checked once.

As Werner points out, this isn't currently strictly necessary, since
npth will not switch threads unless a blocking system call is made,
and no blocking system call is made in these two loops.

However, in a subsequent change in this series, we will call a
function in this loop, and that function may sometimes write(2), or
call other functions, which may themselves block.  Keeping this as a
single-pass loop avoids the need to keep track of what might block and
what might not.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

dirmngr idling/0002 dimrngr Avoid need for hkp housekeeping.patch | (download)

dirmngr/dirmngr.c | 3 0 + 3 - 0 !
dirmngr/dirmngr.h | 1 0 + 1 - 0 !
dirmngr/ks-engine-hkp.c | 73 36 + 37 - 0 !
3 files changed, 36 insertions(+), 41 deletions(-)

 dimrngr: avoid need for hkp housekeeping.

* dirmngr/ks-engine-hkp.c (host_is_alive): New function.  Test whether
host is alive and resurrects it if it has been dead long enough.
(select_random_host, map_host, ks_hkp_mark_host): Use host_is_alive
instead of testing hostinfo_t->dead directly.
(ks_hkp_housekeeping): Remove function, no longer needed.
* dirmngr/dirmngr.c (housekeeping_thread): Remove call to
ks_hkp_housekeeping.

--

Rather than resurrecting hosts upon scheduled resurrection times, test
whether hosts should be resurrected as they're inspected for being
dead.  This removes the need for explicit housekeeping, and makes host
resurrections happen "just in time", rather than being clustered on
HOUSEKEEPING_INTERVAL seconds.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

dirmngr idling/0004 dirmngr Avoid automatically checking upstream swdb.patch | (download)

dirmngr/dirmngr.c | 13 0 + 13 - 0 !
doc/dirmngr.texi | 11 5 + 6 - 0 !
2 files changed, 5 insertions(+), 19 deletions(-)

 dirmngr: avoid automatically checking upstream swdb.

* dirmngr/dirmngr.c (housekeeping_thread): Avoid automatically
checking upstream's software database.  In Debian, software updates
should be handled by the distro mechanism, and additional upstream
checks only confuse the user.
* doc/dirmngr.texi: document that --allow-version-check does nothing.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

dirmngr idling/0005 dirmngr Drop useless housekeeping.patch | (download)

dirmngr/dirmngr.c | 113 5 + 108 - 0 !
1 file changed, 5 insertions(+), 108 deletions(-)

 dirmngr: drop useless housekeeping.

* dirmngr/dirmngr.c (handle_tick, time_for_housekeeping_p,
housekeeping_thread): Remove, no longer needed.
(handle_connections): Drop any attempt at a timeout, since no
housekeeping is necessary.

--

The housekeeping thread no longer does anything, and the main loop was
waking up every 60 seconds for no good reason.  The code is simpler
and the runtime is more efficient if we drop this.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

gpg agent idling/0001 agent Create framework of scheduled timers.patch | (download)

agent/gpg-agent.c | 87 58 + 29 - 0 !
1 file changed, 58 insertions(+), 29 deletions(-)

 agent: create framework of scheduled timers.

agent/gpg-agent.c (handle_tick): Remove intermittent call to
check_own_socket.
(tv_is_set): Add inline helper function for readability.
(handle_connections) Create general table of pending scheduled
timeouts.

--

handle_tick() does fine-grained, rapid activity.  check_own_socket()
gpg agent idling/0002 agent Allow threads to interrupt main select loop wi.patch | (download)

agent/agent.h | 1 1 + 0 - 0 !
agent/gpg-agent.c | 18 17 + 1 - 0 !
2 files changed, 18 insertions(+), 1 deletion(-)

 agent: allow threads to interrupt main select loop with sigcont.

* agent/gpg-agent.c (interrupt_main_thread_loop): New function on
non-windows platforms, allows other threads to interrupt the main loop
if there's something that the main loop might be interested in.

--

For example, the main loop might be interested in changes in program
state that affect the timers it expects to see.

I don't know how to do this on Windows platforms, but i welcome any
proposed improvements.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

gpg agent idling/0003 agent Avoid tight timer tick when possible.patch | (download)

agent/call-scd.c | 4 3 + 1 - 0 !
agent/gpg-agent.c | 31 28 + 3 - 0 !
2 files changed, 31 insertions(+), 4 deletions(-)

 agent: avoid tight timer tick when possible.

* agent/gpg-agent.c (need_tick): Evaluate whether the short-phase
handle_tick() is needed.
(handle_connections): On each cycle of the select loop, adjust whether
we should call handle_tick() or not.
(start_connection_thread_ssh, do_start_connection_thread): Signal the
main loop when the child terminates.
* agent/call-scd.c (start_scd): Call interrupt_main_thread_loop() once
the scdaemon thread context has started up.

--

With this change, an idle gpg-agent that has no scdaemon running only
wakes up once a minute (to check_own_socket).

Thanks to Ian Jackson and NIIBE Yutaka who helped me improve some of
the blocking and corner cases.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

gpg agent idling/0004 agent Avoid scheduled checks on socket when inotify .patch | (download)

agent/gpg-agent.c | 2 2 + 0 - 0 !
1 file changed, 2 insertions(+)

 agent: avoid scheduled checks on socket when inotify is working.

* agent/gpg-agent.c (handle_connections): When inotify is working, we
do not need to schedule a timer to evaluate whether we control our own
socket or not.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

0012 tools Fix memory leak.patch | (download)

tools/gpgconf-comp.c | 2 2 + 0 - 0 !
1 file changed, 2 insertions(+)

 tools: fix memory leak.

* tools/gpgconf-comp.c (change_options_file): Fix leak.
--
Previously, 'src_filename' and 'orig_filename' leaked if creating the
backup file failed.

Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 5b28f025085b386e0ec49535d4cd3f875a414eb0)

0013 tools Improve error handling.patch | (download)

tools/gpgconf-comp.c | 2 2 + 0 - 0 !
1 file changed, 2 insertions(+)

 tools: improve error handling.

* tools/gpgconf-comp.c (gp_component_change_options): Improve error
handling when reading from stdin.
--
Previously, errors encountered while reading the configuration changes
were ignored.

Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit b0348fdb26637b0bcbd68a96c1746a1613b309af)

0014 dirmngr New option disable ipv4.patch | (download)

dirmngr/crlfetch.c | 4 3 + 1 - 0 !
dirmngr/dirmngr.c | 5 5 + 0 - 0 !
dirmngr/dirmngr.h | 1 1 + 0 - 0 !
dirmngr/dns-stuff.c | 15 15 + 0 - 0 !
dirmngr/dns-stuff.h | 4 4 + 0 - 0 !
dirmngr/ks-engine-finger.c | 4 3 + 1 - 0 !
dirmngr/ks-engine-hkp.c | 8 6 + 2 - 0 !
dirmngr/ks-engine-http.c | 3 2 + 1 - 0 !
dirmngr/ocsp.c | 3 2 + 1 - 0 !
doc/dirmngr.texi | 5 5 + 0 - 0 !
10 files changed, 46 insertions(+), 6 deletions(-)

 dirmngr: new option --disable-ipv4.

* dirmngr/dirmngr.c (oDisableIPv4): New const.
(opts): New option --disable-ipv4.
(parse_rereadable_options): Set that option.
* dirmngr/dirmngr.h (opt): New field 'disable_ipv4'.
* dirmngr/dns-stuff.c (opt_disable_ipv4): bew var.
(set_dns_disable_ipv4): New.
(resolve_name_standard): Skip v4 addresses when OPT_DISABLE_IPV4 is
set.
* dirmngr/ks-engine-hkp.c (map_host): Ditto.
(send_request): Pass HTTP_FLAG_IGNORE_IPv4 if opt.disable_v4 is set.
* dirmngr/crlfetch.c (crl_fetch): Ditto.
* dirmngr/ks-engine-finger.c (ks_finger_fetch): Ditto.
* dirmngr/ks-engine-http.c (ks_http_fetch): Ditto.
* dirmngr/ocsp.c (do_ocsp_request): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 72736af86a501592d974d46ff754a63959e183bd)

0015 dirmngr Simplify error returning inside http.c.patch | (download)

dirmngr/http.c | 101 50 + 51 - 0 !
1 file changed, 50 insertions(+), 51 deletions(-)

 dirmngr: simplify error returning inside http.c.

* dirmngr/http.c (connect_server): Change to return an gpg_error_t
and to store socket at the passed address.
(http_raw_connect, send_request): Adjust accordingly.
--

This change removes cruft from the code and allows to return the error
code from the name lookup.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 51e5a5e5a46279809848b4ab4419f35045336010)

0016 gpg Print a warning on Tor problems.patch | (download)

dirmngr/ks-engine-hkp.c | 60 45 + 15 - 0 !
g10/call-dirmngr.c | 26 25 + 1 - 0 !
2 files changed, 70 insertions(+), 16 deletions(-)

 gpg: print a warning on tor problems.

* dirmngr/ks-engine-hkp.c (tor_not_running_p): New.
(map_host): Call that to print a warning.
(handle_send_request_error): Ditto and avoid marking the host dead.
Also print a tor_config_problem warning.  Add arg CTRL; adjust callers
to pass that new arg.
* g10/call-dirmngr.c (ks_status_cb): Detect and print the new
warnings.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 770b75a746836773909af25ccb9b480e61cea677)

0017 agent Fix double free.patch | (download)

agent/cache.c | 17 15 + 2 - 0 !
1 file changed, 15 insertions(+), 2 deletions(-)

 agent: fix double free.

* agent/cache.c (agent_store_cache_hit): Make sure the update is
atomic.
--
Previously, the function freed the last key, and duplicated the new
key after doing that.  There is a chance, however, that calling the
0018 gpg Fix searching for mail addresses in keyrings.patch | (download)

g10/keyring.c | 22 18 + 4 - 0 !
1 file changed, 18 insertions(+), 4 deletions(-)

 gpg: fix searching for mail addresses in keyrings.

* g10/keyring.c (compare_name): Fix KEYDB_SEARCH_MODE_MAIL* searches
in keyrings when the UID is a plain addr-spec.
--
Previously, 'gpg --list-key "<foo@example.org>"' failed if 1/ the
keyring format is used and 2/ the key's UID is a plain addr-spec
(cf. RFC2822 section 4.3), e.g. 'foo@example.org'.

GnuPG-bug-id: 2930
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 3f4f20ee6eff052c88647b820d9ecfdbd8df0f40)

0019 dirmngr New option no use tor and internal changes.patch | (download)

dirmngr/crlfetch.c | 10 5 + 5 - 0 !
dirmngr/dirmngr.c | 46 43 + 3 - 0 !
dirmngr/dirmngr.h | 3 1 + 2 - 0 !
dirmngr/dns-stuff.c | 8 8 + 0 - 0 !
dirmngr/dns-stuff.h | 1 1 + 0 - 0 !
dirmngr/ks-engine-finger.c | 2 1 + 1 - 0 !
dirmngr/ks-engine-hkp.c | 6 3 + 3 - 0 !
dirmngr/ks-engine-http.c | 2 1 + 1 - 0 !
dirmngr/ks-engine-ldap.c | 6 3 + 3 - 0 !
dirmngr/ocsp.c | 4 2 + 2 - 0 !
dirmngr/server.c | 10 7 + 3 - 0 !
11 files changed, 75 insertions(+), 23 deletions(-)

 dirmngr: new option --no-use-tor and internal changes.

* dirmngr/dns-stuff.c (disable_dns_tormode): New.
* dirmngr/dirmngr.c (oNoUseTor): New const.
(opts): New option --no-use-tor.
(tor_mode): New var.
(parse_rereadable_options): Change to use TOR_MODE.
(dirmngr_use_tor): New.
(set_tor_mode): Call disable_dns_tormode.  Implement oNoUseTor.
* dirmngr/dirmngr.h (opt): Remove field 'use_tor'.  Replace all
references by a call to dirmngr_use_tor().
* dirmngr/server.c (cmd_getinfo): Distinguish between default and
enforced TOR_MODE.
--

This patch replaces the global variable opt.use_tar by a function
testing a file local mode flag.  This patch prepares for a
use-tor-if-available mode.

GnuPG-bug-id: 2935
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 7440119e729d3fdedda8a9b44b70f8959beea8d7)

0020 gpg Remove period at end of warning.patch | (download)

g10/tofu.c | 2 1 + 1 - 0 !
1 file changed, 1 insertion(+), 1 deletion(-)

 gpg: remove period at end of warning.

* g10/tofu.c (tofu_register_encryption): Remove period at end of
warning.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
(cherry picked from commit 6f9d8a956b2ca0f5a0eb7acc656fc17af2f2de47)

0021 gpg Add newline to output.patch | (download)

g10/tofu.c | 2 1 + 1 - 0 !
1 file changed, 1 insertion(+), 1 deletion(-)

 gpg: add newline to output.

* g10/tofu.c (ask_about_binding): Add newline to output.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
(cherry picked from commit 74268180e5a3acc827f3a369f1fe5971f3bbe285)

0022 gpg Only print out TOFU statistics for conflicts in .patch | (download)

g10/tofu.c | 83 69 + 14 - 0 !
1 file changed, 69 insertions(+), 14 deletions(-)

 gpg: only print out tofu statistics for conflicts in interactive
 mode

* g10/tofu.c (get_trust): Add arguments POLICYP and CONFLICT_SETP.  If
they are not NULL, return the policy and conflict set (if there is
one), respectively.  Update callers.  If MAY_ASK is FALSE, don't print
out the statistics.
(tofu_register_encryption): If there is a conflict and we haven't yet
printed the statistics about the conflicting bindings, do so now.
(tofu_get_validity): Likewise.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 2914
(cherry picked from commit 027b81b35fe36692005b8dba22d9eb2db05e8c80)

0023 gpg If there is a TOFU conflict elide the too few me.patch | (download)

g10/tofu.c | 4 3 + 1 - 0 !
1 file changed, 3 insertions(+), 1 deletion(-)

 gpg: if there is a tofu conflict, elide the too few message warning.

* g10/tofu.c (tofu_get_validity): If there was a conflict, don't also
print out a warning about too few messages.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
(cherry picked from commit a08c781739e7561093f32b732c4991f2bd817ec2)

0024 gpg Ensure TOFU bindings associated with UTKs are re.patch | (download)

g10/tofu.c | 19 13 + 6 - 0 !
1 file changed, 13 insertions(+), 6 deletions(-)

 gpg: ensure tofu bindings associated with utks are registered as
 usual

* g10/tofu.c (get_trust): Call get_policy before short-circuiting the
policy lookup for ultimately trusted keys to make sure the binding is
added to the bindings table, if necessary.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 2929
(cherry picked from commit 769272ba87f282a69e8d5f9bb27c86e6bec4496b)

0025 gpg Don t assume that strtoul interprets as 0.patch | (download)

g10/tofu.c | 6 4 + 2 - 0 !
1 file changed, 4 insertions(+), 2 deletions(-)

 gpg: don't assume that strtoul interprets "" as 0.

* g10/tofu.c (show_statistics): If there are not records, return 0
instead of NULL.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 2853

According to SUSv3:

  If the subject sequence is empty or does not have the expected form,
  no conversion is performed
  ...
  If no conversion could be performed, 0 is returned and errno may be
  set to [EINVAL].

  http://pubs.opengroup.org/onlinepubs/007908799/xsh/strtol.html

It appears that MacOS X sets errno to EINVAL, but glibc doesn't.
Hence, we map NULL to 0 explicitly.

(cherry picked from commit 407f5f9baea5591f148974240a87dfb43e5efef3)

0026 gpg More diagnostics for a launched pinentry.patch | (download)

agent/call-pinentry.c | 6 5 + 1 - 0 !
g10/server.c | 19 8 + 11 - 0 !
2 files changed, 13 insertions(+), 12 deletions(-)

 gpg: more diagnostics for a launched pinentry.

* agent/call-pinentry.c (start_pinentry): Call getinfo/ttyinfo.
* g10/server.c (gpg_proxy_pinentry_notify): Simplify the output so
that we do not change the code when adding new fields to
PINENTRY_LAUNCHED.
--

This patch changes the --verbose output of gpg to show
for example

  gpg: pinentry launched (5228 gtk2 1.0.1-beta10 \
  /dev/pts/4 xterm localhost:10.0)

the used tty, its type, and the value of DISPLAY in addiion to the
pid, flavor, and version.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 7052a0d77cf8f3a445b252a809d29be445788625)

0027 doc Clarify abbreviation of help.patch | (download)

doc/gpg.texi | 3 2 + 1 - 0 !
1 file changed, 2 insertions(+), 1 deletion(-)

 doc: clarify abbreviation of --help.

* doc/gpg.texi: clarify abbreviation of --help.

Debian-bug-id: 852979
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
(cherry picked from commit f2b276dffbe2435b17abf2b3c51684d3636f3f11)

0028 scd Backport two fixes from master.patch | (download)

scd/app.c | 1 1 + 0 - 0 !
scd/command.c | 5 5 + 0 - 0 !
2 files changed, 6 insertions(+)

 scd: backport two fixes from master.

* scd/app.c (app_new_register): Initialize by -1, so that it can detect
an error correctly when card reader can't power-on the card initially.
* scd/command.c (open_card_with_request): Release APP before the scan.

--
The first one-liner patch handles an erroneous card.

The second patch handles the case when we repeatedly do
signing/decrypting by a single session of scdaemon.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>

0029 scd Fix use case of PC SC.patch | (download)

scd/apdu.c | 14 11 + 3 - 0 !
scd/apdu.h | 2 1 + 1 - 0 !
scd/app.c | 2 1 + 1 - 0 !
3 files changed, 13 insertions(+), 5 deletions(-)

 scd: fix use case of pc/sc.

* scd/apdu.c (apdu_open_reader): Add an argument APP_EMPTY.
When CCID driver fails to open, try PC/SC if APP is nothing.
* scd/app.c (select_application): Supply arg if APP is nothing.

--

After scanning available card readers by CCID driver, scdaemon should
try PC/SC service if no APP is registered yet.  Also, when the slot
is allocated for PC/SC (ccid.handle==NULL), it should not call
ccid_compare_BAI, otherwise scdaemon crashes.

Debian-bug-id: 852702, 854005, 854595, 854616

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>

0030 scd Fix factory reset.patch | (download)

scd/app-common.h | 3 2 + 1 - 0 !
scd/app.c | 86 49 + 37 - 0 !
scd/command.c | 6 3 + 3 - 0 !
scd/scdaemon.c | 51 47 + 4 - 0 !
scd/scdaemon.h | 1 1 + 0 - 0 !
5 files changed, 102 insertions(+), 45 deletions(-)

 scd: fix factory-reset.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>

Backport from master branch:

    99d4dfe83
    e2792813a
    031e3fa7b

Additionally, fix another bug when tested with 2.1.18-7 with PC/SC.

0031 gpg Fix aliases list key list sig and check sig.patch | (download)

g10/gpg.c | 6 3 + 3 - 0 !
1 file changed, 3 insertions(+), 3 deletions(-)

 gpg: fix aliases --list-key, --list-sig, and --check-sig.

* g10/gpg.c (opts): Define commands with ARGPARSE_c
instead of ARGPARSE_s_n.

--

These three entries are commands, but they're being treated as a
string-based option for some reason.  However, if you try to use them
concurrently with another command like --clearsign, you'll get "gpg:
conflicting commands".

0032 gpg common Make sure that all fd given are valid.patch | (download)

common/logging.c | 3 3 + 0 - 0 !
common/sysutils.c | 11 11 + 0 - 0 !
common/sysutils.h | 1 1 + 0 - 0 !
g10/cpr.c | 3 3 + 0 - 0 !
g10/gpg.c | 5 5 + 0 - 0 !
g10/keylist.c | 3 3 + 0 - 0 !
g10/passphrase.c | 3 3 + 0 - 0 !
tests/openpgp/Makefile.am | 4 2 + 2 - 0 !
tests/openpgp/issue2941.scm | 34 34 + 0 - 0 !
9 files changed, 65 insertions(+), 2 deletions(-)

 gpg,common: make sure that all fd given are valid.

* common/sysutils.c (gnupg_fd_valid): New function.
* common/sysutils.h (gnupg_fd_valid): New declaration.
* common/logging.c (log_set_file): Use the new function.
* g10/cpr.c (set_status_fd): Likewise.
* g10/gpg.c (main): Likewise.
* g10/keylist.c (read_sessionkey_from_fd): Likewise.
* g10/passphrase.c (set_attrib_fd): Likewise.
* tests/openpgp/Makefile.am (XTESTS): Add the new test.
* tests/openpgp/issue2941.scm: New file.
--

Consider a situation where the user passes "--status-fd 3" but file
descriptor 3 is not open.

During the course of executing the rest of the commands, it's possible
that gpg itself will open some files, and file descriptor 3 will get
allocated.

In this situation, the status information will be appended directly to
whatever file happens to have landed on fd 3 (the trustdb? the
keyring?).

This is a potential data destruction issue for all writable file
descriptor options:

   --status-fd
   --attribute-fd
   --logger-fd

It's also a potential issue for readable file descriptor options, but
the risk is merely weird behavior, and not data corruption:

   --override-session-key-fd
   --passphrase-fd
   --command-fd

Fixes this by checking whether the fd is valid early on before using
it.

GnuPG-bug-id: 2941
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 6823ed46584e753de3aba48a00ab738ab009a860)

0033 common Avoid warning about implicit declaration of g.patch | (download)

common/logging.c | 1 1 + 0 - 0 !
1 file changed, 1 insertion(+)

 common: avoid warning about implicit declaration of gnupg_fd_valid.
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

* common/logging.c: Add #include "sysutils.h".

--

Without this, we see:

logging.c:573:9: warning: implicit declaration of function \
  ‘gnupg_fd_valid’ [-Wimplicit-function-declaration]
   if (! gnupg_fd_valid (fd))
         ^~~~~~~~~~~~~~

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
(cherry picked from commit 8810314e377a9cb6612150a57cf99260ed0bb9f6)

0034 gpg Fix memory leak in the error case of signature c.patch | (download)

g10/sign.c | 11 9 + 2 - 0 !
1 file changed, 9 insertions(+), 2 deletions(-)

 gpg: fix memory leak in the error case of signature creation.
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

* g10/sign.c (write_signature_packets): Free SIG.  Also replace
xcalloc by xtrycalloc.
--

If do_sign fails SIG was not released.  Note that in the good case SIG
is transferred to PKT and freed by free_packet.

Reported-by: Stephan Müller
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 5996c7bf99f3a681393fd9589276399ebc956cff)

0035 gpg Print a warning if no command has been given.patch | (download)

g10/gpg.c | 6 5 + 1 - 0 !
1 file changed, 5 insertions(+), 1 deletion(-)

 gpg: print a warning if no command has been given.

* g10/gpg.c (main): Print in the default case.
--

GnuPG-bug-id: 2943
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 810adfd47801fc01e45fb71af9f05c91f7890cdb)

0036 gpgconf No ENOENT warning with change options et al.patch | (download)

tools/gpgconf-comp.c | 7 5 + 2 - 0 !
1 file changed, 5 insertions(+), 2 deletions(-)

 gpgconf: no enoent warning with --change-options et al.

* tools/gpgconf-comp.c (retrieve_options_from_program): Check ERRNO
before printing a warning.
--

It is common that a conf files does not exist - thus we should not
print a warning.

GnuPG-bug-id: 2944

BTW: The error messages in gpgconf should be reworked to match those
of the other components.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 30dac0486b6357e84fbe79c612eea940b654e4d1)

0037 dirmngr Do a DNS lookup even if it is missing from n.patch | (download)

dirmngr/dns-stuff.c | 27 21 + 6 - 0 !
1 file changed, 21 insertions(+), 6 deletions(-)

 dirmngr: do a dns lookup even if it is missing from nsswitch.conf.

* dirmngr/dns-stuff.c (libdns_init): Do not print error message for a
missing nsswitch.conf.  Make sure that tehre is a DNS entry.
--

GnuPG-bug-id: 2948
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit dee026d761ae3d7594c3dbc5b3fa842df53cc189)

0038 gpg Make export ssh key work for the primary key.patch | (download)

g10/export.c | 42 42 + 0 - 0 !
tests/openpgp/samplekeys/README | 2 2 + 0 - 0 !
tests/openpgp/samplekeys/rsa-primary-auth-only.pub.asc | 23 23 + 0 - 0 !
tests/openpgp/samplekeys/rsa-primary-auth-only.sec.asc | 38 38 + 0 - 0 !
4 files changed, 105 insertions(+)

 gpg: make --export-ssh-key work for the primary key.

* g10/export.c (export_ssh_key): Also check the primary key.
--

If no suitable subkey was found for export, we now check whether the
primary key is suitable for export and export this one.  Without this
change it was only possible to export the primary key by using the '!'
suffix in the key specification.

Also added a sample key for testing this.

GnuPG-bug-id: 2957
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit b456e5be91dc064fc9509ea86edab113721ed299)

0039 dirmngr Avoid PTR lookup for hosts in a pool.patch | (download)

dirmngr/ks-engine-hkp.c | 23 18 + 5 - 0 !
1 file changed, 18 insertions(+), 5 deletions(-)

 dirmngr: avoid ptr lookup for hosts in a pool

* dirmngr/ks-engine-hkp.c (add_host): Don't to a PTR lookup for hosts
in a pool.
--

GnuPG-bug-id: 2928
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit da2ba20868093e3054d18adc2b1bc56cb23e4ba7)

0040 gpgv w32 Fix status fd.patch | (download)

g10/gpgv.c | 4 3 + 1 - 0 !
1 file changed, 3 insertions(+), 1 deletion(-)

 gpgv,w32: fix --status-fd.

* g10/gpgv.c (main): Use translate_sys2libc_fd_int for --status-fd.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 8a67dc4c4324b617b5a3fea51c59c674488544d6)

0041 gpg tools Make trust model configurable via gpgconf.patch | (download)

g10/gpg.c | 1 1 + 0 - 0 !
tools/gpgconf-comp.c | 4 4 + 0 - 0 !
2 files changed, 5 insertions(+)

 gpg,tools: make trust-model configurable via gpgconf.

* g10/gpg.c (gpgconf_list): Add 'trust-model'.
* tools/gpgconf-comp.c (gc_options_gpg): Likewise.

GnuPG-bug-id: 2381
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit ebeccd73eb85f9027f0985d77dfe901266c6ddef)

0042 gpg tools Make auto key retrieve configurable via gp.patch | (download)

g10/gpg.c | 1 1 + 0 - 0 !
tools/gpgconf-comp.c | 2 2 + 0 - 0 !
2 files changed, 3 insertions(+)

 gpg,tools: make auto-key-retrieve configurable via gpgconf.

* g10/gpg.c (gpgconf_list): Add 'auto-key-retrieve'.
* tools/gpgconf-comp.c (gc_options_gpg): Likewise.

GnuPG-bug-id: 2381
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit d379a0174cca595204b32da9a66c513a1304e6d0)

0043 gpg Allow creating keys using an existing ECC key.patch | (download)

common/sexputil.c | 65 18 + 47 - 0 !
common/util.h | 6 3 + 3 - 0 !
g10/keygen.c | 22 3 + 19 - 0 !
sm/certreqgen-ui.c | 24 10 + 14 - 0 !
4 files changed, 34 insertions(+), 83 deletions(-)

 gpg: allow creating keys using an existing ecc key.

* common/sexputil.c (get_pk_algo_from_canon_sexp): Remove arg R_ALGO.
Change to return the algo id.  Reimplement using get_pk_algo_from_key.
* g10/keygen.c (check_keygrip): Adjust for change.
* sm/certreqgen-ui.c (check_keygrip): Ditto.
--

GnuPG-bug-id: 2976
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 2bbdeb8ee87a6c7ec211be16391a11b7c6030bed)

0044 gpg Make export options work with export secret keys.patch | (download)

doc/gpg.texi | 7 4 + 3 - 0 !
g10/export.c | 31 16 + 15 - 0 !
g10/gpg.c | 4 2 + 2 - 0 !
g10/main.h | 6 4 + 2 - 0 !
4 files changed, 26 insertions(+), 22 deletions(-)

 gpg: make --export-options work with --export-secret-keys.

* g10/export.c (export_seckeys): Add arg OPTIONS and pass it to
do_export.
(export_secsubkeys): Ditto.
* g10/gpg.c (main): Pass opt.export_options to export_seckeys and
export_secsubkeys
--

Back in the old days we did not used the export options for secret
keys export because of a lot of duplicated code and that the old
secring.gpg was anyway smaller that the pubring.gpg.  With 2.1 it was
pretty easy to enable it.

Reported-by: Peter Lebbing
GnuPG-bug-id: 2973
(cherry picked from commit 891ab23411b7f20ef37d8bde81d9857b083235df)

0045 common tools Always escape newlines when escaping da.patch | (download)

common/stringhelp.c | 10 9 + 1 - 0 !
tools/gpgconf-comp.c | 7 7 + 0 - 0 !
2 files changed, 16 insertions(+), 1 deletion(-)

 common,tools: always escape newlines when escaping data.

* common/stringhelp.c (do_percent_escape): Always escape newlines.
* tools/gpgconf-comp.c (gc_percent_escape): Likewise.
--
Newlines always pose a problem for a line-based communication format.

GnuPG-bug-id: 2387
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit e064c75b08a523f738108428fe0c417a46e66238)

0046 g10 Signal an error when trying to revoke non exista.patch | (download)

g10/keyedit.c | 2 2 + 0 - 0 !
tests/openpgp/quick-key-manipulation.scm | 6 6 + 0 - 0 !
2 files changed, 8 insertions(+)

 g10: signal an error when trying to revoke non-existant uid.

* g10/keyedit.c (keyedit_quick_revuid): Signal an error when trying to
revoke non-existant UID.
* tests/openpgp/quick-key-manipulation.scm: Test that.

GnuPG-bug-id: 2962
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 62d21a4ab4029b32ea129f1cf3a0e1f22e2fb7b0)

0047 gpg Fix possible segv when attribute packets are fil.patch | (download)

g10/import.c | 12 6 + 6 - 0 !
1 file changed, 6 insertions(+), 6 deletions(-)

 gpg: fix possible segv when attribute packets are filtered.

* g10/import.c (impex_filter_getval): Handle PKT_ATTRIBUTE the same as
PKT_USER_ID
(apply_drop_sig_filter): Ditto.
--

The old code was plainly wrong in that it considered PKT_ATTRIBUTE to
use a PKT_signature object.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 5f6f3f5cae8a95ed469129f9677782c17951dab3)

0048 gpg Fix attempt to double free an UID structure.patch | (download)

g10/getkey.c | 9 7 + 2 - 0 !
1 file changed, 7 insertions(+), 2 deletions(-)

 gpg: fix attempt to double free an uid structure.

* g10/getkey.c (get_best_pubkey_byname): Set released .UID to NULL.
--

Phil Pennock reported an assertion failure when doing

  % gpg --auto-key-locate dane --locate-keys someone
  gpg: Ohhhh jeeee: Assertion "uid->ref > 0" in \
         free_user_id failed (free-packet.c:310)

on his keyring.  This patch is not tested but a good guess.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 4a130bbc2c2f4be6e8c6357512a943f435ade28f)

0049 doc Add a note to the trust model direct.patch | (download)

doc/gpg.texi | 20 12 + 8 - 0 !
1 file changed, 12 insertions(+), 8 deletions(-)

 doc: add a note to the trust model direct.

* doc/gpg.texi (GPG Configuration Options): Add note.  Chnage Index
from trust-mode:foo to trust-model:foo.

(cherry picked from commit f0257b4a86b73f5b956028e68590b6d2a23ea4da)

0050 gpg Flush stdout before printing stats with check si.patch | (download)

g10/keylist.c | 6 5 + 1 - 0 !
1 file changed, 5 insertions(+), 1 deletion(-)

 gpg: flush stdout before printing stats with --check-sigs.

* g10/keylist.c (print_signature_stats): Flush stdout.
(list_keyblock_colon): Use es_flush instead of fflush.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 9a77b3b6e41f97b1209ad61c04b3dd33242ecae8)

0051 dirmngr Ignore warning alerts in the GNUTLS handshak.patch | (download)

dirmngr/http.c | 8 7 + 1 - 0 !
1 file changed, 7 insertions(+), 1 deletion(-)

 dirmngr: ignore warning alerts in the gnutls handshake.

* dirmngr/http.c (send_request) [GNUTLS]: Don't bail out on warning
alerts.
--

GnuPG-bug-id: 2833
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 69c521df422a6c9a6b0a93e45c9373a8b6ceb28e)

0052 gpg Make sure the conflict set includes the current .patch | (download)

g10/tofu.c | 28 25 + 3 - 0 !
1 file changed, 25 insertions(+), 3 deletions(-)

 gpg: make sure the conflict set includes the current key.

* g10/tofu.c (get_trust): Sanity check CONFLICT_SET after calling
get_policy.  If POLICY is 'auto' and the default policy is 'ask', make
sure CONFLICT_SET includes the current key.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 2959
Debian-bug-id: 854829

Signed-off-by: Neal H. Walfield <neal@g10code.com>
(cherry picked from commit b1106b4d640325c60a7212a4a44e4f67c0e3312d)

0053 dirmngr Load the hosts file into libdns.patch | (download)

dirmngr/dns-stuff.c | 26 25 + 1 - 0 !
1 file changed, 25 insertions(+), 1 deletion(-)

 dirmngr: load the hosts file into libdns.

* dirmngr/dns-stuff.c (libdns_init): Actually load the hosts file into
libdns.
--

Previously, connecting to key servers specified in /etc/hosts was not
possible because libdns' hosts structure was initialized, but not
filled with the content of the hosts file.

GnuPG-bug-id: 2977
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 88f1505f0613894d5544290a170119eb538921e5)

0054 dirmngr Fix error handling.patch | (download)

dirmngr/dns-stuff.c | 2 1 + 1 - 0 !
1 file changed, 1 insertion(+), 1 deletion(-)

 dirmngr: fix error handling.

* dirmngr/dns-stuff.c (libdns_init): Convert error before printing it.

Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 483c1288a8f86dc6bf93d0d3f2865ecc246aecba)

0055 common Implicitly do a gpgconf create socketdir.patch | (download)

common/homedir.c | 25 18 + 7 - 0 !
1 file changed, 18 insertions(+), 7 deletions(-)

 common: implicitly do a gpgconf --create-socketdir.

* common/homedir.c (_gnupg_socketdir_internal): Create the
sub-directory.
--

Although there is no auto cleanup (yet) this should be helpful.  Let's
see whether possibly leaving stale directories around is better than
running into trouble when --create-socketdir was not used.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 26086b362ff47d21b1abefaf674a6464bf0a8921)

0056 common Fix connecting to the agent.patch | (download)

common/homedir.c | 2 2 + 0 - 0 !
1 file changed, 2 insertions(+)

 common: fix connecting to the agent.

* common/homedir.c (_gnupg_socketdir_internal): Fix error handling.
--

Prior to 26086b36 the non-existance of the socket directory was
considered an error if a non-default home directory is used.  Since
26086b36 we now create the directory on demand, but the function still
returned the fallback path.  This made the agent bind the socket in
the socket directory, and the client trying to connect to the socket
in the home directory.

Fixes-commit: 26086b362ff47d21b1abefaf674a6464bf0a8921
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit caf00915532e6e8e509738962964edcd14fb0654)

0057 g10 Fix memory leak.patch | (download)

g10/decrypt-data.c | 3 2 + 1 - 0 !
1 file changed, 2 insertions(+), 1 deletion(-)

 g10: fix memory leak.

* g10/decrypt-data.c (decrypt_data): Free 'filename'.

Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 6d3edfd972c1114f43f6b35773dc25e0256f48f4)

0058 common Avoid undefined behavior.patch | (download)

common/iobuf.c | 2 1 + 1 - 0 !
1 file changed, 1 insertion(+), 1 deletion(-)

 common: avoid undefined behavior.

* common/iobuf.c (iobuf_read_line): Do not consider 'length' if
'buffer' is NULL.

Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 214fa9012296d796b78f1a3106d656639cf50aef)

0059 gpg Handle critical marked Reason for Revocation.patch | (download)

g10/parse-packet.c | 1 1 + 0 - 0 !
1 file changed, 1 insertion(+)

 gpg: handle critical marked 'reason for revocation'.

* g10/parse-packet.c (can_handle_critical): Add
SIGSUBPKT_REVOC_REASON.
--

Some software seems to mark that subpacket as criticial.  Although gpg
has no special treatment for a revocation reasons (except for
--list-packets) we can accept a criticial marked anyway.  There are no
mandatary rules specified on how to handle a revocation reason.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 3f6d949011f485613bb4bd3e06a2643be79cce40)

0060 dirmngr Do not assume that etc hosts exists.patch | (download)

dirmngr/dns-stuff.c | 16 12 + 4 - 0 !
1 file changed, 12 insertions(+), 4 deletions(-)

 dirmngr: do not assume that /etc/hosts exists.

* dirmngr/dns-stuff.c (libdns_init): Do not bail out.
--

A standard Windows installation does not have a hosts file and thus we
can't bail out here.  We should also not bail out on a Unix system
because /etc/hosts is just one method in  nsswitch.conf.

Fixes-commit: 88f1505f0613894d5544290a170119eb538921e5
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 5d873f288e86edfb684f4dd57ac36466b06494a4)