Commit Graph

3516 Commits

Author SHA1 Message Date
Werner Koch
f84abcad25
core: Add commented debug helper to posix-io.c.
* src/posix-io.c (_gpgme_is_fd_valid): New out-commented function.
--

This code is sometimes useful to track down invalid file descriptors.
We keep it commented in the code.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-06 18:57:28 +02:00
Werner Koch
6b9ff1ba39
core: Fix error return value of _gpgme_run_io_cb.
* src/wait.c (_gpgme_run_io_cb): Fix return code.
--

The function needs to return an gpg_error_t and not ERRNO.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-06 18:57:28 +02:00
Andre Heinecke
e6f2827306
tests: Add option "allow-del" to run-threaded
* tests/run-threaded.c (main): Handle allow-del.
(allow-del): New. Variable to allow deletion of keys.
(import): Delete key after import if allow-del is set.
(delete_impres): Delete keys from an import result.
(delete_fpr): Delete a key by fingerprint.

--
This is intended to test write access and locking of the
keyring by repeatedly importing and deleting pubkeys.

It is an option because it might cause keyring corruption
etc. so it should be explicitly enabled.
2019-06-06 09:19:02 +02:00
Andre Heinecke
024a7f75d4
tests: Implement import in run-threaded
* tests/run-threaded.c (import): New.
(do_data_op): Call it.
2019-06-05 17:23:59 +02:00
Werner Koch
0f68c9f16b
core: Prettify _gpgme_io_select debug output again and fix TRACE_SYSRES.
* src/debug.c (_gpgme_debug): Take better care of NULL userinfo.
(_gpgme_debug_end): Rework.
(_trace_sysres): Print ERRNO and not the supplied RES.
--

The TRACE_SYSRES patch fixes
Regression-due-to: 7a1e7006d0

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-05 16:48:47 +02:00
Andre Heinecke
3a3648e3a5
tests: Use synced output for error in run-threaded
* tests/run-threaded.c (do_data_op): Use synced out macro.
2019-06-05 16:20:31 +02:00
Andre Heinecke
3a11421d0f
tests: Avoid variable named the same as a macro
* tests/run-threaded.c (decrypt, verify): Don't use a variable name
that is also a macro.

--
It just looks confusing and strange at first glance.
2019-06-05 16:20:31 +02:00
Andre Heinecke
9bbe15ebbc
tests,w32: Fix thread creation in run-threaded
* tests/run-threaded.c (create_thread): Check proper return
value and not return value of CloseHandle.
2019-06-05 16:20:31 +02:00
Werner Koch
8f9f3224aa
core: Improve the debug messages even more.
* src/debug.c (_gpgme_debug): Add arg LINE.  Chnage all callers.
(_gpgme_debug_begin): Remove.
* src/debug.h (TRACE_SEQ): Use the LINE arg of _gpgme_debug.
--

This includes chnages to always print fds in decimal as weel as
tweaking the TARCE_SEQ function to make use of the new machinery.

The standard 'tag' can now always be NULL and no tag information will
be printed.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-05 15:54:55 +02:00
Werner Koch
856d2e8d64
core: Avoid explicit locks in the debug code.
* src/debug.c (debug_lock): Remove.  Also remove all users.
(_gpgme_debug): Use gpgrt_bsprintf to prepare the output and finally
print using standard fprintf.  Reformat to prefix to be narrower.
--

Note that the locks are now implicitly done using the systems stdio.

The threadid is now printed with 4 digits in hex and thus without the
angle brackets and the 0x.  However it is still a hex number even if it
may look like an octal number.  The hex letters are uppercase to make
searching in locks easier iff the threadid happens to have a letter in
it.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-05 13:11:16 +02:00
Werner Koch
f56c996318
json: Print "nan", "-inf", "inf" if needed.
* src/cJSON.c (print_number): Print NaN and INF.
--

GnuPG-bug-id: 4328
Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-04 10:56:48 +02:00
Werner Koch
fabe96126b
json: Improve handling of large exponents in the JSON parsor.
* src/cJSON.c: Include stdint.h.
(parse_number): Avoid overflob in SUBSCALE and cap integer values.
--

GnuPG-bug-id: 4330
Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-04 10:42:40 +02:00
Werner Koch
1024884e07
core: Implement recpstring option parsing for gpgsm.
* src/engine-gpg.c (append_args_from_recipients_string): Detect bad
options.
* src/engine-gpgsm.c (set_recipients_from_string): Implement option
parsing.
--

The only option we actually implement is "--" but the code layout is
now very simlar to engine-gpg and can easily be extended if ever
needed.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-04 09:29:09 +02:00
Werner Koch
e9ca36f876
core: Make gpgme_op_encrypt_ext work for CMS.
* src/engine-gpgsm.c (gpgsm_encrypt): Fix argument check.
--

It is pretty obvious thar the string based new encrypt function has
never been tested for S/MIME.  The fix was easy.  A followup patch
will extend it to allow for keywords in the future.

GnuPG-bug-id: 4556
Fixes-commit: a1f76b3b54
Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-04 08:27:49 +02:00
NIIBE Yutaka
47135ffdb9 python: Fix typo in DecryptionError exception.
* lang/python/src/errors.py (DecryptionError): Rename from
DeryptionError.
(UnsupportedAlgorithm): Use DecryptionError.

--

GnuPG-bug-id: 4478
Reported-by: Jan Girlich
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2019-06-04 10:38:17 +09:00
Andre Heinecke
49883023f6
Add NEWS for 1.13.1
* NEWS: Add news for 1.13.1

--
2019-06-03 13:01:37 +02:00
Andre Heinecke
f9c923bb2d
python: Make EXTRA_DIST files explicit
* configure.ac: Configure new Makefiles.
* lang/python/Makefile.am: Remove dirs from extra dist and use
subdirs.
* lang/python/examples/Makefile.am, lang/python/src/Makefile.am,
lang/python/doc/Makefile.am: New. Files that list EXTRA_DIST files.

--
This is similar to what lang/js does by explicitly listing the
files. This ensures that we have clean distribution tarballs
without accidentall additions that just lay in the directory.

GnuPG-Bug-Id: T4481
2019-05-06 16:08:26 +02:00
Andre Heinecke
63055f1340
Python, doc: Minor style improvement
* lang/python/src/core.py (Context): Retab and shorten
max line length.
2019-05-06 08:36:26 +02:00
Andre Heinecke
f303806a11
Merge remote-tracking branch 'origin/dkg/fix-T4276' 2019-05-06 08:10:03 +02:00
Andre Heinecke
33b13d1c29
Always use maintainer mode -Wno cflags
* configure.ac (CFLAGS): Move -Wno flags out of the maintainer mode.

--
It makes sense to have more warnings in maintainer mode and
not more warnings in release builds.

GnuPG-Bug-Id: T4477
2019-05-03 10:56:03 +02:00
Andre Heinecke
0ed8149814
cpp: Fix initialization warning
* lanc/cpp/src/gpggencardkeyinteractor.cpp
(GpgGenCardKeyInteractor::Private): Fix initialization warning.
2019-05-03 08:49:34 +02:00
Daniel Kahn Gillmor
4100794e30 python: stop raising BadSignatures from decrypt(verify=True)
* src/core.py (decrypt): filter out signatures with errors from the
returned verify_result, but avoid raising BadSignatures
* tests/t-decrypt-verify.py: ensure that only a single signature is
returned when evaluating cipher-3.asc, since the other signature is
unknown.

--

This change preserves the invariant that decrypt() only ever returns
valid signatures in the verify_result, but it avoids unnecessary
errors in the face of the presence of an additional bad signature.

GnuPG-bug-id: 4276
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-05-02 23:28:11 -04:00
Daniel Kahn Gillmor
bd2d282e57 python/tests: try to decrypt and verify new test data
* lang/python/tests/t-decrypt.py: test decryption of cipher-3.asc and
cipher-no-sig.asc
* lang/python/tests/t-decrypt-verify.py: test decryption and
verification of cipher-3.asc and cipher-no-sig.asc

--

note that this introduces a failed test -- decrypt-verify.py
misbehaves on cipher-3.asc by throwing a BadSignature even though

GnuPG-bug-id: 4276
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-05-02 22:23:28 -04:00
Daniel Kahn Gillmor
c5c3a9d10b tests: add two new types of encrypted data
* tests/gpg/cipher-3.asc: add an encrypted file containing signatures
(one from a known key, and one from an unknown key)
* tests/gpg/cipher-no-sig.asc: add an encrypted file containing no
signatures at all

--

We currently aren't using these files yet, but they should be useful
for exercising the library in unusual circumstances (where the bugs
are).

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-05-02 22:23:28 -04:00
Daniel Kahn Gillmor
30bd1c0975 python: make it easier to run a limited number of tests
* lang/python/tests/Makefile.am: prefer py_tests from the environment
if present.

--

I'm trying to make it nicer/quicker to hack on the testsuite for
python bindings. With this change, if you're improving the python
bindings test suite, you can selectively run only a few specific tests
like so:

   lang/python$ make check py_tests='t-decrypt.py t-decrypt-verify.py'

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-05-02 22:23:28 -04:00
Andre Heinecke
4746c5c9e2
tests: Add cms mode to run-import
* tests/run-import.c (show_usage): Add doc for cms / openpgp.
(main): Handle protocol.
2019-05-02 10:26:44 +02:00
Andre Heinecke
7981ec4147
cpp: Add wrapper for gpgme_set_global_flag
* lang/cpp/src/context.cpp (setGlobalFlag): New.
* lang/cpp/src/global.h (setGlobalFlag): Export it.

--
GnuPG-Bug-Id: T4471
2019-04-24 12:36:14 +02:00
NIIBE Yutaka
7673ef7953 core: Fix duplication of close_notify_handler for gpgsm.
* src/engine-gpgsm.c [!USE_DESCRIPTOR_PASSING] (gpgsm_new): Remove
last call to _gpgme_io_set_close_notify.

--

It is called just after the code in question for all cases.

GnuPG-bug-id: 4456
Fixes-commit: dd21ec997c
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2019-04-19 14:54:52 +09:00
NIIBE Yutaka
814f6c8de8 core: Fix error return.
* src/engine.c (_gpgme_set_engine_info): Add error return.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2019-04-19 11:34:12 +09:00
Andre Heinecke
140d694e1f
core,w32: Fix minor potential memleak
* src/w32-util.c (_gpgme_create_process_utf8): Free converted
startup info strings.
2019-04-09 14:24:17 +02:00
Andre Heinecke
ecbba12b86
core,w32: Fix new w32-util functions
* src/w32-util.c (_gpgme_access): Respect mode parameter.
(_gpgme_create_process_utf8): Convert startupinfo, too.

--
This both did not show up in testing as we only use
mode F_OK and STARTUPINFOA is basically the same as
STARTUPINFOW.

Fixes commit: a82e3a0ae5

GnuPG-Bug-Id: T4453
2019-04-09 14:11:21 +02:00
Andre Heinecke
a82e3a0ae5
core,w32: Improve handling of Unicode paths
* src/dirinfo.c (get_gpgconf_item): Use _gpgme_access.
* src/posix-util.c (_gpgme_access): Add forward to normal access.
* src/sys-util.h (_gpgme_access): New for posix and w32.
* src/w32-io.c (_gpgme_io_spawn): Use _gpgme_crate_process_utf8.
* src/w32-util.c (utf8_to_wchar, utf8_to_wchar0): The usual w32 conv.
(find_program_in_dir): Use _gpgme_access.
(find_program_at_standard_place): Use wchar API and convert to UTF-8.
(_gpgme_access): Convert UTF-8 to wchar and use wchar API.
(_gpgme_create_process_utf8): Convert UTF-8 to wchar and use wchar API.

--
While we should not say that we have full support for unicode path
installations of GnuPG, this ensures that GPGME works if GPGME
itself is installed in a unicode path. e.g.: Libreoffice supports
this.

GnuPG-Bug-Id: T4453

Based on a patch provided by Egor Pugin. Thanks.
2019-04-09 13:42:58 +02:00
Andre Heinecke
937adfdcbb
core,w32: Show w32-spawn warning only once
* src/w32-io.c (_gpgme_io_spawn): Show MessageBox only once.

--
This prevents multiple message boxes from showing when
the GPGME installation is unworkable.

GnuPG-Bug-Id: T4453
2019-04-09 13:25:08 +02:00
Andre Heinecke
4a4680f890
core, w32: Fix format string errors on windows
* src/debug.c (_gpgme_debug): Use gpgrt_vasprintf instead of
vfprintf to have a more portable format.

--
This fixes crashes on Windows because "%zu" is used which
is not natively supported on Windows but which gpgrt supports.
2019-03-27 17:47:41 +01:00
Andre Heinecke
19a4c4daa2
core: Fix assuan logger-fd hack for windows
* src/assuan-support.c (my_spawn): Zero is a perfectly fine fd.
2019-03-27 16:12:38 +01:00
Andre Heinecke
213c4bc1eb
core,w32,glib: Fix build of w32-glib-io.c
* src/w32-glib-io.c (_gpgme_io_pipe, _gpgme_io_connect): Do not
use TRACE_SUC in a return statement.
2019-03-26 19:22:44 +01:00
Werner Koch
5d2b3b28aa
Post release updates.
--
2019-03-26 18:42:26 +01:00
Werner Koch
1b5a6bf27a
Release GPGME 1.13.0
* configure.ac: Bump LT versions.
                For C to C33/A22/R0.
                For C++ to C15/A9/R0.
                For Qt to C10/A3/R3.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-03-26 17:17:08 +01:00
Andre Heinecke
10576dc427
core: Fix a strtoul to strtol
* src/assuan-support.c (my_spawn): Fix using strtoul for
a long.

--
This was commented on in129def87b262 and is correct.
It is signed here to better handle cases where an
invalid handle value (-1) would be passed.
2019-03-26 16:35:13 +01:00
Andre Heinecke
ffdb75217b
cpp: Fix GenCardKeyInteractor and extend it
* NEWS: Mention interface change.
* lang/cpp/src/gpggencardkeyinteractor.cpp
(GpgGenCardKeyInteractor::setAlgo): New.
(GpgGenCardKeyInteractor::action),
(GpgGenCardKeyInteractor::nextState: Handle new interface.

--
Tested that this workes with the old interface of GnuPG 2.2.5
and the new interface since GnuPG 2.2.6

GnuPG-Bug-Id: T4428
2019-03-26 12:02:28 +01:00
Andre Heinecke
129def87b2
core, w32: Add hack to translate diag logger-fd
* src/assuan-support.c (my_spawn): Add hack to
mark the logger fd for w32spawn translation.

--
The w32 spawn code needs to modify argv with
an updated fd that matches the real id
in the spawned process.

It uses spawn_fd_item_s.arg_loc for that.
We hack it here so that the arg_loc is set
for gpgsm's logger-fd without changing
the assuan API.

GnuPG-Bug-Id: T4426
2019-03-25 14:56:37 +01:00
Andre Heinecke
47369569e2
qt: Handle diagnostic audit log for CMS
* lang/qt/src/threadedjobmixin.cpp(_detail::audit_log_as_html):
Handle CMS audit log.
2019-03-20 09:56:38 +01:00
Werner Koch
dd21ec997c
core: Support GPGME_AUDITLOG_DIAG for gpgsm.
* src/engine-gpgsm.c (struct engine_gpgsm): Add fields diag_cb and
diagnostics.
(close_notify_handler): Close the diag fd on status fd close.
Handle diag close.
(gpgsm_cancel): Handle diag.
(gpgsm_release): Free DIAGNOSTICS.
(gpgsm_new): Support the diag feature.
(start): Set a handler for the diag fd.
(gpgsm_getauditlog): Support GPGME_AUDITLOG_DIAG.
--

Co-authored-by: Andre Heinecke <aheinecke@gnupg.org>
Signed-off-by: Werner Koch <wk@gnupg.org>
2019-03-19 19:53:22 +01:00
Andre Heinecke
c4cc47ee8f
cpp: Fix Error::hasSystemError
* lang/cpp/src/context.cpp (Error::hasSystemError): Invert logic to
do what it says.

--
This is safe because according to codesearch it is only used
in QGpgME
2019-03-13 12:02:05 +01:00
Werner Koch
1bdab961c5
json: Fix cosmetic error in the repl.
* src/gpgme-json.c (native_messaging_repl): Use correct var with sizeof.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-28 14:05:06 +01:00
Werner Koch
b159b2eddd
tests: Let run-verify print the de-vs flag.
* tests/run-verify.c (print_result): Chack is_de_vs.
* tests/run-import.c (main): Fix bad parameter for format string.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-28 14:01:47 +01:00
Andre Heinecke
4a117859e7
json: Limit recursion depth
* src/cJSON.c (MAX_DEPTH): New. Maximum recursion depth.
(parse_value, parse_array, parse_object): Carry and check
depth argument.
(cJSON_ParseWithOpts): Initialize depth.

--
This fixes a stack overflow if we get weird recursive
json data.

GnuPG-Bug-Id: T4331
2019-02-27 14:27:47 +01:00
Andre Heinecke
73b2f40ae5
cpp: Add ostream operators for import result
* lang/cpp/src/importresult.cpp: Add ostream operators.
* lang/cpp/src/importresult.h: Update accordingly.
2019-02-21 13:05:55 +01:00
Andre Heinecke
6175025c82
cpp: Make GpgME::Data::toKeys really const
* lang/cpp/src/data.cpp (GpgME::Data::toKeys): Rewind afterards.

--
This fixes unexpected behavior that the seek pointer is changed
after calling the const toKeys.
2019-02-21 13:04:54 +01:00
Werner Koch
4c49417cc0
core,w32: Fix missing sentinel in dir name builder.
* src/w32-util.c (_gpgme_get_gpgconf_path): Add NULL top strconcat.
--

Fortunately this is called early and the stack like cleared out so
that we have not seen wrong behaviour until now.  We should really fix
all these annoying HANDLE/int cast warnings and alike so that real
bugs are not drowned by them.

GnuPG-bug-id: 4369
Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-19 12:11:22 +01:00