aboutsummaryrefslogtreecommitdiffstats
path: root/src (unfollow)
Commit message (Collapse)AuthorFilesLines
2015-07-17Add per-ctx custom engine options.bjk/custom-engine-optionsBen Kibbey13-1/+161
* src/gpgme.h.in (gpgme_ctx_set_engine_options): New prototype. (gpgme_ctx_get_engine_options): Ditto. * src/engine-backend.h (engine_ops): Add set_options and get_options. * src/engine.c (gpgme_ctx_set_engine_options): New. (gpgme_ctx_get_engine_options): Ditto. * src/engine-gpg.c (gpg_set_options): New. (gpg_get_options): Ditto. * src/op-support.c (_gpgme_op_reset): Keep custom options. * src/engine-gpg.c (_gpgme_engine_ops_gpg): Adjust for new members. * src/engine-assuan.c (_gpgme_engine_ops_assuan): Ditto. * src/engine-g13.c (_gpgme_engine_ops_g13): Ditto. * src/engine-gpgconf.c (_gpgme_engine_ops_gpgconf): Ditto. * src/engine-gpgsm.c (_gpgme_engine_ops_gpgsm): Ditto. * src/engine-spawn.c (_gpgme_engine_ops_spawn): Ditto. * src/engine-uiserver.c (_gpgme_engine_ops_uiserver): Ditto. * src/gpgme.def: Export new symbols. * src/libgpgme.vers: Ditto. * doc/gpgme.texi: Document these new functions. -- Not all of gpg2's features are exposed to libgpgme and adding these functions makes it possible to do things like specify an --s2k-count, etc.
2015-06-08Fix regression with gpgsm 2.0 due to "OPTION with-secret".Werner Koch1-16/+30
* src/engine-gpgsm.c (gpgsm_assuan_simple_command): Do not terminate on a status lines. -- This bug has been with us since the support for gpgsm: If there is no status line handler but a status line is received anyway the command handling loop terminates and thus the command/answer order gets out of sync. In the case of the bug report this is triggered by sending an option which starts the agent and that starting emits a "PROGRESS" status line. The solution is not to stop reading after a status line but record a possible error code and return that only after OK or ERR. GnuPG-bug-id: 1795 Signed-off-by: Werner Koch <[email protected]>
2015-06-08Fix compiler warnings about unused value in TRACE macros.Werner Koch2-37/+45
* src/debug.h: Change macros to not have a literal 0 as last expression of the comma operator. * src/debug.c (_gpgme_debug_frame_end): Return 0. (_gpgme_debug): Return 0. -- Instead of using foo(), 0 for the trace macros we let foo() return 0 instead. Signed-off-by: Werner Koch <[email protected]>
2015-06-05Set GPGME_SIGSUM_KEY_REVOKED also for gpg.Matthew Barnes1-0/+7
* src/verify.c (calc_sig_summary): Handle GPG_ERR_CERT_REVOKED. -- parse_new_sig() handles a revoked key by setting sig->status to GPG_ERR_CERT_REVOKED, but then later calc_sig_summary() expects that code in sig->validity_reason. Additional comments added by wk.
2015-06-05Fix segv for userids with a backslash.Werner Koch1-0/+1
* src/engine-gpg.c (gpg_keylist_preprocess): Increment SRC for a backslash. -- This bug is not exploitable because this bug fills up .data with backslashes and thus causes the segv. Signed-off-by: Werner Koch <[email protected]>
2015-04-13w32: Use -static-libgcc to avoid linking to libgcc_s_sjlj-1.dll.Werner Koch1-4/+8
* src/Makefile.am (extra_ltoptions): New. (libgpgme_la_LDFLAGS): Use it. (libgpgme_pthread_la_LDFLAGS): Ditto. (libgpgme_glib_la_LDFLAGS): Ditto. -- Since gcc 4.8 there is a regression in Mingw64 in that plain C programs may link to libgcc_s.a which has a dependency on libgcc_s_sjlj.dll. This is for example triggered by using long long arithmetic on a 32 bit Windows (e.g symbol __udivdi3). Note that we don't use this patch for the Qt version which, as C++ programs, actually requires that DLL, Signed-off-by: Werner Koch <[email protected]>
2015-03-16Fix potential crash in trace macro.Werner Koch3-5/+3
* src/signers.c (gpgme_signers_add): Avoid deref of a NULL KEY in the trace macro. * src/engine-spawn.c (engspawn_release): Remove always true condition. * src/engine-gpg.c (gpg_release): Ditto. Signed-off-by: Werner Koch <[email protected]>
2015-03-16Fix one byte too short malloc.Werner Koch1-1/+1
* src/engine-spawn.c (add_data): Fix malloc -- Bummer. Why did I subtracted one from the size? Did I assume a dynamically allocated structure with a string field which was not going to be used? Very strange. Not a real problem though because malloc will anyway round up the allocation to at least the next word size. Detected by Stack 0.3.
2014-12-08Return an error for some export key operations.Werner Koch2-4/+127
* src/context.h (OPDATA_EXPORT): New. * src/export.c (op_data_t): New. (release_op_data): New. (parse_error): New. (export_status_handler): New. (export_start, export_ext_start): Prepare op_data. (gpgme_op_export_ext, gpgme_op_export_keys): Return an error from the status handler. -- To support an error return also for the async functions we need to extend the API. Until we have done that this new features helps at least in some cases; in particular for --send-keys.
2014-11-21Update the previous commitWerner Koch1-58/+54
* src/sign.c (gpgme_op_sign_result): Reformat and take care of failed malloc. -- Although _gpgme_debug_trace() is current always true, the code should be run always and not just in trace mode. Also added error checking to malloc and strdup. And while at replace some while by for loop for easier readability.
2014-11-21Fix returning new signatures when there are none.Ben Kibbey1-8/+54
* src/sign.c (gpgme_op_sign_result): Test that invalid and valid signatures add up to gpgme_signers_count(). -- When invalid and valid signatures do not equal gpgme_signers_count() it means that there was a bad passphrase during signing after the first signer. This leaves the result.signatures from previous signers intact which isn't correct since gpg will report: gpg: number of one-pass packets does not match number of signature packets gpg: can't handle this ambiguous signature data during verify. So when this happens append the valid signatures to the .invalid_signers list with .reason set to GPG_ERR_GENERAL.
2014-11-06Improve the debug output a bit.Werner Koch1-2/+2
* src/debug.h (TRACE_ERR): Include the line number in the output.
2014-10-02build: Implement SYSROOT feature.origin/bjk/masterWerner Koch1-7/+52
* configure.ac: Document SYSROOT. * m4/gpg-error.m4: Update from libgpg-error master. * src/gpgme.m4: Implement SYSROOT stuff.
2014-10-02Use --no-sk-comments, not --no-sk-comment.Daniel Kahn Gillmor1-2/+2
-- The --no-sk-comments flag is (or should be) a no-op in modern versions of gnupg, but gpgme should still use its full form rather than the (slightly) abbreviated --no-sk-comment
2014-08-12gpgme-tool: Print fingerprint and keyid with keyservers.Werner Koch1-1/+3
* src/gpgme-tool.c (cmd_keylist): Print keyid. Print FPR only if available.
2014-08-12Handle modern keyserver output which may emit the fingerprint.Werner Koch1-9/+44
* src/engine-gpg.c (read_colon_line): Split preprocessed lines. (gpg_keylist_preprocess): Limit keyid field and print fingerprint.
2014-08-12gpgme-tool: Install gpgme-tool.Werner Koch1-4/+6
* src/Makefile.am (bin_PROGRAMS): New. Add gpgme-tools. (noinst_PROGRAMS): Remove.
2014-08-12gpgme-tool: Fix segv for external key listing.Werner Koch1-7/+10
* src/gpgme-tool.c (result_xml_escape): Allow for DATA being NULL.
2014-07-30Fix possible realloc overflow for gpgsm and uiserver engines.Werner Koch2-2/+2
* src/engine-gpgsm.c (status_handler): * src/engine-uiserver.c (status_handler): -- After a realloc (realloc is also used for initial alloc) the allocated size if the buffer is not correctly recorded. Thus an overflow can be introduced by receiving data with different line lengths in a specific order. This is not easy exploitable because libassuan constructs the line. However a crash has been reported and thus it might be possible to constructs an exploit. CVE-id: CVE-2014-3564 Reported-by: Tomáš Trnka
2014-06-26w32: Get IOSPAWN flag back in sync with spawn helper.Werner Koch2-18/+8
* src/gpgme-w32spawn.c: Include priv-io.h.
2014-06-26w32: Add comment about a compiler warningWerner Koch1-0/+6
--
2014-06-10Add new reason codes to the INV_RECP status code.Werner Koch1-0/+8
* src/op-support.c (_gpgme_parse_inv_recp): Add codes 13 and 14.
2014-06-04Add new keylist mode GPGME_KEYLIST_MODE_WITH_SECRET.Werner Koch5-7/+42
* src/gpgme.h.in (GPGME_KEYLIST_MODE_WITH_SECRET): New. * src/engine-gpg.c (gpg_keylist_build_options): Handle new mode. * src/engine-gpgsm.c (gpgsm_keylist, gpgsm_keylist_ext): Ditto. * src/keylist.c (parse_sec_field15): Add arg key and take care of --with-secret output. * src/gpgme-tool.c (gt_get_keylist_mode, cmd_keylist_mode): Add "with_secret". Print card info and and secret flag for subkeys. -- Note: This mode may only be used with GnuPG >= 2.1.
2014-05-13Add 6 new GPGME_STATUS_ codes.Werner Koch2-18/+31
* src/status-table.c: Also add missing DECRYPTION_INFO entry.
2014-05-08Add field CURVE to the key info.Werner Koch4-1/+26
* src/gpgme.h.in (struct _gpgme_subkey): Add field CURVE. * src/key.c (gpgme_key_unref): Free CURVE. * src/keylist.c (keylist_colon_handler): Set CURVE. * src/gpgme.c (gpgme_release): For failsafe reasons reset engine and engine info after freeing. -- The engine hack is useful in case the other release functions accidently call engine release.
2014-05-08Fix a memory access and a double slash bug.Werner Koch2-2/+2
* src/engine-spawn.c (engspawn_start): Allocate space for list terminator. * src/posix-util.c (walk_path): Fix trailing slash detection. -- Kudos to Valgrind for pointing out these two problems. The first is a plain allocation bug in a code pattern I have written thousands of times - this time it went wrong. The allocation is not user controlled thus not directly exploitable. The second is missed to do what it intended to do. Found due to the access of malloced but not initialized memory. Not using calloc again proved to be helpful to detect logical error.
2014-05-08Map public key algos returned by gpg to gpgme values.Werner Koch8-17/+51
* src/conversion.c (_gpgme_map_pk_algo): New. * src/decrypt.c (parse_enc_to): Add arg PROTOCOL and map pubkey algo. (_gpgme_decrypt_status_handler): Map pubkey algo. * src/keylist.c (keylist_colon_handler): Map pubkey algo. * src/sign.c (parse_sig_created): Add arg PROTOCOL and map pubkey algo. * src/verify.c (parse_new_sig): Ditto. (parse_valid_sig): Ditto. * src/gpgme.h.in (GPGME_PK_ECC): New. (GPGME_MD_SHA224): New. * src/gpgme.c (gpgme_pubkey_algo_name): Add GPGME_PK_ECC case. (gpgme_hash_algo_name): Add GPGME_MD_SHA224. -- This affects only the not yet released ECC code of GnuPG 2.1.
2014-05-08Add GPGME_ENCRYPT_NO_COMPRESS flag.Werner Koch3-3/+12
* src/gpgme.h.in (GPGME_ENCRYPT_NO_COMPRESS): New. * src/engine-gpg.c (gpg_encrypt, gpg_encrypt_sign): Implement it. * src/gpgme-tool.c (_cmd_sign_encrypt): Add option --no-compress.
2014-04-16w32: Fix another memleak on error.Werner Koch2-0/+5
* src/w32-io.c (create_reader): free CTX. -- Found by Hans-Christoph Steiner with cppcheck.
2014-04-15w32: Fix memleak in an error code paths.Werner Koch2-1/+5
* src/w32-io.c (create_writer): Free CTX in cased of bad FD. * src/w32-util.c (_gpgme_mkstemp): Free TMPNAME in case of a failed mkstemp. -- Found by Hans-Christoph Steiner with cppcheck.
2014-04-15Fix possible zombie processes.Werner Koch1-3/+14
* src/posix-io.c (_gpgme_io_waitpid): Protect waitpid agains EINTR. (_gpgme_io_dup): Likewise. (_gpgme_io_connect): Likewise. -- GnuPG-bug-id: 1630
2014-04-10Actually implement flags for gpgme_op_spawn.Werner Koch5-8/+19
* src/spawn.c (gpgme_op_spawn_start, gpgme_op_spawn): Pass FLAGS dow to spawn_start and add FLAGS args along the call path. * src/engine-spawn.c (engspawn_start): Hack to automagically provide argv[0].
2014-04-10Add GPGME_PROTOCOL_SPAWN and gpgme_op_spawn.Werner Koch17-16/+723
* src/gpgme.h.in (GPGME_PROTOCOL_SPAWN): New. (GPGME_SPAWN_DETACHED, GPGME_SPAWN_ALLOW_SET_FG): New. * src/gpgme.c (gpgme_set_protocol): Add new protocol. (gpgme_get_protocol_name): Ditto. * src/spawn.c: New. * src/libgpgme.vers, src/gpgme.def: Add new public functions. * src/engine-spawn.c: New. * src/Makefile.am: Add new files. * src/engine-backend.h (struct engine_ops): Add OPSPAWN. * src/engine.c (engine_ops): Add _gpgme_engine_ops_spawn. (gpgme_get_engine_info): Add Spawn to the list of protocols. (_gpgme_engine_op_spawn): New. * src/gpgme-tool.c (gt_protocol_from_name): Add new protocol. (gt_spawn, cmd_spawn): New.
2014-04-10Add gpgme_get_dirinfo.Werner Koch4-0/+32
* src/dirinfo.c (gpgme_get_dirinfo): New. * tests/t-engine-info.c (main): Print results from that function.
2014-04-10Make use of internal iospawn flags more flexible.Werner Koch10-35/+43
* src/priv-io.h (IOSPAWN_FLAG_DETACHED): New. Renumber the others. * src/w32-io.c (_gpgme_io_spawn): Use DETACHED_PROCESS process only if IOSPAWN_FLAG_DETACHED is given. * src/w32-qt-io.cpp (_gpgme_io_spawn): Ditto. * src/w32-glib-io.c (_gpgme_io_spawn): Ditto. * src/assuan-support.c (my_spawn): Pass IOSPAWN_FLAG_DETACHED flags. * src/dirinfo.c (read_gpgconf_dirs): Ditto. * src/engine-gpg.c (start): Ditto. * src/engine-gpgconf.c (gpgconf_read, gpgconf_write): Ditto. * src/version.c (_gpgme_get_program_version): Ditto.
2014-04-10Make sure a spawned process has all standard fds connected.Werner Koch1-33/+18
* src/posix-io.c (_gpgme_io_spawn): dup /dev/null also to unsued stdout. -- Better be sure that stdout of a spawned process is connected to stdout so that the process does not run into a write error if it writes to stdout. AFAICS we always use a connected stdout; thus this is only for correctness.
2014-03-13Add configure option --enable-fixed-path.Werner Koch1-1/+5
* configure.ac: Add option --enable-fixed-path. (FIXED_SEARCH_PATH): New ac_define. * src/posix-util.c (walk_path): Make use of the option. Remove current directory from fallback PATH. -- Note that using this option PATH is entirely ignored by GPGME and only the given value is used instead to locate the GnuPG binaries. On Android the use of PATH is not desirable. Instead the GnuPG tools are expected in a fixed directory. By using ./configure --enable-fixed-path="/foo/bar" gpg et al are expected to be installed as /foo/bar/gpg. With ./configure --enable-fixed-path="/foo/bar:/bin" gpg is expected as /foo/bar/gpg or /bin/gpg.
2014-03-11Avoid pointer arithmetic on void pointer.Werner Koch1-1/+2
* src/gpgme.c (gpgme_io_writen): Use new var buffer. -- Reported-by: Albert Chin
2014-03-11Change implementation return type to match the definition.Werner Koch1-1/+1
* src/gpgme.c (gpgme_get_sub_protocol): Change return type to gpgme_protocol_t. -- Yet another enum/int mismatch. Reported-by: Albert Chin.
2014-02-21Always pass correct name to argv[0]. Ignore GPG_AGENT_INFO for gpg2.Werner Koch5-31/+72
* src/dirinfo.c (WANT_GPG_ONE_MODE): New. (struct dirinfo): Add field "gpg_one_mode". (get_gpgconf_item): Set that field and return it if requested. (_gpgme_in_gpg_one_mode): New. * src/engine-gpg.c (build_argv): Check GPG_AGENT_INFO only in gpg-1 mode. * src/dirinfo.c (_gpgme_get_basename): New. * src/engine-g13.c (g13_new): Take argv[0] from the pgmname. * src/engine-gpgsm.c (gpgsm_new): Ditto. * src/engine-gpg.c (build_argv): Ditto. Add arg PGMNAME. (start): Pass PGMNAME to buildargv.
2014-02-12Fix type inconsistency between gpgme.h and gpgme.c.Werner Koch1-1/+1
* src/gpgme.c (gpgme_set_pinentry_mode): Fix type of MODE. -- GnuPG-bug-id: 1617
2014-01-07Make gpgconf engine work again - fixes 02ba35c1.Werner Koch2-32/+13
* src/gpgconf.c: Remove ENABLE_GPGCONF and move prototypes to ... * src/engine-backend.h: ... here. -- gpgconf is a required part for gpgme.
2014-01-07Make gpgme_new return a proper error if no engines are installed.Werner Koch2-15/+34
* src/engine.c (gpgme_get_engine_info): Improve error handling. (_gpgme_engine_info_copy): Ditto. * src/gpgme.c (gpgme_new): Return error GPG_ERR_NO_ENGINE.
2014-01-07Print the full PATH in the log if gpg was not found.Werner Koch1-6/+7
* src/posix-util.c (walk_path): Keep a copy of PATH.
2014-01-06Add global flags disable-gpgconf, gpgconf-name, and gpg-name.Werner Koch6-18/+172
* src/gpgme.c (gpgme_set_global_flag): Add names "disable-gpgconf", "gpgconf-name", and "gpg-name". * src/dirinfo.c (_gpgme_dirinfo_disable_gpgconf): New. (get_gpgconf_item): Minor debug info change. * src/posix-util.c (default_gpg_name, default_gpgconf_name): Add vars. (_gpgme_set_default_gpg_name): New. (_gpgme_set_default_gpgconf_name): New. (_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use new vars. (walk_path): Add debug output on failure. * src/w32-util.c (default_gpg_name, default_gpgconf_name): Add vars. (replace_slashes): New. (get_basename): New. (_gpgme_set_default_gpg_name): New. (_gpgme_set_default_gpgconf_name): New. (_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use new vars. * tests/t-engine-info.c (main): Add --verbose and --set-global-flag options. -- Note that the Windows part has not been tested.
2013-12-27Locate engine names only at runtime and prefer GnuPG-2.Werner Koch12-164/+81
* configure.ac (NEED_GPG_VERSION, NEED_GPGSM_VERSION) (NEED_G13_VERSION, NEED_GPGCONF_VERSION): Remove vars and all related checks. Do not check for any engine version. (HAVE_ASSUAN): Remove AM conditional. * src/Makefile.am: Remove separate component vars and always build all engines but uiserver. * src/dirinfo.c (WANT_GPGCONF_NAME): New. (struct dirinfo): Add field gpgconf_name. (_gpgme_get_default_gpgconf_name): Use WANT_GPGCONF_NAME. (get_gpgconf_item): Set gpgconf name and adjust for _gpgme_get_*_path now returning a malloced string. * src/engine.c (engine_ops): Always init all engines except for uiserver. * src/posix-util.c (_gpgme_get_gpgsm_path, _gpgme_get_g13_path): Remove unused functions. (walk_path): New. (_gpgme_get_gpg_path, _gpgme_get_gpgconf_path ): Re-implement using walk_path. * src/w32-util.c (_gpgme_get_gpgsm_path, _gpgme_get_g13_path): Remove unused functions. (_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Return a malloced string. * src/engine-g13.c (g13_get_req_version): Use a hardwired string with the required version. This info belongs into this file. * src/engine-gpg.c (gpg_get_req_version): Ditto. * src/engine-gpgconf.c (gpgconf_get_req_version): Ditto. * src/engine-gpgsm.c (gpgsm_get_req_version): Ditto. * tests/t-engine-info.c: Replace now useless test by an info output. * tests/gpg/Makefile.am (GPG, GPG_AGENT): Hardwire gpg and gpg-agent. * tests/gpgsm/Makefile.am (GPGSM): Hardwire gpgsm. Signed-off-by: Werner Koch <[email protected]>
2013-08-19Fix possible segv in the gpgme_op_card_edit.Werner Koch1-4/+4
* src/edit.c (gpgme_op_edit_start, gpgme_op_card_edit_start): Do not deref a NULL KEY in TRACE_BEG.
2013-08-09Add function gpgme_data_identify.Werner Koch8-8/+488
* src/gpgme.h.in (gpgme_data_type_t): New. (gpgme_data_identify): New prototype. * src/data-identify.c: New. * src/parsetlv.c, src/parsetlv.h: New. Take from gpa. * src/libgpgme.vers, src/gpgme.def: Add gpgme_data_identify. * src/gpgme-tool.c (status): Add STATUS_IDENTIFY_RESULT. (gt_identify): New. (cmd_identify): New. (hlp_passwd): Move close to cmd_passwd. -- It is often useful to have a way to identify the data which needs processing. This is such a common task that it makes sense to implement this in gpgme to avoid diverging implementations.
2013-08-02Prefer GnuPG-2 engines over GnuPG-1.Werner Koch11-91/+201
* src/util.h: Move some prototypes to ... * src/sys-util.h: New. * src/Makefile.am (main_sources): Add sys-util.h. * configure.ac (AH_VERBATIM): Add DIRSEP_C and DIRSEP_S. * src/dirinfo.c: Include sys-util.h. (WANT_GPG_NAME, WANT_GPGSM_NAME, WANT_G13_NAME) (WANT_UISRV_SOCKET): New. (dirinfo): Add corresponding fields. (parse_output): Add arg COMPONENTS and set new fields. (read_gpgconf_dirs): Add arg components and act upon it. (get_gpgconf_item): Call read_gpgconf_dirs two times. Add debug output. (_gpgme_get_default_gpg_name): New. (_gpgme_get_default_gpgsm_name): New. (_gpgme_get_default_g13_name): New. (_gpgme_get_default_gpgconf_name): New. (_gpgme_get_default_uisrv_socket): New. * src/engine-gpg.c, src/engine-g13.c, src/engine-gpgconf.c * src/engine-gpgsm.c, src/engine-uiserver.c: Change to use _gpgme_get_default_ instead of those from sys-util.h. * src/posix-util.c (_gpgme_get_gpg_path): Include sys-util.h. (_gpgme_get_uiserver_socket_path): Remove. * src/w32-util.c (_gpgme_get_gpg_path): Include sys-util.h. (_gpgme_get_uiserver_socket_path): Remove. -- The default engines names are now taken from the output of gpgconf. If gpgconf is not installed gpg 1 is assumed and locate the same was as gpgconf.
2013-08-02w32: Try to locate gpg in the gpgme installation dir.Werner Koch1-73/+156
* src/w32-util.c (my_hmodule): New. (wchar_to_utf8): New. (DllMain): New. (_gpgme_get_inst_dir): New. (find_program_in_dir): New. (find_program_in_inst_dir): Add arg INST_DIR. (_gpgme_get_gpg_path): Get inst_dir before acquiring the lock. (_gpgme_get_gpgconf_path): Ditto. (_gpgme_get_g13_path): Ditto. (_gpgme_get_w32spawn_path): Ditto.