gnupg.git
23 months agotests: Clarify comments.
Justus Winter [Mon, 8 May 2017 10:37:20 +0000 (12:37 +0200)]
tests: Clarify comments.

--
Signed-off-by: Justus Winter <justus@g10code.com>
23 months agodoc: Fix documentation.
Justus Winter [Mon, 8 May 2017 10:18:19 +0000 (12:18 +0200)]
doc: Fix documentation.

--
Fixes-commit: da4db172f6f8fb254b770e59770c531a488e2400
Signed-off-by: Justus Winter <justus@g10code.com>
23 months agotests: Support tests that are expected to fail.
Justus Winter [Thu, 4 May 2017 13:12:49 +0000 (15:12 +0200)]
tests: Support tests that are expected to fail.

* tests/gpgscm/tests.scm (test-pool): Rework reporting.  Filter using
the computed test status instead of the return value.  Also print the
new categories 'failed expectedly' and 'passed unexpectedly'.
(test): If a test ends with a bang (!), it is expected to fail.  Adapt
status, status-string, and xml accordingly.
--

Allow tests to be marked as being expected to fail by appending a bang
(!) to the tests name.  If such a test fails, it will not be counted
as failure, but will still be prominently displayed in the report.  If
it succeeds unexpectedly, this is counted as a failure.

Fixes T3134.

GnuPG-bug-id: 3134
Signed-off-by: Justus Winter <justus@g10code.com>
23 months agotests: Add function to dump packets.
Justus Winter [Thu, 4 May 2017 12:24:50 +0000 (14:24 +0200)]
tests: Add function to dump packets.

* tests/openpgp/defs.scm (gpg-dump-packets): New function.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agospeedo,w32: Fix silent user mode installation
Andre Heinecke [Wed, 3 May 2017 14:28:24 +0000 (16:28 +0200)]
speedo,w32: Fix silent user mode installation

* build-aux/speedo/w32/inst.nsi (AddToPath): Move account
check here.
(PrintNonAdminWarning): Remove is_user_install variable.

--
The PrintNonAdminWarning is not called in silent mode so the
variable was never set.

Signed-off-by: Andre Heinecke <aheinecke@intevation.de>
23 months agogpgscm: Create and re-use frame objects.
Justus Winter [Thu, 6 Apr 2017 09:52:36 +0000 (11:52 +0200)]
gpgscm: Create and re-use frame objects.

* tests/gpgscm/scheme-private.h (struct scheme): New field
'frame_freelist'.
* tests/gpgscm/scheme.c (enum scheme_types): New type 'T_FRAME'.
(type_to_string): Handle new type.
(settype): New macro.
(gc_disable): Make sure there is at least one frame in the free list.
(mark): Handle frame objects.
(finalize_cell): Likewise.
(dump_stack_initialize): Initialize free list.
(dump_stack_free): Simplify.
(frame_length): New variable.
(dump_stack_make_frame): New function.
(frame_slots): Likewise.
(frame_payload): New macro.
(dump_stack_allocate_frame): New function.
(dump_stack_deallocate_frame): Likewise.
(dump_stack_preallocate_frame): Likewise.
(_s_return): Unpack frame object and deallocate it.
(s_save): Wrap state in an frame object.
(dump_stack_mark): Mark the free list.
--

TinySCHEME being a SECD-machine needs to push frames onto the dump
stack.  Previously, the dump stack was a list.  This required four
cells for the spine, as well as up to one additional cell to encode
the current opcode.  This was quite inefficient despite the fact that
we recovered the spine as well as the integer cell.

We introduce frame objects, which are a special variant of vectors of
length four.  Since the length is fixed, this frees up the length
field of the vector object to store the unboxed opcode.  A frame
object now fits in two cells.

Saving two or three cells is a mere byproduct, the performance gain
comes from increased locality, unboxed opcode representation, and the
ability to easily put the objects in a free list, keeping the garbage
collector out of the continuous motion of the virtual machine.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agogpgscm: Merge opexe_0.
Justus Winter [Wed, 5 Apr 2017 15:30:44 +0000 (17:30 +0200)]
gpgscm: Merge opexe_0.

* tests/gpgscm/scheme-private.h (struct scheme): Remove field 'op'.
* tests/gpgscm/scheme.c (opexe_0): Inline into 'Eval_Cycle'.
(_Error_1): Return the opcode to evaluate next.
(Error_1): Do not return, but set the opcode and goto dispatch.
(Error_0): Likewise.
(s_goto): Likewise.
(s_return): Likewise.
(s_return_enable_gc): Likewise.
(s_thread_to): Remove superfluous cast.
(_s_return): Return the opcode to evaluate next.
(scheme_init_custom_alloc): Adapt to removal of field 'op'.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agospeedo,w32: Allow installation as normal user
Andre Heinecke [Wed, 3 May 2017 12:40:16 +0000 (14:40 +0200)]
speedo,w32: Allow installation as normal user

* build-aux/speedo/w32/g4wihelp.c (ENV_HK_USER, ENV_REG_USER):
New defines.
(path_add): Handle is_user_install variable. Don't abort
if Path reg key does not exist. Fix crash if Path reg key
does not contain a semicolon.
(path_remove): Handle is_user_install variable. Fix crash
if Path reg key does not exist.
* build-aux/speedo/w32/inst.nsi: Remove obsolete HAVE_STARTMENU
this was double guarded with WITH_GUI. Add Multiuser plugin and
defines for this. Use SHCTX instead of HKLM / HKCU.
(PrintNonAdminWarning): Only Warn and don't abort.

--
The default is still to install as Adminstrator system wide
but the user now has the option to explicitly install GnuPG without
Administrator rights. A warning will be shown in that case but
a user may continue.

A per user install is by default under %LOCALAPPDATA%\GnuPG

Related Task: T2971

Signed-off-by: Andre Heinecke <aheinecke@intevation.de>
23 months agog10: Remove skeleton options files.
Daniel Kahn Gillmor [Mon, 17 Apr 2017 14:51:55 +0000 (10:51 -0400)]
g10: Remove skeleton options files.

* build-aux/speed/w32/inst.nsi: stop installing skeleton files.
* doc/gpg.texi: stop documenting skeleton files.
* g10/Makefile.am: stop installing skeleton files.
* g10/openfile.c (copy_options_file): Remove.
(try_make_homedir): do not call copy_options_file.

--

The defaults for gpg and dirmngr are good.  Both programs should work
fine for the simple case without any config file.  The skeleton config
files were being copied at first use (when the defaults are fine).
But when the user needs to fiddle with them (after they've become
sophisticated users), they're likely out of date because gpg has been
upgraded since then.  So they're used for documentation, but they're
stale documentation, which is probably worse than a clean empty file.

GnuPG-bug-id: 3086
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
23 months agoSpelling fixes in docs and comments.
NIIBE Yutaka [Fri, 28 Apr 2017 01:06:33 +0000 (10:06 +0900)]
Spelling fixes in docs and comments.

--

In addition, fix trailing spaces in tests/inittests.

GnuPG-bug-id: 3121
Reported-by: ka7 (klemens)
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
23 months agog10: For signing, prefer available card key when no -u option.
NIIBE Yutaka [Thu, 27 Apr 2017 01:33:58 +0000 (10:33 +0900)]
g10: For signing, prefer available card key when no -u option.

* g10/skclist.c (build_sk_list): Ask gpg-agent if card is available.
Then, use the card key if any.

--

GnuPG-bug-id: 1983
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
23 months agog10: Minor clean up.
NIIBE Yutaka [Wed, 26 Apr 2017 02:39:28 +0000 (11:39 +0900)]
g10: Minor clean up.

* g10/main.h (complete_sig): Remove declaration.
* g10/sign.c (complete_sig): Make it static.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
23 months agodirmngr: Fix aliasing problem in dns.c.
NIIBE Yutaka [Tue, 25 Apr 2017 12:00:41 +0000 (21:00 +0900)]
dirmngr: Fix aliasing problem in dns.c.

* dirmngr/dns.c (dns_ai_setent): Care about aliasing.

--

Co-authored-by: Tomas Mraz
GnuPG-bug-id: 3105
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
23 months agotests: Remove *.conf.tmpl from Makefile.
NIIBE Yutaka [Tue, 25 Apr 2017 02:39:59 +0000 (11:39 +0900)]
tests: Remove *.conf.tmpl from Makefile.

* tests/openpgp/Makefile.am (TEST_FILES): Remove gpg.conf.tmpl
and gpg-agent.conf.tmpl.

--

Fixes-commit: 06a177ceea529269a7404740c60416bd6a4567b1
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
23 months agog10: invalidate the fd cache for keyring.
NIIBE Yutaka [Mon, 24 Apr 2017 22:48:51 +0000 (07:48 +0900)]
g10: invalidate the fd cache for keyring.

* g10/keyring.c (keyring_search_reset): Don't keep the FD cache.

--

GnuPG-bug-id: 3096
Fixes-commit: 5556eca5acd46983bff0b38a1ffbc2f07fbaba9f
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
23 months agow32: Enable wildcard expansion with mingw-w64
Andre Heinecke [Tue, 12 Aug 2014 19:22:23 +0000 (21:22 +0200)]
w32: Enable wildcard expansion with mingw-w64

* g10/gpg.c: Define _dowildcard = -1;

--
If this value is defined wildcard support in the c runtime
is enabled again. This fixes a regression caused by switching to
mingw 3.0

Signed-off-by: Andre Heinecke <aheinecke@intevation.de>
23 months agotests: Fix Python detection.
Justus Winter [Mon, 24 Apr 2017 15:32:41 +0000 (17:32 +0200)]
tests: Fix Python detection.

* tests/gpgme/gpgme-defs.scm (python): Fix Python detection.
--
In 25e6444b3f4601c7821beab06bc4520deacb007b we changed the way GPGME
creates the build directory for the Python bindings.  We now use the
basename of the interpreter as an identifier, that means we have to
get the base name right, a link to the same binary is not sufficient.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agogpgscm: Refactor cell finalization.
Justus Winter [Thu, 20 Apr 2017 15:39:41 +0000 (17:39 +0200)]
gpgscm: Refactor cell finalization.

* tests/gpgscm/scheme.c (finalize_cell): Use switch, return whether
the cell may be freed.
(gc): Update callsite.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agogpgscm: Tweak error message display.
Justus Winter [Thu, 20 Apr 2017 15:38:43 +0000 (17:38 +0200)]
gpgscm: Tweak error message display.

* tests/gpgscm/init.scm (throw'): If the first argument to the error
is a string, display it as such.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agotests: Deduplicate and simplify code.
Justus Winter [Thu, 20 Apr 2017 15:35:15 +0000 (17:35 +0200)]
tests: Deduplicate and simplify code.

* tests/gpgme/gpgme-defs.scm (create-file): Move...
* tests/gpgsm/gpgsm-defs.scm (create-file): ... likewise...
* tests/openpgp/defs.scm (create-file): Here.
(create-gpghome): Use 'create-file'.
* tests/openpgp/gpg-agent.conf.tmpl: Delete file.
* tests/openpgp/gpg.conf.tmpl: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agogpgscm: Fix test.
Justus Winter [Thu, 20 Apr 2017 15:32:25 +0000 (17:32 +0200)]
gpgscm: Fix test.

* tests/gpgscm/t-child.scm: Use 'string-length' on the string.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agogpgscm: Improve syntax checking.
Justus Winter [Thu, 20 Apr 2017 13:09:13 +0000 (15:09 +0200)]
gpgscm: Improve syntax checking.

* tests/gpgscm/scheme.c (opexe_0): Make sure closure arguments are
symbols.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agogpgscm: Emit JUnit-style XML reports.
Justus Winter [Tue, 18 Apr 2017 16:51:06 +0000 (18:51 +0200)]
gpgscm: Emit JUnit-style XML reports.

* tests/gpgscm/Makefile.am (EXTRA_DIST): Add new file.
* tests/gpgscm/lib.scm (string-translate): New function.
* tests/gpgscm/main.c (main): Load new file.
* tests/gpgscm/tests.scm (dirname): New function.
(test-pool): Record execution times, emit XML report.
(test): Record execution times, record log file name, emit XML report.
(run-tests-parallel): Write XML report.
(run-tests-sequential): Likewise.
* tests/gpgscm/xml.scm: New file.
* tests/gpgme/Makefile.am (CLEANFILES): Add 'report.xml'.
* tests/gpgsm/Makefile.am: Likewise.
* tests/migrations/Makefile.am: Likewise.
* tests/openpgp/Makefile.am: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agogpgscm: Make logging less verbose and more useful.
Justus Winter [Thu, 20 Apr 2017 09:49:17 +0000 (11:49 +0200)]
gpgscm: Make logging less verbose and more useful.

* tests/gpgscm/tests.scm (call-with-io): When being verbose, include
the pid in the output, and avoid duplicating the command arguments.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agogpgscm: Make test framework less functional.
Justus Winter [Tue, 18 Apr 2017 10:27:49 +0000 (12:27 +0200)]
gpgscm: Make test framework less functional.

* tests/gpgscm/tests.scm (test-pool, tests): Previously, these methods
updated objects by creating new updated copies of the object being
manipulated.  This made the code awkward without any benefit,
therefore I change it to just update the object.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agotests: Locate resources and scripts relative to top source dir.
Justus Winter [Wed, 22 Mar 2017 11:40:42 +0000 (12:40 +0100)]
tests: Locate resources and scripts relative to top source dir.

--

Locate every resource and every script used in the tests using a path
relative to the top of the source tree.

This is a purely mechanical change, mostly done using regular
expressions, with a few manual fixups here and there.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agogpgscm: Move 'trace' and 'stringify'.
Justus Winter [Wed, 19 Apr 2017 14:09:44 +0000 (16:09 +0200)]
gpgscm: Move 'trace' and 'stringify'.

* tests/gpgscm/tests.scm (trace, stringify): Move...
* tests/gpgscm/lib.scm: ... here.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agogpgscm: Avoid fruitless garbage collection cycles.
Justus Winter [Thu, 20 Apr 2017 13:04:52 +0000 (15:04 +0200)]
gpgscm: Avoid fruitless garbage collection cycles.

* tests/gpgscm/scheme-private.h (CELL_MINRECOVER): New macro.
* tests/gpgscm/scheme.c (_get_cell): Move the heuristic to get more
cells...
(gc): ... here where every caller benefits from the optimization.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agog13: Fix for Solaris.
NIIBE Yutaka [Thu, 20 Apr 2017 11:43:29 +0000 (20:43 +0900)]
g13: Fix for Solaris.

* configure.ac: Check sys/mkdev.h.
* g13/sh-dmcrypt.c: Include sys/mkdev.h.

--

GnuPG-bug-id: 3098
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: Fix final close of LISTEN_FD.
NIIBE Yutaka [Tue, 18 Apr 2017 00:04:11 +0000 (09:04 +0900)]
dirmngr: Fix final close of LISTEN_FD.

* dirmngr/dirmngr.c (handle_connections): Close LISTEN_FD.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: Fix API difference for Windows.
NIIBE Yutaka [Tue, 18 Apr 2017 00:03:14 +0000 (09:03 +0900)]
dirmngr: Fix API difference for Windows.

* dirmngr/http.c (read_server, write_server): Use assuan_fd_t.
(http_wait_response): Use FD2INT to get unsigned integer fd.
(read_server, write_server): Likewise.
(simple_cookie_read, simple_cookie_write): Use assuan_fd_t.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoagent: More minor change.
NIIBE Yutaka [Mon, 17 Apr 2017 11:03:36 +0000 (20:03 +0900)]
agent: More minor change.

* agent/command.c (cmd_pksign): Remove redundant assignment.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoagent: Minor cleanup.
NIIBE Yutaka [Mon, 17 Apr 2017 07:43:36 +0000 (16:43 +0900)]
agent: Minor cleanup.

* agent/command-ssh.c (ssh_key_to_protected_buffer): Not touch ERR.
* agent/command.c (cmd_genkey, cmd_import_key): Clean up.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agotests: Minor memory fix.
NIIBE Yutaka [Mon, 17 Apr 2017 00:44:37 +0000 (09:44 +0900)]
tests: Minor memory fix.

* tests/openpgp/fake-pinentry.c (get_passphrase): Free the memory.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agog10: Fix parse_ring_trust.
NIIBE Yutaka [Mon, 17 Apr 2017 00:33:19 +0000 (09:33 +0900)]
g10: Fix parse_ring_trust.

* g10/parse-packet.c (parse_ring_trust): Fix condition.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agog10: Minor fixes.
NIIBE Yutaka [Mon, 17 Apr 2017 00:15:13 +0000 (09:15 +0900)]
g10: Minor fixes.

* g10/export.c (cleartext_secret_key_to_openpgp): No initialization.
(do_export_one_keyblock): Initialize with GPG_ERR_NOT_FOUND.
* g10/getkey.c (get_best_pubkey_byname): Add non-null check.
* g10/tofu.c (tofu_set_policy): ERR initialize to 0.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agog10: Fix import/export filter property match.
NIIBE Yutaka [Mon, 17 Apr 2017 00:08:31 +0000 (09:08 +0900)]
g10: Fix import/export filter property match.

* g10/import.c (impex_filter_getval): Fix to "else if".

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoagent: Clean up error initialize/return.
NIIBE Yutaka [Fri, 14 Apr 2017 03:54:06 +0000 (12:54 +0900)]
agent: Clean up error initialize/return.

* agent/call-pinentry.c (start_pinentry): Return RC.
* agent/command-ssh.c (ssh_handler_request_identities): Don't set ERR.
* agent/findkey.c (try_unprotect_cb): Return ERR.
(unprotect): Don't set RC.
* agent/gpg-agent.c (handle_connections): Don't set fd.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: More fix for test program.
NIIBE Yutaka [Fri, 14 Apr 2017 00:18:41 +0000 (09:18 +0900)]
dirmngr: More fix for test program.

* dirmngr/t-http.c (main): Care about no TLS.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: More fix for Windows.
NIIBE Yutaka [Thu, 13 Apr 2017 23:32:49 +0000 (08:32 +0900)]
dirmngr: More fix for Windows.

* dirmngr/http.c (simple_cookie_read, simple_cookie_write): Only
valid with HTTP_USE_NTBTLS.
(_my_socket_new): Simply cast to int since it's for debug.
(_my_socket_ref, _my_socket_unref): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: Fix http.c for sockaddr_storage.
NIIBE Yutaka [Thu, 13 Apr 2017 05:46:57 +0000 (14:46 +0900)]
dirmngr: Fix http.c for sockaddr_storage.

dirmngr/http.c (use_socks): Use sockaddr_storage.
(my_sock_new_for_addr, connect_server): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: Fix alignment of ADDR.
NIIBE Yutaka [Thu, 13 Apr 2017 05:33:33 +0000 (14:33 +0900)]
dirmngr: Fix alignment of ADDR.

* dirmngr/dns-stuff.h (dns_addrinfo_s): Use struct sockaddr_storage
for size and alignment.
* dirmngr/dns-stuff.c (resolve_name_libdns): Follow the change.
(resolve_dns_name): Use struct sockaddr_storage.
(resolve_addr_standard, resolve_dns_addr): Likewise.
(resolve_dns_addr): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: Fix thread key type.
NIIBE Yutaka [Thu, 13 Apr 2017 04:06:38 +0000 (13:06 +0900)]
dirmngr: Fix thread key type.

* dirmngr/dirmngr.c (my_tlskey_current_fd): Use npth_key_t.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agocommon, g10: Fix enumeration types.
NIIBE Yutaka [Thu, 13 Apr 2017 03:54:52 +0000 (12:54 +0900)]
common, g10: Fix enumeration types.

* common/openpgpdefs.h (CIPHER_ALGO_PRIVATE10, PUBKEY_ALGO_PRIVATE10)
(DIGEST_ALGO_PRIVATE10, COMPRESS_ALGO_PRIVATE10): New.
* g10/misc.c (map_pk_gcry_to_openpgp): Add type conversion.
(map_cipher_openpgp_to_gcry, openpgp_cipher_algo_name)
(openpgp_pk_test_algo2, map_md_openpgp_to_gcry)
(pubkey_get_npkey): Add default handling.

--

Compilers may emit code assuming the maximum value of enum type.
According to OpenPGP specification, there are cases for private uses.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: More fix for Windows.
NIIBE Yutaka [Thu, 13 Apr 2017 00:52:19 +0000 (09:52 +0900)]
dirmngr: More fix for Windows.

* dirmngr/dns.c (socket_fd_t, STDCALL): New.
(dns_te_initname): Use.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: Fix type of sock.
NIIBE Yutaka [Wed, 12 Apr 2017 11:50:50 +0000 (20:50 +0900)]
dirmngr: Fix type of sock.

* dirmngr/http.c (send_request): Use assuan_fd_t for SOCK.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agotools: Fix condition for gpg-connect-agent.
NIIBE Yutaka [Wed, 12 Apr 2017 07:01:16 +0000 (16:01 +0900)]
tools: Fix condition for gpg-connect-agent.

* tools/gpg-connect-agent.c (start_agent): Add paren.

--

The intention is comparing the error code depending opt.use_dirmngr.
Considering C Operator Precedence, we should have paren here.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: Fix possible null reference.
NIIBE Yutaka [Wed, 12 Apr 2017 06:58:11 +0000 (15:58 +0900)]
dirmngr: Fix possible null reference.

* dirmngr/dns.c (dns_error_t dns_trace_fput): Check NULL.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agocommon: Simplify format_text.
NIIBE Yutaka [Wed, 12 Apr 2017 05:47:30 +0000 (14:47 +0900)]
common: Simplify format_text.

* common/stringhelp.c (format_text): Don't allow IN_PLACE formatting.
* common/stringhelp.h: Change the API with no IN_PLACE.
* common/t-stringhelp.c (test_format_text): Follow the change.
* g10/gpgcompose.c (show_help): Likewise.
* g10/tofu.c (format_conflict_msg_part1, ask_about_binding)
(show_statistics, show_warning): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agogpgscm: Fix test program.
NIIBE Yutaka [Wed, 12 Apr 2017 03:05:53 +0000 (12:05 +0900)]
gpgscm: Fix test program.

* tests/gpgscm/t-child.c (main): Fix for setmode.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: Fix plus1_ns.
NIIBE Yutaka [Wed, 12 Apr 2017 02:44:10 +0000 (11:44 +0900)]
dirmngr: Fix plus1_ns.

* dirmngr/dns.c (plus1_ns): Fix the initial implementation.

--

Fixes-commit: 64904ce627b6b0661acf15b5b70103c4842bb0f3
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoscd: Handle unexpected suspend/resume by CCID driver.
NIIBE Yutaka [Wed, 12 Apr 2017 02:21:08 +0000 (11:21 +0900)]
scd: Handle unexpected suspend/resume by CCID driver.

* scd/ccid-driver.c (bulk_in): Handle unexpected failure.

--

GnuPG-bug-id: 3083
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: Fix dns-stuff.c in another way.
NIIBE Yutaka [Wed, 12 Apr 2017 01:19:27 +0000 (10:19 +0900)]
dirmngr: Fix dns-stuff.c in another way.

* dirmngr/dns-stuff.c (T_CERT): Define our own.

--

T_CERT may be defined by another enum type even if the value is same.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoRevert "dirmngr: Fix dns-stuff.c."
NIIBE Yutaka [Wed, 12 Apr 2017 01:00:37 +0000 (10:00 +0900)]
Revert "dirmngr: Fix dns-stuff.c."

This reverts commit 1538523156be568046f632d1775eae30ea8bd556.

2 years agodirmngr: Fix dns-stuff.c.
NIIBE Yutaka [Wed, 12 Apr 2017 00:48:27 +0000 (09:48 +0900)]
dirmngr: Fix dns-stuff.c.

* dirmngr/dns-stuff.c: Don't include arpa/nameser.h.

--

It is not needed at all.  T_CERT may be defined by different type of
ns_type.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoagent: Simplify stream_read_cstring.
NIIBE Yutaka [Wed, 12 Apr 2017 00:24:48 +0000 (09:24 +0900)]
agent: Simplify stream_read_cstring.

* agent/command-ssh.c (stream_read_cstring): Just call
stream_read_string.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agodirmngr: Use a function to increment network short.
NIIBE Yutaka [Wed, 12 Apr 2017 00:11:20 +0000 (09:11 +0900)]
dirmngr: Use a function to increment network short.

* dirmngr/dns.c (plus1_ns): New.
(dns_p_push): Use it.

--

On OpenBSD, htons and ntohs are expanded to GCC's statement
expressions where local variable is allowed.  Consecutive use
of htons and ntohs causes problem of variable name.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agog10: Minor clean up for export.c.
NIIBE Yutaka [Tue, 11 Apr 2017 23:47:23 +0000 (08:47 +0900)]
g10: Minor clean up for export.c.

* g10/export.c (export_ssh_key): Check IDENTIFIER for error.
Release base64 thing on error of get_membuf.

--

Compiler (older) may misunderstand the variable IDENTIFIER is not
initialized, while good one can do better analysys on the value for
ERR (and thus, IDENTIFIER).

On the error of get_membuf, still, b64enc_finish should be called,
even if it lost the ERR value.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agog13: Include sys/sysmacros.h if available.
NIIBE Yutaka [Tue, 11 Apr 2017 10:59:07 +0000 (19:59 +0900)]
g13: Include sys/sysmacros.h if available.

* configure.ac: Add test for sys/sysmacros.h.
* g13/sh-dmcrypt.c: Include sys/sysmacros.h.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agotests: Fix distcheck.
Justus Winter [Tue, 11 Apr 2017 09:50:54 +0000 (11:50 +0200)]
tests: Fix distcheck.

* tests/gpgscm/Makefile.am (EXTRA_DIST): Add 'gnupg.scm'.

Fixes-commit: ccd2187212c12b84c86a10fd4417a16536243179
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests: Avoid relying on implicit gpg commands.
Justus Winter [Tue, 11 Apr 2017 09:37:37 +0000 (11:37 +0200)]
tests: Avoid relying on implicit gpg commands.

* tests/openpgp/armdetach.scm: Always use an explicit command instead
of relying on gpg to guess what we want.
* tests/openpgp/armdetachm.scm: Likewise.
* tests/openpgp/armencrypt.scm: Likewise.
* tests/openpgp/armencryptp.scm: Likewise.
* tests/openpgp/armor.scm: Likewise.
* tests/openpgp/armsignencrypt.scm: Likewise.
* tests/openpgp/armsigs.scm: Likewise.
* tests/openpgp/clearsig.scm: Likewise.
* tests/openpgp/compression.scm: Likewise.
* tests/openpgp/conventional-mdc.scm: Likewise.
* tests/openpgp/conventional.scm: Likewise.
* tests/openpgp/decrypt-dsa.scm: Likewise.
* tests/openpgp/decrypt.scm: Likewise.
* tests/openpgp/detach.scm: Likewise.
* tests/openpgp/detachm.scm: Likewise.
* tests/openpgp/ecc.scm: Likewise.
* tests/openpgp/encrypt-dsa.scm: Likewise.
* tests/openpgp/encrypt-multifile.scm: Likewise.
* tests/openpgp/encrypt.scm: Likewise.
* tests/openpgp/encryptp.scm: Likewise.
* tests/openpgp/seat.scm: Likewise.
* tests/openpgp/signencrypt-dsa.scm: Likewise.
* tests/openpgp/signencrypt.scm: Likewise.
* tests/openpgp/sigs-dsa.scm: Likewise.
* tests/openpgp/sigs.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests: Make tests more robust.
Justus Winter [Tue, 11 Apr 2017 08:46:09 +0000 (10:46 +0200)]
tests: Make tests more robust.

* tests/openpgp/defs.scm (have-opt-always-trust): Execute in empty
ephemeral home directory.  This prevents gpg from picking up the
configuration from the current gnupghome (if any).
* tests/migrations/common.scm (untar-armored): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests: Move common functionality.
Justus Winter [Tue, 11 Apr 2017 08:43:52 +0000 (10:43 +0200)]
tests: Move common functionality.

* tests/openpgp/defs.scm (with-home-directory,
with-ephemeral-home-directory): Move...
* tests/gpgscm/gnupg.scm: ... to this new file.
* tests/gpgscm/main.c (main): Load the new file.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agodirmngr: Fix build for Windows.
NIIBE Yutaka [Tue, 11 Apr 2017 07:12:34 +0000 (16:12 +0900)]
dirmngr: Fix build for Windows.

* dirmngr/ldap-wrapper-ce.c (outstream_cookie_writer): Use
gpgrt_ssize_t.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agog10,tools: Fix bzlib.h include order.
NIIBE Yutaka [Tue, 11 Apr 2017 04:52:19 +0000 (13:52 +0900)]
g10,tools: Fix bzlib.h include order.

* g10/compress-bz2.c: Include bzlib.h after gcrypt.h.
* tools/gpgsplit.c: Likewise.

--

bzlib.h may include windows.h on Windows.  It is better
after gcrypt.h which may include winsock2.h.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agog10: Minor clean up for TOFU.
NIIBE Yutaka [Tue, 11 Apr 2017 03:51:47 +0000 (12:51 +0900)]
g10: Minor clean up for TOFU.

* g10/tofu.c (ask_about_binding): Fix for qualifier.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agocommon: Portability fix for logging.c.
NIIBE Yutaka [Tue, 11 Apr 2017 02:53:52 +0000 (11:53 +0900)]
common: Portability fix for logging.c.

* common/logging.c (S_IRGRP, S_IWGRP, S_IROTH, S_IWOTH): Avoid
duplicated definition.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agotools: Portability fix for gpgparsemail.
NIIBE Yutaka [Tue, 11 Apr 2017 02:23:05 +0000 (11:23 +0900)]
tools: Portability fix for gpgparsemail.

* tools/rfc822parse.c (my_stpcpy): Rename from stpcpy.

--

When HAVE_STPCPY is not defined (no definition in libc), still,
compiler may have definition as a built-in function (for some specific
case like second argument is constant).  In that case, having stpcpy
implementation with the same name but different signature ("static"
qualifier) is not good.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agogpgscm: Fix opcode dispatch.
Justus Winter [Wed, 5 Apr 2017 14:56:46 +0000 (16:56 +0200)]
gpgscm: Fix opcode dispatch.

* tests/gpgscm/scheme.c (opexe_0): Consider 'op', not 'sc->op'.  The
former is the opcode we are currently executing.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Mmap script files.
Justus Winter [Wed, 5 Apr 2017 12:11:57 +0000 (14:11 +0200)]
gpgscm: Mmap script files.

* tests/gpgscm/main.c (load): Try to mmap the script.
* tests/gpgscm/scheme.c (scheme_load_memory): New function, a
generalization of 'scheme_load_string'.
* tests/gpgscm/scheme.h (scheme_load_memory): New prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Refactor checking for opcode arguments.
Justus Winter [Mon, 3 Apr 2017 09:25:49 +0000 (11:25 +0200)]
gpgscm: Refactor checking for opcode arguments.

* tests/gpgscm/scheme.c (op_code_info): Fix type, add forward
declaration.
(check_arguments): New function.
(Eval_cycle): Use the new function.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Improve syntax dispatch.
Justus Winter [Wed, 29 Mar 2017 16:10:17 +0000 (18:10 +0200)]
gpgscm: Improve syntax dispatch.

* tests/gpgscm/scheme.c (assign_syntax): Add opcode parameter, store
opcode in the tag.
(syntaxnum): Add sc parameter, retrieve opcode from tag.
(opexe_0): Adapt callsite.
(scheme_init_custom_alloc): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Make tags mandatory.
Justus Winter [Wed, 29 Mar 2017 16:05:33 +0000 (18:05 +0200)]
gpgscm: Make tags mandatory.

* tests/gpgscm/opdefines.h: Make tags mandatory.
* tests/gpgscm/scheme.c: Likewise.
* tests/gpgscm/scheme.h: Likewise.
--

Tags provide a constant-time lookup mechanism for almost every object.
This is useful for the interpreter itself, and the code for tags is
tiny.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Add and use opcode for reversing a list in place.
Justus Winter [Tue, 4 Apr 2017 10:02:54 +0000 (12:02 +0200)]
gpgscm: Add and use opcode for reversing a list in place.

* tests/gpgscm/lib.scm (string-split-pln): Use 'reverse!'.
(string-rtrim): Likewise.
* tests/gpgscm/opdefines.h (reverse!): New opcode.
* tests/gpgscm/scheme.c (opexe_0): Handle new opcode.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Deduplicate code.
Justus Winter [Wed, 29 Mar 2017 15:09:01 +0000 (17:09 +0200)]
gpgscm: Deduplicate code.

* tests/gpgscm/scheme.c (oblist_add_by_name): Deduplicate.
(new_slot_spec_in_env): Likewise.

Fixes-commit: 6a3f857224eab108ae38e6259194b01b0ffdad8b
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Move dispatch table into rodata.
Justus Winter [Wed, 29 Mar 2017 14:32:36 +0000 (16:32 +0200)]
gpgscm: Move dispatch table into rodata.

* tests/gpgscm/opdefines.h: Use 0 instead of NULL.
* tests/gpgscm/scheme.c (op_code_info): Use char arrays instead of
pointers, make arity parameters smaller.
(INF_ARG): Adapt.
(_OP_DEF): Likewise.
(dispatch_table): Likewise.
(procname): Likewise.
(Eval_cycle): Likewise.
(scheme_init_custom_alloc): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Use more threaded code.
Justus Winter [Wed, 29 Mar 2017 12:24:49 +0000 (14:24 +0200)]
gpgscm: Use more threaded code.

* tests/gpgscm/scheme.c (opexe_0): Use 's_thread_to' instead of
's_goto' wherever possible.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Remove now obsolete dispatcher function from the opcodes.
Justus Winter [Wed, 29 Mar 2017 12:11:58 +0000 (14:11 +0200)]
gpgscm: Remove now obsolete dispatcher function from the opcodes.

* tests/gpgscm/opdefines.h: Remove now obsolete dispatcher function
from the opcodes.
* tests/gpgscm/scheme-private.h (_OP_DEF): Adapt.
* tests/gpgscm/scheme.c (dispatch_func): Remove type declaration.
(op_code_info): Remove 'func'.
(_OP_DEF): Adapt.
(Eval_Cycle): Always call 'opexe_0'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Merge 'opexe_6'.
Justus Winter [Wed, 29 Mar 2017 12:05:22 +0000 (14:05 +0200)]
gpgscm: Merge 'opexe_6'.

* tests/gpgscm/scheme.c (opexe_6): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Merge 'opexe_5'.
Justus Winter [Wed, 29 Mar 2017 11:57:54 +0000 (13:57 +0200)]
gpgscm: Merge 'opexe_5'.

* tests/gpgscm/scheme.c (opexe_5): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Merge 'opexe_4'.
Justus Winter [Wed, 29 Mar 2017 11:47:54 +0000 (13:47 +0200)]
gpgscm: Merge 'opexe_4'.

* tests/gpgscm/scheme.c (opexe_4): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Merge 'opexe_3'.
Justus Winter [Wed, 29 Mar 2017 11:45:25 +0000 (13:45 +0200)]
gpgscm: Merge 'opexe_3'.

* tests/gpgscm/scheme.c (opexe_3): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Merge 'opexe_2'.
Justus Winter [Wed, 29 Mar 2017 11:40:01 +0000 (13:40 +0200)]
gpgscm: Merge 'opexe_2'.

* tests/gpgscm/scheme.c (opexe_2): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Merge 'opexe_1'.
Justus Winter [Wed, 29 Mar 2017 11:32:38 +0000 (13:32 +0200)]
gpgscm: Merge 'opexe_1'.

* tests/gpgscm/scheme.c (opexe_1): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoagent: Use "ll" length specifier when time_t is larger.
NIIBE Yutaka [Mon, 10 Apr 2017 06:04:57 +0000 (15:04 +0900)]
agent: Use "ll" length specifier when time_t is larger.

* agent/command.c (cmd_keytocard): Use KEYTOCARD_TIMESTAMP_FORMAT.

--

On a big-endian 32-bit platform which uses 64-bit time_t, it might go
wrong.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoscd: Relax a condition for p15 driver.
NIIBE Yutaka [Mon, 10 Apr 2017 04:18:30 +0000 (13:18 +0900)]
scd: Relax a condition for p15 driver.

* scd/app-p15.c (read_ef_aodf): Fix.

--

Fixes-commit: 3c1ad96f1ce838daf2d861b33e6611f6d3043d25
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoscd: Relax a condition for p15 driver.
NIIBE Yutaka [Mon, 10 Apr 2017 03:59:29 +0000 (12:59 +0900)]
scd: Relax a condition for p15 driver.

* scd/app-p15.c (read_ef_aodf): Remove possibly redundant condition.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoscd: Remove "special transport" support.
NIIBE Yutaka [Mon, 10 Apr 2017 03:25:06 +0000 (12:25 +0900)]
scd: Remove "special transport" support.

* scd/ccid-driver.c (transports, my_sleep, prepare_special_transport)
(writen): Remove.
(ccid_dev_scan, ccid_dev_scan_finish, ccid_get_BAI): Only for USB.
(ccid_open_reader, do_close_reader, bulk_out, bulk_in, abort_cmd)
(ccid_poll, ccid_transceive): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agogpgscm: Allocate small integers in the rodata section.
Justus Winter [Thu, 23 Mar 2017 14:21:36 +0000 (15:21 +0100)]
gpgscm: Allocate small integers in the rodata section.

* tests/gpgscm/Makefile.am (gpgscm_SOURCES): Add new file.
* tests/gpgscm/scheme-private.h (struct cell): Move number to the top
of the union so that we can initialize it.
(struct scheme): Remove 'integer_segment'.
* tests/gpgscm/scheme.c (initialize_small_integers): Remove function.
(small_integers): New variable.
(MAX_SMALL_INTEGER): Compute.
(mk_small_integer): Adapt.
(mark): Avoid marking objects already marked.  This allows us to run
the algorithm over objects in the rodata section if they are already
marked.
(scheme_init_custom_alloc): Remove initialization.
(scheme_deinit): Remove deallocation.
* tests/gpgscm/small-integers.h: New file.
--

Allocate small integers from a fixed pool in the rodata section.  This
spares us the initialization, and deduplicates integers across
different processes.  It also makes the integers immutable, increasing
memory safety.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Make global data constant when possible.
Justus Winter [Thu, 23 Mar 2017 11:50:27 +0000 (12:50 +0100)]
gpgscm: Make global data constant when possible.

* tests/gpgscm/scheme-private.h (struct scheme): Make 'vptr' const.
* tests/gpgscm/scheme.c (num_zero): Statically initialize and turn
into constant.
(num_one): Likewise.
(charnames): Change type so that it can be stored in rodata.
(is_ascii_name): Adapt slightly.
(assign_proc): Make argument const char *.
(op_code_info): Make some fields const char *.
(tests): Make const.
(dispatch_table): Make const.  At least it can be made read-only after
relocation.
(Eval_Cycle): Adapt slightly.
(vtbl): Make const.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Remove arbitrary limit on number of cell segments.
Justus Winter [Wed, 22 Mar 2017 15:22:57 +0000 (16:22 +0100)]
gpgscm: Remove arbitrary limit on number of cell segments.

* tests/gpgscm/scheme-private.h (struct scheme): Remove fixed-size
arrays for cell segments, replace them with a pointer to the new
'struct cell_segment' instead.
* tests/gpgscm/scheme.c (struct cell_segment): New definition.
(_alloc_cellseg): Allocate the header within the segment, return a
pointer to the header.
(_dealloc_cellseg): New function.
(alloc_cellseg): Insert the segments into a list.
(_get_cell): Allocate a new segment if less than a quarter of
CELL_SIGSIZE is recovered during garbage collection.
(initialize_small_integers): Adapt callsite.
(gc): Walk the list of segments.
(scheme_init_custom_alloc): Remove initialization of removed field.
(scheme_deinit): Adapt deallocation.
--

Previously the number of cells that could be allocated was a
compile-time limit.  Remove this limit.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Fix compact vector encoding.
Justus Winter [Fri, 7 Apr 2017 10:27:47 +0000 (12:27 +0200)]
gpgscm: Fix compact vector encoding.

* tests/gpgscm/scheme-private.h (struct cell): Use uintptr_t for
'_flags'.  This way, '_flags' has the size of a machine word.
--

The compact vector representation introduced in 49e2ae65 requires that
we can tell apart pointers and type flags.  This did not work on
64-bit big-endian architectures.

Fixes a crash on 64-bit big-endian architectures.

Hat-tip-to: gniibe
Fixes-commit: 49e2ae65e892f93be7f87cfaae3392b50a99e4b1
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agodoc: Explain the '>' in a key listing.
Werner Koch [Fri, 7 Apr 2017 08:26:55 +0000 (10:26 +0200)]
doc: Explain the '>' in a key listing.

--

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agogpg: Fix printing of offline taken subkey.
Werner Koch [Fri, 7 Apr 2017 08:11:07 +0000 (10:11 +0200)]
gpg: Fix printing of offline taken subkey.

* g10/keylist.c (list_keyblock_print): Set SECRET to 2 and not 0x32.
--

Reported-by: Danielle McLean <dani@00dani.me>
Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoscd: Internal CCID reader cleanup.
NIIBE Yutaka [Fri, 7 Apr 2017 04:30:35 +0000 (13:30 +0900)]
scd: Internal CCID reader cleanup.

* scd/ccid-reader.c (scan_usb_device): Only for scan mode, so, rename
from scan_or_find_usb_device.
(scan_devices): Likewise.  Remove support of special transport types.
(ccid_get_reader_list): Simplify.
(abort_cmd): Fix error return.
(send_escape_cmd): Fix for RESULTLEN == NULL.
(ccid_transceive_secure): Remove unnecessary var updates.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoscd: Don't keep CCID reader open when card is not available.
NIIBE Yutaka [Fri, 7 Apr 2017 03:18:16 +0000 (12:18 +0900)]
scd: Don't keep CCID reader open when card is not available.

* scd/apdu.c (open_ccid_reader): Fail if no ATR.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agoagent: Serialize access to passphrase cache.
NIIBE Yutaka [Thu, 6 Apr 2017 23:39:26 +0000 (08:39 +0900)]
agent: Serialize access to passphrase cache.

* agent/cache.c (encryption_lock): Remove.
(cache_lock): New.  Now, we have coarse grain lock to serialize
entire cache access.
(initialize_module_cache): Use CACHE_LOCK.
(init_encryption, new_data): Remove ENCRYPTION_LOCK.
(agent_flush_cache, agent_put_cache, agent_get_cache): Lock the cache.

--

GnuPG-bug-id: 3027
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agogpgscm: Avoid mutating integer.
Justus Winter [Thu, 6 Apr 2017 14:24:49 +0000 (16:24 +0200)]
gpgscm: Avoid mutating integer.

* tests/gpgscm/scheme.c (opexe_5): Do not modify the integer in-place
while printing an vector.  Integer objects may be shared, so they must
not be mutated.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpgscm: Initialize unused slots in vectors.
Justus Winter [Thu, 6 Apr 2017 14:21:48 +0000 (16:21 +0200)]
gpgscm: Initialize unused slots in vectors.

* tests/gpgscm/scheme.c (get_vector_object): Initialize unused slots
at the end of vectors.
--

They should not be used for anything, but let's just initialize them
to something benign to be sure.

GnuPG-bug-id: 3014
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests: Fix distcheck.
Justus Winter [Thu, 6 Apr 2017 13:17:08 +0000 (15:17 +0200)]
tests: Fix distcheck.

* tests/Makefile.am (SUBDIRS): Add 'pkits' again.  Simply dropping it
makes 'make distcheck' unhappy.
* tests/pkits/Makefile.am (TESTS): Remove all tests.
--

Disable the 'pkits' tests in a way that keeps 'make distcheck' happy.
To run tests individually, do

  make -Ctests/pkits check TESTS=some-test

GnuPG-bug-id: 3067
Fixes-commit: af1c1a57e46a00a32d83c1a58c5f3ef6f4a1c1d1
Signed-off-by: Justus Winter <justus@g10code.com>