diff --git a/agent/cache.c b/agent/cache.c index 799d595ab..4a3e5a547 100644 --- a/agent/cache.c +++ b/agent/cache.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "agent.h" diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c index 34dde3744..5b4713f41 100644 --- a/agent/call-pinentry.c +++ b/agent/call-pinentry.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #ifndef HAVE_W32_SYSTEM diff --git a/agent/call-scd.c b/agent/call-scd.c index b2266225e..b52c6c8eb 100644 --- a/agent/call-scd.c +++ b/agent/call-scd.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #ifdef HAVE_SIGNAL_H # include diff --git a/agent/command-ssh.c b/agent/command-ssh.c index 727bb9b94..5f7884b1f 100644 --- a/agent/command-ssh.c +++ b/agent/command-ssh.c @@ -41,7 +41,6 @@ #include #include #include -#include #ifndef HAVE_W32_SYSTEM #include #include @@ -1030,7 +1029,7 @@ search_control_file (ssh_control_file_t cf, const char *hexgrip, { gpg_error_t err; - assert (strlen (hexgrip) == 40 ); + log_assert (strlen (hexgrip) == 40 ); if (r_disabled) *r_disabled = 0; @@ -2646,7 +2645,7 @@ ssh_handler_request_identities (ctrl_t ctrl, continue; /* Should not happen. */ if (cf->item.disabled) continue; - assert (strlen (cf->item.hexgrip) == 40); + log_assert (strlen (cf->item.hexgrip) == 40); hex2bin (cf->item.hexgrip, grip, sizeof (grip)); err = agent_public_key_from_file (ctrl, grip, &key_public); diff --git a/agent/command.c b/agent/command.c index 6efd1bff2..c056eb3f0 100644 --- a/agent/command.c +++ b/agent/command.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -2212,7 +2211,7 @@ cmd_import_key (assuan_context_t ctx, char *line) goto leave; /* Invalid canonical encoded S-expression. */ if (passphrase) { - assert (!opt_unattended); + log_assert (!opt_unattended); if (!cache_nonce) { char buf[12]; diff --git a/agent/cvt-openpgp.c b/agent/cvt-openpgp.c index 42052d48e..003402956 100644 --- a/agent/cvt-openpgp.c +++ b/agent/cvt-openpgp.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "agent.h" #include "../common/i18n.h" @@ -571,7 +570,7 @@ do_unprotect (const char *passphrase, } skey[i] = NULL; skeylen = i; - assert (skeylen <= skeysize); + log_assert (skeylen <= skeysize); /* Note: at this point NDATA should be 2 for a simple checksum or 20 for the sha1 digest. */ @@ -1105,8 +1104,8 @@ apply_protection (gcry_mpi_t *array, int npkey, int nskey, int ndata; unsigned char *p, *data; - assert (npkey < nskey); - assert (nskey < DIM (bufarr)); + log_assert (npkey < nskey); + log_assert (nskey < DIM (bufarr)); /* Collect only the secret key parameters into BUFARR et al and compute the required size of the data buffer. */ @@ -1143,7 +1142,7 @@ apply_protection (gcry_mpi_t *array, int npkey, int nskey, xfree (bufarr[i]); bufarr[i] = NULL; } - assert (p == data + ndata - 20); + log_assert (p == data + ndata - 20); /* Append a hash of the secret key parameters. */ gcry_md_hash_buffer (GCRY_MD_SHA1, p, data, ndata - 20); diff --git a/agent/findkey.c b/agent/findkey.c index 20c9dc56a..370050d8b 100644 --- a/agent/findkey.c +++ b/agent/findkey.c @@ -26,10 +26,8 @@ #include #include #include -#include #include #include -#include #include /* (we use pth_sleep) */ #include "agent.h" @@ -336,7 +334,7 @@ try_unprotect_cb (struct pin_entry_info_s *pi) gnupg_isotime_t now, protected_at, tmptime; char *desc = NULL; - assert (!arg->unprotected_key); + log_assert (!arg->unprotected_key); arg->change_required = 0; err = agent_unprotect (ctrl, arg->protected_key, pi->pin, protected_at, @@ -740,7 +738,7 @@ unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text, } else { - assert (arg.unprotected_key); + log_assert (arg.unprotected_key); if (arg.change_required) { /* The callback told as that the user should change their @@ -748,7 +746,7 @@ unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text, size_t canlen, erroff; gcry_sexp_t s_skey; - assert (arg.unprotected_key); + log_assert (arg.unprotected_key); canlen = gcry_sexp_canon_len (arg.unprotected_key, 0, NULL, NULL); rc = gcry_sexp_sscan (&s_skey, &erroff, (char*)arg.unprotected_key, canlen); @@ -1415,7 +1413,7 @@ agent_public_key_from_file (ctrl_t ctrl, such a task. After all that is what we do in protect.c. Need to find common patterns and write a straightformward API to use them. */ - assert (sizeof (size_t) <= sizeof (void*)); + log_assert (sizeof (size_t) <= sizeof (void*)); format = xtrymalloc (15+4+7*npkey+10+15+1+1); if (!format) @@ -1440,14 +1438,14 @@ agent_public_key_from_file (ctrl_t ctrl, *p++ = '('; *p++ = *s++; p = stpcpy (p, " %m)"); - assert (argidx < DIM (args)); + log_assert (argidx < DIM (args)); args[argidx++] = &array[idx]; } *p++ = ')'; if (uri) { p = stpcpy (p, "(uri %b)"); - assert (argidx+1 < DIM (args)); + log_assert (argidx+1 < DIM (args)); uri_intlen = (int)uri_length; args[argidx++] = (void *)&uri_intlen; args[argidx++] = (void *)&uri; @@ -1455,14 +1453,14 @@ agent_public_key_from_file (ctrl_t ctrl, if (comment) { p = stpcpy (p, "(comment %b)"); - assert (argidx+1 < DIM (args)); + log_assert (argidx+1 < DIM (args)); comment_intlen = (int)comment_length; args[argidx++] = (void *)&comment_intlen; args[argidx++] = (void*)&comment; } *p++ = ')'; *p = 0; - assert (argidx < DIM (args)); + log_assert (argidx < DIM (args)); args[argidx] = NULL; err = gcry_sexp_build_array (&list, NULL, format, args); @@ -1559,7 +1557,7 @@ agent_key_info_from_file (ctrl_t ctrl, const unsigned char *grip, if (!err) { n = gcry_sexp_canon_len (s, 0, NULL, NULL); - assert (n); + log_assert (n); *r_shadow_info = xtrymalloc (n); if (!*r_shadow_info) err = gpg_error_from_syserror (); diff --git a/agent/genkey.c b/agent/genkey.c index 84342f9ea..46a772eda 100644 --- a/agent/genkey.c +++ b/agent/genkey.c @@ -24,7 +24,6 @@ #include #include #include -#include #include "agent.h" #include "../common/i18n.h" @@ -47,12 +46,12 @@ store_key (gcry_sexp_t private, const char *passphrase, int force, } len = gcry_sexp_sprint (private, GCRYSEXP_FMT_CANON, NULL, 0); - assert (len); + log_assert (len); buf = gcry_malloc_secure (len); if (!buf) return out_of_core (); len = gcry_sexp_sprint (private, GCRYSEXP_FMT_CANON, buf, len); - assert (len); + log_assert (len); if (passphrase) { @@ -127,7 +126,7 @@ check_passphrase_pattern (ctrl_t ctrl, const char *pw) argv[i++] = "--", argv[i++] = opt.check_passphrase_pattern, argv[i] = NULL; - assert (i < sizeof argv); + log_assert (i < sizeof argv); if (gnupg_spawn_process_fd (pgmname, argv, fileno (infp), -1, -1, &pid)) result = 1; /* Execute error - assume password should no be used. */ @@ -557,7 +556,7 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce, if (DBG_CRYPTO) log_debug ("returning public key\n"); len = gcry_sexp_sprint (s_public, GCRYSEXP_FMT_CANON, NULL, 0); - assert (len); + log_assert (len); buf = xtrymalloc (len); if (!buf) { @@ -567,7 +566,7 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce, return tmperr; } len = gcry_sexp_sprint (s_public, GCRYSEXP_FMT_CANON, buf, len); - assert (len); + log_assert (len); put_membuf (outbuf, buf, len); gcry_sexp_release (s_public); xfree (buf); diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index d9e2bbf25..d3fe7fe56 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -1952,7 +1951,7 @@ agent_set_progress_cb (void (*cb)(ctrl_t ctrl, const char *what, static void agent_init_default_ctrl (ctrl_t ctrl) { - assert (ctrl->session_env); + log_assert (ctrl->session_env); /* Note we ignore malloc errors because we can't do much about it and the request will fail anyway shortly after this diff --git a/agent/learncard.c b/agent/learncard.c index f3219ed8f..f40f5ac4d 100644 --- a/agent/learncard.c +++ b/agent/learncard.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/agent/pkdecrypt.c b/agent/pkdecrypt.c index 06a8e0b6f..a0ced2f55 100644 --- a/agent/pkdecrypt.c +++ b/agent/pkdecrypt.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -119,10 +118,10 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text, gcry_sexp_dump (s_plain); } len = gcry_sexp_sprint (s_plain, GCRYSEXP_FMT_CANON, NULL, 0); - assert (len); + log_assert (len); buf = xmalloc (len); len = gcry_sexp_sprint (s_plain, GCRYSEXP_FMT_CANON, buf, len); - assert (len); + log_assert (len); if (*buf == '(') put_membuf (outbuf, buf, len); else diff --git a/agent/pksign.c b/agent/pksign.c index 828e63f58..bc8d7336a 100644 --- a/agent/pksign.c +++ b/agent/pksign.c @@ -24,8 +24,6 @@ #include #include #include -#include -#include #include #include "agent.h" @@ -250,13 +248,13 @@ do_encode_raw_pkcs1 (const byte *md, size_t mdlen, unsigned int nbits, frame[n++] = 0; frame[n++] = 1; /* Block type. */ i = nframe - mdlen - 3 ; - assert (i >= 8); /* At least 8 bytes of padding. */ + log_assert (i >= 8); /* At least 8 bytes of padding. */ memset (frame+n, 0xff, i ); n += i; frame[n++] = 0; memcpy (frame+n, md, mdlen ); n += mdlen; - assert (n == nframe); + log_assert (n == nframe); /* Create the S-expression. */ rc = gcry_sexp_build (&hash, NULL, diff --git a/agent/preset-passphrase.c b/agent/preset-passphrase.c index 7a9ea1b44..e22e9d58d 100644 --- a/agent/preset-passphrase.c +++ b/agent/preset-passphrase.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #ifdef HAVE_LOCALE_H diff --git a/agent/protect-tool.c b/agent/protect-tool.c index 30d78cd43..059a9bdbd 100644 --- a/agent/protect-tool.c +++ b/agent/protect-tool.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #ifdef HAVE_LOCALE_H @@ -198,10 +197,10 @@ make_canonical (const char *fname, const char *buf, size_t buflen) return NULL; } len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0); - assert (len); + log_assert (len); result = xmalloc (len); len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, result, len); - assert (len); + log_assert (len); gcry_sexp_release (sexp); return result; } @@ -222,10 +221,10 @@ make_advanced (const unsigned char *buf, size_t buflen) return NULL; } len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, NULL, 0); - assert (len); + log_assert (len); result = xmalloc (len); len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, result, len); - assert (len); + log_assert (len); gcry_sexp_release (sexp); return result; } @@ -433,7 +432,7 @@ read_and_shadow (const char *fname) return; } resultlen = gcry_sexp_canon_len (result, 0, NULL,NULL); - assert (resultlen); + log_assert (resultlen); if (opt_armor) { @@ -469,7 +468,7 @@ show_shadow_info (const char *fname) return; } infolen = gcry_sexp_canon_len (info, 0, NULL,NULL); - assert (infolen); + log_assert (infolen); if (opt_armor) { @@ -496,7 +495,7 @@ show_file (const char *fname) return; keylen = gcry_sexp_canon_len (key, 0, NULL,NULL); - assert (keylen); + log_assert (keylen); if (opt_canonical) { @@ -723,7 +722,7 @@ get_passphrase (int promptno) gpg_strerror (err)); agent_exit (0); } - assert (pw); + log_assert (pw); return pw; } diff --git a/agent/protect.c b/agent/protect.c index c7fb773e1..e3bbf3ed5 100644 --- a/agent/protect.c +++ b/agent/protect.c @@ -528,7 +528,7 @@ do_encryption (const unsigned char *hashbegin, size_t hashlen, memcpy (p, iv+blklen, blklen); /* Add padding. */ p += blklen; } - assert ( p - outbuf == outlen); + log_assert ( p - outbuf == outlen); if (use_ocb) { gcry_cipher_final (hd); @@ -718,11 +718,11 @@ agent_protect (const unsigned char *plainkey, const char *passphrase, hash_end = s; s++; /* Skip to the end of the S-expression. */ - assert (depth == 1); + log_assert (depth == 1); rc = sskip (&s, &depth); if (rc) return rc; - assert (!depth); + log_assert (!depth); real_end = s-1; rc = do_encryption (hash_begin, hash_end - hash_begin + 1, @@ -760,7 +760,7 @@ agent_protect (const unsigned char *plainkey, const char *passphrase, memcpy (p, prot_end+1, real_end - prot_end); p += real_end - prot_end; - assert ( p - *result == *resultlen); + log_assert ( p - *result == *resultlen); xfree (protected); return 0; @@ -999,7 +999,7 @@ merge_lists (const unsigned char *protectedkey, /* Skip over the protected list element in the original list. */ s = protectedkey + replacepos; - assert (*s == '('); + log_assert (*s == '('); s++; i = 1; rc = sskip (&s, &i); @@ -1026,7 +1026,7 @@ merge_lists (const unsigned char *protectedkey, rc = sskip (&s, &i); if (rc) goto failure; - assert (s[-1] == ')'); + log_assert (s[-1] == ')'); endpos = s; /* one behind the end of the list */ /* Append the rest. */ @@ -1571,7 +1571,7 @@ agent_shadow_key (const unsigned char *pubkey, point = s; /* insert right before the point */ depth--; s++; - assert (depth == 1); + log_assert (depth == 1); /* Calculate required length by taking in account: the "shadowed-" prefix, the "shadowed", "t1-v1" as well as some parenthesis */ diff --git a/agent/trans.c b/agent/trans.c index ff1a34e68..9d090ff86 100644 --- a/agent/trans.c +++ b/agent/trans.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include diff --git a/agent/trustlist.c b/agent/trustlist.c index af177b2e2..d91e92e07 100644 --- a/agent/trustlist.c +++ b/agent/trustlist.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -550,7 +549,7 @@ insert_colons (const char *string) } } *p = 0; - assert (strlen (buffer) <= nnew); + log_assert (strlen (buffer) <= nnew); return buffer; }