Commit Graph

11 Commits

Author SHA1 Message Date
Ingo Klöcker
305d8668ca core: Detect bad passphrase error on certificate import
* src/import.c (gpgme_op_import_result): Check fpr for NULL.
(parse_error): New.
(import_status_handler): Handle error status line.

* doc/gpgme.texi (gpgme_import_status_t): Mention that fpr can be NULL.

* tests/gpg/t-import.c (check_result): Check fpr for NULL.
* tests/run-threaded.c (delete_impres): Check fpr for NULL.
--

When importing an encrypted certificate a wrong passphrase may be
entered. In this case gpgsm emits a status line with a bad passphrase
error and an "invalid object" error. To make it possible for callers
to handle a wrong passphrase error more gracefully, an import status
with bad passphrase error is added to the import result for each
status line with bad passphrase error.

GnuPG-bug-id: 5713
2021-12-22 15:25:42 +01:00
Werner Koch
aa98081356
core: Allow for older compilers.
* tests/run-verify.c (main): Remove C99-only syntax.
* tests/run-threaded.c (start_keylistings): Ditto.
--

Older gcc's do not grok this and there is no real need for it.

  run-verify.c:324: error: ‘for’ loop initial declarations are only
  allowed in C99 mode
  run-verify.c:324: note: use option -std=c99 or -std=gnu99 to compile
  your code

Reported-by: Lars Hecking
2021-05-12 08:50:04 +02:00
Werner Koch
f6fd90c99a
tests: Minor fix to run-threaded.c.
* tests/run-threaded.c (random_data_close): Correct FD test.
--

An invalid DS is -1 and not 0; this fix is for correctness and does
not chnage anything in the real world.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-06 18:59:16 +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
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
Andre Heinecke
f8312d7c33
tests: Fix memleak in run-threaded
* tests/run-threaded.c (verify): Free msg.
2019-02-11 15:33:34 +01:00
Werner Koch
8d91c0f4cd
Add SPDX identifiers to most source files
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-11-16 13:27:33 +01:00
Andre Heinecke
d0402f886b
tests: Add run-threaded for multithread tests
* tests/Makefile.am (run-threaded): Add.
* tests/run-threaded.c: New.

--
This test is intended to help detect race conditions
or other multithread problems. It can also be used
to put the whole GnuPG system under extreme load.
2018-11-15 11:57:27 +01:00