From 1c16878efd0bcf036f56abef93d64ac41ce9e95b Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 31 Mar 2021 19:16:05 +0200 Subject: scd: Replace all assert macros by the log_assert macro. Signed-off-by: Werner Koch --- scd/app-openpgp.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'scd/app-openpgp.c') diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index 6fe13354c..5508ec68e 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include "scdaemon.h" @@ -466,7 +465,7 @@ get_cached_data (app_t app, int tag, /* Okay, cache it. */ for (c=app->app_local->cache; c; c = c->next) - assert (c->tag != tag); + log_assert (c->tag != tag); c = xtrymalloc (sizeof *c + len); if (c) @@ -505,7 +504,7 @@ flush_cache_item (app_t app, int tag) for (c=app->app_local->cache; c ; c = c->next) { - assert (c->tag != tag); /* Oops: duplicated entry. */ + log_assert (c->tag != tag); /* Oops: duplicated entry. */ } return; } @@ -1447,7 +1446,7 @@ retrieve_fpr_from_card (app_t app, int keyno, char *fpr) unsigned char *value; size_t valuelen; - assert (keyno >=0 && keyno <= 2); + log_assert (keyno >=0 && keyno <= 2); relptr = get_one_do (app, 0x00C5, &value, &valuelen, NULL); if (relptr && valuelen >= 60) @@ -2056,7 +2055,7 @@ send_keypair_info (app_t app, ctrl_t ctrl, int key) if (err) goto leave; - assert (keyno >= 0 && keyno <= 2); + log_assert (keyno >= 0 && keyno <= 2); if (!app->app_local->pk[keyno].key) goto leave; /* No such key - ignore. */ @@ -3533,7 +3532,7 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr, else { /* Version 2 cards. */ - assert (chvno == 1 || chvno == 3); + log_assert (chvno == 1 || chvno == 3); if (use_pinpad) { @@ -3594,7 +3593,7 @@ does_key_exist (app_t app, int keyidx, int generating, int force) size_t buflen, n; int i; - assert (keyidx >=0 && keyidx <= 2); + log_assert (keyidx >=0 && keyidx <= 2); if (iso7816_get_data (app_get_slot (app), 0, 0x006E, &buffer, &buflen)) { @@ -3634,7 +3633,7 @@ add_tlv (unsigned char *buffer, unsigned int tag, size_t length) { unsigned char *p = buffer; - assert (tag <= 0xffff); + log_assert (tag <= 0xffff); if ( tag > 0xff ) *p++ = tag >> 8; *p++ = tag; @@ -3698,7 +3697,7 @@ build_privkey_template (app_t app, int keyno, /* Get the required length for E. Rounded up to the nearest byte */ rsa_e_reqlen = (app->app_local->keyattr[keyno].rsa.e_bits + 7) / 8; - assert (rsa_e_len <= rsa_e_reqlen); + log_assert (rsa_e_len <= rsa_e_reqlen); /* Build the 7f48 cardholder private key template. */ datalen = 0; @@ -3797,7 +3796,7 @@ build_privkey_template (app_t app, int keyno, /* Sanity check. We don't know the exact length because we allocated 3 bytes for the first length header. */ - assert (tp - template <= template_size); + log_assert (tp - template <= template_size); *result = template; *resultlen = tp - template; @@ -3904,7 +3903,7 @@ build_ecc_privkey_template (app_t app, int keyno, tp += ecc_q_len; } - assert (tp - template == template_size); + log_assert (tp - template == template_size); *result = template; *resultlen = tp - template; @@ -3922,7 +3921,7 @@ change_keyattr (app_t app, ctrl_t ctrl, { gpg_error_t err; - assert (keyno >=0 && keyno <= 2); + log_assert (keyno >=0 && keyno <= 2); /* Prepare for storing the key. */ err = verify_chv3 (app, ctrl, pincb, pincb_arg); @@ -4437,7 +4436,7 @@ rsa_writekey (app_t app, ctrl_t ctrl, 0xC1 prime p 0xC2 prime q */ - assert (rsa_e_len <= 4); + log_assert (rsa_e_len <= 4); template_len = (1 + 1 + 4 + 1 + 1 + rsa_p_len + 1 + 1 + rsa_q_len); @@ -4468,7 +4467,7 @@ rsa_writekey (app_t app, ctrl_t ctrl, memcpy (tp, rsa_q, rsa_q_len); tp += rsa_q_len; - assert (tp - template == template_len); + log_assert (tp - template == template_len); /* Prepare for storing the key. */ err = verify_chv3 (app, ctrl, pincb, pincb_arg); @@ -5019,7 +5018,7 @@ compare_fingerprint (app_t app, int keyno, unsigned char *sha1fpr) size_t buflen, n; int rc, i; - assert (keyno >= 0 && keyno <= 2); + log_assert (keyno >= 0 && keyno <= 2); rc = get_cached_data (app, 0x006E, &buffer, &buflen, 0, 0); if (rc) @@ -5262,7 +5261,7 @@ do_sign (app_t app, ctrl_t ctrl, const char *keyidstr, int hashalgo, if (hashalgo == GCRY_MD_ ## a && (d) ) \ { \ datalen = sizeof b ## _prefix + indatalen; \ - assert (datalen <= sizeof data); \ + log_assert (datalen <= sizeof data); \ memcpy (data, b ## _prefix, sizeof b ## _prefix); \ memcpy (data + sizeof b ## _prefix, indata, indatalen); \ } -- cgit v1.2.3