Trace the use of GPG_ERR_INV_ENGINE.
* src/debug.h: Include "gpgme.h" (_gpgme_trace_gpgme_error): New. (trace_gpg_error): New macro. Use it in all files where we return GPG_ERR_INV_ENGINE; also "include debug.h" as needed. -- This is a pretty common error code but often it is hard to figure out the actual cause. With debug level 4 we now print the file name and line number where this error code is generated by gpgme. Along with the git revision printed in the first log lines, this should give us an easier way to track down the problems related to this error code.
This commit is contained in:
parent
14a8fd4eec
commit
bd24feaa86
17
src/debug.h
17
src/debug.h
@ -26,6 +26,9 @@
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include "gpgme.h" /* Required for gpgme_error stuff. */
|
||||
|
||||
|
||||
/* Indirect stringification, requires __STDC__ to work. */
|
||||
#define STRINGIFY(v) #v
|
||||
#define XSTRINGIFY(v) STRINGIFY(v)
|
||||
@ -81,6 +84,13 @@ void _gpgme_debug_buffer (int lvl, const char *const fmt,
|
||||
void _gpgme_debug_frame_begin (void);
|
||||
void _gpgme_debug_frame_end (void);
|
||||
|
||||
static inline gpgme_error_t
|
||||
_gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line)
|
||||
{
|
||||
_gpgme_debug (DEBUG_ENGINE, "%s:%d: returning error: %s\n",
|
||||
_gpgme_debug_srcname (file), line, gpgme_strerror (err));
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Trace support. */
|
||||
@ -262,4 +272,11 @@ void _gpgme_debug_frame_end (void);
|
||||
_gpgme_debug_end (&(hlp))
|
||||
#define TRACE_ENABLED(hlp) (!!(hlp))
|
||||
|
||||
/* And finally a simple macro to trace the location of an error code.
|
||||
This macro is independent of the other trace macros and may be used
|
||||
without any preconditions. */
|
||||
#define trace_gpg_error(e) \
|
||||
_gpgme_trace_gpgme_error (gpg_error (e), __FILE__, __LINE__)
|
||||
|
||||
|
||||
#endif /* DEBUG_H */
|
||||
|
@ -146,7 +146,7 @@ parse_enc_to (char *args, gpgme_recipient_t *recp)
|
||||
if (*args != '\0' && *args != ' ')
|
||||
{
|
||||
free (rec);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
while (*args == ' ')
|
||||
@ -160,7 +160,7 @@ parse_enc_to (char *args, gpgme_recipient_t *recp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (rec);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
|
||||
}
|
||||
/* FIXME: Is this ok? */
|
||||
if (!rec)
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -48,7 +48,7 @@ delete_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
gpg_err_set_errno (0);
|
||||
problem = strtol (args, &tail, 0);
|
||||
if (errno || (*tail && *tail != ' '))
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
switch (problem)
|
||||
{
|
||||
|
@ -1269,7 +1269,7 @@ start (engine_gpg_t gpg)
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!gpg->file_name && !_gpgme_get_gpg_path ())
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
if (gpg->lc_ctype)
|
||||
{
|
||||
|
@ -300,7 +300,7 @@ gpgconf_config_load_cb (void *hook, char *line)
|
||||
|
||||
/* We require at least the first 3 fields. */
|
||||
if (fields < 2)
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
/* Find the pointer to the new component in the list. */
|
||||
while (comp && comp->next)
|
||||
@ -426,7 +426,7 @@ gpgconf_config_load_cb2 (void *hook, char *line)
|
||||
|
||||
/* We require at least the first 10 fields. */
|
||||
if (fields < 10)
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
opt = calloc (1, sizeof (*opt));
|
||||
if (!opt)
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "util.h"
|
||||
#include "sema.h"
|
||||
#include "ops.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "engine.h"
|
||||
#include "engine-backend.h"
|
||||
@ -166,7 +167,7 @@ gpgme_engine_check_version (gpgme_protocol_t proto)
|
||||
info->req_version);
|
||||
|
||||
UNLOCK (engine_info_lock);
|
||||
return result ? 0 : gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return result ? 0 : trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
|
||||
@ -359,7 +360,7 @@ _gpgme_set_engine_info (gpgme_engine_info_t info, gpgme_protocol_t proto,
|
||||
info = info->next;
|
||||
|
||||
if (!info)
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
/* Prepare new members. */
|
||||
if (file_name)
|
||||
@ -449,7 +450,7 @@ _gpgme_engine_new (gpgme_engine_info_t info, engine_t *r_engine)
|
||||
engine_t engine;
|
||||
|
||||
if (!info->file_name || !info->version)
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
engine = calloc (1, sizeof *engine);
|
||||
if (!engine)
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "ops.h"
|
||||
#include "engine.h"
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef ENABLE_GPGCONF
|
||||
/* engine-gpgconf.c. */
|
||||
|
@ -131,7 +131,7 @@ parse_import (char *args, gpgme_import_status_t *import_status, int problem)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (import);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
args = tail;
|
||||
|
||||
@ -196,7 +196,7 @@ parse_import_res (char *args, gpgme_import_result_t result)
|
||||
(x) = strtol (args, &tail, 0); \
|
||||
if (errno || args == tail || *tail != ' ') \
|
||||
/* The crypto backend does not behave. */ \
|
||||
return gpg_error (GPG_ERR_INV_ENGINE); \
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE); \
|
||||
args = tail;
|
||||
|
||||
PARSE_NEXT (result->considered);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "util.h"
|
||||
#include "ops.h"
|
||||
#include "sema.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
/* Protects all reference counters in keys. All other accesses to a
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "context.h"
|
||||
#include "ops.h"
|
||||
#include "util.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
gpgme_error_t
|
||||
@ -199,7 +200,7 @@ _gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (inv_key);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
switch (reason)
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "context.h"
|
||||
#include "ops.h"
|
||||
#include "util.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
|
@ -56,7 +56,7 @@ parse_error (char *args)
|
||||
where = args;
|
||||
}
|
||||
else
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
err = atoi (which);
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "util.h"
|
||||
#include "context.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
gpgme_error_t
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "util.h"
|
||||
#include "context.h"
|
||||
#include "ops.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
/* Free the signature notation object and all associated resources.
|
||||
@ -159,13 +160,13 @@ _gpgme_parse_notation (gpgme_sig_notation_t *notationp,
|
||||
|
||||
/* A few simple sanity checks. */
|
||||
if (len > strlen (data))
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
/* See below for the format of a notation subpacket. It has at
|
||||
least four octets of flags and two times two octets of length
|
||||
information. */
|
||||
if (type == 20 && len < 4 + 2 + 2)
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
err = _gpgme_decode_percent_string (data, &decoded_data, 0, 1);
|
||||
if (err)
|
||||
@ -234,7 +235,7 @@ _gpgme_parse_notation (gpgme_sig_notation_t *notationp,
|
||||
if (4 + 2 + 2 + name_len + value_len > len)
|
||||
{
|
||||
free (decoded_data);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
name = (char *) bdata;
|
||||
|
14
src/sign.c
14
src/sign.c
@ -169,14 +169,14 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
default:
|
||||
/* The backend engine is not behaving. */
|
||||
free (sig);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
args++;
|
||||
if (*args != ' ')
|
||||
{
|
||||
free (sig);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
gpg_err_set_errno (0);
|
||||
@ -185,7 +185,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (sig);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
args = tail;
|
||||
|
||||
@ -194,7 +194,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (sig);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
args = tail;
|
||||
|
||||
@ -205,7 +205,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (sig);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
args = tail;
|
||||
|
||||
@ -214,7 +214,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (sig);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
args = tail;
|
||||
while (*args == ' ')
|
||||
@ -224,7 +224,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (sig);
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
tail = strchr (args, ' ');
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "util.h"
|
||||
#include "ops.h"
|
||||
#include "sema.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
/* Protects all reference counters in trust items. All other accesses
|
||||
|
26
src/verify.c
26
src/verify.c
@ -346,7 +346,7 @@ parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args)
|
||||
/* Parse the timestamp. */
|
||||
sig->timestamp = _gpgme_parse_timestamp (end, &tail);
|
||||
if (sig->timestamp == -1 || end == tail || (*tail && *tail != ' '))
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
end = tail;
|
||||
while (*end == ' ')
|
||||
end++;
|
||||
@ -420,12 +420,12 @@ parse_valid_sig (gpgme_signature_t sig, char *args)
|
||||
|
||||
sig->timestamp = _gpgme_parse_timestamp (end, &tail);
|
||||
if (sig->timestamp == -1 || end == tail || (*tail && *tail != ' '))
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
end = tail;
|
||||
|
||||
sig->exp_timestamp = _gpgme_parse_timestamp (end, &tail);
|
||||
if (sig->exp_timestamp == -1 || end == tail || (*tail && *tail != ' '))
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
end = tail;
|
||||
|
||||
while (*end == ' ')
|
||||
@ -445,7 +445,7 @@ parse_valid_sig (gpgme_signature_t sig, char *args)
|
||||
gpg_err_set_errno (0);
|
||||
sig->pubkey_algo = strtol (end, &tail, 0);
|
||||
if (errno || end == tail || *tail != ' ')
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
end = tail;
|
||||
|
||||
while (*end == ' ')
|
||||
@ -458,7 +458,7 @@ parse_valid_sig (gpgme_signature_t sig, char *args)
|
||||
gpg_err_set_errno (0);
|
||||
sig->hash_algo = strtol (end, &tail, 0);
|
||||
if (errno || end == tail || *tail != ' ')
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
end = tail;
|
||||
}
|
||||
}
|
||||
@ -491,7 +491,7 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
||||
if (notation)
|
||||
/* There is another notation name without data for the
|
||||
previous one. The crypto backend misbehaves. */
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
err = _gpgme_sig_notation_create (¬ation, NULL, 0, NULL, 0, 0);
|
||||
if (err)
|
||||
@ -544,7 +544,7 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
||||
if (!notation || !notation->name)
|
||||
/* There is notation data without a previous notation
|
||||
name. The crypto backend misbehaves. */
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
if (!notation->value)
|
||||
{
|
||||
@ -569,7 +569,7 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
||||
notation->value_len += strlen (dest);
|
||||
}
|
||||
else
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -645,7 +645,7 @@ parse_error (gpgme_signature_t sig, char *args, int set_status)
|
||||
where = args;
|
||||
}
|
||||
else
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
err = atoi (which);
|
||||
|
||||
@ -708,7 +708,7 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
case GPGME_STATUS_VALIDSIG:
|
||||
opd->only_newsig_seen = 0;
|
||||
return sig ? parse_valid_sig (sig, args)
|
||||
: gpg_error (GPG_ERR_INV_ENGINE);
|
||||
: trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
case GPGME_STATUS_NODATA:
|
||||
opd->only_newsig_seen = 0;
|
||||
@ -729,7 +729,7 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
case GPGME_STATUS_POLICY_URL:
|
||||
opd->only_newsig_seen = 0;
|
||||
return sig ? parse_notation (sig, code, args)
|
||||
: gpg_error (GPG_ERR_INV_ENGINE);
|
||||
: trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
case GPGME_STATUS_TRUST_UNDEFINED:
|
||||
case GPGME_STATUS_TRUST_NEVER:
|
||||
@ -738,7 +738,7 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
case GPGME_STATUS_TRUST_ULTIMATE:
|
||||
opd->only_newsig_seen = 0;
|
||||
return sig ? parse_trust (sig, code, args)
|
||||
: gpg_error (GPG_ERR_INV_ENGINE);
|
||||
: trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
case GPGME_STATUS_PKA_TRUST_BAD:
|
||||
case GPGME_STATUS_PKA_TRUST_GOOD:
|
||||
@ -746,7 +746,7 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
/* Check that we only get one of these status codes per
|
||||
signature; if not the crypto backend misbehaves. */
|
||||
if (!sig || sig->pka_trust || sig->pka_address)
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||
sig->pka_trust = code == GPGME_STATUS_PKA_TRUST_GOOD? 2 : 1;
|
||||
end = strchr (args, ' ');
|
||||
if (end)
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "wait.h"
|
||||
#include "priv-io.h"
|
||||
#include "ops.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* The global event loop is used for all asynchronous operations
|
||||
(except key listing) for which no user I/O callbacks are specified.
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "ops.h"
|
||||
#include "priv-io.h"
|
||||
#include "util.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
/* The private event loops are used for all blocking operations, and
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "priv-io.h"
|
||||
#include "wait.h"
|
||||
#include "ops.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
/* The user event loops are used for all asynchronous operations for
|
||||
|
Loading…
Reference in New Issue
Block a user