start_new_gpg_agent:
  609|   176k|{
  610|   176k|  return start_new_service (r_ctx, GNUPG_MODULE_NAME_AGENT,
  ------------------
  |  |  286|   176k|#define GNUPG_MODULE_NAME_AGENT        1
  ------------------
  611|   176k|                            errsource, agent_program,
  612|   176k|                            opt_lc_ctype, opt_lc_messages, session_env,
  613|   176k|                            autostart, verbose, debug,
  614|   176k|                            status_cb, status_cb_arg);
  615|   176k|}
asshelp.c:start_new_service:
  392|   176k|{
  393|   176k|  gpg_error_t err;
  394|   176k|  assuan_context_t ctx;
  395|   176k|  int did_success_msg = 0;
  396|   176k|  char *sockname;
  397|   176k|  const char *printed_name;
  398|   176k|  const char *lock_name;
  399|   176k|  const char *status_start_line;
  400|   176k|  int no_service_err;
  401|   176k|  int seconds_to_wait;
  402|   176k|  unsigned int connect_flags = 0;
  403|   176k|  const char *argv[6];
  404|       |
  405|   176k|  *r_ctx = NULL;
  406|       |
  407|   176k|  err = assuan_new (&ctx);
  408|   176k|  if (err)
  ------------------
  |  Branch (408:7): [True: 0, False: 176k]
  ------------------
  409|      0|    {
  410|      0|      log_error ("error allocating assuan context: %s\n", gpg_strerror (err));
  411|      0|      return err;
  412|      0|    }
  413|       |
  414|   176k|  switch (module_name_id)
  415|   176k|    {
  416|   176k|    case GNUPG_MODULE_NAME_AGENT:
  ------------------
  |  |  286|   176k|#define GNUPG_MODULE_NAME_AGENT        1
  ------------------
  |  Branch (416:5): [True: 176k, False: 0]
  ------------------
  417|   176k|      sockname = make_filename (gnupg_socketdir (), GPG_AGENT_SOCK_NAME, NULL);
  ------------------
  |  |  146|   176k|#define GPG_AGENT_SOCK_NAME "S.gpg-agent"
  ------------------
  418|   176k|      lock_name = "agent";
  419|   176k|      printed_name = "gpg-agent";
  420|   176k|      status_start_line = "starting_agent ? 0 0";
  421|   176k|      no_service_err = GPG_ERR_NO_AGENT;
  422|   176k|      seconds_to_wait = SECS_TO_WAIT_FOR_AGENT;
  ------------------
  |  |   57|   176k|#define SECS_TO_WAIT_FOR_AGENT 5
  ------------------
  423|   176k|      break;
  424|      0|    case GNUPG_MODULE_NAME_DIRMNGR:
  ------------------
  |  |  289|      0|#define GNUPG_MODULE_NAME_DIRMNGR      4
  ------------------
  |  Branch (424:5): [True: 0, False: 176k]
  ------------------
  425|      0|      sockname = make_filename (gnupg_socketdir (), DIRMNGR_SOCK_NAME, NULL);
  ------------------
  |  |   64|      0|#define DIRMNGR_SOCK_NAME "S.dirmngr"
  ------------------
  426|      0|      lock_name = "dirmngr";
  427|      0|      printed_name = "dirmngr";
  428|      0|      status_start_line = "starting_dirmngr ? 0 0";
  429|      0|      no_service_err = GPG_ERR_NO_DIRMNGR;
  430|      0|      seconds_to_wait = SECS_TO_WAIT_FOR_DIRMNGR;
  ------------------
  |  |   59|      0|#define SECS_TO_WAIT_FOR_DIRMNGR 5
  ------------------
  431|      0|      break;
  432|      0|    case GNUPG_MODULE_NAME_KEYBOXD:
  ------------------
  |  |  298|      0|#define GNUPG_MODULE_NAME_KEYBOXD       13
  ------------------
  |  Branch (432:5): [True: 0, False: 176k]
  ------------------
  433|      0|      sockname = make_filename (gnupg_socketdir (), KEYBOXD_SOCK_NAME, NULL);
  ------------------
  |  |  650|      0|#define KEYBOXD_SOCK_NAME "S.keyboxd"
  ------------------
  434|      0|      lock_name = "keyboxd";
  435|      0|      printed_name = "keyboxd";
  436|      0|      status_start_line = "starting_keyboxd ? 0 0";
  437|      0|      no_service_err = GPG_ERR_NO_KEYBOXD;
  438|      0|      seconds_to_wait = SECS_TO_WAIT_FOR_KEYBOXD;
  ------------------
  |  |   58|      0|#define SECS_TO_WAIT_FOR_KEYBOXD 5
  ------------------
  439|      0|      connect_flags |= ASSUAN_SOCKET_CONNECT_FDPASSING;
  440|      0|      break;
  441|      0|    default:
  ------------------
  |  Branch (441:5): [True: 0, False: 176k]
  ------------------
  442|      0|      err = gpg_error (GPG_ERR_INV_ARG);
  443|      0|      assuan_release (ctx);
  444|      0|      return err;
  445|   176k|    }
  446|       |
  447|   176k|  err = assuan_socket_connect (ctx, sockname, 0, connect_flags);
  448|   176k|  if (err && autostart)
  ------------------
  |  Branch (448:7): [True: 176k, False: 0]
  |  Branch (448:14): [True: 0, False: 176k]
  ------------------
  449|      0|    {
  450|      0|      char *abs_homedir;
  451|      0|      lock_spawn_t lock;
  ------------------
  |  |   52|      0|# define lock_spawn_t dotlock_t
  ------------------
  452|      0|      char *program = NULL;
  453|      0|      const char *program_arg = NULL;
  454|      0|      char *p;
  455|      0|      const char *s;
  456|      0|      int i;
  457|       |
  458|       |      /* With no success start a new server.  */
  459|      0|      if (!program_name || !*program_name)
  ------------------
  |  Branch (459:11): [True: 0, False: 0]
  |  Branch (459:28): [True: 0, False: 0]
  ------------------
  460|      0|        program_name = gnupg_module_name (module_name_id);
  461|      0|      else if ((s=strchr (program_name, '|')) && s[1] == '-' && s[2]=='-')
  ------------------
  |  Branch (461:16): [True: 0, False: 0]
  |  Branch (461:50): [True: 0, False: 0]
  |  Branch (461:65): [True: 0, False: 0]
  ------------------
  462|      0|        {
  463|       |          /* Hack to insert an additional option on the command line.  */
  464|      0|          program = xtrystrdup (program_name);
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
  465|      0|          if (!program)
  ------------------
  |  Branch (465:15): [True: 0, False: 0]
  ------------------
  466|      0|            {
  467|      0|              gpg_error_t tmperr = gpg_err_make (errsource,
  468|      0|                                                 gpg_err_code_from_syserror ());
  469|      0|              xfree (sockname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  470|      0|              assuan_release (ctx);
  471|      0|              return tmperr;
  472|      0|            }
  473|      0|          p = strchr (program, '|');
  474|      0|          *p++ = 0;
  475|      0|          program_arg = p;
  476|      0|        }
  477|       |
  478|      0|      if (verbose)
  ------------------
  |  Branch (478:11): [True: 0, False: 0]
  ------------------
  479|      0|        log_info (_("no running %s - starting '%s'\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  480|      0|                  printed_name, program_name);
  481|       |
  482|      0|      if (status_cb)
  ------------------
  |  Branch (482:11): [True: 0, False: 0]
  ------------------
  483|      0|        status_cb (status_cb_arg, STATUS_PROGRESS, status_start_line, NULL);
  484|       |
  485|       |      /* We better pass an absolute home directory to the service just
  486|       |       * in case the service does not convert the passed name to an
  487|       |       * absolute one (which it should do).  */
  488|      0|      abs_homedir = make_absfilename_try (gnupg_homedir (), NULL);
  489|      0|      if (!abs_homedir)
  ------------------
  |  Branch (489:11): [True: 0, False: 0]
  ------------------
  490|      0|        {
  491|      0|          gpg_error_t tmperr = gpg_err_make (errsource,
  492|      0|                                             gpg_err_code_from_syserror ());
  493|      0|          log_error ("error building filename: %s\n", gpg_strerror (tmperr));
  494|      0|          xfree (sockname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  495|      0|          assuan_release (ctx);
  496|      0|          xfree (program);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  497|      0|          return tmperr;
  498|      0|        }
  499|       |
  500|      0|      if (fflush (NULL))
  ------------------
  |  Branch (500:11): [True: 0, False: 0]
  ------------------
  501|      0|        {
  502|      0|          gpg_error_t tmperr = gpg_err_make (errsource,
  503|      0|                                             gpg_err_code_from_syserror ());
  504|      0|          log_error ("error flushing pending output: %s\n", strerror (errno));
  505|      0|          xfree (sockname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  506|      0|          assuan_release (ctx);
  507|      0|          xfree (abs_homedir);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  508|      0|          xfree (program);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  509|      0|          return tmperr;
  510|      0|        }
  511|       |
  512|      0|      i = 0;
  513|      0|      argv[i++] = "--homedir";
  514|      0|      argv[i++] = abs_homedir;
  515|      0|      if (module_name_id == GNUPG_MODULE_NAME_AGENT)
  ------------------
  |  |  286|      0|#define GNUPG_MODULE_NAME_AGENT        1
  ------------------
  |  Branch (515:11): [True: 0, False: 0]
  ------------------
  516|      0|        argv[i++] = "--use-standard-socket";
  517|      0|      if (program_arg)
  ------------------
  |  Branch (517:11): [True: 0, False: 0]
  ------------------
  518|      0|        argv[i++] = program_arg;
  519|      0|      argv[i++] = "--daemon";
  520|      0|      argv[i++] = NULL;
  521|       |
  522|      0|      if (!(err = lock_spawning (&lock, gnupg_homedir (), lock_name, verbose))
  ------------------
  |  Branch (522:11): [True: 0, False: 0]
  ------------------
  523|      0|          && assuan_socket_connect (ctx, sockname, 0, connect_flags))
  ------------------
  |  Branch (523:14): [True: 0, False: 0]
  ------------------
  524|      0|        {
  525|       |#ifdef HAVE_W32_SYSTEM
  526|       |          err = gnupg_spawn_process_detached (program? program : program_name,
  527|       |                                              argv, NULL);
  528|       |#else /*!W32*/
  529|      0|          pid_t pid;
  530|       |
  531|      0|          err = gnupg_spawn_process_fd (program? program : program_name,
  ------------------
  |  Branch (531:41): [True: 0, False: 0]
  ------------------
  532|      0|                                        argv, -1, -1, -1, &pid);
  533|      0|          if (!err)
  ------------------
  |  Branch (533:15): [True: 0, False: 0]
  ------------------
  534|      0|            err = gnupg_wait_process (program? program : program_name,
  ------------------
  |  Branch (534:39): [True: 0, False: 0]
  ------------------
  535|      0|                                      pid, 1, NULL);
  536|      0|#endif /*!W32*/
  537|      0|          if (err)
  ------------------
  |  Branch (537:15): [True: 0, False: 0]
  ------------------
  538|      0|            log_error ("failed to start %s '%s': %s\n",
  539|      0|                       printed_name, program? program : program_name,
  ------------------
  |  Branch (539:38): [True: 0, False: 0]
  ------------------
  540|      0|                       gpg_strerror (err));
  541|      0|          else
  542|      0|            err = wait_for_sock (seconds_to_wait, module_name_id,
  543|      0|                                 sockname, connect_flags,
  544|      0|                                 verbose, ctx, &did_success_msg);
  545|      0|        }
  546|       |
  547|      0|      unlock_spawning (&lock, lock_name);
  548|      0|      xfree (abs_homedir);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  549|      0|      xfree (program);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  550|      0|    }
  551|   176k|  xfree (sockname);
  ------------------
  |  |  104|   176k|#define xfree(a)         gcry_free ((a))
  ------------------
  552|   176k|  if (err)
  ------------------
  |  Branch (552:7): [True: 176k, False: 0]
  ------------------
  553|   176k|    {
  554|   176k|      if (autostart || gpg_err_code (err) != GPG_ERR_ASS_CONNECT_FAILED)
  ------------------
  |  Branch (554:11): [True: 0, False: 176k]
  |  Branch (554:24): [True: 0, False: 176k]
  ------------------
  555|      0|        log_error ("can't connect to the %s: %s\n",
  556|      0|                   printed_name, gpg_strerror (err));
  557|   176k|      assuan_release (ctx);
  558|   176k|      return gpg_err_make (errsource, no_service_err);
  559|   176k|    }
  560|       |
  561|      0|  if (debug && !did_success_msg)
  ------------------
  |  Branch (561:7): [True: 0, False: 0]
  |  Branch (561:16): [True: 0, False: 0]
  ------------------
  562|      0|    log_debug ("connection to the %s established\n", printed_name);
  563|       |
  564|      0|  if (module_name_id == GNUPG_MODULE_NAME_AGENT)
  ------------------
  |  |  286|      0|#define GNUPG_MODULE_NAME_AGENT        1
  ------------------
  |  Branch (564:7): [True: 0, False: 0]
  ------------------
  565|      0|    err = assuan_transact (ctx, "RESET",
  566|      0|                           NULL, NULL, NULL, NULL, NULL, NULL);
  567|       |
  568|      0|  if (!err
  ------------------
  |  Branch (568:7): [True: 0, False: 0]
  ------------------
  569|      0|      && module_name_id == GNUPG_MODULE_NAME_AGENT)
  ------------------
  |  |  286|      0|#define GNUPG_MODULE_NAME_AGENT        1
  ------------------
  |  Branch (569:10): [True: 0, False: 0]
  ------------------
  570|      0|    {
  571|      0|      err = send_pinentry_environment (ctx, errsource,
  572|      0|                                       opt_lc_ctype, opt_lc_messages,
  573|      0|                                       session_env);
  574|      0|      if (gpg_err_code (err) == GPG_ERR_FORBIDDEN
  ------------------
  |  Branch (574:11): [True: 0, False: 0]
  ------------------
  575|      0|          && gpg_err_source (err) == GPG_ERR_SOURCE_GPGAGENT)
  ------------------
  |  Branch (575:14): [True: 0, False: 0]
  ------------------
  576|      0|        {
  577|       |          /* Check whether the agent is in restricted mode.  */
  578|      0|          if (!assuan_transact (ctx, "GETINFO restricted",
  ------------------
  |  Branch (578:15): [True: 0, False: 0]
  ------------------
  579|      0|                                NULL, NULL, NULL, NULL, NULL, NULL))
  580|      0|            {
  581|      0|              if (verbose)
  ------------------
  |  Branch (581:19): [True: 0, False: 0]
  ------------------
  582|      0|                log_info (_("connection to the agent is in restricted mode\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  583|      0|              err = 0;
  584|      0|            }
  585|      0|        }
  586|      0|    }
  587|      0|  if (err)
  ------------------
  |  Branch (587:7): [True: 0, False: 0]
  ------------------
  588|      0|    {
  589|      0|      assuan_release (ctx);
  590|      0|      return err;
  591|      0|    }
  592|       |
  593|      0|  *r_ctx = ctx;
  594|      0|  return 0;
  595|      0|}

gnupg_initialize_compliance:
   82|      1|{
   83|      1|  log_assert (! initialized);
   84|       |
   85|       |  /* We accept both OpenPGP-style and gcrypt-style algorithm ids.
   86|       |   * Assert that they are compatible.  */
   87|      0|  log_assert ((int) GCRY_PK_RSA          == (int) PUBKEY_ALGO_RSA);
   88|      0|  log_assert ((int) GCRY_PK_RSA_E        == (int) PUBKEY_ALGO_RSA_E);
   89|      0|  log_assert ((int) GCRY_PK_RSA_S        == (int) PUBKEY_ALGO_RSA_S);
   90|      0|  log_assert ((int) GCRY_PK_ELG_E        == (int) PUBKEY_ALGO_ELGAMAL_E);
   91|      0|  log_assert ((int) GCRY_PK_DSA          == (int) PUBKEY_ALGO_DSA);
   92|      0|  log_assert ((int) GCRY_PK_ECC          == (int) PUBKEY_ALGO_ECDH);
   93|      0|  log_assert ((int) GCRY_PK_ELG          == (int) PUBKEY_ALGO_ELGAMAL);
   94|      0|  log_assert ((int) GCRY_CIPHER_NONE     == (int) CIPHER_ALGO_NONE);
   95|      0|  log_assert ((int) GCRY_CIPHER_IDEA     == (int) CIPHER_ALGO_IDEA);
   96|      0|  log_assert ((int) GCRY_CIPHER_3DES     == (int) CIPHER_ALGO_3DES);
   97|      0|  log_assert ((int) GCRY_CIPHER_CAST5    == (int) CIPHER_ALGO_CAST5);
   98|      0|  log_assert ((int) GCRY_CIPHER_BLOWFISH == (int) CIPHER_ALGO_BLOWFISH);
   99|      0|  log_assert ((int) GCRY_CIPHER_AES      == (int) CIPHER_ALGO_AES);
  100|      0|  log_assert ((int) GCRY_CIPHER_AES192   == (int) CIPHER_ALGO_AES192);
  101|      0|  log_assert ((int) GCRY_CIPHER_AES256   == (int) CIPHER_ALGO_AES256);
  102|      0|  log_assert ((int) GCRY_CIPHER_TWOFISH  == (int) CIPHER_ALGO_TWOFISH);
  103|      0|  log_assert ((int) GCRY_MD_MD5          == (int) DIGEST_ALGO_MD5);
  104|      0|  log_assert ((int) GCRY_MD_SHA1         == (int) DIGEST_ALGO_SHA1);
  105|      0|  log_assert ((int) GCRY_MD_RMD160       == (int) DIGEST_ALGO_RMD160);
  106|      0|  log_assert ((int) GCRY_MD_SHA256       == (int) DIGEST_ALGO_SHA256);
  107|      0|  log_assert ((int) GCRY_MD_SHA384       == (int) DIGEST_ALGO_SHA384);
  108|      0|  log_assert ((int) GCRY_MD_SHA512       == (int) DIGEST_ALGO_SHA512);
  109|      0|  log_assert ((int) GCRY_MD_SHA224       == (int) DIGEST_ALGO_SHA224);
  110|       |
  111|      0|  switch (gnupg_module_name)
  112|      1|    {
  113|      0|    case GNUPG_MODULE_NAME_GPGSM:
  ------------------
  |  |  292|      0|#define GNUPG_MODULE_NAME_GPGSM         7
  ------------------
  |  Branch (113:5): [True: 0, False: 1]
  ------------------
  114|      1|    case GNUPG_MODULE_NAME_GPG:
  ------------------
  |  |  293|      1|#define GNUPG_MODULE_NAME_GPG           8
  ------------------
  |  Branch (114:5): [True: 1, False: 0]
  ------------------
  115|      1|      break;
  116|       |
  117|      0|    default:
  ------------------
  |  Branch (117:5): [True: 0, False: 1]
  ------------------
  118|      0|      log_assert (!"no policies for this module");
  119|      1|    }
  120|       |
  121|      1|  module = gnupg_module_name;
  122|      1|  initialized = 1;
  123|      1|}

bin2hex:
  158|  6.92k|{
  159|  6.92k|  return do_bin2hex (buffer, length, stringbuf, 0);
  160|  6.92k|}
convert.c:do_bin2hex:
  117|  6.92k|{
  118|  6.92k|  const unsigned char *s;
  119|  6.92k|  char *p;
  120|       |
  121|  6.92k|  if (!stringbuf)
  ------------------
  |  Branch (121:7): [True: 1.05k, False: 5.87k]
  ------------------
  122|  1.05k|    {
  123|       |      /* Not really correct for with_colon but we don't care about the
  124|       |         one wasted byte. */
  125|  1.05k|      size_t n = with_colon? 3:2;
  ------------------
  |  Branch (125:18): [True: 0, False: 1.05k]
  ------------------
  126|  1.05k|      size_t nbytes = n * length + 1;
  127|  1.05k|      if (length &&  (nbytes-1) / n != length)
  ------------------
  |  Branch (127:11): [True: 1.05k, False: 0]
  |  Branch (127:22): [True: 0, False: 1.05k]
  ------------------
  128|      0|        {
  129|      0|          gpg_err_set_errno (ENOMEM);
  130|      0|          return NULL;
  131|      0|        }
  132|  1.05k|      stringbuf = xtrymalloc (nbytes);
  ------------------
  |  |   97|  1.05k|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  133|  1.05k|      if (!stringbuf)
  ------------------
  |  Branch (133:11): [True: 0, False: 1.05k]
  ------------------
  134|      0|        return NULL;
  135|  1.05k|    }
  136|       |
  137|  91.8k|  for (s = buffer, p = stringbuf; length; length--, s++)
  ------------------
  |  Branch (137:35): [True: 84.9k, False: 6.92k]
  ------------------
  138|  84.9k|    {
  139|  84.9k|      if (with_colon && s != buffer)
  ------------------
  |  Branch (139:11): [True: 0, False: 84.9k]
  |  Branch (139:25): [True: 0, False: 0]
  ------------------
  140|      0|        *p++ = ':';
  141|  84.9k|      *p++ = tohex ((*s>>4)&15);
  ------------------
  |  |   38|  84.9k|#define tohex(n) ((n) < 10 ? ((n) + '0') : (((n) - 10) + 'A'))
  |  |  ------------------
  |  |  |  Branch (38:19): [True: 60.7k, False: 24.1k]
  |  |  ------------------
  ------------------
  142|  84.9k|      *p++ = tohex (*s&15);
  ------------------
  |  |   38|  84.9k|#define tohex(n) ((n) < 10 ? ((n) + '0') : (((n) - 10) + 'A'))
  |  |  ------------------
  |  |  |  Branch (38:19): [True: 49.8k, False: 35.1k]
  |  |  ------------------
  ------------------
  143|  84.9k|    }
  144|  6.92k|  *p = 0;
  145|       |
  146|  6.92k|  return stringbuf;
  147|  6.92k|}

dotlock_create:
  885|      3|{
  886|      3|  static int initialized;
  887|      3|  dotlock_t h;
  888|       |
  889|      3|  if ( !initialized )
  ------------------
  |  Branch (889:8): [True: 1, False: 2]
  ------------------
  890|      1|    {
  891|      1|      atexit (dotlock_remove_lockfiles);
  892|      1|      initialized = 1;
  893|      1|    }
  894|       |
  895|      3|  if ( !file_to_lock )
  ------------------
  |  Branch (895:8): [True: 0, False: 3]
  ------------------
  896|      0|    return NULL;  /* Only initialization was requested.  */
  897|       |
  898|      3|  if (flags)
  ------------------
  |  Branch (898:7): [True: 0, False: 3]
  ------------------
  899|      0|    {
  900|      0|      my_set_errno (EINVAL);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  901|      0|      return NULL;
  902|      0|    }
  903|       |
  904|      3|  h = xtrycalloc (1, sizeof *h);
  ------------------
  |  |   99|      3|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  905|      3|  if (!h)
  ------------------
  |  Branch (905:7): [True: 0, False: 3]
  ------------------
  906|      0|    return NULL;
  907|      3|  h->extra_fd = -1;
  908|       |
  909|      3|  if (never_lock)
  ------------------
  |  Branch (909:7): [True: 0, False: 3]
  ------------------
  910|      0|    {
  911|      0|      h->disable = 1;
  912|      0|      LOCK_all_lockfiles ();
  ------------------
  |  |  424|      0|# define LOCK_all_lockfiles()   do { } while (0)
  |  |  ------------------
  |  |  |  Branch (424:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  913|      0|      h->next = all_lockfiles;
  914|      0|      all_lockfiles = h;
  915|      0|      UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      0|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  916|      0|      return h;
  917|      0|    }
  918|       |
  919|       |#ifdef HAVE_DOSISH_SYSTEM
  920|       |  return dotlock_create_w32 (h, file_to_lock);
  921|       |#else /*!HAVE_DOSISH_SYSTEM */
  922|      3|  return dotlock_create_unix (h, file_to_lock);
  923|      3|#endif /*!HAVE_DOSISH_SYSTEM*/
  924|      3|}
dotlock_destroy:
  980|      3|{
  981|      3|  dotlock_t hprev, htmp;
  982|       |
  983|      3|  if ( !h )
  ------------------
  |  Branch (983:8): [True: 0, False: 3]
  ------------------
  984|      0|    return;
  985|       |
  986|       |  /* First remove the handle from our global list of all locks. */
  987|      3|  LOCK_all_lockfiles ();
  ------------------
  |  |  424|      3|# define LOCK_all_lockfiles()   do { } while (0)
  |  |  ------------------
  |  |  |  Branch (424:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  988|      3|  for (hprev=NULL, htmp=all_lockfiles; htmp; hprev=htmp, htmp=htmp->next)
  ------------------
  |  Branch (988:40): [True: 1, False: 2]
  ------------------
  989|      1|    if (htmp == h)
  ------------------
  |  Branch (989:9): [True: 1, False: 0]
  ------------------
  990|      1|      {
  991|      1|        if (hprev)
  ------------------
  |  Branch (991:13): [True: 0, False: 1]
  ------------------
  992|      0|          hprev->next = htmp->next;
  993|      1|        else
  994|      1|          all_lockfiles = htmp->next;
  995|      1|        h->next = NULL;
  996|      1|        break;
  997|      1|      }
  998|      3|  UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      3|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  999|       |
 1000|       |  /* Then destroy the lock. */
 1001|      3|  if (!h->disable)
  ------------------
  |  Branch (1001:7): [True: 3, False: 0]
  ------------------
 1002|      3|    {
 1003|       |#ifdef HAVE_DOSISH_SYSTEM
 1004|       |      dotlock_destroy_w32 (h);
 1005|       |#else /* !HAVE_DOSISH_SYSTEM */
 1006|      3|      dotlock_destroy_unix (h);
 1007|      3|#endif /* HAVE_DOSISH_SYSTEM */
 1008|      3|      xfree (h->lockname);
  ------------------
  |  |  104|      3|#define xfree(a)         gcry_free ((a))
  ------------------
 1009|      3|    }
 1010|      3|  xfree(h);
  ------------------
  |  |  104|      3|#define xfree(a)         gcry_free ((a))
  ------------------
 1011|      3|}
dotlock_take:
 1281|      3|{
 1282|      3|  int ret;
 1283|       |
 1284|      3|  if ( h->disable )
  ------------------
  |  Branch (1284:8): [True: 0, False: 3]
  ------------------
 1285|      0|    return 0; /* Locks are completely disabled.  Return success. */
 1286|       |
 1287|      3|  if ( h->locked )
  ------------------
  |  Branch (1287:8): [True: 0, False: 3]
  ------------------
 1288|      0|    {
 1289|      0|      my_debug_1 ("Oops, '%s' is already locked\n", h->lockname);
  ------------------
  |  |  359|      0|# define my_debug_1(a,b)    log_debug ((a), (b))
  ------------------
 1290|      0|      return 0;
 1291|      0|    }
 1292|       |
 1293|       |#ifdef HAVE_DOSISH_SYSTEM
 1294|       |  ret = dotlock_take_w32 (h, timeout);
 1295|       |#else /*!HAVE_DOSISH_SYSTEM*/
 1296|      3|  ret = dotlock_take_unix (h, timeout);
 1297|      3|#endif /*!HAVE_DOSISH_SYSTEM*/
 1298|       |
 1299|      3|  return ret;
 1300|      3|}
dotlock_release:
 1367|      3|{
 1368|      3|  int ret;
 1369|       |
 1370|       |  /* To avoid atexit race conditions we first check whether there are
 1371|       |     any locks left.  It might happen that another atexit handler
 1372|       |     tries to release the lock while the atexit handler of this module
 1373|       |     already ran and thus H is undefined.  */
 1374|      3|  LOCK_all_lockfiles ();
  ------------------
  |  |  424|      3|# define LOCK_all_lockfiles()   do { } while (0)
  |  |  ------------------
  |  |  |  Branch (424:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1375|      3|  ret = !all_lockfiles;
 1376|      3|  UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      3|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1377|      3|  if (ret)
  ------------------
  |  Branch (1377:7): [True: 0, False: 3]
  ------------------
 1378|      0|    return 0;
 1379|       |
 1380|      3|  if ( h->disable )
  ------------------
  |  Branch (1380:8): [True: 0, False: 3]
  ------------------
 1381|      0|    return 0;
 1382|       |
 1383|      3|  if ( !h->locked )
  ------------------
  |  Branch (1383:8): [True: 0, False: 3]
  ------------------
 1384|      0|    {
 1385|      0|      my_debug_1 ("Oops, '%s' is not locked\n", h->lockname);
  ------------------
  |  |  359|      0|# define my_debug_1(a,b)    log_debug ((a), (b))
  ------------------
 1386|      0|      return 0;
 1387|      0|    }
 1388|       |
 1389|       |#ifdef HAVE_DOSISH_SYSTEM
 1390|       |  ret = dotlock_release_w32 (h);
 1391|       |#else
 1392|      3|  ret = dotlock_release_unix (h);
 1393|      3|#endif
 1394|       |
 1395|      3|  if (!ret)
  ------------------
  |  Branch (1395:7): [True: 3, False: 0]
  ------------------
 1396|      3|    h->locked = 0;
 1397|      3|  return ret;
 1398|      3|}
dotlock_remove_lockfiles:
 1407|      1|{
 1408|      1|  dotlock_t h, h2;
 1409|       |
 1410|       |  /* First set the lockfiles list to NULL so that for example
 1411|       |     dotlock_release is aware that this function is currently
 1412|       |     running.  */
 1413|      1|  LOCK_all_lockfiles ();
  ------------------
  |  |  424|      1|# define LOCK_all_lockfiles()   do { } while (0)
  |  |  ------------------
  |  |  |  Branch (424:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1414|      1|  h = all_lockfiles;
 1415|      1|  all_lockfiles = NULL;
 1416|      1|  UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      1|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1417|       |
 1418|      3|  while ( h )
  ------------------
  |  Branch (1418:11): [True: 2, False: 1]
  ------------------
 1419|      2|    {
 1420|      2|      h2 = h->next;
 1421|      2|      dotlock_destroy (h);
 1422|      2|      h = h2;
 1423|      2|    }
 1424|      1|}
dotlock.c:dotlock_create_unix:
  662|      3|{
  663|      3|  int  fd = -1;
  664|      3|  char pidstr[16];
  665|      3|  const char *nodename;
  666|      3|  const char *dirpart;
  667|      3|  int dirpartlen;
  668|      3|  struct utsname utsbuf;
  669|      3|  size_t tnamelen;
  670|       |
  671|      3|  snprintf (pidstr, sizeof pidstr, "%10d\n", (int)getpid() );
  ------------------
  |  |   84|      3|#define snprintf gpgrt_snprintf
  ------------------
  672|       |
  673|       |  /* Create a temporary file. */
  674|      3|  if ( uname ( &utsbuf ) )
  ------------------
  |  Branch (674:8): [True: 0, False: 3]
  ------------------
  675|      0|    nodename = "unknown";
  676|      3|  else
  677|      3|    nodename = utsbuf.nodename;
  678|       |
  679|      3|  if ( !(dirpart = strrchr (file_to_lock, DIRSEP_C)) )
  ------------------
  |  |  886|      3|#define DIRSEP_C '/'
  ------------------
  |  Branch (679:8): [True: 0, False: 3]
  ------------------
  680|      0|    {
  681|      0|      dirpart = EXTSEP_S;
  ------------------
  |  |  889|      0|#define EXTSEP_S "."
  ------------------
  682|      0|      dirpartlen = 1;
  683|      0|    }
  684|      3|  else
  685|      3|    {
  686|      3|      dirpartlen = dirpart - file_to_lock;
  687|      3|      dirpart = file_to_lock;
  688|      3|    }
  689|       |
  690|      3|  LOCK_all_lockfiles ();
  ------------------
  |  |  424|      3|# define LOCK_all_lockfiles()   do { } while (0)
  |  |  ------------------
  |  |  |  Branch (424:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  691|      3|  h->next = all_lockfiles;
  692|      3|  all_lockfiles = h;
  693|       |
  694|      3|  tnamelen = dirpartlen + 6 + 30 + strlen(nodename) + 10 + 1;
  695|      3|  h->tname = xtrymalloc (tnamelen + 1);
  ------------------
  |  |   97|      3|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  696|      3|  if (!h->tname)
  ------------------
  |  Branch (696:7): [True: 0, False: 3]
  ------------------
  697|      0|    {
  698|      0|      all_lockfiles = h->next;
  699|      0|      UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      0|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  700|      0|      xfree (h);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  701|      0|      return NULL;
  702|      0|    }
  703|      3|  h->nodename_len = strlen (nodename);
  704|       |
  705|      3|  snprintf (h->tname, tnamelen, "%.*s/.#lk%p.", dirpartlen, dirpart, h );
  ------------------
  |  |   84|      3|#define snprintf gpgrt_snprintf
  ------------------
  706|      3|  h->nodename_off = strlen (h->tname);
  707|      3|  snprintf (h->tname+h->nodename_off, tnamelen - h->nodename_off,
  ------------------
  |  |   84|      3|#define snprintf gpgrt_snprintf
  ------------------
  708|      3|           "%s.%d", nodename, (int)getpid ());
  709|       |
  710|      3|  do
  711|      3|    {
  712|      3|      my_set_errno (0);
  ------------------
  |  |  341|      3|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  713|      3|      fd = open (h->tname, O_WRONLY|O_CREAT|O_EXCL,
  714|      3|                 S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR );
  715|      3|    }
  716|      3|  while (fd == -1 && errno == EINTR);
  ------------------
  |  Branch (716:10): [True: 0, False: 3]
  |  Branch (716:22): [True: 0, False: 0]
  ------------------
  717|       |
  718|      3|  if ( fd == -1 )
  ------------------
  |  Branch (718:8): [True: 0, False: 3]
  ------------------
  719|      0|    {
  720|      0|      int saveerrno = errno;
  721|      0|      all_lockfiles = h->next;
  722|      0|      UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      0|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  723|      0|      my_error_2 (_("failed to create temporary file '%s': %s\n"),
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
  724|      0|                  h->tname, strerror (errno));
  725|      0|      xfree (h->tname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  726|      0|      xfree (h);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  727|      0|      my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  728|      0|      return NULL;
  729|      0|    }
  730|      3|  if ( write (fd, pidstr, 11 ) != 11 )
  ------------------
  |  Branch (730:8): [True: 0, False: 3]
  ------------------
  731|      0|    goto write_failed;
  732|      3|  if ( write (fd, nodename, strlen (nodename) ) != strlen (nodename) )
  ------------------
  |  Branch (732:8): [True: 0, False: 3]
  ------------------
  733|      0|    goto write_failed;
  734|      3|  if ( write (fd, "\n", 1 ) != 1 )
  ------------------
  |  Branch (734:8): [True: 0, False: 3]
  ------------------
  735|      0|    goto write_failed;
  736|      3|  if ( close (fd) )
  ------------------
  |  Branch (736:8): [True: 0, False: 3]
  ------------------
  737|      0|    {
  738|      0|      if ( errno == EINTR )
  ------------------
  |  Branch (738:12): [True: 0, False: 0]
  ------------------
  739|      0|        fd = -1;
  740|      0|      goto write_failed;
  741|      0|    }
  742|      3|  fd = -1;
  743|       |
  744|       |  /* Check whether we support hard links.  */
  745|      3|  switch (use_hardlinks_p (h->tname))
  746|      3|    {
  747|      3|    case 0: /* Yes.  */
  ------------------
  |  Branch (747:5): [True: 3, False: 0]
  ------------------
  748|      3|      break;
  749|      0|    case 1: /* No.  */
  ------------------
  |  Branch (749:5): [True: 0, False: 3]
  ------------------
  750|      0|      unlink (h->tname);
  751|      0|      h->use_o_excl = 1;
  752|      0|      break;
  753|      0|    default:
  ------------------
  |  Branch (753:5): [True: 0, False: 3]
  ------------------
  754|      0|      {
  755|      0|        int saveerrno = errno;
  756|      0|        my_error_2 ("can't check whether hardlinks are supported for '%s': %s\n"
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
  757|      0|                    , h->tname, strerror (saveerrno));
  758|      0|        my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  759|      0|      }
  760|      0|      goto write_failed;
  761|      3|    }
  762|       |
  763|      3|  h->lockname = xtrymalloc (strlen (file_to_lock) + 6 );
  ------------------
  |  |   97|      3|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  764|      3|  if (!h->lockname)
  ------------------
  |  Branch (764:7): [True: 0, False: 3]
  ------------------
  765|      0|    {
  766|      0|      int saveerrno = errno;
  767|      0|      all_lockfiles = h->next;
  768|      0|      UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      0|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  769|      0|      unlink (h->tname);
  770|      0|      xfree (h->tname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  771|      0|      xfree (h);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  772|      0|      my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  773|      0|      return NULL;
  774|      0|    }
  775|      3|  strcpy (stpcpy (h->lockname, file_to_lock), EXTSEP_S "lock");
  ------------------
  |  |  889|      3|#define EXTSEP_S "."
  ------------------
  776|      3|  UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      3|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  777|       |
  778|      3|  return h;
  779|       |
  780|      0| write_failed:
  781|      0|  {
  782|      0|    int saveerrno = errno;
  783|      0|    all_lockfiles = h->next;
  784|      0|    UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      0|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  785|      0|    my_error_2 (_("error writing to '%s': %s\n"), h->tname, strerror (errno));
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
  786|      0|    if ( fd != -1 )
  ------------------
  |  Branch (786:10): [True: 0, False: 0]
  ------------------
  787|      0|      close (fd);
  788|      0|    unlink (h->tname);
  789|      0|    xfree (h->tname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  790|      0|    xfree (h);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  791|      0|    my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  792|      0|  }
  793|      0|  return NULL;
  794|      3|}
dotlock.c:use_hardlinks_p:
  623|      3|{
  624|      3|  char *lname;
  625|      3|  struct stat sb;
  626|      3|  unsigned int nlink;
  627|      3|  int res;
  628|       |
  629|      3|  if (stat (tname, &sb))
  ------------------
  |  Branch (629:7): [True: 0, False: 3]
  ------------------
  630|      0|    return -1;
  631|      3|  nlink = (unsigned int)sb.st_nlink;
  632|       |
  633|      3|  lname = xtrymalloc (strlen (tname) + 1 + 1);
  ------------------
  |  |   97|      3|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  634|      3|  if (!lname)
  ------------------
  |  Branch (634:7): [True: 0, False: 3]
  ------------------
  635|      0|    return -1;
  636|      3|  strcpy (lname, tname);
  637|      3|  strcat (lname, "x");
  638|       |
  639|       |  /* We ignore the return value of link() because it is unreliable.  */
  640|      3|  (void) link (tname, lname);
  641|       |
  642|      3|  if (stat (tname, &sb))
  ------------------
  |  Branch (642:7): [True: 0, False: 3]
  ------------------
  643|      0|    res = -1;  /* Ooops.  */
  644|      3|  else if (sb.st_nlink == nlink + 1)
  ------------------
  |  Branch (644:12): [True: 3, False: 0]
  ------------------
  645|      3|    res = 0;   /* Yeah, hardlinks are supported.  */
  646|      0|  else
  647|      0|    res = 1;   /* No hardlink support.  */
  648|       |
  649|      3|  unlink (lname);
  650|      3|  xfree (lname);
  ------------------
  |  |  104|      3|#define xfree(a)         gcry_free ((a))
  ------------------
  651|      3|  return res;
  652|      3|}
dotlock.c:dotlock_destroy_unix:
  950|      3|{
  951|      3|  if (h->locked && h->lockname)
  ------------------
  |  Branch (951:7): [True: 0, False: 3]
  |  Branch (951:20): [True: 0, False: 0]
  ------------------
  952|      0|    unlink (h->lockname);
  953|      3|  if (h->tname && !h->use_o_excl)
  ------------------
  |  Branch (953:7): [True: 3, False: 0]
  |  Branch (953:19): [True: 3, False: 0]
  ------------------
  954|      3|    unlink (h->tname);
  955|      3|  xfree (h->tname);
  ------------------
  |  |  104|      3|#define xfree(a)         gcry_free ((a))
  ------------------
  956|      3|}
dotlock.c:dotlock_take_unix:
 1020|      3|{
 1021|      3|  int wtime = 0;
 1022|      3|  int sumtime = 0;
 1023|      3|  int pid;
 1024|      3|  int lastpid = -1;
 1025|      3|  int ownerchanged;
 1026|      3|  const char *maybe_dead="";
 1027|      3|  int same_node;
 1028|      3|  int saveerrno;
 1029|      3|  int fd;
 1030|       |
 1031|      3| again:
 1032|      3|  if (h->use_o_excl)
  ------------------
  |  Branch (1032:7): [True: 0, False: 3]
  ------------------
 1033|      0|    {
 1034|       |      /* No hardlink support - use open(O_EXCL).  */
 1035|      0|      do
 1036|      0|        {
 1037|      0|          my_set_errno (0);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1038|      0|          fd = open (h->lockname, O_WRONLY|O_CREAT|O_EXCL,
 1039|      0|                     S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR );
 1040|      0|        }
 1041|      0|      while (fd == -1 && errno == EINTR);
  ------------------
  |  Branch (1041:14): [True: 0, False: 0]
  |  Branch (1041:26): [True: 0, False: 0]
  ------------------
 1042|       |
 1043|      0|      if (fd == -1 && errno == EEXIST)
  ------------------
  |  Branch (1043:11): [True: 0, False: 0]
  |  Branch (1043:23): [True: 0, False: 0]
  ------------------
 1044|      0|        ; /* Lock held by another process.  */
 1045|      0|      else if (fd == -1)
  ------------------
  |  Branch (1045:16): [True: 0, False: 0]
  ------------------
 1046|      0|        {
 1047|      0|          saveerrno = errno;
 1048|      0|          my_error_2 ("lock not made: open(O_EXCL) of '%s' failed: %s\n",
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
 1049|      0|                      h->lockname, strerror (saveerrno));
 1050|      0|          my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1051|      0|          return -1;
 1052|      0|        }
 1053|      0|      else
 1054|      0|        {
 1055|      0|          char pidstr[16];
 1056|       |
 1057|      0|          snprintf (pidstr, sizeof pidstr, "%10d\n", (int)getpid());
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
 1058|      0|          if (write (fd, pidstr, 11 ) == 11
  ------------------
  |  Branch (1058:15): [True: 0, False: 0]
  ------------------
 1059|      0|              && write (fd, h->tname + h->nodename_off,h->nodename_len)
  ------------------
  |  Branch (1059:18): [True: 0, False: 0]
  ------------------
 1060|      0|              == h->nodename_len
 1061|      0|              && write (fd, "\n", 1) == 1
  ------------------
  |  Branch (1061:18): [True: 0, False: 0]
  ------------------
 1062|      0|              && !close (fd))
  ------------------
  |  Branch (1062:18): [True: 0, False: 0]
  ------------------
 1063|      0|            {
 1064|      0|              h->locked = 1;
 1065|      0|              return 0;
 1066|      0|            }
 1067|       |          /* Write error.  */
 1068|      0|          saveerrno = errno;
 1069|      0|          my_error_2 ("lock not made: writing to '%s' failed: %s\n",
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
 1070|      0|                      h->lockname, strerror (errno));
 1071|      0|          close (fd);
 1072|      0|          unlink (h->lockname);
 1073|      0|          my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1074|      0|          return -1;
 1075|      0|        }
 1076|      0|    }
 1077|      3|  else /* Standard method:  Use hardlinks.  */
 1078|      3|    {
 1079|      3|      struct stat sb;
 1080|       |
 1081|       |      /* We ignore the return value of link() because it is unreliable.  */
 1082|      3|      (void) link (h->tname, h->lockname);
 1083|       |
 1084|      3|      if (stat (h->tname, &sb))
  ------------------
  |  Branch (1084:11): [True: 0, False: 3]
  ------------------
 1085|      0|        {
 1086|      0|          saveerrno = errno;
 1087|      0|          my_error_1 ("lock not made: Oops: stat of tmp file failed: %s\n",
  ------------------
  |  |  357|      0|# define my_error_1(a,b)    log_error ((a), (b))
  ------------------
 1088|      0|                      strerror (errno));
 1089|       |          /* In theory this might be a severe error: It is possible
 1090|       |             that link succeeded but stat failed due to changed
 1091|       |             permissions.  We can't do anything about it, though.  */
 1092|      0|          my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1093|      0|          return -1;
 1094|      0|        }
 1095|       |
 1096|      3|      if (sb.st_nlink == 2)
  ------------------
  |  Branch (1096:11): [True: 3, False: 0]
  ------------------
 1097|      3|        {
 1098|      3|          h->locked = 1;
 1099|      3|          return 0; /* Okay.  */
 1100|      3|        }
 1101|      3|    }
 1102|       |
 1103|       |  /* Check for stale lock files.  */
 1104|      0|  if ( (pid = read_lockfile (h, &same_node, &fd)) == -1 )
  ------------------
  |  Branch (1104:8): [True: 0, False: 0]
  ------------------
 1105|      0|    {
 1106|      0|      if ( errno != ENOENT )
  ------------------
  |  Branch (1106:12): [True: 0, False: 0]
  ------------------
 1107|      0|        {
 1108|      0|          saveerrno = errno;
 1109|      0|          my_info_0 ("cannot read lockfile\n");
  ------------------
  |  |  352|      0|# define my_info_0(a)       log_info ((a))
  ------------------
 1110|      0|          my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1111|      0|          return -1;
 1112|      0|        }
 1113|      0|      my_info_0 ("lockfile disappeared\n");
  ------------------
  |  |  352|      0|# define my_info_0(a)       log_info ((a))
  ------------------
 1114|      0|      goto again;
 1115|      0|    }
 1116|      0|  else if ( (pid == getpid() && same_node)
  ------------------
  |  Branch (1116:14): [True: 0, False: 0]
  |  Branch (1116:33): [True: 0, False: 0]
  ------------------
 1117|      0|            || (same_node && kill (pid, 0) && errno == ESRCH) )
  ------------------
  |  Branch (1117:17): [True: 0, False: 0]
  |  Branch (1117:30): [True: 0, False: 0]
  |  Branch (1117:47): [True: 0, False: 0]
  ------------------
 1118|       |    /* Stale lockfile is detected. */
 1119|      0|    {
 1120|      0|      struct stat sb;
 1121|       |
 1122|       |      /* Check if it's unlocked during examining the lockfile.  */
 1123|      0|      if (fstat (fd, &sb) || sb.st_nlink == 0)
  ------------------
  |  Branch (1123:11): [True: 0, False: 0]
  |  Branch (1123:30): [True: 0, False: 0]
  ------------------
 1124|      0|        {
 1125|       |          /* It's gone already by another process.  */
 1126|      0|          close (fd);
 1127|      0|          goto again;
 1128|      0|        }
 1129|       |
 1130|       |      /*
 1131|       |       * Here, although it's quite _rare_, we have a race condition.
 1132|       |       *
 1133|       |       * When multiple processes race on a stale lockfile, detecting
 1134|       |       * AND removing should be done atomically.  That is, to work
 1135|       |       * correctly, the file to be removed should be the one which is
 1136|       |       * examined for detection.
 1137|       |       *
 1138|       |       * But, when it's not atomic, consider the case for us where it
 1139|       |       * takes some time between the detection and the removal of the
 1140|       |       * lockfile.
 1141|       |       *
 1142|       |       * In this situation, it is possible that the file which was
 1143|       |       * detected as stale is already removed by another process and
 1144|       |       * then new lockfile is created (by that process or other one).
 1145|       |       *
 1146|       |       * And it is newly created valid lockfile which is going to be
 1147|       |       * removed by us.
 1148|       |       *
 1149|       |       * Consider this long comment as it expresses possible (long)
 1150|       |       * time between fstat above and unlink below; Meanwhile, the
 1151|       |       * lockfile in question may be removed and there may be new
 1152|       |       * valid one.
 1153|       |       *
 1154|       |       * In short, when you see the message of removing stale lockfile
 1155|       |       * when there are multiple processes for the work, there is
 1156|       |       * (very) little possibility something went wrong.
 1157|       |       */
 1158|       |
 1159|      0|      unlink (h->lockname);
 1160|      0|      my_info_1 (_("removing stale lockfile (created by %d)\n"), pid);
  ------------------
  |  |  353|      0|# define my_info_1(a,b)     log_info ((a), (b))
  ------------------
 1161|      0|      close (fd);
 1162|      0|      goto again;
 1163|      0|    }
 1164|       |
 1165|      0|  close (fd);
 1166|      0|  if (lastpid == -1)
  ------------------
  |  Branch (1166:7): [True: 0, False: 0]
  ------------------
 1167|      0|    lastpid = pid;
 1168|      0|  ownerchanged = (pid != lastpid);
 1169|       |
 1170|      0|  if (timeout)
  ------------------
  |  Branch (1170:7): [True: 0, False: 0]
  ------------------
 1171|      0|    {
 1172|      0|      struct timeval tv;
 1173|       |
 1174|       |      /* Wait until lock has been released.  We use increasing retry
 1175|       |         intervals of 50ms, 100ms, 200ms, 400ms, 800ms, 2s, 4s and 8s
 1176|       |         but reset it if the lock owner meanwhile changed.  */
 1177|      0|      if (!wtime || ownerchanged)
  ------------------
  |  Branch (1177:11): [True: 0, False: 0]
  |  Branch (1177:21): [True: 0, False: 0]
  ------------------
 1178|      0|        wtime = 50;
 1179|      0|      else if (wtime < 800)
  ------------------
  |  Branch (1179:16): [True: 0, False: 0]
  ------------------
 1180|      0|        wtime *= 2;
 1181|      0|      else if (wtime == 800)
  ------------------
  |  Branch (1181:16): [True: 0, False: 0]
  ------------------
 1182|      0|        wtime = 2000;
 1183|      0|      else if (wtime < 8000)
  ------------------
  |  Branch (1183:16): [True: 0, False: 0]
  ------------------
 1184|      0|        wtime *= 2;
 1185|       |
 1186|      0|      if (timeout > 0)
  ------------------
  |  Branch (1186:11): [True: 0, False: 0]
  ------------------
 1187|      0|        {
 1188|      0|          if (wtime > timeout)
  ------------------
  |  Branch (1188:15): [True: 0, False: 0]
  ------------------
 1189|      0|            wtime = timeout;
 1190|      0|          timeout -= wtime;
 1191|      0|        }
 1192|       |
 1193|      0|      sumtime += wtime;
 1194|      0|      if (sumtime >= 1500)
  ------------------
  |  Branch (1194:11): [True: 0, False: 0]
  ------------------
 1195|      0|        {
 1196|      0|          sumtime = 0;
 1197|      0|          my_info_3 (_("waiting for lock (held by %d%s) %s...\n"),
  ------------------
  |  |  355|      0|# define my_info_3(a,b,c,d) log_info ((a), (b), (c), (d))
  |  |  ------------------
  |  |  |  Branch (355:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1198|      0|                     pid, maybe_dead, maybe_deadlock(h)? _("(deadlock?) "):"");
 1199|      0|        }
 1200|       |
 1201|       |
 1202|      0|      tv.tv_sec = wtime / 1000;
 1203|      0|      tv.tv_usec = (wtime % 1000) * 1000;
 1204|      0|      select (0, NULL, NULL, NULL, &tv);
 1205|      0|      goto again;
 1206|      0|    }
 1207|       |
 1208|      0|  my_set_errno (EACCES);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1209|      0|  return -1;
 1210|      0|}
dotlock.c:read_lockfile:
  525|      3|{
  526|      3|  char buffer_space[10+1+70+1]; /* 70 is just an estimated value; node
  527|       |                                   names are usually shorter. */
  528|      3|  int fd;
  529|      3|  int pid = -1;
  530|      3|  char *buffer, *p;
  531|      3|  size_t expected_len;
  532|      3|  int res, nread;
  533|       |
  534|      3|  *same_node = 0;
  535|      3|  expected_len = 10 + 1 + h->nodename_len + 1;
  536|      3|  if ( expected_len >= sizeof buffer_space)
  ------------------
  |  Branch (536:8): [True: 0, False: 3]
  ------------------
  537|      0|    {
  538|      0|      buffer = xtrymalloc (expected_len);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  539|      0|      if (!buffer)
  ------------------
  |  Branch (539:11): [True: 0, False: 0]
  ------------------
  540|      0|        return -1;
  541|      0|    }
  542|      3|  else
  543|      3|    buffer = buffer_space;
  544|       |
  545|      3|  if ( (fd = open (h->lockname, O_RDONLY)) == -1 )
  ------------------
  |  Branch (545:8): [True: 0, False: 3]
  ------------------
  546|      0|    {
  547|      0|      int e = errno;
  548|      0|      my_info_2 ("error opening lockfile '%s': %s\n",
  ------------------
  |  |  354|      0|# define my_info_2(a,b,c)   log_info ((a), (b), (c))
  ------------------
  549|      0|                 h->lockname, strerror(errno) );
  550|      0|      if (buffer != buffer_space)
  ------------------
  |  Branch (550:11): [True: 0, False: 0]
  ------------------
  551|      0|        xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  552|      0|      my_set_errno (e); /* Need to return ERRNO here. */
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  553|      0|      return -1;
  554|      0|    }
  555|       |
  556|      3|  p = buffer;
  557|      3|  nread = 0;
  558|      3|  do
  559|      3|    {
  560|      3|      res = read (fd, p, expected_len - nread);
  561|      3|      if (res == -1 && errno == EINTR)
  ------------------
  |  Branch (561:11): [True: 0, False: 3]
  |  Branch (561:24): [True: 0, False: 0]
  ------------------
  562|      0|        continue;
  563|      3|      if (res < 0)
  ------------------
  |  Branch (563:11): [True: 0, False: 3]
  ------------------
  564|      0|        {
  565|      0|          int e = errno;
  566|      0|          my_info_1 ("error reading lockfile '%s'\n", h->lockname );
  ------------------
  |  |  353|      0|# define my_info_1(a,b)     log_info ((a), (b))
  ------------------
  567|      0|          close (fd);
  568|      0|          if (buffer != buffer_space)
  ------------------
  |  Branch (568:15): [True: 0, False: 0]
  ------------------
  569|      0|            xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  570|      0|          my_set_errno (e);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  571|      0|          return -1;
  572|      0|        }
  573|      3|      p += res;
  574|      3|      nread += res;
  575|      3|    }
  576|      3|  while (res && nread != expected_len);
  ------------------
  |  Branch (576:10): [True: 3, False: 0]
  |  Branch (576:17): [True: 0, False: 3]
  ------------------
  577|       |
  578|      3|  if (r_fd)
  ------------------
  |  Branch (578:7): [True: 0, False: 3]
  ------------------
  579|      0|    *r_fd = fd;
  580|      3|  else
  581|      3|    close(fd);
  582|       |
  583|      3|  if (nread < 11)
  ------------------
  |  Branch (583:7): [True: 0, False: 3]
  ------------------
  584|      0|    {
  585|      0|      my_info_1 ("invalid size of lockfile '%s'\n", h->lockname);
  ------------------
  |  |  353|      0|# define my_info_1(a,b)     log_info ((a), (b))
  ------------------
  586|      0|      if (buffer != buffer_space)
  ------------------
  |  Branch (586:11): [True: 0, False: 0]
  ------------------
  587|      0|        xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  588|      0|      my_set_errno (EINVAL);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  589|      0|      return -1;
  590|      0|    }
  591|       |
  592|      3|  if (buffer[10] != '\n'
  ------------------
  |  Branch (592:7): [True: 0, False: 3]
  ------------------
  593|      3|      || (buffer[10] = 0, pid = atoi (buffer)) == -1
  ------------------
  |  Branch (593:10): [True: 0, False: 3]
  ------------------
  594|      3|      || !pid )
  ------------------
  |  Branch (594:10): [True: 0, False: 3]
  ------------------
  595|      0|    {
  596|      0|      my_error_2 ("invalid pid %d in lockfile '%s'\n", pid, h->lockname);
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
  597|      0|      if (buffer != buffer_space)
  ------------------
  |  Branch (597:11): [True: 0, False: 0]
  ------------------
  598|      0|        xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  599|      0|      my_set_errno (EINVAL);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  600|      0|      return -1;
  601|      0|    }
  602|       |
  603|      3|  if (nread == expected_len
  ------------------
  |  Branch (603:7): [True: 3, False: 0]
  ------------------
  604|      3|      && !memcmp (h->tname+h->nodename_off, buffer+11, h->nodename_len)
  ------------------
  |  Branch (604:10): [True: 3, False: 0]
  ------------------
  605|      3|      && buffer[11+h->nodename_len] == '\n')
  ------------------
  |  Branch (605:10): [True: 3, False: 0]
  ------------------
  606|      3|    *same_node = 1;
  607|       |
  608|      3|  if (buffer != buffer_space)
  ------------------
  |  Branch (608:7): [True: 0, False: 3]
  ------------------
  609|      0|    xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  610|      3|  return pid;
  611|      3|}
dotlock.c:dotlock_release_unix:
 1308|      3|{
 1309|      3|  int pid, same_node;
 1310|      3|  int saveerrno;
 1311|       |
 1312|      3|  pid = read_lockfile (h, &same_node, NULL);
 1313|      3|  if ( pid == -1 )
  ------------------
  |  Branch (1313:8): [True: 0, False: 3]
  ------------------
 1314|      0|    {
 1315|      0|      saveerrno = errno;
 1316|      0|      my_error_0 ("release_dotlock: lockfile error\n");
  ------------------
  |  |  356|      0|# define my_error_0(a)      log_error ((a))
  ------------------
 1317|      0|      my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1318|      0|      return -1;
 1319|      0|    }
 1320|      3|  if ( pid != getpid() || !same_node )
  ------------------
  |  Branch (1320:8): [True: 0, False: 3]
  |  Branch (1320:27): [True: 0, False: 3]
  ------------------
 1321|      0|    {
 1322|      0|      my_error_1 ("release_dotlock: not our lock (pid=%d)\n", pid);
  ------------------
  |  |  357|      0|# define my_error_1(a,b)    log_error ((a), (b))
  ------------------
 1323|      0|      my_set_errno (EACCES);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1324|      0|      return -1;
 1325|      0|    }
 1326|       |
 1327|      3|  if ( unlink( h->lockname ) )
  ------------------
  |  Branch (1327:8): [True: 0, False: 3]
  ------------------
 1328|      0|    {
 1329|      0|      saveerrno = errno;
 1330|      0|      my_error_1 ("release_dotlock: error removing lockfile '%s'\n",
  ------------------
  |  |  357|      0|# define my_error_1(a,b)    log_error ((a), (b))
  ------------------
 1331|      0|                  h->lockname);
 1332|      0|      my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1333|      0|      return -1;
 1334|      0|    }
 1335|       |  /* Fixme: As an extra check we could check whether the link count is
 1336|       |     now really at 1. */
 1337|      3|  return 0;
 1338|      3|}

gnupg_get_time:
   68|    751|{
   69|    751|  time_t current = time (NULL);
   70|    751|  if (current == (time_t)(-1))
  ------------------
  |  Branch (70:7): [True: 0, False: 751]
  ------------------
   71|      0|    log_fatal ("time() failed\n");
   72|       |
   73|    751|  if (timemode == NORMAL)
  ------------------
  |  Branch (73:7): [True: 751, False: 0]
  ------------------
   74|    751|    return current;
   75|      0|  else if (timemode == FROZEN)
  ------------------
  |  Branch (75:12): [True: 0, False: 0]
  ------------------
   76|      0|    return timewarp;
   77|      0|  else if (timemode == FUTURE)
  ------------------
  |  Branch (77:12): [True: 0, False: 0]
  ------------------
   78|      0|    return current + timewarp;
   79|      0|  else
   80|      0|    return current - timewarp;
   81|    751|}
make_timestamp:
  169|    751|{
  170|    751|  time_t t = gnupg_get_time ();
  171|    751|  return (u32)t;
  172|    751|}
strtimevalue:
  573|  1.19k|{
  574|  1.19k|    static char buffer[30];
  575|  1.19k|    unsigned int years, days, hours, minutes;
  576|       |
  577|  1.19k|    value /= 60;
  578|  1.19k|    minutes = value % 60;
  579|  1.19k|    value /= 60;
  580|  1.19k|    hours = value % 24;
  581|  1.19k|    value /= 24;
  582|  1.19k|    days = value % 365;
  583|  1.19k|    value /= 365;
  584|  1.19k|    years = value;
  585|       |
  586|  1.19k|    sprintf(buffer,"%uy%ud%uh%um", years, days, hours, minutes );
  587|  1.19k|    if( years )
  ------------------
  |  Branch (587:9): [True: 624, False: 572]
  ------------------
  588|    624|	return buffer;
  589|    572|    if( days )
  ------------------
  |  Branch (589:9): [True: 233, False: 339]
  ------------------
  590|    233|	return strchr( buffer, 'y' ) + 1;
  591|    339|    return strchr( buffer, 'd' ) + 1;
  592|    572|}
strtimestamp:
  639|    474|{
  640|    474|  static char buffer[11+5];
  641|    474|  struct tm *tp;
  642|    474|  time_t atime = stamp;
  643|       |
  644|    474|  if (IS_INVALID_TIME_T (atime))
  ------------------
  |  |   53|    474|# define IS_INVALID_TIME_T(a) ((a) < 0)
  |  |  ------------------
  |  |  |  Branch (53:31): [True: 0, False: 474]
  |  |  ------------------
  ------------------
  645|      0|    {
  646|      0|      strcpy (buffer, "????" "-??" "-??");
  647|      0|    }
  648|    474|  else
  649|    474|    {
  650|    474|      tp = gmtime( &atime );
  651|    474|      snprintf (buffer, sizeof buffer, "%04d-%02d-%02d",
  ------------------
  |  |   84|    474|#define snprintf gpgrt_snprintf
  ------------------
  652|    474|                1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday );
  653|    474|    }
  654|    474|  return buffer;
  655|    474|}

standard_homedir:
  234|      1|{
  235|       |#ifdef HAVE_W32_SYSTEM
  236|       |  static const char *dir;
  237|       |
  238|       |  if (!dir)
  239|       |    {
  240|       |      const char *rdir;
  241|       |
  242|       |      rdir = w32_rootdir ();
  243|       |      if (w32_portable_app)
  244|       |        {
  245|       |          dir = xstrconcat (rdir, DIRSEP_S "home", NULL);
  246|       |          gpgrt_annotate_leaked_object (dir);
  247|       |        }
  248|       |      else
  249|       |        {
  250|       |          char *path;
  251|       |
  252|       |          path = w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
  253|       |                                      NULL, 0);
  254|       |          if (path)
  255|       |            {
  256|       |              dir = xstrconcat (path, "\\gnupg", NULL);
  257|       |              xfree (path);
  258|       |              gpgrt_annotate_leaked_object (dir);
  259|       |
  260|       |              /* Try to create the directory if it does not yet exists.  */
  261|       |              if (gnupg_access (dir, F_OK))
  262|       |                gnupg_mkdir (dir, "-rwx");
  263|       |            }
  264|       |          else
  265|       |            dir = GNUPG_DEFAULT_HOMEDIR;
  266|       |        }
  267|       |    }
  268|       |  return dir;
  269|       |#else/*!HAVE_W32_SYSTEM*/
  270|      1|  return GNUPG_DEFAULT_HOMEDIR;
  ------------------
  |  |  906|      1|#define GNUPG_DEFAULT_HOMEDIR "~/.gnupg"
  ------------------
  271|      1|#endif /*!HAVE_W32_SYSTEM*/
  272|      1|}
gnupg_set_homedir:
  742|      1|{
  743|      1|  char *tmp = NULL;
  744|       |
  745|      1|  if (!newdir || !*newdir)
  ------------------
  |  Branch (745:7): [True: 0, False: 1]
  |  Branch (745:18): [True: 0, False: 1]
  ------------------
  746|      0|    newdir = default_homedir ();
  747|      1|  else
  748|      1|    {
  749|      1|      tmp = copy_dir_with_fixup (newdir);
  750|      1|      if (tmp)
  ------------------
  |  Branch (750:11): [True: 1, False: 0]
  ------------------
  751|      1|        newdir = tmp;
  752|       |
  753|      1|      if (!is_gnupg_default_homedir (newdir))
  ------------------
  |  Branch (753:11): [True: 1, False: 0]
  ------------------
  754|      1|        non_default_homedir = 1;
  755|      1|    }
  756|      1|  xfree (the_gnupg_homedir);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  757|      1|  the_gnupg_homedir = make_absfilename (newdir, NULL);;
  758|      1|  xfree (tmp);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  759|       |  /* Fixme: Should we use
  760|       |   *   gpgrt_annotate_leaked_object(the_gnupg_homedir)
  761|       |   * despite that we may free and allocate a new one in some
  762|       |   * cases?  */
  763|      1|}
gnupg_homedir:
  803|      4|{
  804|       |  /* If a homedir has not been set, set it to the default.  */
  805|      4|  if (!the_gnupg_homedir)
  ------------------
  |  Branch (805:7): [True: 0, False: 4]
  ------------------
  806|      0|    the_gnupg_homedir = make_absfilename (default_homedir (), NULL);
  807|      4|  return the_gnupg_homedir;
  808|      4|}
_gnupg_socketdir_internal:
  866|      1|{
  867|       |#if defined(HAVE_W32_SYSTEM)
  868|       |  char *name;
  869|       |
  870|       |  (void)skip_checks;
  871|       |
  872|       |  *r_info = 0;
  873|       |
  874|       |  /* First make sure that non_default_homedir and w32_portable_app can
  875|       |   * be set.  */
  876|       |  gnupg_homedir ();
  877|       |
  878|       |  if (w32_portable_app)
  879|       |    {
  880|       |      name = xstrconcat (w32_rootdir (), DIRSEP_S, "gnupg", NULL);
  881|       |    }
  882|       |  else
  883|       |    {
  884|       |      char *path;
  885|       |
  886|       |      path = w32_shgetfolderpath (NULL,
  887|       |                                  CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE,
  888|       |                                  NULL, 0);
  889|       |      if (path)
  890|       |        {
  891|       |          name = xstrconcat (path, "\\gnupg", NULL);
  892|       |          xfree (path);
  893|       |          if (gnupg_access (name, F_OK))
  894|       |            gnupg_mkdir (name, "-rwx");
  895|       |        }
  896|       |      else
  897|       |        {
  898|       |          name = xstrdup (gnupg_homedir ());
  899|       |        }
  900|       |    }
  901|       |
  902|       |  /* If a non default homedir is used, we check whether an
  903|       |   * corresponding sub directory below the socket dir is available
  904|       |   * and use that.  We hash the non default homedir to keep the new
  905|       |   * subdir short enough.  */
  906|       |  if (non_default_homedir)
  907|       |    {
  908|       |      char sha1buf[20];
  909|       |      struct stat sb;
  910|       |      char *suffix;
  911|       |      char *p;
  912|       |
  913|       |      *r_info |= 32; /* Testing subdir.  */
  914|       |
  915|       |      /* Canonicalize the name to avoid problems with mixed case
  916|       |       * names.  Note that we use only 10 bytes of the hash because on
  917|       |       * Windows the account name is also part of the name.  */
  918|       |      suffix = ascii_strlwr (xstrdup (gnupg_homedir ()));
  919|       |      for (p=suffix; *p; p++)
  920|       |        if ( *p == '\\')
  921|       |          *p = '/';
  922|       |      gcry_md_hash_buffer (GCRY_MD_SHA1, sha1buf, suffix, strlen (suffix));
  923|       |      xfree (suffix);
  924|       |      suffix = zb32_encode (sha1buf, 8*10);
  925|       |      if (!suffix)
  926|       |        {
  927|       |          *r_info |= 1; /* Out of core etc. */
  928|       |          goto leave_w32;
  929|       |        }
  930|       |      p = xstrconcat (name, "\\d.", suffix, NULL);
  931|       |      xfree (suffix);
  932|       |      xfree (name);
  933|       |      name = p;
  934|       |
  935|       |      /* Stat that directory and check constraints.
  936|       |       * The command
  937|       |       *    gpgconf --remove-socketdir
  938|       |       * can be used to remove that directory.  */
  939|       |      if (gnupg_stat (name, &sb))
  940|       |        {
  941|       |          if (errno != ENOENT)
  942|       |            *r_info |= 1; /* stat failed. */
  943|       |          else if (!skip_checks)
  944|       |            {
  945|       |              /* Try to create the directory and check again.  */
  946|       |              if (gnupg_mkdir (name, "-rwx"))
  947|       |                *r_info |= 16; /* mkdir failed.  */
  948|       |              else if (gnupg_stat (name, &sb))
  949|       |                {
  950|       |                  if (errno != ENOENT)
  951|       |                    *r_info |= 1; /* stat failed. */
  952|       |                  else
  953|       |                    *r_info |= 64; /* Subdir does not exist.  */
  954|       |                }
  955|       |              else
  956|       |                goto leave_w32; /* Success!  */
  957|       |            }
  958|       |          else
  959|       |            *r_info |= 64; /* Subdir does not exist.  */
  960|       |          if (!skip_checks)
  961|       |            {
  962|       |              xfree (name);
  963|       |              name = NULL;
  964|       |              goto leave_w32;
  965|       |            }
  966|       |        }
  967|       |    }
  968|       |
  969|       | leave_w32:
  970|       |  /* If nothing works - fall back to the homedir.  */
  971|       |  if (!name)
  972|       |    {
  973|       |      *r_info |= 128; /* Fallback.  */
  974|       |      name = xstrdup (gnupg_homedir ());
  975|       |    }
  976|       |
  977|       |#elif !defined(HAVE_STAT)
  978|       |  char *name;
  979|       |
  980|       |  (void)skip_checks;
  981|       |  *r_info = 0;
  982|       |  name = xstrdup (gnupg_homedir ());
  983|       |
  984|       |#else /* Unix and stat(2) available. */
  985|       |
  986|      1|  static const char * const bases[] = {
  987|       |#ifdef USE_RUN_GNUPG_USER_SOCKET
  988|       |    "/run/gnupg",
  989|       |#endif
  990|      1|    "/run",
  991|       |#ifdef USE_RUN_GNUPG_USER_SOCKET
  992|       |    "/var/run/gnupg",
  993|       |#endif
  994|      1|    "/var/run",
  995|      1|    NULL
  996|      1|  };
  997|      1|  int i;
  998|      1|  struct stat sb;
  999|      1|  char prefix[19 + 1 + 20 + 6 + 1];
 1000|      1|  const char *s;
 1001|      1|  char *name = NULL;
 1002|       |
 1003|      1|  *r_info = 0;
 1004|       |
 1005|       |  /* First make sure that non_default_homedir can be set.  */
 1006|      1|  gnupg_homedir ();
 1007|       |
 1008|       |  /* It has been suggested to first check XDG_RUNTIME_DIR envvar.
 1009|       |   * However, the specs state that the lifetime of the directory MUST
 1010|       |   * be bound to the user being logged in.  Now GnuPG may also be run
 1011|       |   * as a background process with no (desktop) user logged in.  Thus
 1012|       |   * we better don't do that.  */
 1013|       |
 1014|       |  /* Check whether we have a /run/[gnupg/]user dir.  */
 1015|      3|  for (i=0; bases[i]; i++)
  ------------------
  |  Branch (1015:13): [True: 2, False: 1]
  ------------------
 1016|      2|    {
 1017|      2|      snprintf (prefix, sizeof prefix, "%s/user/%u",
  ------------------
  |  |   84|      2|#define snprintf gpgrt_snprintf
  ------------------
 1018|      2|                bases[i], (unsigned int)getuid ());
 1019|      2|      if (!stat (prefix, &sb) && S_ISDIR(sb.st_mode))
  ------------------
  |  Branch (1019:11): [True: 0, False: 2]
  ------------------
 1020|      0|        break;
 1021|      2|    }
 1022|      1|  if (!bases[i])
  ------------------
  |  Branch (1022:7): [True: 1, False: 0]
  ------------------
 1023|      1|    {
 1024|      1|      *r_info |= 2; /* No /run/user directory.  */
 1025|      1|      goto leave;
 1026|      1|    }
 1027|       |
 1028|      0|  if (sb.st_uid != getuid ())
  ------------------
  |  Branch (1028:7): [True: 0, False: 0]
  ------------------
 1029|      0|    {
 1030|      0|      *r_info |= 4; /* Not owned by the user.  */
 1031|      0|      if (!skip_checks)
  ------------------
  |  Branch (1031:11): [True: 0, False: 0]
  ------------------
 1032|      0|        goto leave;
 1033|      0|    }
 1034|       |
 1035|      0|  if (strlen (prefix) + 7 >= sizeof prefix)
  ------------------
  |  Branch (1035:7): [True: 0, False: 0]
  ------------------
 1036|      0|    {
 1037|      0|      *r_info |= 1; /* Ooops: Buffer too short to append "/gnupg".  */
 1038|      0|      goto leave;
 1039|      0|    }
 1040|      0|  strcat (prefix, "/gnupg");
 1041|       |
 1042|       |  /* Check whether the gnupg sub directory has proper permissions.  */
 1043|      0|  if (stat (prefix, &sb))
  ------------------
  |  Branch (1043:7): [True: 0, False: 0]
  ------------------
 1044|      0|    {
 1045|      0|      if (errno != ENOENT)
  ------------------
  |  Branch (1045:11): [True: 0, False: 0]
  ------------------
 1046|      0|        {
 1047|      0|          *r_info |= 1; /* stat failed.  */
 1048|      0|          goto leave;
 1049|      0|        }
 1050|       |
 1051|       |      /* Try to create the directory and check again.  */
 1052|      0|      if (gnupg_mkdir (prefix, "-rwx"))
  ------------------
  |  Branch (1052:11): [True: 0, False: 0]
  ------------------
 1053|      0|        {
 1054|      0|          *r_info |= 16; /* mkdir failed.  */
 1055|      0|          goto leave;
 1056|      0|        }
 1057|      0|      if (stat (prefix, &sb))
  ------------------
  |  Branch (1057:11): [True: 0, False: 0]
  ------------------
 1058|      0|        {
 1059|      0|          *r_info |= 1; /* stat failed.  */
 1060|      0|          goto leave;
 1061|      0|        }
 1062|      0|    }
 1063|       |  /* Check that it is a directory, owned by the user, and only the
 1064|       |   * user has permissions to use it.  */
 1065|      0|  if (!S_ISDIR(sb.st_mode)
  ------------------
  |  Branch (1065:7): [True: 0, False: 0]
  ------------------
 1066|      0|      || sb.st_uid != getuid ()
  ------------------
  |  Branch (1066:10): [True: 0, False: 0]
  ------------------
 1067|      0|      || (sb.st_mode & (S_IRWXG|S_IRWXO)))
  ------------------
  |  Branch (1067:10): [True: 0, False: 0]
  ------------------
 1068|      0|    {
 1069|      0|      *r_info |= 4; /* Bad permissions or not a directory. */
 1070|      0|      if (!skip_checks)
  ------------------
  |  Branch (1070:11): [True: 0, False: 0]
  ------------------
 1071|      0|        goto leave;
 1072|      0|    }
 1073|       |
 1074|       |  /* If a non default homedir is used, we check whether an
 1075|       |   * corresponding sub directory below the socket dir is available
 1076|       |   * and use that.  We hash the non default homedir to keep the new
 1077|       |   * subdir short enough.  */
 1078|      0|  if (non_default_homedir)
  ------------------
  |  Branch (1078:7): [True: 0, False: 0]
  ------------------
 1079|      0|    {
 1080|      0|      char sha1buf[20];
 1081|      0|      char *suffix;
 1082|       |
 1083|      0|      *r_info |= 32; /* Testing subdir.  */
 1084|      0|      s = gnupg_homedir ();
 1085|      0|      gcry_md_hash_buffer (GCRY_MD_SHA1, sha1buf, s, strlen (s));
 1086|      0|      suffix = zb32_encode (sha1buf, 8*15);
 1087|      0|      if (!suffix)
  ------------------
  |  Branch (1087:11): [True: 0, False: 0]
  ------------------
 1088|      0|        {
 1089|      0|          *r_info |= 1; /* Out of core etc. */
 1090|      0|          goto leave;
 1091|      0|        }
 1092|      0|      name = strconcat (prefix, "/d.", suffix, NULL);
 1093|      0|      xfree (suffix);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1094|      0|      if (!name)
  ------------------
  |  Branch (1094:11): [True: 0, False: 0]
  ------------------
 1095|      0|        {
 1096|      0|          *r_info |= 1; /* Out of core etc. */
 1097|      0|          goto leave;
 1098|      0|        }
 1099|       |
 1100|       |      /* Stat that directory and check constraints.
 1101|       |       * The command
 1102|       |       *    gpgconf --remove-socketdir
 1103|       |       * can be used to remove that directory.  */
 1104|      0|      if (stat (name, &sb))
  ------------------
  |  Branch (1104:11): [True: 0, False: 0]
  ------------------
 1105|      0|        {
 1106|      0|          if (errno != ENOENT)
  ------------------
  |  Branch (1106:15): [True: 0, False: 0]
  ------------------
 1107|      0|            *r_info |= 1; /* stat failed. */
 1108|      0|          else if (!skip_checks)
  ------------------
  |  Branch (1108:20): [True: 0, False: 0]
  ------------------
 1109|      0|            {
 1110|       |              /* Try to create the directory and check again.  */
 1111|      0|              if (gnupg_mkdir (name, "-rwx"))
  ------------------
  |  Branch (1111:19): [True: 0, False: 0]
  ------------------
 1112|      0|                *r_info |= 16; /* mkdir failed.  */
 1113|      0|              else if (stat (prefix, &sb))
  ------------------
  |  Branch (1113:24): [True: 0, False: 0]
  ------------------
 1114|      0|                {
 1115|      0|                  if (errno != ENOENT)
  ------------------
  |  Branch (1115:23): [True: 0, False: 0]
  ------------------
 1116|      0|                    *r_info |= 1; /* stat failed. */
 1117|      0|                  else
 1118|      0|                    *r_info |= 64; /* Subdir does not exist.  */
 1119|      0|                }
 1120|      0|              else
 1121|      0|                goto leave; /* Success!  */
 1122|      0|            }
 1123|      0|          else
 1124|      0|            *r_info |= 64; /* Subdir does not exist.  */
 1125|      0|          if (!skip_checks)
  ------------------
  |  Branch (1125:15): [True: 0, False: 0]
  ------------------
 1126|      0|            {
 1127|      0|              xfree (name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1128|      0|              name = NULL;
 1129|      0|              goto leave;
 1130|      0|            }
 1131|      0|        }
 1132|      0|      else if (!S_ISDIR(sb.st_mode)
  ------------------
  |  Branch (1132:16): [True: 0, False: 0]
  ------------------
 1133|      0|               || sb.st_uid != getuid ()
  ------------------
  |  Branch (1133:19): [True: 0, False: 0]
  ------------------
 1134|      0|               || (sb.st_mode & (S_IRWXG|S_IRWXO)))
  ------------------
  |  Branch (1134:19): [True: 0, False: 0]
  ------------------
 1135|      0|        {
 1136|      0|          *r_info |= 8; /* Bad permissions or subdir is not a directory.  */
 1137|      0|          if (!skip_checks)
  ------------------
  |  Branch (1137:15): [True: 0, False: 0]
  ------------------
 1138|      0|            {
 1139|      0|              xfree (name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1140|      0|              name = NULL;
 1141|      0|              goto leave;
 1142|      0|            }
 1143|      0|        }
 1144|      0|    }
 1145|      0|  else
 1146|      0|    name = xstrdup (prefix);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 1147|       |
 1148|      1| leave:
 1149|       |  /* If nothing works fall back to the homedir.  */
 1150|      1|  if (!name)
  ------------------
  |  Branch (1150:7): [True: 1, False: 0]
  ------------------
 1151|      1|    {
 1152|      1|      *r_info |= 128; /* Fallback.  */
 1153|      1|      name = xstrdup (gnupg_homedir ());
  ------------------
  |  |  112|      1|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 1154|      1|    }
 1155|       |
 1156|      1|#endif /* Unix */
 1157|       |
 1158|      1|  return name;
 1159|      0|}
gnupg_socketdir:
 1168|   176k|{
 1169|   176k|  static char *name;
 1170|       |
 1171|   176k|  if (!name)
  ------------------
  |  Branch (1171:7): [True: 1, False: 176k]
  ------------------
 1172|      1|    {
 1173|      1|      unsigned int dummy;
 1174|      1|      name = _gnupg_socketdir_internal (0, &dummy);
 1175|      1|      gpgrt_annotate_leaked_object (name);
 1176|      1|    }
 1177|       |
 1178|   176k|  return name;
 1179|   176k|}
homedir.c:copy_dir_with_fixup:
  178|      1|{
  179|      1|  char *result = NULL;
  180|      1|  char *p;
  181|       |
  182|      1|  if (!*newdir)
  ------------------
  |  Branch (182:7): [True: 0, False: 1]
  ------------------
  183|      0|    return NULL;
  184|       |
  185|       |#ifdef HAVE_W32_SYSTEM
  186|       |  if (newdir[0] && newdir[1] == ':'
  187|       |      && !(newdir[2] == '/' || newdir[2] == '\\'))
  188|       |    {
  189|       |      /* Drive letter with missing leading slash.  */
  190|       |      p = result = xmalloc (strlen (newdir) + 1 + 1);
  191|       |      *p++ = newdir[0];
  192|       |      *p++ = newdir[1];
  193|       |      *p++ = '\\';
  194|       |      strcpy (p, newdir+2);
  195|       |
  196|       |      /* Remove trailing slashes.  */
  197|       |      p = result + strlen (result) - 1;
  198|       |      while (p > result+2 && (*p == '/' || *p == '\\'))
  199|       |        *p-- = 0;
  200|       |    }
  201|       |  else if (newdir[strlen (newdir)-1] == '/'
  202|       |           || newdir[strlen (newdir)-1] == '\\' )
  203|       |    {
  204|       |      result = xstrdup (newdir);
  205|       |      p = result + strlen (result) - 1;
  206|       |      while (p > result
  207|       |             && (*p == '/' || *p == '\\')
  208|       |             && (p-1 > result && p[-1] != ':')) /* We keep "c:/". */
  209|       |        *p-- = 0;
  210|       |    }
  211|       |
  212|       |#else /*!HAVE_W32_SYSTEM*/
  213|       |
  214|      1|  if (newdir[strlen (newdir)-1] == '/')
  ------------------
  |  Branch (214:7): [True: 1, False: 0]
  ------------------
  215|      1|    {
  216|      1|      result = xstrdup (newdir);
  ------------------
  |  |  112|      1|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  217|      1|      p = result + strlen (result) - 1;
  218|      2|      while (p > result && *p == '/')
  ------------------
  |  Branch (218:14): [True: 2, False: 0]
  |  Branch (218:28): [True: 1, False: 1]
  ------------------
  219|      1|        *p-- = 0;
  220|      1|    }
  221|       |
  222|      1|#endif /*!HAVE_W32_SYSTEM*/
  223|       |
  224|      1|  return result;
  225|      1|}
homedir.c:is_gnupg_default_homedir:
  161|      1|{
  162|      1|  int result;
  163|      1|  char *a = make_absfilename (dir, NULL);
  164|      1|  char *b = make_absfilename (standard_homedir (), NULL);
  165|      1|  result = !compare_filenames (a, b);
  166|      1|  xfree (b);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  167|      1|  xfree (a);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  168|      1|  return result;
  169|      1|}

i18n_switchto_utf8:
  102|   118k|{
  103|       |#ifdef USE_SIMPLE_GETTEXT
  104|       |  /* Return an arbitrary pointer as true value.  */
  105|       |  return gettext_use_utf8 (1) ? (char*)(-1) : NULL;
  106|       |#elif defined(ENABLE_NLS)
  107|   118k|  char *orig_codeset = bind_textdomain_codeset (PACKAGE_GT, NULL);
  ------------------
  |  |  689|   118k|#define PACKAGE_GT "gnupg2"
  ------------------
  108|   118k|# ifdef HAVE_LANGINFO_CODESET
  109|   118k|  if (!orig_codeset)
  ------------------
  |  Branch (109:7): [True: 1, False: 118k]
  ------------------
  110|      1|    orig_codeset = nl_langinfo (CODESET);
  111|   118k|# endif
  112|   118k|  if (orig_codeset)
  ------------------
  |  Branch (112:7): [True: 118k, False: 0]
  ------------------
  113|   118k|    { /* We only switch when we are able to restore the codeset later.
  114|       |         Note that bind_textdomain_codeset does only return on memory
  115|       |         errors but not if a codeset is not available.  Thus we don't
  116|       |         bother printing a diagnostic here. */
  117|   118k|      orig_codeset = xstrdup (orig_codeset);
  ------------------
  |  |  112|   118k|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  118|   118k|      if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8"))
  ------------------
  |  |  689|   118k|#define PACKAGE_GT "gnupg2"
  ------------------
  |  Branch (118:11): [True: 0, False: 118k]
  ------------------
  119|      0|        {
  120|      0|	  xfree (orig_codeset);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  121|      0|	  orig_codeset = NULL;
  122|      0|	}
  123|   118k|    }
  124|   118k|  return orig_codeset;
  125|       |#else
  126|       |  return NULL;
  127|       |#endif
  128|   118k|}
i18n_switchback:
  133|   118k|{
  134|       |#ifdef USE_SIMPLE_GETTEXT
  135|       |  gettext_use_utf8 (!!saved_codeset);
  136|       |#elif defined(ENABLE_NLS)
  137|   118k|  if (saved_codeset)
  ------------------
  |  Branch (137:7): [True: 118k, False: 0]
  ------------------
  138|   118k|    {
  139|   118k|      bind_textdomain_codeset (PACKAGE_GT, saved_codeset);
  ------------------
  |  |  689|   118k|#define PACKAGE_GT "gnupg2"
  ------------------
  140|   118k|      xfree (saved_codeset);
  ------------------
  |  |  104|   118k|#define xfree(a)         gcry_free ((a))
  ------------------
  141|   118k|    }
  142|       |#else
  143|       |  (void)saved_codeset;
  144|       |#endif
  145|   118k|}

iobuf_alloc:
 1182|  11.9k|{
 1183|  11.9k|  iobuf_t a;
 1184|  11.9k|  static int number = 0;
 1185|       |
 1186|  11.9k|  assert (use == IOBUF_INPUT || use == IOBUF_INPUT_TEMP
 1187|  11.9k|	  || use == IOBUF_OUTPUT || use == IOBUF_OUTPUT_TEMP);
 1188|  11.9k|  if (bufsize == 0)
  ------------------
  |  Branch (1188:7): [True: 0, False: 11.9k]
  ------------------
 1189|      0|    {
 1190|      0|      log_bug ("iobuf_alloc() passed a bufsize of 0!\n");
 1191|      0|      bufsize = iobuf_buffer_size;
 1192|      0|    }
 1193|       |
 1194|  11.9k|  a = xcalloc (1, sizeof *a);
  ------------------
  |  |  109|  11.9k|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
 1195|  11.9k|  a->use = use;
 1196|  11.9k|  a->d.buf = xmalloc (bufsize);
  ------------------
  |  |  107|  11.9k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1197|  11.9k|  a->d.size = bufsize;
 1198|  11.9k|  a->e_d.buf = NULL;
 1199|  11.9k|  a->e_d.len = 0;
 1200|  11.9k|  a->e_d.used = 0;
 1201|  11.9k|  a->e_d.preferred = 0;
 1202|  11.9k|  a->no = ++number;
 1203|  11.9k|  a->subno = 0;
 1204|  11.9k|  a->real_fname = NULL;
 1205|  11.9k|  return a;
 1206|  11.9k|}
iobuf_close:
 1210|  7.05M|{
 1211|  7.05M|  iobuf_t a_chain;
 1212|  7.05M|  size_t dummy_len = 0;
 1213|  7.05M|  int rc = 0;
 1214|       |
 1215|  7.06M|  for (; a; a = a_chain)
  ------------------
  |  Branch (1215:10): [True: 14.2k, False: 7.05M]
  ------------------
 1216|  14.2k|    {
 1217|  14.2k|      byte desc[MAX_IOBUF_DESC];
 1218|  14.2k|      int rc2 = 0;
 1219|       |
 1220|  14.2k|      a_chain = a->chain;
 1221|       |
 1222|  14.2k|      if (a->use == IOBUF_OUTPUT && (rc = filter_flush (a)))
  ------------------
  |  Branch (1222:11): [True: 1, False: 14.2k]
  |  Branch (1222:37): [True: 0, False: 1]
  ------------------
 1223|      0|	log_error ("filter_flush failed on close: %s\n", gpg_strerror (rc));
 1224|       |
 1225|  14.2k|      if (DBG_IOBUF)
  ------------------
  |  |   98|  14.2k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 14.2k]
  |  |  ------------------
  ------------------
 1226|      0|	log_debug ("iobuf-%d.%d: close '%s'\n",
 1227|      0|		   a->no, a->subno, iobuf_desc (a, desc));
 1228|       |
 1229|  14.2k|      if (a->filter && (rc2 = a->filter (a->filter_ov, IOBUFCTRL_FREE,
  ------------------
  |  Branch (1229:11): [True: 2.36k, False: 11.8k]
  |  Branch (1229:24): [True: 0, False: 2.36k]
  ------------------
 1230|  2.36k|					 a->chain, NULL, &dummy_len)))
 1231|      0|	log_error ("IOBUFCTRL_FREE failed on close: %s\n", gpg_strerror (rc));
 1232|  14.2k|      if (! rc && rc2)
  ------------------
  |  Branch (1232:11): [True: 14.2k, False: 0]
  |  Branch (1232:19): [True: 0, False: 14.2k]
  ------------------
 1233|       |	/* Whoops!  An error occurred.  Save it in RC if we haven't
 1234|       |	   already recorded an error.  */
 1235|      0|	rc = rc2;
 1236|       |
 1237|  14.2k|      xfree (a->real_fname);
  ------------------
  |  |  104|  14.2k|#define xfree(a)         gcry_free ((a))
  ------------------
 1238|  14.2k|      if (a->d.buf)
  ------------------
  |  Branch (1238:11): [True: 14.2k, False: 0]
  ------------------
 1239|  14.2k|	{
 1240|  14.2k|	  memset (a->d.buf, 0, a->d.size);	/* erase the buffer */
 1241|  14.2k|	  xfree (a->d.buf);
  ------------------
  |  |  104|  14.2k|#define xfree(a)         gcry_free ((a))
  ------------------
 1242|  14.2k|	}
 1243|  14.2k|      xfree (a);
  ------------------
  |  |  104|  14.2k|#define xfree(a)         gcry_free ((a))
  ------------------
 1244|  14.2k|    }
 1245|  7.05M|  return rc;
 1246|  7.05M|}
iobuf_open:
 1391|  11.9k|{
 1392|  11.9k|  return do_open (fname, 1, IOBUF_INPUT, "rb", 0);
 1393|  11.9k|}
iobuf_create:
 1397|      1|{
 1398|      1|  return do_open (fname, 1, IOBUF_OUTPUT, "wb", mode700);
 1399|      1|}
iobuf_ioctl:
 1504|      1|{
 1505|      1|  byte desc[MAX_IOBUF_DESC];
 1506|       |
 1507|      1|  if (cmd == IOBUF_IOCTL_KEEP_OPEN)
  ------------------
  |  Branch (1507:7): [True: 0, False: 1]
  ------------------
 1508|      0|    {
 1509|       |      /* Keep system filepointer/descriptor open.  This was used in
 1510|       |         the past by http.c; this ioctl is not directly used
 1511|       |         anymore.  */
 1512|      0|      if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1513|      0|	log_debug ("iobuf-%d.%d: ioctl '%s' keep_open=%d\n",
 1514|      0|		   a ? a->no : -1, a ? a->subno : -1, iobuf_desc (a, desc),
  ------------------
  |  Branch (1514:6): [True: 0, False: 0]
  |  Branch (1514:22): [True: 0, False: 0]
  ------------------
 1515|      0|		   intval);
 1516|      0|      for (; a; a = a->chain)
  ------------------
  |  Branch (1516:14): [True: 0, False: 0]
  ------------------
 1517|      0|	if (!a->chain && a->filter == file_filter)
  ------------------
  |  Branch (1517:6): [True: 0, False: 0]
  |  Branch (1517:19): [True: 0, False: 0]
  ------------------
 1518|      0|	  {
 1519|      0|	    file_filter_ctx_t *b = a->filter_ov;
 1520|      0|	    b->keep_open = intval;
 1521|      0|	    return 0;
 1522|      0|	  }
 1523|       |#ifdef HAVE_W32_SYSTEM
 1524|       |	else if (!a->chain && a->filter == sock_filter)
 1525|       |	  {
 1526|       |	    sock_filter_ctx_t *b = a->filter_ov;
 1527|       |	    b->keep_open = intval;
 1528|       |	    return 0;
 1529|       |	  }
 1530|       |#endif
 1531|      0|    }
 1532|      1|  else if (cmd == IOBUF_IOCTL_INVALIDATE_CACHE)
  ------------------
  |  Branch (1532:12): [True: 1, False: 0]
  ------------------
 1533|      1|    {
 1534|      1|      if (DBG_IOBUF)
  ------------------
  |  |   98|      1|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  ------------------
 1535|      0|	log_debug ("iobuf-*.*: ioctl '%s' invalidate\n",
 1536|      0|		   ptrval ? (char *) ptrval : "?");
  ------------------
  |  Branch (1536:6): [True: 0, False: 0]
  ------------------
 1537|      1|      if (!a && !intval && ptrval)
  ------------------
  |  Branch (1537:11): [True: 1, False: 0]
  |  Branch (1537:17): [True: 1, False: 0]
  |  Branch (1537:28): [True: 1, False: 0]
  ------------------
 1538|      1|	{
 1539|      1|	  if (fd_cache_invalidate (ptrval))
  ------------------
  |  Branch (1539:8): [True: 0, False: 1]
  ------------------
 1540|      0|            return -1;
 1541|      1|	  return 0;
 1542|      1|	}
 1543|      1|    }
 1544|      0|  else if (cmd == IOBUF_IOCTL_NO_CACHE)
  ------------------
  |  Branch (1544:12): [True: 0, False: 0]
  ------------------
 1545|      0|    {
 1546|      0|      if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1547|      0|	log_debug ("iobuf-%d.%d: ioctl '%s' no_cache=%d\n",
 1548|      0|		   a ? a->no : -1, a ? a->subno : -1, iobuf_desc (a, desc),
  ------------------
  |  Branch (1548:6): [True: 0, False: 0]
  |  Branch (1548:22): [True: 0, False: 0]
  ------------------
 1549|      0|		   intval);
 1550|      0|      for (; a; a = a->chain)
  ------------------
  |  Branch (1550:14): [True: 0, False: 0]
  ------------------
 1551|      0|	if (!a->chain && a->filter == file_filter)
  ------------------
  |  Branch (1551:6): [True: 0, False: 0]
  |  Branch (1551:19): [True: 0, False: 0]
  ------------------
 1552|      0|	  {
 1553|      0|	    file_filter_ctx_t *b = a->filter_ov;
 1554|      0|	    b->no_cache = intval;
 1555|      0|	    return 0;
 1556|      0|	  }
 1557|       |#ifdef HAVE_W32_SYSTEM
 1558|       |	else if (!a->chain && a->filter == sock_filter)
 1559|       |	  {
 1560|       |	    sock_filter_ctx_t *b = a->filter_ov;
 1561|       |	    b->no_cache = intval;
 1562|       |	    return 0;
 1563|       |	  }
 1564|       |#endif
 1565|      0|    }
 1566|      0|  else if (cmd == IOBUF_IOCTL_FSYNC)
  ------------------
  |  Branch (1566:12): [True: 0, False: 0]
  ------------------
 1567|      0|    {
 1568|       |      /* Do a fsync on the open fd and return any errors to the caller
 1569|       |         of iobuf_ioctl.  Note that we work on a file name here. */
 1570|      0|      if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1571|      0|        log_debug ("iobuf-*.*: ioctl '%s' fsync\n",
 1572|      0|                   ptrval? (const char*)ptrval:"<null>");
  ------------------
  |  Branch (1572:20): [True: 0, False: 0]
  ------------------
 1573|       |
 1574|      0|      if (!a && !intval && ptrval)
  ------------------
  |  Branch (1574:11): [True: 0, False: 0]
  |  Branch (1574:17): [True: 0, False: 0]
  |  Branch (1574:28): [True: 0, False: 0]
  ------------------
 1575|      0|        {
 1576|      0|          return fd_cache_synchronize (ptrval);
 1577|      0|        }
 1578|      0|    }
 1579|       |
 1580|       |
 1581|      0|  return -1;
 1582|      1|}
iobuf_push_filter:
 1593|  37.5k|{
 1594|  37.5k|  return iobuf_push_filter2 (a, f, ov, 0);
 1595|  37.5k|}
iobuf_push_filter2:
 1602|  37.5k|{
 1603|  37.5k|  iobuf_t b;
 1604|  37.5k|  size_t dummy_len = 0;
 1605|  37.5k|  int rc = 0;
 1606|       |
 1607|  37.5k|  if (a->use == IOBUF_OUTPUT && (rc = filter_flush (a)))
  ------------------
  |  Branch (1607:7): [True: 0, False: 37.5k]
  |  Branch (1607:33): [True: 0, False: 0]
  ------------------
 1608|      0|    return rc;
 1609|       |
 1610|  37.5k|  if (a->subno >= MAX_NESTING_FILTER)
  ------------------
  |  |   67|  37.5k|#define MAX_NESTING_FILTER 64
  ------------------
  |  Branch (1610:7): [True: 0, False: 37.5k]
  ------------------
 1611|      0|    {
 1612|      0|      log_error ("i/o filter too deeply nested - corrupted data?\n");
 1613|      0|      return GPG_ERR_BAD_DATA;
 1614|      0|    }
 1615|       |
 1616|       |  /* We want to create a new filter and put it in front of A.  A
 1617|       |     simple implementation would do:
 1618|       |
 1619|       |       b = iobuf_alloc (...);
 1620|       |       b->chain = a;
 1621|       |       return a;
 1622|       |
 1623|       |     This is a bit problematic: A is the head of the pipeline and
 1624|       |     there are potentially many pointers to it.  Requiring the caller
 1625|       |     to update all of these pointers is a burden.
 1626|       |
 1627|       |     An alternative implementation would add a level of indirection.
 1628|       |     For instance, we could use a pipeline object, which contains a
 1629|       |     pointer to the first filter in the pipeline.  This is not what we
 1630|       |     do either.
 1631|       |
 1632|       |     Instead, we allocate a new buffer (B) and copy the first filter's
 1633|       |     state into that and use the initial buffer (A) for the new
 1634|       |     filter.  One limitation of this approach is that it is not
 1635|       |     practical to maintain a pointer to a specific filter's state.
 1636|       |
 1637|       |     Before:
 1638|       |
 1639|       |           A
 1640|       |           |
 1641|       |           v 0x100               0x200
 1642|       |           +----------+          +----------+
 1643|       |           | filter x |--------->| filter y |---->....
 1644|       |           +----------+          +----------+
 1645|       |
 1646|       |     After:           B
 1647|       |                      |
 1648|       |                      v 0x300
 1649|       |                      +----------+
 1650|       |           A          | filter x |
 1651|       |           |          +----------+
 1652|       |           v 0x100    ^          v 0x200
 1653|       |           +----------+          +----------+
 1654|       |           | filter w |          | filter y |---->....
 1655|       |           +----------+          +----------+
 1656|       |
 1657|       |     Note: filter x's address changed from 0x100 to 0x300, but A still
 1658|       |     points to the head of the pipeline.
 1659|       |  */
 1660|       |
 1661|  37.5k|  b = xmalloc (sizeof *b);
  ------------------
  |  |  107|  37.5k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1662|  37.5k|  memcpy (b, a, sizeof *b);
 1663|       |  /* fixme: it is stupid to keep a copy of the name at every level
 1664|       |   * but we need the name somewhere because the name known by file_filter
 1665|       |   * may have been released when we need the name of the file */
 1666|  37.5k|  b->real_fname = a->real_fname ? xstrdup (a->real_fname) : NULL;
  ------------------
  |  |  112|  37.5k|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  |  Branch (1666:19): [True: 37.5k, False: 0]
  ------------------
 1667|       |  /* remove the filter stuff from the new stream */
 1668|  37.5k|  a->filter = NULL;
 1669|  37.5k|  a->filter_ov = NULL;
 1670|  37.5k|  a->filter_ov_owner = 0;
 1671|  37.5k|  a->filter_eof = 0;
 1672|  37.5k|  if (a->use == IOBUF_OUTPUT_TEMP)
  ------------------
  |  Branch (1672:7): [True: 0, False: 37.5k]
  ------------------
 1673|       |    /* A TEMP filter buffers any data sent to it; it does not forward
 1674|       |       any data down the pipeline.  If we add a new filter to the
 1675|       |       pipeline, it shouldn't also buffer data.  It should send it
 1676|       |       downstream to be buffered.  Thus, the correct type for a filter
 1677|       |       added in front of an IOBUF_OUTPUT_TEMP filter is IOBUF_OUPUT, not
 1678|       |       IOBUF_OUTPUT_TEMP.  */
 1679|      0|    {
 1680|      0|      a->use = IOBUF_OUTPUT;
 1681|       |
 1682|       |      /* When pipeline is written to, the temp buffer's size is
 1683|       |	 increased accordingly.  We don't need to allocate a 10 MB
 1684|       |	 buffer for a non-terminal filter.  Just use the default
 1685|       |	 size.  */
 1686|      0|      a->d.size = iobuf_buffer_size;
 1687|      0|    }
 1688|  37.5k|  else if (a->use == IOBUF_INPUT_TEMP)
  ------------------
  |  Branch (1688:12): [True: 0, False: 37.5k]
  ------------------
 1689|       |    /* Same idea as above.  */
 1690|      0|    {
 1691|      0|      a->use = IOBUF_INPUT;
 1692|      0|      a->d.size = iobuf_buffer_size;
 1693|      0|    }
 1694|       |
 1695|       |  /* The new filter (A) gets a new buffer.
 1696|       |
 1697|       |     If the pipeline is an output or temp pipeline, then giving the
 1698|       |     buffer to the new filter means that data that was written before
 1699|       |     the filter was pushed gets sent to the filter.  That's clearly
 1700|       |     wrong.
 1701|       |
 1702|       |     If the pipeline is an input pipeline, then giving the buffer to
 1703|       |     the new filter (A) means that data that has read from (B), but
 1704|       |     not yet read from the pipeline won't be processed by the new
 1705|       |     filter (A)!  That's certainly not what we want.  */
 1706|  37.5k|  a->d.buf = xmalloc (a->d.size);
  ------------------
  |  |  107|  37.5k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1707|  37.5k|  a->d.len = 0;
 1708|  37.5k|  a->d.start = 0;
 1709|       |
 1710|       |  /* disable nlimit for the new stream */
 1711|  37.5k|  a->ntotal = b->ntotal + b->nbytes;
 1712|  37.5k|  a->nlimit = a->nbytes = 0;
 1713|  37.5k|  a->nofast = 0;
 1714|       |  /* make a link from the new stream to the original stream */
 1715|  37.5k|  a->chain = b;
 1716|       |
 1717|       |  /* setup the function on the new stream */
 1718|  37.5k|  a->filter = f;
 1719|  37.5k|  a->filter_ov = ov;
 1720|  37.5k|  a->filter_ov_owner = rel_ov;
 1721|       |
 1722|  37.5k|  a->subno = b->subno + 1;
 1723|       |
 1724|  37.5k|  if (DBG_IOBUF)
  ------------------
  |  |   98|  37.5k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 37.5k]
  |  |  ------------------
  ------------------
 1725|      0|    {
 1726|      0|      byte desc[MAX_IOBUF_DESC];
 1727|      0|      log_debug ("iobuf-%d.%d: push '%s'\n",
 1728|      0|		 a->no, a->subno, iobuf_desc (a, desc));
 1729|      0|      print_chain (a);
 1730|      0|    }
 1731|       |
 1732|       |  /* now we can initialize the new function if we have one */
 1733|  37.5k|  if (a->filter && (rc = a->filter (a->filter_ov, IOBUFCTRL_INIT, a->chain,
  ------------------
  |  Branch (1733:7): [True: 37.5k, False: 0]
  |  Branch (1733:20): [True: 0, False: 37.5k]
  ------------------
 1734|  37.5k|				    NULL, &dummy_len)))
 1735|      0|    log_error ("IOBUFCTRL_INIT failed: %s\n", gpg_strerror (rc));
 1736|  37.5k|  return rc;
 1737|  37.5k|}
iobuf_readbyte:
 2101|  1.05G|{
 2102|  1.05G|  int c;
 2103|       |
 2104|  1.05G|  if (a->use == IOBUF_OUTPUT || a->use == IOBUF_OUTPUT_TEMP)
  ------------------
  |  Branch (2104:7): [True: 0, False: 1.05G]
  |  Branch (2104:33): [True: 0, False: 1.05G]
  ------------------
 2105|      0|    {
 2106|      0|      log_bug ("iobuf_readbyte called on a non-INPUT pipeline!\n");
 2107|      0|      return -1;
 2108|      0|    }
 2109|       |
 2110|  1.05G|  assert (a->d.start <= a->d.len);
 2111|       |
 2112|  1.05G|  if (a->nlimit && a->nbytes >= a->nlimit)
  ------------------
  |  Branch (2112:7): [True: 0, False: 1.05G]
  |  Branch (2112:20): [True: 0, False: 0]
  ------------------
 2113|      0|    return -1;			/* forced EOF */
 2114|       |
 2115|  1.05G|  if (a->d.start < a->d.len)
  ------------------
  |  Branch (2115:7): [True: 19.8k, False: 1.05G]
  ------------------
 2116|  19.8k|    {
 2117|  19.8k|      c = a->d.buf[a->d.start++];
 2118|  19.8k|    }
 2119|  1.05G|  else if ((c = underflow (a, 1)) == -1)
  ------------------
  |  Branch (2119:12): [True: 1.05G, False: 49.0k]
  ------------------
 2120|  1.05G|    return -1;			/* EOF */
 2121|       |
 2122|  68.8k|  assert (a->d.start <= a->d.len);
 2123|       |
 2124|       |  /* Note: if underflow doesn't return EOF, then it returns the first
 2125|       |     byte that was read and advances a->d.start appropriately.  */
 2126|       |
 2127|  68.8k|  a->nbytes++;
 2128|  68.8k|  return c;
 2129|  68.8k|}
iobuf_read:
 2134|   138k|{
 2135|   138k|  unsigned char *buf = (unsigned char *)buffer;
 2136|   138k|  int c, n;
 2137|       |
 2138|   138k|  if (a->use == IOBUF_OUTPUT || a->use == IOBUF_OUTPUT_TEMP)
  ------------------
  |  Branch (2138:7): [True: 0, False: 138k]
  |  Branch (2138:33): [True: 0, False: 138k]
  ------------------
 2139|      0|    {
 2140|      0|      log_bug ("iobuf_read called on a non-INPUT pipeline!\n");
 2141|      0|      return -1;
 2142|      0|    }
 2143|       |
 2144|   138k|  if (a->nlimit)
  ------------------
  |  Branch (2144:7): [True: 0, False: 138k]
  ------------------
 2145|      0|    {
 2146|       |      /* Handle special cases. */
 2147|      0|      for (n = 0; n < buflen; n++)
  ------------------
  |  Branch (2147:19): [True: 0, False: 0]
  ------------------
 2148|      0|	{
 2149|      0|	  if ((c = iobuf_readbyte (a)) == -1)
  ------------------
  |  Branch (2149:8): [True: 0, False: 0]
  ------------------
 2150|      0|	    {
 2151|      0|	      if (!n)
  ------------------
  |  Branch (2151:12): [True: 0, False: 0]
  ------------------
 2152|      0|		return -1;	/* eof */
 2153|      0|	      break;
 2154|      0|	    }
 2155|       |
 2156|      0|	  if (buf)
  ------------------
  |  Branch (2156:8): [True: 0, False: 0]
  ------------------
 2157|      0|	    {
 2158|      0|	      *buf = c;
 2159|      0|	      buf++;
 2160|      0|	    }
 2161|      0|	}
 2162|      0|      return n;
 2163|      0|    }
 2164|       |
 2165|   138k|  a->e_d.buf = NULL;
 2166|   138k|  a->e_d.len = 0;
 2167|       |
 2168|       |  /* Hint for how full to fill iobuf internal drain buffer. */
 2169|   138k|  a->e_d.preferred = (a->use != IOBUF_INPUT_TEMP)
  ------------------
  |  Branch (2169:22): [True: 138k, False: 0]
  ------------------
 2170|   138k|    && (buf && buflen >= IOBUF_ZEROCOPY_THRESHOLD_SIZE);
  ------------------
  |  |   71|   121k|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (2170:9): [True: 121k, False: 16.3k]
  |  Branch (2170:16): [True: 12.6k, False: 109k]
  ------------------
 2171|       |
 2172|   138k|  n = 0;
 2173|   138k|  do
 2174|   156k|    {
 2175|   156k|      if (n < buflen && a->d.start < a->d.len)
  ------------------
  |  Branch (2175:11): [True: 156k, False: 0]
  |  Branch (2175:25): [True: 142k, False: 14.3k]
  ------------------
 2176|       |	/* Drain the buffer.  */
 2177|   142k|	{
 2178|   142k|	  unsigned size = a->d.len - a->d.start;
 2179|   142k|	  if (size > buflen - n)
  ------------------
  |  Branch (2179:8): [True: 113k, False: 28.7k]
  ------------------
 2180|   113k|	    size = buflen - n;
 2181|   142k|	  if (buf)
  ------------------
  |  Branch (2181:8): [True: 132k, False: 9.65k]
  ------------------
 2182|   132k|	    memcpy (buf, a->d.buf + a->d.start, size);
 2183|   142k|	  n += size;
 2184|   142k|	  a->d.start += size;
 2185|   142k|	  if (buf)
  ------------------
  |  Branch (2185:8): [True: 132k, False: 9.65k]
  ------------------
 2186|   132k|	    buf += size;
 2187|   142k|	}
 2188|   156k|      if (n < buflen)
  ------------------
  |  Branch (2188:11): [True: 35.3k, False: 121k]
  ------------------
 2189|       |	/* Draining the internal buffer didn't fill BUFFER.  Call
 2190|       |	   underflow to read more data into the filter's internal
 2191|       |	   buffer.  */
 2192|  35.3k|	{
 2193|  35.3k|	  if (a->use != IOBUF_INPUT_TEMP && buf && n < buflen)
  ------------------
  |  Branch (2193:8): [True: 35.3k, False: 0]
  |  Branch (2193:38): [True: 14.2k, False: 21.1k]
  |  Branch (2193:45): [True: 14.2k, False: 0]
  ------------------
 2194|  14.2k|	    {
 2195|       |	      /* Setup external drain buffer for faster moving of data
 2196|       |	       * (avoid memcpy). */
 2197|  14.2k|	      a->e_d.buf = buf;
 2198|  14.2k|	      a->e_d.len = (buflen - n) / IOBUF_ZEROCOPY_THRESHOLD_SIZE
  ------------------
  |  |   71|  14.2k|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
 2199|  14.2k|			    * IOBUF_ZEROCOPY_THRESHOLD_SIZE;
  ------------------
  |  |   71|  14.2k|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
 2200|  14.2k|	      if (a->e_d.len == 0)
  ------------------
  |  Branch (2200:12): [True: 13.4k, False: 771]
  ------------------
 2201|  13.4k|		a->e_d.buf = NULL;
 2202|  14.2k|	      if (a->e_d.buf && DBG_IOBUF)
  ------------------
  |  |   98|    771|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 771]
  |  |  ------------------
  ------------------
  |  Branch (2202:12): [True: 771, False: 13.4k]
  ------------------
 2203|      0|		log_debug ("iobuf-%d.%d: reading to external buffer, %lu bytes\n",
 2204|      0|			   a->no, a->subno, (ulong)a->e_d.len);
 2205|  14.2k|	    }
 2206|       |
 2207|  35.3k|	  if ((c = underflow (a, 1)) == -1)
  ------------------
  |  Branch (2207:8): [True: 17.0k, False: 18.3k]
  ------------------
 2208|       |	    /* EOF.  If we managed to read something, don't return EOF
 2209|       |	       now.  */
 2210|  17.0k|	    {
 2211|  17.0k|	      a->e_d.buf = NULL;
 2212|  17.0k|	      a->e_d.len = 0;
 2213|  17.0k|	      a->nbytes += n;
 2214|  17.0k|	      return n ? n : -1 /*EOF*/;
  ------------------
  |  Branch (2214:15): [True: 7.54k, False: 9.53k]
  ------------------
 2215|  17.0k|	    }
 2216|       |
 2217|  18.3k|	  if (a->e_d.buf && a->e_d.used > 0)
  ------------------
  |  Branch (2217:8): [True: 502, False: 17.8k]
  |  Branch (2217:22): [True: 502, False: 0]
  ------------------
 2218|    502|	    {
 2219|       |	      /* Drain buffer was used, 'c' only contains return code
 2220|       |	       * 0 or -1. */
 2221|    502|	      n += a->e_d.used;
 2222|    502|	      buf += a->e_d.used;
 2223|    502|	    }
 2224|  17.8k|	  else
 2225|  17.8k|	    {
 2226|  17.8k|	      if (buf)
  ------------------
  |  Branch (2226:12): [True: 11.5k, False: 6.29k]
  ------------------
 2227|  11.5k|		*buf++ = c;
 2228|  17.8k|	      n++;
 2229|  17.8k|	    }
 2230|       |
 2231|  18.3k|	  a->e_d.buf = NULL;
 2232|  18.3k|	  a->e_d.len = 0;
 2233|  18.3k|	}
 2234|   156k|    }
 2235|   139k|  while (n < buflen);
  ------------------
  |  Branch (2235:10): [True: 18.2k, False: 121k]
  ------------------
 2236|   121k|  a->nbytes += n;
 2237|   121k|  return n;
 2238|   138k|}
iobuf_peek:
 2244|  11.9k|{
 2245|  11.9k|  int n = 0;
 2246|       |
 2247|  11.9k|  assert (buflen > 0);
 2248|  11.9k|  assert (a->use == IOBUF_INPUT || a->use == IOBUF_INPUT_TEMP);
 2249|       |
 2250|  11.9k|  if (buflen > a->d.size)
  ------------------
  |  Branch (2250:7): [True: 0, False: 11.9k]
  ------------------
 2251|       |    /* We can't peek more than we can buffer.  */
 2252|      0|    buflen = a->d.size;
 2253|       |
 2254|       |  /* Try to fill the internal buffer with enough data to satisfy the
 2255|       |     request.  */
 2256|  23.9k|  while (buflen > a->d.len - a->d.start)
  ------------------
  |  Branch (2256:10): [True: 12.0k, False: 11.9k]
  ------------------
 2257|  12.0k|    {
 2258|  12.0k|      if (underflow_target (a, 0, buflen) == -1)
  ------------------
  |  Branch (2258:11): [True: 31, False: 11.9k]
  ------------------
 2259|       |	/* EOF.  We can't read any more.  */
 2260|     31|	break;
 2261|       |
 2262|       |      /* Underflow consumes the first character (it's the return
 2263|       |	 value).  unget() it by resetting the "file position".  */
 2264|  11.9k|      assert (a->d.start == 1);
 2265|  11.9k|      a->d.start = 0;
 2266|  11.9k|    }
 2267|       |
 2268|  11.9k|  n = a->d.len - a->d.start;
 2269|  11.9k|  if (n > buflen)
  ------------------
  |  Branch (2269:7): [True: 11.6k, False: 310]
  ------------------
 2270|  11.6k|    n = buflen;
 2271|       |
 2272|  11.9k|  if (n == 0)
  ------------------
  |  Branch (2272:7): [True: 0, False: 11.9k]
  ------------------
 2273|       |    /* EOF.  */
 2274|      0|    return -1;
 2275|       |
 2276|  11.9k|  memcpy (buf, &a->d.buf[a->d.start], n);
 2277|       |
 2278|  11.9k|  return n;
 2279|  11.9k|}
iobuf_tell:
 2598|  2.43M|{
 2599|  2.43M|  return a->ntotal + a->nbytes;
 2600|  2.43M|}
iobuf_set_partial_body_length_mode:
 2745|  34.8k|{
 2746|  34.8k|  if (!len)
  ------------------
  |  Branch (2746:7): [True: 0, False: 34.8k]
  ------------------
 2747|       |    /* Disable partial body length mode.  */
 2748|      0|    {
 2749|      0|      if (a->use == IOBUF_INPUT)
  ------------------
  |  Branch (2749:11): [True: 0, False: 0]
  ------------------
 2750|      0|	log_debug ("iobuf_pop_filter called in set_partial_block_mode"
 2751|      0|		   " - please report\n");
 2752|       |
 2753|      0|      log_assert (a->filter == block_filter);
 2754|      0|      iobuf_pop_filter (a, block_filter, NULL);
 2755|      0|    }
 2756|  34.8k|  else
 2757|       |    /* Enabled partial body length mode.  */
 2758|  34.8k|    {
 2759|  34.8k|      block_filter_ctx_t *ctx = xcalloc (1, sizeof *ctx);
  ------------------
  |  |  109|  34.8k|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
 2760|  34.8k|      ctx->use = a->use;
 2761|  34.8k|      ctx->partial = 1;
 2762|  34.8k|      ctx->size = 0;
 2763|  34.8k|      ctx->first_c = len;
 2764|  34.8k|      iobuf_push_filter (a, block_filter, ctx);
 2765|  34.8k|    }
 2766|  34.8k|}
iobuf_read_line:
 2773|  93.0k|{
 2774|  93.0k|  int c;
 2775|  93.0k|  char *buffer = (char *)*addr_of_buffer;
 2776|  93.0k|  unsigned length = *length_of_buffer;
 2777|  93.0k|  unsigned nbytes = 0;
 2778|  93.0k|  unsigned maxlen = *max_length;
 2779|  93.0k|  char *p;
 2780|       |
 2781|       |  /* The code assumes that we have space for at least a newline and a
 2782|       |     NUL character in the buffer.  This requires at least 2 bytes.  We
 2783|       |     don't complicate the code by handling the stupid corner case, but
 2784|       |     simply assert that it can't happen.  */
 2785|  93.0k|  assert (!buffer || length >= 2 || maxlen >= 2);
 2786|       |
 2787|  93.0k|  if (!buffer || length <= 1)
  ------------------
  |  Branch (2787:7): [True: 2.68k, False: 90.3k]
  |  Branch (2787:18): [True: 0, False: 90.3k]
  ------------------
 2788|       |    /* must allocate a new buffer */
 2789|  2.68k|    {
 2790|  2.68k|      length = 256 <= maxlen ? 256 : maxlen;
  ------------------
  |  Branch (2790:16): [True: 2.68k, False: 0]
  ------------------
 2791|  2.68k|      buffer = xrealloc (buffer, length);
  ------------------
  |  |  111|  2.68k|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 2792|  2.68k|      *addr_of_buffer = (unsigned char *)buffer;
 2793|  2.68k|      *length_of_buffer = length;
 2794|  2.68k|    }
 2795|       |
 2796|  93.0k|  p = buffer;
 2797|   100k|  while (1)
  ------------------
  |  Branch (2797:10): [Folded - Ignored]
  ------------------
 2798|   100k|    {
 2799|   100k|      if (!a->nofast && a->d.start < a->d.len && nbytes < length - 1)
  ------------------
  |  Branch (2799:11): [True: 100k, False: 0]
  |  Branch (2799:25): [True: 94.7k, False: 5.33k]
  |  Branch (2799:50): [True: 94.7k, False: 0]
  ------------------
 2800|       |	/* Fast path for finding '\n' by using standard C library's optimized
 2801|       |	   memchr.  */
 2802|  94.7k|	{
 2803|  94.7k|	  unsigned size = a->d.len - a->d.start;
 2804|  94.7k|	  byte *newline_pos;
 2805|       |
 2806|  94.7k|	  if (size > length - 1 - nbytes)
  ------------------
  |  Branch (2806:8): [True: 75.5k, False: 19.1k]
  ------------------
 2807|  75.5k|	    size = length - 1 - nbytes;
 2808|       |
 2809|  94.7k|	  newline_pos = memchr (a->d.buf + a->d.start, '\n', size);
 2810|  94.7k|	  if (newline_pos)
  ------------------
  |  Branch (2810:8): [True: 87.6k, False: 7.09k]
  ------------------
 2811|  87.6k|	    {
 2812|       |	      /* Found newline, copy buffer and return. */
 2813|  87.6k|	      size = (newline_pos - (a->d.buf + a->d.start)) + 1;
 2814|  87.6k|	      memcpy (p, a->d.buf + a->d.start, size);
 2815|  87.6k|	      p += size;
 2816|  87.6k|	      nbytes += size;
 2817|  87.6k|	      a->d.start += size;
 2818|  87.6k|	      a->nbytes += size;
 2819|  87.6k|	      break;
 2820|  87.6k|	    }
 2821|  7.09k|	  else
 2822|  7.09k|	    {
 2823|       |	      /* No newline, copy buffer and continue. */
 2824|  7.09k|	      memcpy (p, a->d.buf + a->d.start, size);
 2825|  7.09k|	      p += size;
 2826|  7.09k|	      nbytes += size;
 2827|  7.09k|	      a->d.start += size;
 2828|  7.09k|	      a->nbytes += size;
 2829|  7.09k|	    }
 2830|  94.7k|	}
 2831|  5.33k|      else
 2832|  5.33k|	{
 2833|  5.33k|	  c = iobuf_readbyte (a);
 2834|  5.33k|	  if (c == -1)
  ------------------
  |  Branch (2834:8): [True: 5.33k, False: 0]
  ------------------
 2835|  5.33k|	    break;
 2836|      0|	  *p++ = c;
 2837|      0|	  nbytes++;
 2838|      0|	  if (c == '\n')
  ------------------
  |  Branch (2838:8): [True: 0, False: 0]
  ------------------
 2839|      0|	    break;
 2840|      0|	}
 2841|       |
 2842|  7.09k|      if (nbytes == length - 1)
  ------------------
  |  Branch (2842:11): [True: 5.12k, False: 1.96k]
  ------------------
 2843|       |	/* We don't have enough space to add a \n and a \0.  Increase
 2844|       |	   the buffer size.  */
 2845|  5.12k|	{
 2846|  5.12k|	  if (length == maxlen)
  ------------------
  |  Branch (2846:8): [True: 67, False: 5.06k]
  ------------------
 2847|       |	    /* We reached the buffer's size limit!  */
 2848|     67|	    {
 2849|       |	      /* Skip the rest of the line.  */
 2850|  48.5k|	      while ((c = iobuf_get (a)) != -1 && c != '\n')
  ------------------
  |  |  500|  48.5k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 48.5k]
  |  |  |  Branch (500:24): [True: 34, False: 48.5k]
  |  |  ------------------
  |  |  501|  48.5k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (2850:15): [True: 48.5k, False: 34]
  |  Branch (2850:44): [True: 48.4k, False: 33]
  ------------------
 2851|  48.4k|		;
 2852|       |
 2853|       |	      /* p is pointing at the last byte in the buffer.  We
 2854|       |		 always terminate the line with "\n\0" so overwrite
 2855|       |		 the previous byte with a \n.  */
 2856|     67|	      assert (p > buffer);
 2857|     67|	      p[-1] = '\n';
 2858|       |
 2859|       |	      /* Indicate truncation.  */
 2860|     67|	      *max_length = 0;
 2861|     67|	      break;
 2862|     67|	    }
 2863|       |
 2864|  5.06k|	  length += length < 1024 ? 256 : 1024;
  ------------------
  |  Branch (2864:14): [True: 1.57k, False: 3.48k]
  ------------------
 2865|  5.06k|	  if (length > maxlen)
  ------------------
  |  Branch (2865:8): [True: 65, False: 4.99k]
  ------------------
 2866|     65|	    length = maxlen;
 2867|       |
 2868|  5.06k|	  buffer = xrealloc (buffer, length);
  ------------------
  |  |  111|  5.06k|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 2869|  5.06k|	  *addr_of_buffer = (unsigned char *)buffer;
 2870|  5.06k|	  *length_of_buffer = length;
 2871|  5.06k|	  p = buffer + nbytes;
 2872|  5.06k|	}
 2873|  7.09k|    }
 2874|       |  /* Add the terminating NUL.  */
 2875|  93.0k|  *p = 0;
 2876|       |
 2877|       |  /* Return the number of characters written to the buffer including
 2878|       |     the newline, but not including the terminating NUL.  */
 2879|  93.0k|  return nbytes;
 2880|  93.0k|}
iobuf_skip_rest:
 2915|   279k|{
 2916|   279k|  if ( partial )
  ------------------
  |  Branch (2916:8): [True: 0, False: 279k]
  ------------------
 2917|      0|    {
 2918|      0|      for (;;)
 2919|      0|        {
 2920|      0|          if (a->nofast || a->d.start >= a->d.len)
  ------------------
  |  Branch (2920:15): [True: 0, False: 0]
  |  Branch (2920:28): [True: 0, False: 0]
  ------------------
 2921|      0|            {
 2922|      0|              if (iobuf_readbyte (a) == -1)
  ------------------
  |  Branch (2922:19): [True: 0, False: 0]
  ------------------
 2923|      0|                {
 2924|      0|                  break;
 2925|      0|                }
 2926|      0|	    }
 2927|      0|          else
 2928|      0|            {
 2929|      0|              unsigned long count = a->d.len - a->d.start;
 2930|      0|              a->nbytes += count;
 2931|      0|              a->d.start = a->d.len;
 2932|      0|	    }
 2933|      0|	}
 2934|      0|    }
 2935|   279k|  else
 2936|   279k|    {
 2937|   279k|      unsigned long remaining = n;
 2938|   347k|      while (remaining > 0)
  ------------------
  |  Branch (2938:14): [True: 75.4k, False: 271k]
  ------------------
 2939|  75.4k|        {
 2940|  75.4k|          if (a->nofast || a->d.start >= a->d.len)
  ------------------
  |  Branch (2940:15): [True: 0, False: 75.4k]
  |  Branch (2940:28): [True: 10.8k, False: 64.6k]
  ------------------
 2941|  10.8k|            {
 2942|  10.8k|              if (iobuf_readbyte (a) == -1)
  ------------------
  |  Branch (2942:19): [True: 7.14k, False: 3.68k]
  ------------------
 2943|  7.14k|                {
 2944|  7.14k|                  break;
 2945|  7.14k|		}
 2946|  3.68k|              --remaining;
 2947|  3.68k|	    }
 2948|  64.6k|          else
 2949|  64.6k|            {
 2950|  64.6k|              unsigned long count = a->d.len - a->d.start;
 2951|  64.6k|              if (count > remaining)
  ------------------
  |  Branch (2951:19): [True: 60.5k, False: 4.08k]
  ------------------
 2952|  60.5k|                {
 2953|  60.5k|                  count = remaining;
 2954|  60.5k|		}
 2955|  64.6k|              a->nbytes += count;
 2956|  64.6k|              a->d.start += count;
 2957|  64.6k|              remaining -= count;
 2958|  64.6k|	    }
 2959|  75.4k|	}
 2960|   279k|    }
 2961|   279k|}
iobuf.c:print_chain:
 1160|  35.2k|{
 1161|  35.2k|  if (!DBG_IOBUF)
  ------------------
  |  |   98|  35.2k|#define DBG_IOBUF   iobuf_debug_mode
  ------------------
  |  Branch (1161:7): [True: 35.2k, False: 0]
  ------------------
 1162|  35.2k|    return;
 1163|      0|  for (; a; a = a->chain)
  ------------------
  |  Branch (1163:10): [True: 0, False: 0]
  ------------------
 1164|      0|    {
 1165|      0|      byte desc[MAX_IOBUF_DESC];
 1166|       |
 1167|      0|      log_debug ("iobuf chain: %d.%d '%s' filter_eof=%d start=%d len=%d\n",
 1168|      0|		 a->no, a->subno, iobuf_desc (a, desc), a->filter_eof,
 1169|      0|		 (int) a->d.start, (int) a->d.len);
 1170|      0|    }
 1171|      0|}
iobuf.c:do_open:
 1329|  11.9k|{
 1330|  11.9k|  iobuf_t a;
 1331|  11.9k|  gnupg_fd_t fp;
 1332|  11.9k|  file_filter_ctx_t *fcx;
 1333|  11.9k|  size_t len = 0;
 1334|  11.9k|  int print_only = 0;
 1335|  11.9k|  int fd;
 1336|  11.9k|  byte desc[MAX_IOBUF_DESC];
 1337|       |
 1338|  11.9k|  assert (use == IOBUF_INPUT || use == IOBUF_OUTPUT);
 1339|       |
 1340|  11.9k|  if (special_filenames
  ------------------
  |  Branch (1340:7): [True: 11.9k, False: 0]
  ------------------
 1341|       |      /* NULL or '-'.  */
 1342|  11.9k|      && (!fname || (*fname == '-' && !fname[1])))
  ------------------
  |  Branch (1342:11): [True: 0, False: 11.9k]
  |  Branch (1342:22): [True: 0, False: 11.9k]
  |  Branch (1342:39): [True: 0, False: 0]
  ------------------
 1343|      0|    {
 1344|      0|      if (use == IOBUF_INPUT)
  ------------------
  |  Branch (1344:11): [True: 0, False: 0]
  ------------------
 1345|      0|	{
 1346|      0|	  fp = FD_FOR_STDIN;
  ------------------
  |  |   84|      0|# define FD_FOR_STDIN  (0)
  ------------------
 1347|      0|	  fname = "[stdin]";
 1348|      0|	}
 1349|      0|      else
 1350|      0|	{
 1351|      0|	  fp = FD_FOR_STDOUT;
  ------------------
  |  |   85|      0|# define FD_FOR_STDOUT (1)
  ------------------
 1352|      0|	  fname = "[stdout]";
 1353|      0|	}
 1354|      0|      print_only = 1;
 1355|      0|    }
 1356|  11.9k|  else if (!fname)
  ------------------
  |  Branch (1356:12): [True: 0, False: 11.9k]
  ------------------
 1357|      0|    return NULL;
 1358|  11.9k|  else if (special_filenames
  ------------------
  |  Branch (1358:12): [True: 11.9k, False: 0]
  ------------------
 1359|  11.9k|           && (fd = check_special_filename (fname, 0, 1)) != -1)
  ------------------
  |  Branch (1359:15): [True: 0, False: 11.9k]
  ------------------
 1360|      0|    return iobuf_fdopen (translate_file_handle (fd, use == IOBUF_INPUT ? 0 : 1),
  ------------------
  |  Branch (1360:53): [True: 0, False: 0]
  ------------------
 1361|      0|			 opentype);
 1362|  11.9k|  else
 1363|  11.9k|    {
 1364|  11.9k|      if (use == IOBUF_INPUT)
  ------------------
  |  Branch (1364:11): [True: 11.9k, False: 1]
  ------------------
 1365|  11.9k|	fp = fd_cache_open (fname, opentype);
 1366|      1|      else
 1367|      1|	fp = direct_open (fname, opentype, mode700);
 1368|  11.9k|      if (fp == GNUPG_INVALID_FD)
  ------------------
  |  |   44|  11.9k|#define GNUPG_INVALID_FD (-1)
  ------------------
  |  Branch (1368:11): [True: 0, False: 11.9k]
  ------------------
 1369|      0|	return NULL;
 1370|  11.9k|    }
 1371|       |
 1372|  11.9k|  a = iobuf_alloc (use, iobuf_buffer_size);
 1373|  11.9k|  fcx = xmalloc (sizeof *fcx + strlen (fname));
  ------------------
  |  |  107|  11.9k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1374|  11.9k|  fcx->fp = fp;
 1375|  11.9k|  fcx->print_only_name = print_only;
 1376|  11.9k|  strcpy (fcx->fname, fname);
 1377|  11.9k|  if (!print_only)
  ------------------
  |  Branch (1377:7): [True: 11.9k, False: 0]
  ------------------
 1378|  11.9k|    a->real_fname = xstrdup (fname);
  ------------------
  |  |  112|  11.9k|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 1379|  11.9k|  a->filter = file_filter;
 1380|  11.9k|  a->filter_ov = fcx;
 1381|  11.9k|  file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len);
 1382|  11.9k|  if (DBG_IOBUF)
  ------------------
  |  |   98|  11.9k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 11.9k]
  |  |  ------------------
  ------------------
 1383|      0|    log_debug ("iobuf-%d.%d: open '%s' desc=%s fd=%d\n",
 1384|      0|	       a->no, a->subno, fname, iobuf_desc (a, desc), FD2INT (fcx->fp));
  ------------------
  |  |   46|      0|#define FD2INT(h) (h)
  ------------------
 1385|       |
 1386|  11.9k|  return a;
 1387|  11.9k|}
iobuf.c:fd_cache_open:
  411|  11.9k|{
  412|  11.9k|  close_cache_t cc;
  413|       |
  414|  11.9k|  assert (fname);
  415|  11.9k|  for (cc = close_cache; cc; cc = cc->next)
  ------------------
  |  Branch (415:26): [True: 11.9k, False: 1]
  ------------------
  416|  11.9k|    {
  417|  11.9k|      if (cc->fp != GNUPG_INVALID_FD && !fd_cache_strcmp (cc->fname, fname))
  ------------------
  |  |   44|  23.9k|#define GNUPG_INVALID_FD (-1)
  ------------------
  |  Branch (417:11): [True: 11.9k, False: 1]
  |  Branch (417:41): [True: 11.9k, False: 0]
  ------------------
  418|  11.9k|	{
  419|  11.9k|	  gnupg_fd_t fp = cc->fp;
  420|  11.9k|	  cc->fp = GNUPG_INVALID_FD;
  ------------------
  |  |   44|  11.9k|#define GNUPG_INVALID_FD (-1)
  ------------------
  421|  11.9k|	  if (DBG_IOBUF)
  ------------------
  |  |   98|  11.9k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 11.9k]
  |  |  ------------------
  ------------------
  422|      0|	    log_debug ("fd_cache_open (%s) using cached fp\n", fname);
  423|       |#ifdef HAVE_W32_SYSTEM
  424|       |	  if (SetFilePointer (fp, 0, NULL, FILE_BEGIN) == 0xffffffff)
  425|       |	    {
  426|       |	      log_error ("rewind file failed on handle %p: ec=%d\n",
  427|       |			 fp, (int) GetLastError ());
  428|       |	      fp = GNUPG_INVALID_FD;
  429|       |	    }
  430|       |#else
  431|  11.9k|	  if (lseek (fp, 0, SEEK_SET) == (off_t) - 1)
  ------------------
  |  Branch (431:8): [True: 0, False: 11.9k]
  ------------------
  432|      0|	    {
  433|      0|	      log_error ("can't rewind fd %d: %s\n", fp, strerror (errno));
  434|      0|	      fp = GNUPG_INVALID_FD;
  ------------------
  |  |   44|      0|#define GNUPG_INVALID_FD (-1)
  ------------------
  435|      0|	    }
  436|  11.9k|#endif
  437|  11.9k|	  return fp;
  438|  11.9k|	}
  439|  11.9k|    }
  440|      1|  if (DBG_IOBUF)
  ------------------
  |  |   98|      1|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  441|      0|    log_debug ("fd_cache_open (%s) not cached\n", fname);
  442|      1|  return direct_open (fname, mode, 0);
  443|  11.9k|}
iobuf.c:fd_cache_strcmp:
  186|  23.9k|{
  187|       |#ifdef HAVE_DOSISH_SYSTEM
  188|       |  for (; *a && *b; a++, b++)
  189|       |    {
  190|       |      if (*a != *b && !((*a == '/' && *b == '\\')
  191|       |                        || (*a == '\\' && *b == '/')) )
  192|       |        break;
  193|       |    }
  194|       |  return *(const unsigned char *)a - *(const unsigned char *)b;
  195|       |#else
  196|  23.9k|  return strcmp (a, b);
  197|  23.9k|#endif
  198|  23.9k|}
iobuf.c:direct_open:
  267|      2|{
  268|       |#ifdef HAVE_W32_SYSTEM
  269|       |  unsigned long da, cd, sm;
  270|       |  HANDLE hfile;
  271|       |
  272|       |  (void)mode700;
  273|       |  /* Note, that we do not handle all mode combinations */
  274|       |
  275|       |  /* According to the ReactOS source it seems that open() of the
  276|       |   * standard MSW32 crt does open the file in shared mode which is
  277|       |   * something new for MS applications ;-)
  278|       |   */
  279|       |  if (strchr (mode, '+'))
  280|       |    {
  281|       |      if (fd_cache_invalidate (fname))
  282|       |        return GNUPG_INVALID_FD;
  283|       |      da = GENERIC_READ | GENERIC_WRITE;
  284|       |      cd = OPEN_EXISTING;
  285|       |      sm = FILE_SHARE_READ | FILE_SHARE_WRITE;
  286|       |    }
  287|       |  else if (strchr (mode, 'w'))
  288|       |    {
  289|       |      if (fd_cache_invalidate (fname))
  290|       |        return GNUPG_INVALID_FD;
  291|       |      da = GENERIC_WRITE;
  292|       |      cd = CREATE_ALWAYS;
  293|       |      sm = FILE_SHARE_WRITE;
  294|       |    }
  295|       |  else
  296|       |    {
  297|       |      da = GENERIC_READ;
  298|       |      cd = OPEN_EXISTING;
  299|       |      sm = FILE_SHARE_READ;
  300|       |    }
  301|       |
  302|       |  /* We always use the Unicode version because it supports file names
  303|       |   * longer than MAX_PATH.  (requires gpgrt 1.45) */
  304|       |  if (1)
  305|       |    {
  306|       |      wchar_t *wfname = gpgrt_fname_to_wchar (fname);
  307|       |      if (wfname)
  308|       |        {
  309|       |          hfile = CreateFileW (wfname, da, sm, NULL, cd,
  310|       |                               FILE_ATTRIBUTE_NORMAL, NULL);
  311|       |          xfree (wfname);
  312|       |        }
  313|       |      else
  314|       |        hfile = INVALID_HANDLE_VALUE;
  315|       |    }
  316|       |
  317|       |  return hfile;
  318|       |
  319|       |#else /*!HAVE_W32_SYSTEM*/
  320|       |
  321|      2|  int oflag;
  322|      2|  int cflag = S_IRUSR | S_IWUSR;
  323|       |
  324|      2|  if (!mode700)
  ------------------
  |  Branch (324:7): [True: 2, False: 0]
  ------------------
  325|      2|    cflag |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
  326|       |
  327|       |  /* Note, that we do not handle all mode combinations */
  328|      2|  if (strchr (mode, '+'))
  ------------------
  |  Branch (328:7): [True: 0, False: 2]
  ------------------
  329|      0|    {
  330|      0|      if (fd_cache_invalidate (fname))
  ------------------
  |  Branch (330:11): [True: 0, False: 0]
  ------------------
  331|      0|        return GNUPG_INVALID_FD;
  ------------------
  |  |   44|      0|#define GNUPG_INVALID_FD (-1)
  ------------------
  332|      0|      oflag = O_RDWR;
  333|      0|    }
  334|      2|  else if (strchr (mode, 'w'))
  ------------------
  |  Branch (334:12): [True: 1, False: 1]
  ------------------
  335|      1|    {
  336|      1|      if (fd_cache_invalidate (fname))
  ------------------
  |  Branch (336:11): [True: 0, False: 1]
  ------------------
  337|      0|        return GNUPG_INVALID_FD;
  ------------------
  |  |   44|      0|#define GNUPG_INVALID_FD (-1)
  ------------------
  338|      1|      oflag = O_WRONLY | O_CREAT | O_TRUNC;
  339|      1|    }
  340|      1|  else
  341|      1|    {
  342|      1|      oflag = O_RDONLY;
  343|      1|    }
  344|       |#ifdef O_BINARY
  345|       |  if (strchr (mode, 'b'))
  346|       |    oflag |= O_BINARY;
  347|       |#endif
  348|       |
  349|       |#ifdef __riscos__
  350|       |  {
  351|       |    struct stat buf;
  352|       |
  353|       |    /* Don't allow iobufs on directories */
  354|       |    if (!stat (fname, &buf) && S_ISDIR (buf.st_mode) && !S_ISREG (buf.st_mode))
  355|       |      return __set_errno (EISDIR);
  356|       |  }
  357|       |#endif
  358|      2|  return open (fname, oflag, cflag);
  359|       |
  360|      2|#endif /*!HAVE_W32_SYSTEM*/
  361|      2|}
iobuf.c:file_filter:
  449|  47.7k|{
  450|  47.7k|  file_filter_ctx_t *a = opaque;
  451|  47.7k|  gnupg_fd_t f = a->fp;
  452|  47.7k|  size_t size = *ret_len;
  453|  47.7k|  size_t nbytes = 0;
  454|  47.7k|  int rc = 0;
  455|       |
  456|  47.7k|  (void)chain; /* Not used.  */
  457|       |
  458|  47.7k|  if (control == IOBUFCTRL_UNDERFLOW)
  ------------------
  |  Branch (458:7): [True: 23.8k, False: 23.9k]
  ------------------
  459|  23.8k|    {
  460|  23.8k|      log_assert (size); /* We need a buffer.  */
  461|  23.8k|      if (a->eof_seen)
  ------------------
  |  Branch (461:11): [True: 0, False: 23.8k]
  ------------------
  462|      0|	{
  463|      0|	  rc = -1;
  464|      0|	  *ret_len = 0;
  465|      0|	}
  466|  23.8k|      else if (a->delayed_rc)
  ------------------
  |  Branch (466:16): [True: 11.8k, False: 11.9k]
  ------------------
  467|  11.8k|        {
  468|  11.8k|          rc = a->delayed_rc;
  469|  11.8k|          a->delayed_rc = 0;
  470|  11.8k|          if (rc == -1)
  ------------------
  |  Branch (470:15): [True: 11.8k, False: 0]
  ------------------
  471|  11.8k|            a->eof_seen = -1;
  472|  11.8k|	  *ret_len = 0;
  473|  11.8k|        }
  474|  11.9k|      else
  475|  11.9k|	{
  476|       |#ifdef HAVE_W32_SYSTEM
  477|       |	  unsigned long nread;
  478|       |
  479|       |	  nbytes = 0;
  480|       |	  if (!ReadFile (f, buf, size, &nread, NULL))
  481|       |	    {
  482|       |	      int ec = (int) GetLastError ();
  483|       |	      if (ec != ERROR_BROKEN_PIPE)
  484|       |		{
  485|       |		  rc = gpg_error_from_errno (ec);
  486|       |		  log_error ("%s: read error: ec=%d\n", a->fname, ec);
  487|       |		}
  488|       |	    }
  489|       |	  else if (!nread)
  490|       |	    {
  491|       |	      a->eof_seen = 1;
  492|       |	      rc = -1;
  493|       |	    }
  494|       |	  else
  495|       |	    {
  496|       |	      nbytes = nread;
  497|       |	    }
  498|       |
  499|       |#else
  500|       |
  501|  11.9k|	  int n;
  502|       |
  503|  11.9k|	  nbytes = 0;
  504|  23.9k|        read_more:
  505|  23.9k|          do
  506|  23.9k|            {
  507|  23.9k|              n = read (f, buf + nbytes, size - nbytes);
  508|  23.9k|            }
  509|  23.9k|          while (n == -1 && errno == EINTR);
  ------------------
  |  Branch (509:18): [True: 0, False: 23.9k]
  |  Branch (509:29): [True: 0, False: 0]
  ------------------
  510|  23.9k|          if (n > 0)
  ------------------
  |  Branch (510:15): [True: 11.9k, False: 11.9k]
  ------------------
  511|  11.9k|            {
  512|  11.9k|              nbytes += n;
  513|  11.9k|              if (nbytes < size)
  ------------------
  |  Branch (513:19): [True: 11.9k, False: 2]
  ------------------
  514|  11.9k|                goto read_more;
  515|  11.9k|            }
  516|  11.9k|          else if (!n) /* eof */
  ------------------
  |  Branch (516:20): [True: 11.9k, False: 0]
  ------------------
  517|  11.9k|            {
  518|  11.9k|              if (nbytes)
  ------------------
  |  Branch (518:19): [True: 11.9k, False: 1]
  ------------------
  519|  11.9k|                a->delayed_rc = -1;
  520|      1|              else
  521|      1|                {
  522|      1|                  a->eof_seen = 1;
  523|      1|                  rc = -1;
  524|      1|                }
  525|  11.9k|            }
  526|      0|          else /* error */
  527|      0|            {
  528|      0|              rc = gpg_error_from_syserror ();
  529|      0|              if (gpg_err_code (rc) != GPG_ERR_EPIPE)
  ------------------
  |  Branch (529:19): [True: 0, False: 0]
  ------------------
  530|      0|                log_error ("%s: read error: %s\n", a->fname, gpg_strerror (rc));
  531|      0|              if (nbytes)
  ------------------
  |  Branch (531:19): [True: 0, False: 0]
  ------------------
  532|      0|                {
  533|      0|                  a->delayed_rc = rc;
  534|      0|                  rc = 0;
  535|      0|                }
  536|      0|            }
  537|  11.9k|#endif
  538|  11.9k|	  *ret_len = nbytes;
  539|  11.9k|	}
  540|  23.8k|    }
  541|  23.9k|  else if (control == IOBUFCTRL_FLUSH)
  ------------------
  |  Branch (541:12): [True: 1, False: 23.9k]
  ------------------
  542|      1|    {
  543|      1|      if (size)
  ------------------
  |  Branch (543:11): [True: 0, False: 1]
  ------------------
  544|      0|	{
  545|       |#ifdef HAVE_W32_SYSTEM
  546|       |	  byte *p = buf;
  547|       |	  unsigned long n;
  548|       |
  549|       |	  nbytes = size;
  550|       |	  do
  551|       |	    {
  552|       |	      if (size && !WriteFile (f, p, nbytes, &n, NULL))
  553|       |		{
  554|       |		  int ec = (int) GetLastError ();
  555|       |		  rc = gpg_error_from_errno (ec);
  556|       |		  log_error ("%s: write error: ec=%d\n", a->fname, ec);
  557|       |		  break;
  558|       |		}
  559|       |	      p += n;
  560|       |	      nbytes -= n;
  561|       |	    }
  562|       |	  while (nbytes);
  563|       |	  nbytes = p - buf;
  564|       |#else
  565|      0|	  byte *p = buf;
  566|      0|	  int n;
  567|       |
  568|      0|	  nbytes = size;
  569|      0|	  do
  570|      0|	    {
  571|      0|	      do
  572|      0|		{
  573|      0|		  n = write (f, p, nbytes);
  574|      0|		}
  575|      0|	      while (n == -1 && errno == EINTR);
  ------------------
  |  Branch (575:15): [True: 0, False: 0]
  |  Branch (575:26): [True: 0, False: 0]
  ------------------
  576|      0|	      if (n > 0)
  ------------------
  |  Branch (576:12): [True: 0, False: 0]
  ------------------
  577|      0|		{
  578|      0|		  p += n;
  579|      0|		  nbytes -= n;
  580|      0|		}
  581|      0|	    }
  582|      0|	  while (n != -1 && nbytes);
  ------------------
  |  Branch (582:11): [True: 0, False: 0]
  |  Branch (582:22): [True: 0, False: 0]
  ------------------
  583|      0|	  if (n == -1)
  ------------------
  |  Branch (583:8): [True: 0, False: 0]
  ------------------
  584|      0|	    {
  585|      0|	      rc = gpg_error_from_syserror ();
  586|      0|	      log_error ("%s: write error: %s\n", a->fname, strerror (errno));
  587|      0|	    }
  588|      0|	  nbytes = p - buf;
  589|      0|#endif
  590|      0|	}
  591|      1|      *ret_len = nbytes;
  592|      1|    }
  593|  23.9k|  else if (control == IOBUFCTRL_INIT)
  ------------------
  |  Branch (593:12): [True: 11.9k, False: 11.9k]
  ------------------
  594|  11.9k|    {
  595|  11.9k|      a->eof_seen = 0;
  596|  11.9k|      a->delayed_rc = 0;
  597|  11.9k|      a->keep_open = 0;
  598|  11.9k|      a->no_cache = 0;
  599|  11.9k|    }
  600|  11.9k|  else if (control == IOBUFCTRL_DESC)
  ------------------
  |  Branch (600:12): [True: 0, False: 11.9k]
  ------------------
  601|      0|    {
  602|      0|      mem2str (buf, "file_filter(fd)", *ret_len);
  603|      0|    }
  604|  11.9k|  else if (control == IOBUFCTRL_FREE)
  ------------------
  |  Branch (604:12): [True: 11.9k, False: 0]
  ------------------
  605|  11.9k|    {
  606|  11.9k|      if (f != FD_FOR_STDIN && f != FD_FOR_STDOUT)
  ------------------
  |  |   84|  23.9k|# define FD_FOR_STDIN  (0)
  ------------------
                    if (f != FD_FOR_STDIN && f != FD_FOR_STDOUT)
  ------------------
  |  |   85|  11.9k|# define FD_FOR_STDOUT (1)
  ------------------
  |  Branch (606:11): [True: 11.9k, False: 0]
  |  Branch (606:32): [True: 11.9k, False: 0]
  ------------------
  607|  11.9k|	{
  608|  11.9k|	  if (DBG_IOBUF)
  ------------------
  |  |   98|  11.9k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 11.9k]
  |  |  ------------------
  ------------------
  609|      0|	    log_debug ("%s: close fd/handle %d\n", a->fname, FD2INT (f));
  ------------------
  |  |   46|      0|#define FD2INT(h) (h)
  ------------------
  610|  11.9k|	  if (!a->keep_open)
  ------------------
  |  Branch (610:8): [True: 11.9k, False: 0]
  ------------------
  611|  11.9k|	    fd_cache_close (a->no_cache ? NULL : a->fname, f);
  ------------------
  |  Branch (611:22): [True: 0, False: 11.9k]
  ------------------
  612|  11.9k|	}
  613|  11.9k|      xfree (a); /* We can free our context now. */
  ------------------
  |  |  104|  11.9k|#define xfree(a)         gcry_free ((a))
  ------------------
  614|  11.9k|    }
  615|       |
  616|  47.7k|  return rc;
  617|  47.7k|}
iobuf.c:fd_cache_close:
  370|  11.9k|{
  371|  11.9k|  close_cache_t cc;
  372|       |
  373|  11.9k|  assert (fp);
  374|  11.9k|  if (!fname || !*fname)
  ------------------
  |  Branch (374:7): [True: 0, False: 11.9k]
  |  Branch (374:17): [True: 0, False: 11.9k]
  ------------------
  375|      0|    {
  376|       |#ifdef HAVE_W32_SYSTEM
  377|       |      CloseHandle (fp);
  378|       |#else
  379|      0|      close (fp);
  380|      0|#endif
  381|      0|      if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  382|      0|	log_debug ("fd_cache_close (%d) real\n", (int)fp);
  383|      0|      return;
  384|      0|    }
  385|       |  /* try to reuse a slot */
  386|  11.9k|  for (cc = close_cache; cc; cc = cc->next)
  ------------------
  |  Branch (386:26): [True: 11.9k, False: 2]
  ------------------
  387|  11.9k|    {
  388|  11.9k|      if (cc->fp == GNUPG_INVALID_FD && !fd_cache_strcmp (cc->fname, fname))
  ------------------
  |  |   44|  23.9k|#define GNUPG_INVALID_FD (-1)
  ------------------
  |  Branch (388:11): [True: 11.9k, False: 0]
  |  Branch (388:41): [True: 11.9k, False: 1]
  ------------------
  389|  11.9k|	{
  390|  11.9k|	  cc->fp = fp;
  391|  11.9k|	  if (DBG_IOBUF)
  ------------------
  |  |   98|  11.9k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 11.9k]
  |  |  ------------------
  ------------------
  392|      0|	    log_debug ("fd_cache_close (%s) used existing slot\n", fname);
  393|  11.9k|	  return;
  394|  11.9k|	}
  395|  11.9k|    }
  396|       |  /* add a new one */
  397|      2|  if (DBG_IOBUF)
  ------------------
  |  |   98|      2|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  ------------------
  398|      0|    log_debug ("fd_cache_close (%s) new slot created\n", fname);
  399|      2|  cc = xcalloc (1, sizeof *cc + strlen (fname));
  ------------------
  |  |  109|      2|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
  400|      2|  strcpy (cc->fname, fname);
  401|      2|  cc->fp = fp;
  402|      2|  cc->next = close_cache;
  403|      2|  close_cache = cc;
  404|      2|}
iobuf.c:fd_cache_invalidate:
  206|      2|{
  207|      2|  close_cache_t cc;
  208|      2|  int rc = 0;
  209|       |
  210|      2|  assert (fname);
  211|      2|  if (DBG_IOBUF)
  ------------------
  |  |   98|      2|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  ------------------
  212|      0|    log_debug ("fd_cache_invalidate (%s)\n", fname);
  213|       |
  214|      3|  for (cc = close_cache; cc; cc = cc->next)
  ------------------
  |  Branch (214:26): [True: 1, False: 2]
  ------------------
  215|      1|    {
  216|      1|      if (cc->fp != GNUPG_INVALID_FD && !fd_cache_strcmp (cc->fname, fname))
  ------------------
  |  |   44|      2|#define GNUPG_INVALID_FD (-1)
  ------------------
  |  Branch (216:11): [True: 1, False: 0]
  |  Branch (216:41): [True: 1, False: 0]
  ------------------
  217|      1|	{
  218|      1|	  if (DBG_IOBUF)
  ------------------
  |  |   98|      1|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  219|      0|	    log_debug ("                did (%s)\n", cc->fname);
  220|       |#ifdef HAVE_W32_SYSTEM
  221|       |	  if (!CloseHandle (cc->fp))
  222|       |            rc = -1;
  223|       |#else
  224|      1|	  rc = close (cc->fp);
  225|      1|#endif
  226|      1|	  cc->fp = GNUPG_INVALID_FD;
  ------------------
  |  |   44|      1|#define GNUPG_INVALID_FD (-1)
  ------------------
  227|      1|	}
  228|      1|    }
  229|      2|  return rc;
  230|      2|}
iobuf.c:filter_flush:
 2043|      1|{
 2044|      1|  int external_used = 0;
 2045|      1|  byte *src_buf;
 2046|      1|  size_t src_len;
 2047|      1|  size_t len;
 2048|      1|  int rc;
 2049|       |
 2050|      1|  a->e_d.used = 0;
 2051|       |
 2052|      1|  if (a->use == IOBUF_OUTPUT_TEMP)
  ------------------
  |  Branch (2052:7): [True: 0, False: 1]
  ------------------
 2053|      0|    {				/* increase the temp buffer */
 2054|      0|      size_t newsize = a->d.size + iobuf_buffer_size;
 2055|       |
 2056|      0|      if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2057|      0|	log_debug ("increasing temp iobuf from %lu to %lu\n",
 2058|      0|		   (ulong) a->d.size, (ulong) newsize);
 2059|       |
 2060|      0|      a->d.buf = xrealloc (a->d.buf, newsize);
  ------------------
  |  |  111|      0|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 2061|      0|      a->d.size = newsize;
 2062|      0|      return 0;
 2063|      0|    }
 2064|      1|  else if (a->use != IOBUF_OUTPUT)
  ------------------
  |  Branch (2064:12): [True: 0, False: 1]
  ------------------
 2065|      0|    log_bug ("flush on non-output iobuf\n");
 2066|      1|  else if (!a->filter)
  ------------------
  |  Branch (2066:12): [True: 0, False: 1]
  ------------------
 2067|      0|    log_bug ("filter_flush: no filter\n");
 2068|       |
 2069|      1|  if (a->d.len == 0 && a->e_d.buf && a->e_d.len > 0)
  ------------------
  |  Branch (2069:7): [True: 1, False: 0]
  |  Branch (2069:24): [True: 0, False: 1]
  |  Branch (2069:38): [True: 0, False: 0]
  ------------------
 2070|      0|    {
 2071|      0|      src_buf = a->e_d.buf;
 2072|      0|      src_len = a->e_d.len;
 2073|      0|      external_used = 1;
 2074|      0|    }
 2075|      1|  else
 2076|      1|    {
 2077|      1|      src_buf = a->d.buf;
 2078|      1|      src_len = a->d.len;
 2079|      1|      external_used = 0;
 2080|      1|    }
 2081|       |
 2082|      1|  len = src_len;
 2083|      1|  rc = a->filter (a->filter_ov, IOBUFCTRL_FLUSH, a->chain, src_buf, &len);
 2084|      1|  if (!rc && len != src_len)
  ------------------
  |  Branch (2084:7): [True: 1, False: 0]
  |  Branch (2084:14): [True: 0, False: 1]
  ------------------
 2085|      0|    {
 2086|      0|      log_info ("filter_flush did not write all!\n");
 2087|      0|      rc = GPG_ERR_INTERNAL;
 2088|      0|    }
 2089|      1|  else if (rc)
  ------------------
  |  Branch (2089:12): [True: 0, False: 1]
  ------------------
 2090|      0|    a->error = rc;
 2091|      1|  a->d.len = 0;
 2092|      1|  if (external_used)
  ------------------
  |  Branch (2092:7): [True: 0, False: 1]
  ------------------
 2093|      0|    a->e_d.used = len;
 2094|       |
 2095|      1|  return rc;
 2096|      1|}
iobuf.c:underflow:
 1833|  1.05G|{
 1834|  1.05G|  return underflow_target (a, clear_pending_eof, 1);
 1835|  1.05G|}
iobuf.c:underflow_target:
 1844|  1.05G|{
 1845|  1.05G|  size_t len;
 1846|  1.05G|  int rc;
 1847|       |
 1848|  1.05G|  if (DBG_IOBUF)
  ------------------
  |  |   98|  1.05G|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.05G]
  |  |  ------------------
  ------------------
 1849|      0|    log_debug ("iobuf-%d.%d: underflow: buffer size: %d; still buffered: %d => space for %d bytes\n",
 1850|      0|	       a->no, a->subno,
 1851|      0|	       (int) a->d.size, (int) (a->d.len - a->d.start),
 1852|      0|	       (int) (a->d.size - (a->d.len - a->d.start)));
 1853|       |
 1854|  1.05G|  if (a->use == IOBUF_INPUT_TEMP)
  ------------------
  |  Branch (1854:7): [True: 0, False: 1.05G]
  ------------------
 1855|       |    /* By definition, there isn't more data to read into the
 1856|       |       buffer.  */
 1857|      0|    return -1;
 1858|       |
 1859|  1.05G|  assert (a->use == IOBUF_INPUT);
 1860|       |
 1861|  1.05G|  a->e_d.used = 0;
 1862|       |
 1863|       |  /* If there is still some buffered data, then move it to the start
 1864|       |     of the buffer and try to fill the end of the buffer.  (This is
 1865|       |     useful if we are called from iobuf_peek().)  */
 1866|  1.05G|  assert (a->d.start <= a->d.len);
 1867|  1.05G|  a->d.len -= a->d.start;
 1868|  1.05G|  if (a->d.len)
  ------------------
  |  Branch (1868:7): [True: 62, False: 1.05G]
  ------------------
 1869|     62|    memmove (a->d.buf, &a->d.buf[a->d.start], a->d.len);
 1870|  1.05G|  a->d.start = 0;
 1871|       |
 1872|  1.05G|  if (a->d.len < target && a->filter_eof)
  ------------------
  |  Branch (1872:7): [True: 1.05G, False: 0]
  |  Branch (1872:28): [True: 10.2k, False: 1.05G]
  ------------------
 1873|       |    /* The last time we tried to read from this filter, we got an EOF.
 1874|       |       We couldn't return the EOF, because there was buffered data.
 1875|       |       Since there is no longer any buffered data, return the
 1876|       |       error.  */
 1877|  10.2k|    {
 1878|  10.2k|      if (DBG_IOBUF)
  ------------------
  |  |   98|  10.2k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 10.2k]
  |  |  ------------------
  ------------------
 1879|      0|	log_debug ("iobuf-%d.%d: underflow: eof (pending eof)\n",
 1880|      0|		   a->no, a->subno);
 1881|  10.2k|      if (! clear_pending_eof)
  ------------------
  |  Branch (1881:11): [True: 31, False: 10.2k]
  ------------------
 1882|     31|	return -1;
 1883|       |
 1884|  10.2k|      if (a->chain)
  ------------------
  |  Branch (1884:11): [True: 114, False: 10.1k]
  ------------------
 1885|       |	/* A filter follows this one.  Free this filter.  */
 1886|    114|	{
 1887|    114|	  iobuf_t b = a->chain;
 1888|    114|	  if (DBG_IOBUF)
  ------------------
  |  |   98|    114|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 114]
  |  |  ------------------
  ------------------
 1889|      0|	    log_debug ("iobuf-%d.%d: filter popped (pending EOF returned)\n",
 1890|      0|		       a->no, a->subno);
 1891|    114|	  xfree (a->d.buf);
  ------------------
  |  |  104|    114|#define xfree(a)         gcry_free ((a))
  ------------------
 1892|    114|	  xfree (a->real_fname);
  ------------------
  |  |  104|    114|#define xfree(a)         gcry_free ((a))
  ------------------
 1893|    114|	  memcpy (a, b, sizeof *a);
 1894|    114|	  xfree (b);
  ------------------
  |  |  104|    114|#define xfree(a)         gcry_free ((a))
  ------------------
 1895|    114|	  print_chain (a);
 1896|    114|	}
 1897|  10.1k|      else
 1898|  10.1k|	a->filter_eof = 0;	/* for the top level filter */
 1899|  10.2k|      return -1;		/* return one(!) EOF */
 1900|  10.2k|    }
 1901|       |
 1902|  1.05G|  if (a->d.len == 0 && a->error)
  ------------------
  |  Branch (1902:7): [True: 1.05G, False: 31]
  |  Branch (1902:24): [True: 30.3k, False: 1.05G]
  ------------------
 1903|       |    /* The last time we tried to read from this filter, we got an
 1904|       |       error.  We couldn't return the error, because there was
 1905|       |       buffered data.  Since there is no longer any buffered data,
 1906|       |       return the error.  */
 1907|  30.3k|    {
 1908|  30.3k|      if (DBG_IOBUF)
  ------------------
  |  |   98|  30.3k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 30.3k]
  |  |  ------------------
  ------------------
 1909|      0|	log_debug ("iobuf-%d.%d: pending error (%s) returned\n",
 1910|      0|		   a->no, a->subno, gpg_strerror (a->error));
 1911|  30.3k|      return -1;
 1912|  30.3k|    }
 1913|       |
 1914|  1.05G|  if (a->filter && ! a->filter_eof && ! a->error)
  ------------------
  |  Branch (1914:7): [True: 132k, False: 1.05G]
  |  Branch (1914:20): [True: 132k, False: 0]
  |  Branch (1914:39): [True: 132k, False: 0]
  ------------------
 1915|       |    /* We have a filter function and the last time we tried to read we
 1916|       |       didn't get an EOF or an error.  Try to fill the buffer.  */
 1917|   132k|    {
 1918|       |      /* Be careful to account for any buffered data.  */
 1919|   132k|      len = a->d.size - a->d.len;
 1920|       |
 1921|   132k|      if (a->e_d.preferred && a->d.len < IOBUF_ZEROCOPY_THRESHOLD_SIZE
  ------------------
  |  |   71|   146k|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (1921:11): [True: 14.2k, False: 117k]
  |  Branch (1921:31): [True: 14.2k, False: 0]
  ------------------
 1922|   132k|	  && (IOBUF_ZEROCOPY_THRESHOLD_SIZE - a->d.len) < len)
  ------------------
  |  |   71|  14.2k|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (1922:7): [True: 14.2k, False: 0]
  ------------------
 1923|  14.2k|	{
 1924|  14.2k|	  if (DBG_IOBUF)
  ------------------
  |  |   98|  14.2k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 14.2k]
  |  |  ------------------
  ------------------
 1925|      0|	    log_debug ("iobuf-%d.%d: limit buffering as external drain is "
 1926|      0|			"preferred\n",  a->no, a->subno);
 1927|  14.2k|	  len = IOBUF_ZEROCOPY_THRESHOLD_SIZE - a->d.len;
  ------------------
  |  |   71|  14.2k|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
 1928|  14.2k|	}
 1929|       |
 1930|   132k|      if (len == 0)
  ------------------
  |  Branch (1930:11): [True: 0, False: 132k]
  ------------------
 1931|       |	/* There is no space for more data.  Don't bother calling
 1932|       |	   A->FILTER.  */
 1933|      0|	rc = 0;
 1934|   132k|      else
 1935|   132k|      {
 1936|       |	/* If no buffered data and drain buffer has been setup, and drain
 1937|       |	 * buffer is largish, read data directly to drain buffer. */
 1938|   132k|	if (a->d.len == 0
  ------------------
  |  Branch (1938:6): [True: 132k, False: 31]
  ------------------
 1939|   132k|	    && a->e_d.buf
  ------------------
  |  Branch (1939:9): [True: 745, False: 131k]
  ------------------
 1940|   132k|	    && a->e_d.len >= IOBUF_ZEROCOPY_THRESHOLD_SIZE)
  ------------------
  |  |   71|    745|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (1940:9): [True: 745, False: 0]
  ------------------
 1941|    745|	  {
 1942|    745|	    len = a->e_d.len;
 1943|       |
 1944|    745|	    if (DBG_IOBUF)
  ------------------
  |  |   98|    745|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 745]
  |  |  ------------------
  ------------------
 1945|      0|	      log_debug ("iobuf-%d.%d: underflow: A->FILTER (%lu bytes, to external drain)\n",
 1946|      0|			 a->no, a->subno, (ulong)len);
 1947|       |
 1948|    745|	    rc = a->filter (a->filter_ov, IOBUFCTRL_UNDERFLOW, a->chain,
 1949|    745|			    a->e_d.buf, &len);
 1950|    745|	    a->e_d.used = len;
 1951|    745|	    len = 0;
 1952|    745|	  }
 1953|   131k|	else
 1954|   131k|	  {
 1955|   131k|	    if (DBG_IOBUF)
  ------------------
  |  |   98|   131k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 131k]
  |  |  ------------------
  ------------------
 1956|      0|	      log_debug ("iobuf-%d.%d: underflow: A->FILTER (%lu bytes)\n",
 1957|      0|			 a->no, a->subno, (ulong)len);
 1958|       |
 1959|   131k|	    rc = a->filter (a->filter_ov, IOBUFCTRL_UNDERFLOW, a->chain,
 1960|   131k|			    &a->d.buf[a->d.len], &len);
 1961|   131k|	  }
 1962|   132k|      }
 1963|   132k|      a->d.len += len;
 1964|       |
 1965|   132k|      if (DBG_IOBUF)
  ------------------
  |  |   98|   132k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 132k]
  |  |  ------------------
  ------------------
 1966|      0|	log_debug ("iobuf-%d.%d: A->FILTER() returned rc=%d (%s), read %lu bytes%s\n",
 1967|      0|		   a->no, a->subno,
 1968|      0|		   rc, rc == 0 ? "ok" : rc == -1 ? "EOF" : gpg_strerror (rc),
  ------------------
  |  Branch (1968:10): [True: 0, False: 0]
  |  Branch (1968:27): [True: 0, False: 0]
  ------------------
 1969|      0|		   (ulong)(a->e_d.used ? a->e_d.used : len),
  ------------------
  |  Branch (1969:14): [True: 0, False: 0]
  ------------------
 1970|      0|		   a->e_d.used ? " (to external buffer)" : "");
  ------------------
  |  Branch (1970:6): [True: 0, False: 0]
  ------------------
 1971|       |/*  	    if( a->no == 1 ) */
 1972|       |/*                   log_hexdump ("     data:", a->d.buf, len); */
 1973|       |
 1974|   132k|      if (rc == -1)
  ------------------
  |  Branch (1974:11): [True: 47.1k, False: 84.9k]
  ------------------
 1975|       |	/* EOF.  */
 1976|  47.1k|	{
 1977|  47.1k|	  size_t dummy_len = 0;
 1978|       |
 1979|       |	  /* Tell the filter to free itself */
 1980|  47.1k|	  if ((rc = a->filter (a->filter_ov, IOBUFCTRL_FREE, a->chain,
  ------------------
  |  Branch (1980:8): [True: 0, False: 47.1k]
  ------------------
 1981|  47.1k|			       NULL, &dummy_len)))
 1982|      0|	    log_error ("IOBUFCTRL_FREE failed: %s\n", gpg_strerror (rc));
 1983|       |
 1984|       |	  /* Free everything except for the internal buffer.  */
 1985|  47.1k|	  if (a->filter_ov && a->filter_ov_owner)
  ------------------
  |  Branch (1985:8): [True: 47.1k, False: 0]
  |  Branch (1985:24): [True: 0, False: 47.1k]
  ------------------
 1986|      0|	    xfree (a->filter_ov);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1987|  47.1k|	  a->filter_ov = NULL;
 1988|  47.1k|	  a->filter = NULL;
 1989|  47.1k|	  a->filter_eof = 1;
 1990|       |
 1991|  47.1k|	  if (clear_pending_eof && a->d.len == 0 && a->e_d.used == 0
  ------------------
  |  Branch (1991:8): [True: 47.1k, False: 31]
  |  Branch (1991:29): [True: 47.0k, False: 105]
  |  Branch (1991:46): [True: 47.0k, False: 10]
  ------------------
 1992|  47.1k|	      && a->chain)
  ------------------
  |  Branch (1992:11): [True: 35.1k, False: 11.8k]
  ------------------
 1993|       |	    /* We don't need to keep this filter around at all:
 1994|       |
 1995|       |	         - we got an EOF
 1996|       |		 - we have no buffered data
 1997|       |		 - a filter follows this one.
 1998|       |
 1999|       |	      Unlink this filter.  */
 2000|  35.1k|	    {
 2001|  35.1k|	      iobuf_t b = a->chain;
 2002|  35.1k|	      if (DBG_IOBUF)
  ------------------
  |  |   98|  35.1k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 35.1k]
  |  |  ------------------
  ------------------
 2003|      0|		log_debug ("iobuf-%d.%d: pop in underflow (nothing buffered, got EOF)\n",
 2004|      0|			   a->no, a->subno);
 2005|  35.1k|	      xfree (a->d.buf);
  ------------------
  |  |  104|  35.1k|#define xfree(a)         gcry_free ((a))
  ------------------
 2006|  35.1k|	      xfree (a->real_fname);
  ------------------
  |  |  104|  35.1k|#define xfree(a)         gcry_free ((a))
  ------------------
 2007|  35.1k|	      memcpy (a, b, sizeof *a);
 2008|  35.1k|	      xfree (b);
  ------------------
  |  |  104|  35.1k|#define xfree(a)         gcry_free ((a))
  ------------------
 2009|       |
 2010|  35.1k|	      print_chain (a);
 2011|       |
 2012|  35.1k|	      return -1;
 2013|  35.1k|	    }
 2014|  12.0k|	  else if (a->d.len == 0 && a->e_d.used == 0)
  ------------------
  |  Branch (2014:13): [True: 11.8k, False: 136]
  |  Branch (2014:30): [True: 11.8k, False: 10]
  ------------------
 2015|       |	    /* We can't unlink this filter (it is the only one in the
 2016|       |	       pipeline), but we can immediately return EOF.  */
 2017|  11.8k|	    return -1;
 2018|  47.1k|	}
 2019|  84.9k|      else if (rc)
  ------------------
  |  Branch (2019:16): [True: 2.09k, False: 82.8k]
  ------------------
 2020|       |	/* Record the error.  */
 2021|  2.09k|	{
 2022|  2.09k|	  a->error = rc;
 2023|       |
 2024|  2.09k|	  if (a->d.len == 0 && a->e_d.used == 0)
  ------------------
  |  Branch (2024:8): [True: 943, False: 1.14k]
  |  Branch (2024:25): [True: 942, False: 1]
  ------------------
 2025|       |	    /* There is no buffered data.  Immediately return EOF.  */
 2026|    942|	    return -1;
 2027|  2.09k|	}
 2028|   132k|    }
 2029|       |
 2030|  1.05G|  assert (a->d.start <= a->d.len);
 2031|  1.05G|  if (a->e_d.used > 0)
  ------------------
  |  Branch (2031:7): [True: 502, False: 1.05G]
  ------------------
 2032|    502|    return 0;
 2033|  1.05G|  if (a->d.start < a->d.len)
  ------------------
  |  Branch (2033:7): [True: 78.8k, False: 1.05G]
  ------------------
 2034|  78.8k|    return a->d.buf[a->d.start++];
 2035|       |
 2036|       |  /* EOF.  */
 2037|  1.05G|  return -1;
 2038|  1.05G|}
iobuf.c:block_filter:
  837|   148k|{
  838|   148k|  block_filter_ctx_t *a = opaque;
  839|   148k|  char *buf = (char *)buffer;
  840|   148k|  size_t size = *ret_len;
  841|   148k|  int c, needed, rc = 0;
  842|   148k|  char *p;
  843|       |
  844|   148k|  if (control == IOBUFCTRL_UNDERFLOW)
  ------------------
  |  Branch (844:7): [True: 78.9k, False: 69.7k]
  ------------------
  845|  78.9k|    {
  846|  78.9k|      size_t n = 0;
  847|       |
  848|  78.9k|      p = buf;
  849|  78.9k|      assert (size);		/* need a buffer */
  850|  78.9k|      if (a->eof)		/* don't read any further */
  ------------------
  |  Branch (850:11): [True: 32.8k, False: 46.0k]
  ------------------
  851|  32.8k|	rc = -1;
  852|   156k|      while (!rc && size)
  ------------------
  |  Branch (852:14): [True: 122k, False: 33.9k]
  |  Branch (852:21): [True: 111k, False: 11.3k]
  ------------------
  853|   111k|	{
  854|   111k|	  if (!a->size)
  ------------------
  |  Branch (854:8): [True: 99.9k, False: 11.1k]
  ------------------
  855|  99.9k|	    {			/* get the length bytes */
  856|  99.9k|	      if (a->partial == 2)
  ------------------
  |  Branch (856:12): [True: 25.0k, False: 74.8k]
  ------------------
  857|  25.0k|		{
  858|  25.0k|		  a->eof = 1;
  859|  25.0k|		  if (!n)
  ------------------
  |  Branch (859:9): [True: 10, False: 25.0k]
  ------------------
  860|     10|		    rc = -1;
  861|  25.0k|		  break;
  862|  25.0k|		}
  863|  74.8k|	      else if (a->partial)
  ------------------
  |  Branch (863:17): [True: 74.8k, False: 0]
  ------------------
  864|  74.8k|		{
  865|       |		  /* These OpenPGP introduced huffman like encoded length
  866|       |		   * bytes are really a mess :-( */
  867|  74.8k|		  if (a->first_c)
  ------------------
  |  Branch (867:9): [True: 34.8k, False: 40.0k]
  ------------------
  868|  34.8k|		    {
  869|  34.8k|		      c = a->first_c;
  870|  34.8k|		      a->first_c = 0;
  871|  34.8k|		    }
  872|  40.0k|		  else if ((c = iobuf_get (chain)) == -1)
  ------------------
  |  |  500|  40.0k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 40.0k]
  |  |  |  Branch (500:24): [True: 3.78k, False: 36.2k]
  |  |  ------------------
  |  |  501|  40.0k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (872:14): [True: 725, False: 39.3k]
  ------------------
  873|    725|		    {
  874|    725|		      log_error ("block_filter: 1st length byte missing\n");
  875|    725|		      rc = GPG_ERR_BAD_DATA;
  876|    725|		      break;
  877|    725|		    }
  878|  74.1k|		  if (c < 192)
  ------------------
  |  Branch (878:9): [True: 31.2k, False: 42.9k]
  ------------------
  879|  31.2k|		    {
  880|  31.2k|		      a->size = c;
  881|  31.2k|		      a->partial = 2;
  882|  31.2k|		      if (!a->size)
  ------------------
  |  Branch (882:13): [True: 7.48k, False: 23.7k]
  ------------------
  883|  7.48k|			{
  884|  7.48k|			  a->eof = 1;
  885|  7.48k|			  if (!n)
  ------------------
  |  Branch (885:10): [True: 15, False: 7.47k]
  ------------------
  886|     15|			    rc = -1;
  887|  7.48k|			  break;
  888|  7.48k|			}
  889|  31.2k|		    }
  890|  42.9k|		  else if (c < 224)
  ------------------
  |  Branch (890:14): [True: 370, False: 42.5k]
  ------------------
  891|    370|		    {
  892|    370|		      a->size = (c - 192) * 256;
  893|    370|		      if ((c = iobuf_get (chain)) == -1)
  ------------------
  |  |  500|    370|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 370]
  |  |  |  Branch (500:24): [True: 35, False: 335]
  |  |  ------------------
  |  |  501|    370|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (893:13): [True: 11, False: 359]
  ------------------
  894|     11|			{
  895|     11|			  log_error
  896|     11|			    ("block_filter: 2nd length byte missing\n");
  897|     11|			  rc = GPG_ERR_BAD_DATA;
  898|     11|			  break;
  899|     11|			}
  900|    359|		      a->size += c + 192;
  901|    359|		      a->partial = 2;
  902|    359|		      if (!a->size)
  ------------------
  |  Branch (902:13): [True: 0, False: 359]
  ------------------
  903|      0|			{
  904|      0|			  a->eof = 1;
  905|      0|			  if (!n)
  ------------------
  |  Branch (905:10): [True: 0, False: 0]
  ------------------
  906|      0|			    rc = -1;
  907|      0|			  break;
  908|      0|			}
  909|    359|		    }
  910|  42.5k|		  else if (c == 255)
  ------------------
  |  Branch (910:14): [True: 1.57k, False: 40.9k]
  ------------------
  911|  1.57k|		    {
  912|  1.57k|                      size_t len = 0;
  913|  1.57k|                      int i;
  914|       |
  915|  7.79k|                      for (i = 0; i < 4; i++)
  ------------------
  |  Branch (915:35): [True: 6.25k, False: 1.54k]
  ------------------
  916|  6.25k|                        if ((c = iobuf_get (chain)) == -1)
  ------------------
  |  |  500|  6.25k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 6.25k]
  |  |  |  Branch (500:24): [True: 40, False: 6.21k]
  |  |  ------------------
  |  |  501|  6.25k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (916:29): [True: 33, False: 6.22k]
  ------------------
  917|     33|                          break;
  918|  6.22k|                        else
  919|  6.22k|                          len = ((len << 8) | c);
  920|       |
  921|  1.57k|                      if (i < 4)
  ------------------
  |  Branch (921:27): [True: 33, False: 1.54k]
  ------------------
  922|     33|			{
  923|     33|			  log_error ("block_filter: invalid 4 byte length\n");
  924|     33|			  rc = GPG_ERR_BAD_DATA;
  925|     33|			  break;
  926|     33|			}
  927|  1.54k|                      a->size = len;
  928|  1.54k|                      a->partial = 2;
  929|  1.54k|                      if (!a->size)
  ------------------
  |  Branch (929:27): [True: 362, False: 1.18k]
  ------------------
  930|    362|                        {
  931|    362|                          a->eof = 1;
  932|    362|                          if (!n)
  ------------------
  |  Branch (932:31): [True: 1, False: 361]
  ------------------
  933|      1|                            rc = -1;
  934|    362|                          break;
  935|    362|			}
  936|  1.54k|		    }
  937|  40.9k|		  else
  938|  40.9k|		    { /* Next partial body length. */
  939|  40.9k|		      a->size = 1 << (c & 0x1f);
  940|  40.9k|		    }
  941|       |		  /*  log_debug("partial: ctx=%p c=%02x size=%u\n", a, c, a->size); */
  942|  74.1k|		}
  943|      0|	      else
  944|      0|		BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  945|  99.9k|	    }
  946|       |
  947|   154k|	  while (!rc && size && a->size)
  ------------------
  |  Branch (947:11): [True: 153k, False: 1.13k]
  |  Branch (947:18): [True: 142k, False: 11.3k]
  |  Branch (947:26): [True: 77.4k, False: 65.0k]
  ------------------
  948|  77.4k|	    {
  949|  77.4k|	      needed = size < a->size ? size : a->size;
  ------------------
  |  Branch (949:17): [True: 12.0k, False: 65.3k]
  ------------------
  950|  77.4k|	      c = iobuf_read (chain, p, needed);
  951|  77.4k|	      if (c < needed)
  ------------------
  |  Branch (951:12): [True: 1.13k, False: 76.3k]
  ------------------
  952|  1.13k|		{
  953|  1.13k|		  if (c == -1)
  ------------------
  |  Branch (953:9): [True: 238, False: 899]
  ------------------
  954|    238|		    c = 0;
  955|  1.13k|		  log_error
  956|  1.13k|		    ("block_filter %p: read error (size=%lu,a->size=%lu)\n",
  957|  1.13k|		     a, (ulong) size + c, (ulong) a->size + c);
  958|  1.13k|		  rc = GPG_ERR_BAD_DATA;
  959|  1.13k|		}
  960|  76.3k|	      else
  961|  76.3k|		{
  962|  76.3k|		  size -= c;
  963|  76.3k|		  a->size -= c;
  964|  76.3k|		  p += c;
  965|  76.3k|		  n += c;
  966|  76.3k|		}
  967|  77.4k|	    }
  968|  77.4k|	}
  969|  78.9k|      *ret_len = n;
  970|  78.9k|    }
  971|  69.7k|  else if (control == IOBUFCTRL_FLUSH)
  ------------------
  |  Branch (971:12): [True: 0, False: 69.7k]
  ------------------
  972|      0|    {
  973|      0|      if (a->partial)
  ------------------
  |  Branch (973:11): [True: 0, False: 0]
  ------------------
  974|      0|	{			/* the complicated openpgp scheme */
  975|      0|	  size_t blen, n, nbytes = size + a->buflen;
  976|       |
  977|      0|	  assert (a->buflen <= OP_MIN_PARTIAL_CHUNK);
  978|      0|	  if (nbytes < OP_MIN_PARTIAL_CHUNK)
  ------------------
  |  |  144|      0|#define OP_MIN_PARTIAL_CHUNK	  512
  ------------------
  |  Branch (978:8): [True: 0, False: 0]
  ------------------
  979|      0|	    {
  980|       |	      /* not enough to write a partial block out; so we store it */
  981|      0|	      if (!a->buffer)
  ------------------
  |  Branch (981:12): [True: 0, False: 0]
  ------------------
  982|      0|		a->buffer = xmalloc (OP_MIN_PARTIAL_CHUNK);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  983|      0|	      memcpy (a->buffer + a->buflen, buf, size);
  984|      0|	      a->buflen += size;
  985|      0|	    }
  986|      0|	  else
  987|      0|	    {			/* okay, we can write out something */
  988|       |	      /* do this in a loop to use the most efficient block lengths */
  989|      0|	      p = buf;
  990|      0|	      do
  991|      0|		{
  992|       |		  /* find the best matching block length - this is limited
  993|       |		   * by the size of the internal buffering */
  994|      0|		  for (blen = OP_MIN_PARTIAL_CHUNK * 2,
  ------------------
  |  |  144|      0|#define OP_MIN_PARTIAL_CHUNK	  512
  ------------------
  995|      0|		       c = OP_MIN_PARTIAL_CHUNK_2POW + 1; blen <= nbytes;
  ------------------
  |  |  145|      0|#define OP_MIN_PARTIAL_CHUNK_2POW 9
  ------------------
  |  Branch (995:45): [True: 0, False: 0]
  ------------------
  996|      0|		       blen *= 2, c++)
  997|      0|		    ;
  998|      0|		  blen /= 2;
  999|      0|		  c--;
 1000|       |		  /* write the partial length header */
 1001|      0|		  assert (c <= 0x1f);	/*;-) */
 1002|      0|		  c |= 0xe0;
 1003|      0|		  iobuf_put (chain, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1004|      0|		  if ((n = a->buflen))
  ------------------
  |  Branch (1004:9): [True: 0, False: 0]
  ------------------
 1005|      0|		    {		/* write stuff from the buffer */
 1006|      0|		      assert (n == OP_MIN_PARTIAL_CHUNK);
 1007|      0|		      if (iobuf_write (chain, a->buffer, n))
  ------------------
  |  Branch (1007:13): [True: 0, False: 0]
  ------------------
 1008|      0|			rc = gpg_error_from_syserror ();
 1009|      0|		      a->buflen = 0;
 1010|      0|		      nbytes -= n;
 1011|      0|		    }
 1012|      0|		  if ((n = nbytes) > blen)
  ------------------
  |  Branch (1012:9): [True: 0, False: 0]
  ------------------
 1013|      0|		    n = blen;
 1014|      0|		  if (n && iobuf_write (chain, p, n))
  ------------------
  |  Branch (1014:9): [True: 0, False: 0]
  |  Branch (1014:14): [True: 0, False: 0]
  ------------------
 1015|      0|		    rc = gpg_error_from_syserror ();
 1016|      0|		  p += n;
 1017|      0|		  nbytes -= n;
 1018|      0|		}
 1019|      0|	      while (!rc && nbytes >= OP_MIN_PARTIAL_CHUNK);
  ------------------
  |  |  144|      0|#define OP_MIN_PARTIAL_CHUNK	  512
  ------------------
  |  Branch (1019:15): [True: 0, False: 0]
  |  Branch (1019:22): [True: 0, False: 0]
  ------------------
 1020|       |	      /* store the rest in the buffer */
 1021|      0|	      if (!rc && nbytes)
  ------------------
  |  Branch (1021:12): [True: 0, False: 0]
  |  Branch (1021:19): [True: 0, False: 0]
  ------------------
 1022|      0|		{
 1023|      0|		  assert (!a->buflen);
 1024|      0|		  assert (nbytes < OP_MIN_PARTIAL_CHUNK);
 1025|      0|		  if (!a->buffer)
  ------------------
  |  Branch (1025:9): [True: 0, False: 0]
  ------------------
 1026|      0|		    a->buffer = xmalloc (OP_MIN_PARTIAL_CHUNK);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1027|      0|		  memcpy (a->buffer, p, nbytes);
 1028|      0|		  a->buflen = nbytes;
 1029|      0|		}
 1030|      0|	    }
 1031|      0|	}
 1032|      0|      else
 1033|      0|	BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1034|      0|    }
 1035|  69.7k|  else if (control == IOBUFCTRL_INIT)
  ------------------
  |  Branch (1035:12): [True: 34.8k, False: 34.8k]
  ------------------
 1036|  34.8k|    {
 1037|  34.8k|      if (DBG_IOBUF)
  ------------------
  |  |   98|  34.8k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 34.8k]
  |  |  ------------------
  ------------------
 1038|      0|	log_debug ("init block_filter %p\n", a);
 1039|  34.8k|      if (a->partial)
  ------------------
  |  Branch (1039:11): [True: 34.8k, False: 0]
  ------------------
 1040|  34.8k|	a->count = 0;
 1041|      0|      else if (a->use == IOBUF_INPUT)
  ------------------
  |  Branch (1041:16): [True: 0, False: 0]
  ------------------
 1042|      0|	a->count = a->size = 0;
 1043|      0|      else
 1044|      0|	a->count = a->size;	/* force first length bytes */
 1045|  34.8k|      a->eof = 0;
 1046|  34.8k|      a->buffer = NULL;
 1047|  34.8k|      a->buflen = 0;
 1048|  34.8k|    }
 1049|  34.8k|  else if (control == IOBUFCTRL_DESC)
  ------------------
  |  Branch (1049:12): [True: 0, False: 34.8k]
  ------------------
 1050|      0|    {
 1051|      0|      mem2str (buf, "block_filter", *ret_len);
 1052|      0|    }
 1053|  34.8k|  else if (control == IOBUFCTRL_FREE)
  ------------------
  |  Branch (1053:12): [True: 34.8k, False: 0]
  ------------------
 1054|  34.8k|    {
 1055|  34.8k|      if (a->use == IOBUF_OUTPUT)
  ------------------
  |  Branch (1055:11): [True: 0, False: 34.8k]
  ------------------
 1056|      0|	{			/* write the end markers */
 1057|      0|	  if (a->partial)
  ------------------
  |  Branch (1057:8): [True: 0, False: 0]
  ------------------
 1058|      0|	    {
 1059|      0|	      u32 len;
 1060|       |	      /* write out the remaining bytes without a partial header
 1061|       |	       * the length of this header may be 0 - but if it is
 1062|       |	       * the first block we are not allowed to use a partial header
 1063|       |	       * and frankly we can't do so, because this length must be
 1064|       |	       * a power of 2. This is _really_ complicated because we
 1065|       |	       * have to check the possible length of a packet prior
 1066|       |	       * to it's creation: a chain of filters becomes complicated
 1067|       |	       * and we need a lot of code to handle compressed packets etc.
 1068|       |	       *   :-(((((((
 1069|       |	       */
 1070|       |	      /* construct header */
 1071|      0|	      len = a->buflen;
 1072|       |	      /*log_debug("partial: remaining length=%u\n", len ); */
 1073|      0|	      if (len < 192)
  ------------------
  |  Branch (1073:12): [True: 0, False: 0]
  ------------------
 1074|      0|		rc = iobuf_put (chain, len);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1075|      0|	      else if (len < 8384)
  ------------------
  |  Branch (1075:17): [True: 0, False: 0]
  ------------------
 1076|      0|		{
 1077|      0|		  if (!(rc = iobuf_put (chain, ((len - 192) / 256) + 192)))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1077:9): [True: 0, False: 0]
  ------------------
 1078|      0|		    rc = iobuf_put (chain, ((len - 192) % 256));
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1079|      0|		}
 1080|      0|	      else
 1081|      0|		{		/* use a 4 byte header */
 1082|      0|		  if (!(rc = iobuf_put (chain, 0xff)))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1082:9): [True: 0, False: 0]
  ------------------
 1083|      0|		    if (!(rc = iobuf_put (chain, (len >> 24) & 0xff)))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1083:11): [True: 0, False: 0]
  ------------------
 1084|      0|		      if (!(rc = iobuf_put (chain, (len >> 16) & 0xff)))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1084:13): [True: 0, False: 0]
  ------------------
 1085|      0|			if (!(rc = iobuf_put (chain, (len >> 8) & 0xff)))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1085:8): [True: 0, False: 0]
  ------------------
 1086|      0|			  rc = iobuf_put (chain, len & 0xff);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1087|      0|		}
 1088|      0|	      if (!rc && len)
  ------------------
  |  Branch (1088:12): [True: 0, False: 0]
  |  Branch (1088:19): [True: 0, False: 0]
  ------------------
 1089|      0|		rc = iobuf_write (chain, a->buffer, len);
 1090|      0|	      if (rc)
  ------------------
  |  Branch (1090:12): [True: 0, False: 0]
  ------------------
 1091|      0|		{
 1092|      0|		  log_error ("block_filter: write error: %s\n",
 1093|      0|			     strerror (errno));
 1094|      0|		  rc = gpg_error_from_syserror ();
 1095|      0|		}
 1096|      0|	      xfree (a->buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1097|      0|	      a->buffer = NULL;
 1098|      0|	      a->buflen = 0;
 1099|      0|	    }
 1100|      0|	  else
 1101|      0|	    BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1102|      0|	}
 1103|  34.8k|      else if (a->size)
  ------------------
  |  Branch (1103:16): [True: 1.23k, False: 33.6k]
  ------------------
 1104|  1.23k|	{
 1105|  1.23k|	  log_error ("block_filter: pending bytes!\n");
 1106|  1.23k|	}
 1107|  34.8k|      if (DBG_IOBUF)
  ------------------
  |  |   98|  34.8k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 34.8k]
  |  |  ------------------
  ------------------
 1108|      0|	log_debug ("free block_filter %p\n", a);
 1109|  34.8k|      xfree (a);		/* we can free our context now */
  ------------------
  |  |  104|  34.8k|#define xfree(a)         gcry_free ((a))
  ------------------
 1110|  34.8k|    }
 1111|       |
 1112|   148k|  return rc;
 1113|   148k|}

has_invalid_email_chars:
  126|  2.81k|{
  127|  2.81k|  const unsigned char *s = buffer;
  128|  2.81k|  int at_seen=0;
  129|  2.81k|  const char *valid_chars=
  130|  2.81k|    "01234567890_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  131|       |
  132|  12.3k|  for ( ; length && *s; length--, s++ )
  ------------------
  |  Branch (132:11): [True: 10.2k, False: 2.11k]
  |  Branch (132:21): [True: 10.2k, False: 0]
  ------------------
  133|  10.2k|    {
  134|  10.2k|      if ((*s & 0x80))
  ------------------
  |  Branch (134:11): [True: 2.95k, False: 7.31k]
  ------------------
  135|  2.95k|        continue; /* We only care about ASCII.  */
  136|  7.31k|      if (*s == '@')
  ------------------
  |  Branch (136:11): [True: 2.38k, False: 4.93k]
  ------------------
  137|  2.38k|        at_seen=1;
  138|  4.93k|      else if (!at_seen && !(strchr (valid_chars, *s)
  ------------------
  |  Branch (138:16): [True: 3.04k, False: 1.88k]
  |  Branch (138:30): [True: 2.20k, False: 844]
  ------------------
  139|  3.04k|                             || strchr ("!#$%&'*+/=?^`{|}~", *s)))
  ------------------
  |  Branch (139:33): [True: 387, False: 457]
  ------------------
  140|    457|        return 1;
  141|  4.47k|      else if (at_seen && !strchr (valid_chars, *s))
  ------------------
  |  Branch (141:16): [True: 1.88k, False: 2.58k]
  |  Branch (141:27): [True: 248, False: 1.63k]
  ------------------
  142|    248|        return 1;
  143|  7.31k|    }
  144|  2.11k|  return 0;
  145|  2.81k|}
is_valid_mailbox_mem:
  152|  2.81k|{
  153|  2.81k|  const char *name = name_arg;
  154|       |
  155|  2.81k|  return !( !name
  ------------------
  |  Branch (155:13): [True: 0, False: 2.81k]
  ------------------
  156|  2.81k|            || !namelen
  ------------------
  |  Branch (156:16): [True: 0, False: 2.81k]
  ------------------
  157|  2.81k|            || has_invalid_email_chars (name, namelen)
  ------------------
  |  Branch (157:16): [True: 705, False: 2.11k]
  ------------------
  158|  2.81k|            || mem_count_chr (name, '@', namelen) != 1
  ------------------
  |  Branch (158:16): [True: 562, False: 1.55k]
  ------------------
  159|  2.81k|            || *name == '@'
  ------------------
  |  Branch (159:16): [True: 207, False: 1.34k]
  ------------------
  160|  2.81k|            || name[namelen-1] == '@'
  ------------------
  |  Branch (160:16): [True: 241, False: 1.10k]
  ------------------
  161|  2.81k|            || name[namelen-1] == '.'
  ------------------
  |  Branch (161:16): [True: 480, False: 624]
  ------------------
  162|  2.81k|            || my_memstr (name, namelen, ".."));
  ------------------
  |  Branch (162:16): [True: 287, False: 337]
  ------------------
  163|  2.81k|}
is_valid_mailbox:
  170|  2.81k|{
  171|  2.81k|  return name? is_valid_mailbox_mem (name, strlen (name)) : 0;
  ------------------
  |  Branch (171:10): [True: 2.81k, False: 0]
  ------------------
  172|  2.81k|}
mailbox_from_userid:
  182|  6.24k|{
  183|  6.24k|  const char *s, *s_end;
  184|  6.24k|  size_t len;
  185|  6.24k|  char *result = NULL;
  186|       |
  187|  6.24k|  s = strchr (userid, '<');
  188|  6.24k|  if (s)
  ------------------
  |  Branch (188:7): [True: 3.42k, False: 2.81k]
  ------------------
  189|  3.42k|    {
  190|       |      /* Seems to be a standard user id.  */
  191|  3.42k|      s++;
  192|  3.42k|      s_end = strchr (s, '>');
  193|  3.42k|      if (s_end && s_end > s)
  ------------------
  |  Branch (193:11): [True: 3.11k, False: 317]
  |  Branch (193:20): [True: 2.87k, False: 239]
  ------------------
  194|  2.87k|        {
  195|  2.87k|          len = s_end - s;
  196|  2.87k|          result = xtrymalloc (len + 1);
  ------------------
  |  |   97|  2.87k|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  197|  2.87k|          if (!result)
  ------------------
  |  Branch (197:15): [True: 0, False: 2.87k]
  ------------------
  198|      0|            return NULL; /* Ooops - out of core.  */
  199|  2.87k|          strncpy (result, s, len);
  200|  2.87k|          result[len] = 0;
  201|       |          /* Apply some basic checks on the address.  We do not use
  202|       |             is_valid_mailbox because those checks are too strict.  */
  203|  2.87k|          if (string_count_chr (result, '@') != 1  /* Need exactly one '@.  */
  ------------------
  |  Branch (203:15): [True: 463, False: 2.40k]
  ------------------
  204|  2.87k|              || *result == '@'           /* local-part missing.  */
  ------------------
  |  Branch (204:18): [True: 99, False: 2.31k]
  ------------------
  205|  2.87k|              || result[len-1] == '@'     /* domain missing.  */
  ------------------
  |  Branch (205:18): [True: 1.44k, False: 868]
  ------------------
  206|  2.87k|              || result[len-1] == '.'     /* ends with a dot.  */
  ------------------
  |  Branch (206:18): [True: 232, False: 636]
  ------------------
  207|  2.87k|              || string_has_ctrl_or_space (result)
  ------------------
  |  Branch (207:18): [True: 196, False: 440]
  ------------------
  208|  2.87k|              || has_dotdot_after_at (result))
  ------------------
  |  Branch (208:18): [True: 18, False: 422]
  ------------------
  209|  2.45k|            {
  210|  2.45k|              xfree (result);
  ------------------
  |  |  104|  2.45k|#define xfree(a)         gcry_free ((a))
  ------------------
  211|  2.45k|              result = NULL;
  212|  2.45k|              errno = EINVAL;
  213|  2.45k|            }
  214|  2.87k|        }
  215|    556|      else
  216|    556|        errno = EINVAL;
  217|  3.42k|    }
  218|  2.81k|  else if (is_valid_mailbox (userid))
  ------------------
  |  Branch (218:12): [True: 337, False: 2.48k]
  ------------------
  219|    337|    {
  220|       |      /* The entire user id is a mailbox.  Return that one.  Note that
  221|       |         this fallback method has some restrictions on the valid
  222|       |         syntax of the mailbox.  However, those who want weird
  223|       |         addresses should know about it and use the regular <...>
  224|       |         syntax.  */
  225|    337|      result = xtrystrdup (userid);
  ------------------
  |  |  103|    337|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
  226|    337|    }
  227|  2.48k|  else
  228|  2.48k|    errno = EINVAL;
  229|       |
  230|  6.24k|  if (result && subaddress == 1)
  ------------------
  |  Branch (230:7): [True: 759, False: 5.48k]
  |  Branch (230:17): [True: 0, False: 759]
  ------------------
  231|      0|    {
  232|      0|      char *atsign, *plus;
  233|       |
  234|      0|      if ((atsign = strchr (result, '@')))
  ------------------
  |  Branch (234:11): [True: 0, False: 0]
  ------------------
  235|      0|        {
  236|       |          /* We consider a subaddress only if there is a single '+'
  237|       |           * in the local part and the '+' is not the first or last
  238|       |           * character.  */
  239|      0|          *atsign = 0;
  240|      0|          if ((plus = strchr (result, '+'))
  ------------------
  |  Branch (240:15): [True: 0, False: 0]
  ------------------
  241|      0|              && !strchr (plus+1, '+')
  ------------------
  |  Branch (241:18): [True: 0, False: 0]
  ------------------
  242|      0|              && result != plus
  ------------------
  |  Branch (242:18): [True: 0, False: 0]
  ------------------
  243|      0|              && plus[1] )
  ------------------
  |  Branch (243:18): [True: 0, False: 0]
  ------------------
  244|      0|            {
  245|      0|              *atsign = '@';
  246|      0|              memmove (plus, atsign, strlen (atsign)+1);
  247|      0|            }
  248|      0|          else
  249|      0|            *atsign = '@';
  250|      0|        }
  251|      0|    }
  252|       |
  253|  6.24k|  return result? ascii_strlwr (result): NULL;
  ------------------
  |  Branch (253:10): [True: 759, False: 5.48k]
  ------------------
  254|  6.24k|}
mbox-util.c:mem_count_chr:
   49|  2.11k|{
   50|  2.11k|  const char *s = buffer;
   51|  2.11k|  int count;
   52|       |
   53|  10.5k|  for (count=0; length; length--, s++)
  ------------------
  |  Branch (53:17): [True: 8.44k, False: 2.11k]
  ------------------
   54|  8.44k|    if (*s == c)
  ------------------
  |  Branch (54:9): [True: 2.11k, False: 6.33k]
  ------------------
   55|  2.11k|      count++;
   56|  2.11k|  return count;
   57|  2.11k|}
mbox-util.c:my_memstr:
   65|    624|{
   66|    624|  const unsigned char *buf = buffer;
   67|    624|  const unsigned char *t = (const unsigned char *)buf;
   68|    624|  const unsigned char *s = (const unsigned char *)sub;
   69|    624|  size_t n = buflen;
   70|       |
   71|  2.51k|  for ( ; n ; t++, n-- )
  ------------------
  |  Branch (71:11): [True: 2.17k, False: 337]
  ------------------
   72|  2.17k|    {
   73|  2.17k|      if (*t == *s)
  ------------------
  |  Branch (73:11): [True: 890, False: 1.28k]
  ------------------
   74|    890|        {
   75|  1.17k|          for (buf = t++, buflen = n--, s++; n && *t ==*s; t++, s++, n--)
  ------------------
  |  Branch (75:46): [True: 1.17k, False: 0]
  |  Branch (75:51): [True: 287, False: 890]
  ------------------
   76|    287|            ;
   77|    890|          if (!*s)
  ------------------
  |  Branch (77:15): [True: 287, False: 603]
  ------------------
   78|    287|            return (const char*)buf;
   79|    603|          t = (const unsigned char *)buf;
   80|    603|          s = (const unsigned char *)sub ;
   81|    603|          n = buflen;
   82|    603|	}
   83|  2.17k|    }
   84|    337|  return NULL;
   85|    624|}
mbox-util.c:string_count_chr:
   38|  2.87k|{
   39|  2.87k|  int count;
   40|       |
   41|  25.0k|  for (count=0; *string; string++ )
  ------------------
  |  Branch (41:17): [True: 22.1k, False: 2.87k]
  ------------------
   42|  22.1k|    if ( *string == c )
  ------------------
  |  Branch (42:10): [True: 3.29k, False: 18.8k]
  ------------------
   43|  3.29k|      count++;
   44|  2.87k|  return count;
   45|  2.87k|}
mbox-util.c:string_has_ctrl_or_space:
   91|    636|{
   92|  5.69k|  for (; *string; string++ )
  ------------------
  |  Branch (92:10): [True: 5.25k, False: 440]
  ------------------
   93|  5.25k|    if (!(*string & 0x80) && *string <= 0x20)
  ------------------
  |  Branch (93:9): [True: 4.44k, False: 808]
  |  Branch (93:30): [True: 196, False: 4.24k]
  ------------------
   94|    196|      return 1;
   95|    440|  return 0;
   96|    636|}
mbox-util.c:has_dotdot_after_at:
  103|    440|{
  104|    440|  string = strchr (string, '@');
  105|    440|  if (!string)
  ------------------
  |  Branch (105:7): [True: 0, False: 440]
  ------------------
  106|      0|    return 0; /* No at-sign.  */
  107|    440|  string++;
  108|    440|  return !!strstr (string, "..");
  109|    440|}

try_make_printable_string:
  277|  6.24k|{
  278|  6.24k|  const unsigned char *p = p_arg;
  279|  6.24k|  size_t save_n, buflen;
  280|  6.24k|  const unsigned char *save_p;
  281|  6.24k|  char *buffer, *d;
  282|       |
  283|       |  /* First count length. */
  284|  52.0k|  for (save_n = n, save_p = p, buflen=1 ; n; n--, p++ )
  ------------------
  |  Branch (284:43): [True: 45.8k, False: 6.24k]
  ------------------
  285|  45.8k|    {
  286|  45.8k|      if ( *p < 0x20 || *p == 0x7f || *p == delim  || (delim && *p=='\\'))
  ------------------
  |  Branch (286:12): [True: 9.15k, False: 36.6k]
  |  Branch (286:25): [True: 710, False: 35.9k]
  |  Branch (286:39): [True: 0, False: 35.9k]
  |  Branch (286:56): [True: 0, False: 35.9k]
  |  Branch (286:65): [True: 0, False: 0]
  ------------------
  287|  9.86k|        {
  288|  9.86k|          if ( *p=='\n' || *p=='\r' || *p=='\f'
  ------------------
  |  Branch (288:16): [True: 344, False: 9.52k]
  |  Branch (288:28): [True: 518, False: 9.00k]
  |  Branch (288:40): [True: 255, False: 8.74k]
  ------------------
  289|  9.86k|               || *p=='\v' || *p=='\b' || !*p )
  ------------------
  |  Branch (289:19): [True: 288, False: 8.46k]
  |  Branch (289:31): [True: 317, False: 8.14k]
  |  Branch (289:43): [True: 3.80k, False: 4.34k]
  ------------------
  290|  5.52k|            buflen += 2;
  291|  4.34k|          else
  292|  4.34k|            buflen += 5;
  293|  9.86k|	}
  294|  35.9k|      else
  295|  35.9k|        buflen++;
  296|  45.8k|    }
  297|  6.24k|  p = save_p;
  298|  6.24k|  n = save_n;
  299|       |  /* And now make the string */
  300|  6.24k|  d = buffer = xtrymalloc (buflen);
  ------------------
  |  |   97|  6.24k|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  301|  52.0k|  for ( ; n; n--, p++ )
  ------------------
  |  Branch (301:11): [True: 45.8k, False: 6.24k]
  ------------------
  302|  45.8k|    {
  303|  45.8k|      if (*p < 0x20 || *p == 0x7f || *p == delim || (delim && *p=='\\')) {
  ------------------
  |  Branch (303:11): [True: 9.15k, False: 36.6k]
  |  Branch (303:24): [True: 710, False: 35.9k]
  |  Branch (303:38): [True: 0, False: 35.9k]
  |  Branch (303:54): [True: 0, False: 35.9k]
  |  Branch (303:63): [True: 0, False: 0]
  ------------------
  304|  9.86k|        *d++ = '\\';
  305|  9.86k|        if( *p == '\n' )
  ------------------
  |  Branch (305:13): [True: 344, False: 9.52k]
  ------------------
  306|    344|          *d++ = 'n';
  307|  9.52k|        else if( *p == '\r' )
  ------------------
  |  Branch (307:18): [True: 518, False: 9.00k]
  ------------------
  308|    518|          *d++ = 'r';
  309|  9.00k|        else if( *p == '\f' )
  ------------------
  |  Branch (309:18): [True: 255, False: 8.74k]
  ------------------
  310|    255|          *d++ = 'f';
  311|  8.74k|        else if( *p == '\v' )
  ------------------
  |  Branch (311:18): [True: 288, False: 8.46k]
  ------------------
  312|    288|          *d++ = 'v';
  313|  8.46k|        else if( *p == '\b' )
  ------------------
  |  Branch (313:18): [True: 317, False: 8.14k]
  ------------------
  314|    317|          *d++ = 'b';
  315|  8.14k|        else if( !*p )
  ------------------
  |  Branch (315:18): [True: 3.80k, False: 4.34k]
  ------------------
  316|  3.80k|          *d++ = '0';
  317|  4.34k|        else {
  318|  4.34k|          sprintf(d, "x%02x", *p );
  319|  4.34k|          d += 3;
  320|  4.34k|        }
  321|  9.86k|      }
  322|  35.9k|      else
  323|  35.9k|        *d++ = *p;
  324|  45.8k|    }
  325|  6.24k|  *d = 0;
  326|  6.24k|  return buffer;
  327|  6.24k|}

openpgp_oidbuf_to_str:
  224|  18.0k|{
  225|  18.0k|  char *string, *p;
  226|  18.0k|  int n = 0;
  227|  18.0k|  unsigned long val, valmask;
  228|       |
  229|  18.0k|  valmask = (unsigned long)0xfe << (8 * (sizeof (valmask) - 1));
  230|       |  /* The first bytes gives the length; check consistency.  */
  231|       |
  232|  18.0k|  if (!len || buf[0] != len -1)
  ------------------
  |  Branch (232:7): [True: 0, False: 18.0k]
  |  Branch (232:15): [True: 0, False: 18.0k]
  ------------------
  233|      0|    {
  234|      0|      gpg_err_set_errno (EINVAL);
  235|      0|      return NULL;
  236|      0|    }
  237|       |  /* Skip length byte.  */
  238|  18.0k|  len--;
  239|  18.0k|  buf++;
  240|       |
  241|       |  /* To calculate the length of the string we can safely assume an
  242|       |     upper limit of 3 decimal characters per byte.  Two extra bytes
  243|       |     account for the special first octet */
  244|  18.0k|  string = p = xtrymalloc (len*(1+3)+2+1);
  ------------------
  |  |   97|  18.0k|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  245|  18.0k|  if (!string)
  ------------------
  |  Branch (245:7): [True: 0, False: 18.0k]
  ------------------
  246|      0|    return NULL;
  247|  18.0k|  if (!len)
  ------------------
  |  Branch (247:7): [True: 0, False: 18.0k]
  ------------------
  248|      0|    {
  249|      0|      *p = 0;
  250|      0|      return string;
  251|      0|    }
  252|       |
  253|  18.0k|  if (buf[0] < 40)
  ------------------
  |  Branch (253:7): [True: 9.08k, False: 8.96k]
  ------------------
  254|  9.08k|    p += sprintf (p, "0.%d", buf[n]);
  255|  8.96k|  else if (buf[0] < 80)
  ------------------
  |  Branch (255:12): [True: 3.17k, False: 5.78k]
  ------------------
  256|  3.17k|    p += sprintf (p, "1.%d", buf[n]-40);
  257|  5.78k|  else {
  258|  5.78k|    val = buf[n] & 0x7f;
  259|  15.4k|    while ( (buf[n]&0x80) && ++n < len )
  ------------------
  |  Branch (259:13): [True: 10.3k, False: 5.09k]
  |  Branch (259:30): [True: 9.92k, False: 387]
  ------------------
  260|  9.92k|      {
  261|  9.92k|        if ( (val & valmask) )
  ------------------
  |  Branch (261:14): [True: 300, False: 9.62k]
  ------------------
  262|    300|          goto badoid;  /* Overflow.  */
  263|  9.62k|        val <<= 7;
  264|  9.62k|        val |= buf[n] & 0x7f;
  265|  9.62k|      }
  266|  5.48k|    if (val < 80)
  ------------------
  |  Branch (266:9): [True: 754, False: 4.73k]
  ------------------
  267|    754|      goto badoid;
  268|  4.73k|    val -= 80;
  269|  4.73k|    sprintf (p, "2.%lu", val);
  270|  4.73k|    p += strlen (p);
  271|  4.73k|  }
  272|  48.7k|  for (n++; n < len; n++)
  ------------------
  |  Branch (272:13): [True: 32.0k, False: 16.6k]
  ------------------
  273|  32.0k|    {
  274|  32.0k|      val = buf[n] & 0x7f;
  275|  35.9k|      while ( (buf[n]&0x80) && ++n < len )
  ------------------
  |  Branch (275:15): [True: 6.61k, False: 29.3k]
  |  Branch (275:32): [True: 4.26k, False: 2.35k]
  ------------------
  276|  4.26k|        {
  277|  4.26k|          if ( (val & valmask) )
  ------------------
  |  Branch (277:16): [True: 307, False: 3.95k]
  ------------------
  278|    307|            goto badoid;  /* Overflow.  */
  279|  3.95k|          val <<= 7;
  280|  3.95k|          val |= buf[n] & 0x7f;
  281|  3.95k|        }
  282|  31.7k|      sprintf (p, ".%lu", val);
  283|  31.7k|      p += strlen (p);
  284|  31.7k|    }
  285|       |
  286|  16.6k|  *p = 0;
  287|  16.6k|  return string;
  288|       |
  289|  1.36k| badoid:
  290|       |  /* Return a special OID (gnu.gnupg.badoid) to indicate the error
  291|       |     case.  The OID is broken and thus we return one which can't do
  292|       |     any harm.  Formally this does not need to be a bad OID but an OID
  293|       |     with an arc that can't be represented in a 32 bit word is more
  294|       |     than likely corrupt.  */
  295|  1.36k|  xfree (string);
  ------------------
  |  |  104|  1.36k|#define xfree(a)         gcry_free ((a))
  ------------------
  296|  1.36k|  return xtrystrdup ("1.3.6.1.4.1.11591.2.12242973");
  ------------------
  |  |  103|  1.36k|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
  297|  16.9k|}
openpgp_oid_to_str:
  304|  18.0k|{
  305|  18.0k|  const unsigned char *buf;
  306|  18.0k|  unsigned int lengthi;
  307|       |
  308|  18.0k|  if (!a
  ------------------
  |  Branch (308:7): [True: 0, False: 18.0k]
  ------------------
  309|  18.0k|      || !gcry_mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE)
  ------------------
  |  Branch (309:10): [True: 0, False: 18.0k]
  ------------------
  310|  18.0k|      || !(buf = gcry_mpi_get_opaque (a, &lengthi)))
  ------------------
  |  Branch (310:10): [True: 0, False: 18.0k]
  ------------------
  311|      0|    {
  312|      0|      gpg_err_set_errno (EINVAL);
  313|      0|      return NULL;
  314|      0|    }
  315|       |
  316|  18.0k|  return openpgp_oidbuf_to_str (buf, (lengthi+7)/8);
  317|  18.0k|}
openpgp_oid_to_curve:
  469|  18.0k|{
  470|  18.0k|  int i;
  471|       |
  472|  18.0k|  if (!oidstr)
  ------------------
  |  Branch (472:7): [True: 0, False: 18.0k]
  ------------------
  473|      0|    return NULL;
  474|       |
  475|   198k|  for (i=0; oidtable[i].name; i++)
  ------------------
  |  Branch (475:13): [True: 182k, False: 15.8k]
  ------------------
  476|   182k|    if (!strcmp (oidtable[i].oidstr, oidstr))
  ------------------
  |  Branch (476:9): [True: 2.20k, False: 180k]
  ------------------
  477|  2.20k|      return !canon && oidtable[i].alias? oidtable[i].alias : oidtable[i].name;
  ------------------
  |  Branch (477:14): [True: 2.20k, False: 0]
  |  Branch (477:24): [True: 2.00k, False: 194]
  ------------------
  478|       |
  479|  15.8k|  return NULL;
  480|  18.0k|}

trim_trailing_chars:
  273|  18.8k|{
  274|  18.8k|    byte *p, *mark;
  275|  18.8k|    unsigned n;
  276|       |
  277|  1.07M|    for(mark=NULL, p=line, n=0; n < len; n++, p++ ) {
  ------------------
  |  Branch (277:33): [True: 1.05M, False: 18.8k]
  ------------------
  278|  1.05M|	if( strchr(trimchars, *p ) ) {
  ------------------
  |  Branch (278:6): [True: 122k, False: 935k]
  ------------------
  279|   122k|	    if( !mark )
  ------------------
  |  Branch (279:10): [True: 74.2k, False: 47.8k]
  ------------------
  280|  74.2k|		mark = p;
  281|   122k|	}
  282|   935k|	else
  283|   935k|	    mark = NULL;
  284|  1.05M|    }
  285|       |
  286|  18.8k|    if( mark ) {
  ------------------
  |  Branch (286:9): [True: 18.6k, False: 222]
  ------------------
  287|  18.6k|	*mark = 0;
  288|  18.6k|	return mark - line;
  289|  18.6k|    }
  290|    222|    return len;
  291|  18.8k|}
length_sans_trailing_chars:
  305|  24.2k|{
  306|  24.2k|  const unsigned char *p, *mark;
  307|  24.2k|  size_t n;
  308|       |
  309|   785k|  for( mark=NULL, p=line, n=0; n < len; n++, p++ )
  ------------------
  |  Branch (309:32): [True: 761k, False: 24.2k]
  ------------------
  310|   761k|    {
  311|   761k|      if (strchr (trimchars, *p ))
  ------------------
  |  Branch (311:11): [True: 89.8k, False: 671k]
  ------------------
  312|  89.8k|        {
  313|  89.8k|          if( !mark )
  ------------------
  |  Branch (313:15): [True: 51.5k, False: 38.2k]
  ------------------
  314|  51.5k|            mark = p;
  315|  89.8k|        }
  316|   671k|      else
  317|   671k|        mark = NULL;
  318|   761k|    }
  319|       |
  320|  24.2k|  if (mark)
  ------------------
  |  Branch (320:7): [True: 23.1k, False: 1.07k]
  ------------------
  321|  23.1k|    return mark - line;
  322|  1.07k|  return len;
  323|  24.2k|}
length_sans_trailing_ws:
  330|  24.2k|{
  331|  24.2k|  return length_sans_trailing_chars (line, len, " \t\r\n");
  332|  24.2k|}
make_filename:
  612|   176k|{
  613|   176k|  va_list arg_ptr;
  614|   176k|  char *result;
  615|       |
  616|   176k|  va_start (arg_ptr, first_part);
  617|   176k|  result = do_make_filename (1, first_part, arg_ptr);
  618|   176k|  va_end (arg_ptr);
  619|   176k|  return result;
  620|   176k|}
make_absfilename:
  642|      3|{
  643|      3|  va_list arg_ptr;
  644|      3|  char *result;
  645|       |
  646|      3|  va_start (arg_ptr, first_part);
  647|      3|  result = do_make_filename (3, first_part, arg_ptr);
  648|      3|  va_end (arg_ptr);
  649|      3|  return result;
  650|      3|}
compare_filenames:
  676|      1|{
  677|       |#ifdef HAVE_DOSISH_SYSTEM
  678|       |  for ( ; *a && *b; a++, b++ )
  679|       |    {
  680|       |      if (*a != *b
  681|       |          && (toupper (*(const unsigned char*)a)
  682|       |              != toupper (*(const unsigned char*)b) )
  683|       |          && !((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/')))
  684|       |        break;
  685|       |    }
  686|       |  if ((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/'))
  687|       |    return 0;
  688|       |  else
  689|       |    return (toupper (*(const unsigned char*)a)
  690|       |            - toupper (*(const unsigned char*)b));
  691|       |#else
  692|      1|    return strcmp(a,b);
  693|      1|#endif
  694|      1|}
ascii_toupper:
  818|  1.48k|{
  819|  1.48k|    if (c >= 'a' && c <= 'z')
  ------------------
  |  Branch (819:9): [True: 1.04k, False: 445]
  |  Branch (819:21): [True: 1.04k, False: 0]
  ------------------
  820|  1.04k|        c &= ~0x20;
  821|  1.48k|    return c;
  822|  1.48k|}
ascii_strlwr:
  835|    759|{
  836|    759|  char *p = s;
  837|       |
  838|  5.70k|  for (p=s; *p; p++ )
  ------------------
  |  Branch (838:13): [True: 4.94k, False: 759]
  ------------------
  839|  4.94k|    if (isascii (*p) && *p >= 'A' && *p <= 'Z')
  ------------------
  |  Branch (839:25): [True: 1.20k, False: 2.83k]
  |  Branch (839:38): [True: 246, False: 960]
  ------------------
  840|    246|      *p |= 0x20;
  841|       |
  842|    759|  return s;
  843|    759|}
stringhelp.c:do_make_filename:
  444|   176k|{
  445|   176k|  const char *argv[32];
  446|   176k|  int argc;
  447|   176k|  size_t n;
  448|   176k|  int skip = 1;
  449|   176k|  char *home_buffer = NULL;
  450|   176k|  char *name, *home, *p;
  451|   176k|  int want_abs;
  452|       |
  453|   176k|  want_abs = !!(xmode & 2);
  454|   176k|  xmode &= 1;
  455|       |
  456|   176k|  n = strlen (first_part) + 1;
  457|   176k|  argc = 0;
  458|   353k|  while ( (argv[argc] = va_arg (arg_ptr, const char *)) )
  ------------------
  |  Branch (458:11): [True: 176k, False: 176k]
  ------------------
  459|   176k|    {
  460|   176k|      n += strlen (argv[argc]) + 1;
  461|   176k|      if (argc >= DIM (argv)-1)
  ------------------
  |  |   47|   176k|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (461:11): [True: 0, False: 176k]
  ------------------
  462|      0|        {
  463|      0|          if (xmode)
  ------------------
  |  Branch (463:15): [True: 0, False: 0]
  ------------------
  464|      0|            BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  465|      0|          gpg_err_set_errno (EINVAL);
  466|      0|          return NULL;
  467|      0|        }
  468|   176k|      argc++;
  469|   176k|    }
  470|   176k|  n++;
  471|       |
  472|   176k|  home = NULL;
  473|   176k|  if (*first_part == '~')
  ------------------
  |  Branch (473:7): [True: 1, False: 176k]
  ------------------
  474|      1|    {
  475|      1|      if (first_part[1] == '/' || !first_part[1])
  ------------------
  |  Branch (475:11): [True: 1, False: 0]
  |  Branch (475:35): [True: 0, False: 0]
  ------------------
  476|      1|        {
  477|       |          /* This is the "~/" or "~" case.  */
  478|      1|          home = getenv("HOME");
  479|      1|          if (!home)
  ------------------
  |  Branch (479:15): [True: 0, False: 1]
  ------------------
  480|      0|            home = home_buffer = get_pwdir (xmode, NULL);
  481|      1|          if (home && *home)
  ------------------
  |  Branch (481:15): [True: 1, False: 0]
  |  Branch (481:23): [True: 1, False: 0]
  ------------------
  482|      1|            n += strlen (home);
  483|      1|        }
  484|      0|      else
  485|      0|        {
  486|       |          /* This is the "~username/" or "~username" case.  */
  487|      0|          char *user;
  488|       |
  489|      0|          if (xmode)
  ------------------
  |  Branch (489:15): [True: 0, False: 0]
  ------------------
  490|      0|            user = xstrdup (first_part+1);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  491|      0|          else
  492|      0|            {
  493|      0|              user = xtrystrdup (first_part+1);
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
  494|      0|              if (!user)
  ------------------
  |  Branch (494:19): [True: 0, False: 0]
  ------------------
  495|      0|                return NULL;
  496|      0|            }
  497|      0|          p = strchr (user, '/');
  498|      0|          if (p)
  ------------------
  |  Branch (498:15): [True: 0, False: 0]
  ------------------
  499|      0|            *p = 0;
  500|      0|          skip = 1 + strlen (user);
  501|       |
  502|      0|          home = home_buffer = get_pwdir (xmode, user);
  503|      0|          xfree (user);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  504|      0|          if (home)
  ------------------
  |  Branch (504:15): [True: 0, False: 0]
  ------------------
  505|      0|            n += strlen (home);
  506|      0|          else
  507|      0|            skip = 1;
  508|      0|        }
  509|      1|    }
  510|       |
  511|   176k|  if (xmode)
  ------------------
  |  Branch (511:7): [True: 176k, False: 0]
  ------------------
  512|   176k|    name = xmalloc (n);
  ------------------
  |  |  107|   176k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  513|      0|  else
  514|      0|    {
  515|      0|      name = xtrymalloc (n);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  516|      0|      if (!name)
  ------------------
  |  Branch (516:11): [True: 0, False: 0]
  ------------------
  517|      0|        {
  518|      0|          xfree (home_buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  519|      0|          return NULL;
  520|      0|        }
  521|      0|    }
  522|       |
  523|   176k|  if (home)
  ------------------
  |  Branch (523:7): [True: 1, False: 176k]
  ------------------
  524|      1|    p = stpcpy (stpcpy (name, home), first_part + skip);
  525|   176k|  else
  526|   176k|    p = stpcpy (name, first_part);
  527|       |
  528|   176k|  xfree (home_buffer);
  ------------------
  |  |  104|   176k|#define xfree(a)         gcry_free ((a))
  ------------------
  529|   353k|  for (argc=0; argv[argc]; argc++)
  ------------------
  |  Branch (529:16): [True: 176k, False: 176k]
  ------------------
  530|   176k|    {
  531|       |      /* Avoid a leading double slash if the first part was "/".  */
  532|   176k|      if (!argc && name[0] == '/' && !name[1])
  ------------------
  |  Branch (532:11): [True: 176k, False: 0]
  |  Branch (532:20): [True: 176k, False: 0]
  |  Branch (532:38): [True: 0, False: 176k]
  ------------------
  533|      0|        p = stpcpy (p, argv[argc]);
  534|   176k|      else
  535|   176k|        p = stpcpy (stpcpy (p, "/"), argv[argc]);
  536|   176k|    }
  537|       |
  538|   176k|  if (want_abs)
  ------------------
  |  Branch (538:7): [True: 3, False: 176k]
  ------------------
  539|      3|    {
  540|       |#ifdef HAVE_DRIVE_LETTERS
  541|       |      p = strchr (name, ':');
  542|       |      if (p)
  543|       |        p++;
  544|       |      else
  545|       |        p = name;
  546|       |#else
  547|      3|      p = name;
  548|      3|#endif
  549|      3|      if (*p != '/'
  ------------------
  |  Branch (549:11): [True: 0, False: 3]
  ------------------
  550|       |#ifdef HAVE_DRIVE_LETTERS
  551|       |          && *p != '\\'
  552|       |#endif
  553|      3|          )
  554|      0|        {
  555|      0|          home = gnupg_getcwd ();
  556|      0|          if (!home)
  ------------------
  |  Branch (556:15): [True: 0, False: 0]
  ------------------
  557|      0|            {
  558|      0|              if (xmode)
  ------------------
  |  Branch (558:19): [True: 0, False: 0]
  ------------------
  559|      0|                {
  560|      0|                  fprintf (stderr, "\nfatal: getcwd failed: %s\n",
  561|      0|                           strerror (errno));
  562|      0|                  exit(2);
  563|      0|                }
  564|      0|              xfree (name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  565|      0|              return NULL;
  566|      0|            }
  567|      0|          n = strlen (home) + 1 + strlen (name) + 1;
  568|      0|          if (xmode)
  ------------------
  |  Branch (568:15): [True: 0, False: 0]
  ------------------
  569|      0|            home_buffer = xmalloc (n);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  570|      0|          else
  571|      0|            {
  572|      0|              home_buffer = xtrymalloc (n);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  573|      0|              if (!home_buffer)
  ------------------
  |  Branch (573:19): [True: 0, False: 0]
  ------------------
  574|      0|                {
  575|      0|                  xfree (home);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  576|      0|                  xfree (name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  577|      0|                  return NULL;
  578|      0|                }
  579|      0|            }
  580|      0|          if (p == name)
  ------------------
  |  Branch (580:15): [True: 0, False: 0]
  ------------------
  581|      0|            p = home_buffer;
  582|      0|          else /* Windows case.  */
  583|      0|            {
  584|      0|              memcpy (home_buffer, p, p - name + 1);
  585|      0|              p = home_buffer + (p - name + 1);
  586|      0|            }
  587|       |
  588|       |          /* Avoid a leading double slash if the cwd is "/".  */
  589|      0|          if (home[0] == '/' && !home[1])
  ------------------
  |  Branch (589:15): [True: 0, False: 0]
  |  Branch (589:33): [True: 0, False: 0]
  ------------------
  590|      0|            strcpy (stpcpy (p, "/"), name);
  591|      0|          else
  592|      0|            strcpy (stpcpy (stpcpy (p, home), "/"), name);
  593|       |
  594|      0|          xfree (home);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  595|      0|          xfree (name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  596|      0|          name = home_buffer;
  597|       |          /* Let's do a simple compression to catch the most common
  598|       |             case of using "." for gpg's --homedir option.  */
  599|      0|          n = strlen (name);
  600|      0|          if (n > 2 && name[n-2] == '/' && name[n-1] == '.')
  ------------------
  |  Branch (600:15): [True: 0, False: 0]
  |  Branch (600:24): [True: 0, False: 0]
  |  Branch (600:44): [True: 0, False: 0]
  ------------------
  601|      0|            name[n-2] = 0;
  602|      0|        }
  603|      3|    }
  604|   176k|  return change_slashes (name);
  605|   176k|}
stringhelp.c:change_slashes:
   70|   176k|{
   71|       |#ifdef HAVE_DOSISH_SYSTEM
   72|       |  char *p;
   73|       |
   74|       |  if (strchr (name, '\\'))
   75|       |    {
   76|       |      for (p=name; *p; p++)
   77|       |        if (*p == '/')
   78|       |          *p = '\\';
   79|       |    }
   80|       |#endif /*HAVE_DOSISH_SYSTEM*/
   81|   176k|  return name;
   82|   176k|}

free_strlist:
   46|  7.04M|{
   47|  7.04M|    strlist_t sl2;
   48|       |
   49|  7.04M|    for(; sl; sl = sl2 ) {
  ------------------
  |  Branch (49:11): [True: 0, False: 7.04M]
  ------------------
   50|      0|	sl2 = sl->next;
   51|      0|	xfree(sl);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
   52|      0|    }
   53|  7.04M|}
add_to_strlist:
   73|      1|{
   74|      1|    strlist_t sl;
   75|       |
   76|      1|    sl = xmalloc( sizeof *sl + strlen(string));
  ------------------
  |  |  107|      1|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
   77|      1|    sl->flags = 0;
   78|      1|    strcpy(sl->d, string);
   79|      1|    sl->next = *list;
   80|      1|    *list = sl;
   81|      1|    return sl;
   82|      1|}

get_session_marker:
  352|  31.3k|{
  353|  31.3k|  static byte marker[SIZEOF_UNSIGNED_LONG*2];
  354|  31.3k|  static int initialized;
  355|       |
  356|  31.3k|  if (!initialized)
  ------------------
  |  Branch (356:7): [True: 1, False: 31.3k]
  ------------------
  357|      1|    {
  358|      1|      gcry_create_nonce (marker, sizeof marker);
  359|      1|      initialized = 1;
  360|      1|    }
  361|  31.3k|  *rlen = sizeof (marker);
  362|  31.3k|  return marker;
  363|  31.3k|}
check_special_filename:
  582|  11.9k|{
  583|  11.9k|  if (allow_special_filenames
  ------------------
  |  Branch (583:7): [True: 0, False: 11.9k]
  ------------------
  584|  11.9k|      && fname && *fname == '-' && fname[1] == '&')
  ------------------
  |  Branch (584:10): [True: 0, False: 0]
  |  Branch (584:19): [True: 0, False: 0]
  |  Branch (584:36): [True: 0, False: 0]
  ------------------
  585|      0|    {
  586|      0|      int i;
  587|       |
  588|      0|      fname += 2;
  589|      0|      for (i=0; digitp (fname+i); i++ )
  ------------------
  |  |  408|      0|#define digitp(p)   (*(p) >= '0' && *(p) <= '9')
  |  |  ------------------
  |  |  |  Branch (408:22): [True: 0, False: 0]
  |  |  |  Branch (408:37): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  590|      0|        ;
  591|      0|      if (!fname[i])
  ------------------
  |  Branch (591:11): [True: 0, False: 0]
  ------------------
  592|      0|        return notranslate? atoi (fname)
  ------------------
  |  Branch (592:16): [True: 0, False: 0]
  ------------------
  593|      0|          /**/            : translate_sys2libc_fd_int (atoi (fname), for_write);
  594|      0|    }
  595|  11.9k|  return -1;
  596|  11.9k|}
gnupg_access:
 1235|      9|{
 1236|      9|  return gpgrt_access (name, mode);
 1237|      9|}
gnupg_stat:
 1244|      1|{
 1245|       |# ifdef HAVE_W32_SYSTEM
 1246|       |#  if __MINGW32_MAJOR_VERSION > 3
 1247|       |    /* mingw.org's MinGW */
 1248|       |#   define STRUCT_STAT _stat
 1249|       |#  elif defined(_USE_32BIT_TIME_T)
 1250|       |    /* MinGW64 for i686 */
 1251|       |#   define STRUCT_STAT _stat32
 1252|       |#  else
 1253|       |    /* MinGW64 for x86_64 */
 1254|       |#   define STRUCT_STAT _stat64i32
 1255|       |#  endif
 1256|       |  if (any8bitchar (name))
 1257|       |    {
 1258|       |      wchar_t *wname;
 1259|       |      struct STRUCT_STAT st32;
 1260|       |      int ret;
 1261|       |
 1262|       |      wname = utf8_to_wchar (name);
 1263|       |      if (!wname)
 1264|       |        return -1;
 1265|       |      ret = _wstat (wname, &st32);
 1266|       |      xfree (wname);
 1267|       |      if (!ret)
 1268|       |        {
 1269|       |          statbuf->st_dev   = st32.st_dev;
 1270|       |          statbuf->st_ino   = st32.st_ino;
 1271|       |          statbuf->st_mode  = st32.st_mode;
 1272|       |          statbuf->st_nlink = st32.st_nlink;
 1273|       |          statbuf->st_uid   = st32.st_uid;
 1274|       |          statbuf->st_gid   = st32.st_gid;
 1275|       |          statbuf->st_rdev  = st32.st_rdev;
 1276|       |          statbuf->st_size  = st32.st_size;
 1277|       |          statbuf->st_atime = st32.st_atime;
 1278|       |          statbuf->st_mtime = st32.st_mtime;
 1279|       |          statbuf->st_ctime = st32.st_ctime;
 1280|       |        }
 1281|       |      return ret;
 1282|       |    }
 1283|       |  else
 1284|       |    return stat (name, statbuf);
 1285|       |# else
 1286|      1|  return stat (name, statbuf);
 1287|      1|# endif
 1288|      1|}
gnupg_open:
 1295|      1|{
 1296|       |#ifdef HAVE_W32_SYSTEM
 1297|       |  if (any8bitchar (name))
 1298|       |    {
 1299|       |      wchar_t *wname;
 1300|       |      int ret;
 1301|       |
 1302|       |      wname = utf8_to_wchar (name);
 1303|       |      if (!wname)
 1304|       |        return -1;
 1305|       |      ret = _wopen (wname, flags, mode);
 1306|       |      xfree (wname);
 1307|       |      return ret;
 1308|       |    }
 1309|       |  else
 1310|       |    return open (name, flags, mode);
 1311|       |#else
 1312|      1|  return open (name, flags, mode);
 1313|      1|#endif
 1314|      1|}

keyid.c:buf32_to_u32:
  105|  92.5k|{
  106|  92.5k|  const unsigned char *p = buffer;
  107|       |
  108|  92.5k|  return (((u32)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
  109|  92.5k|}
parse-packet.c:buf32_to_ulong:
   89|  2.81k|{
   90|  2.81k|  const unsigned char *p = buffer;
   91|       |
   92|  2.81k|  return (((unsigned long)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
   93|  2.81k|}
parse-packet.c:buf32_to_size_t:
   81|  12.3k|{
   82|  12.3k|  const unsigned char *p = buffer;
   83|       |
   84|  12.3k|  return (((size_t)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
   85|  12.3k|}
parse-packet.c:buf32_to_u32:
  105|  8.23k|{
  106|  8.23k|  const unsigned char *p = buffer;
  107|       |
  108|  8.23k|  return (((u32)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
  109|  8.23k|}
tdbio.c:buf32_to_ulong:
   89|    273|{
   90|    273|  const unsigned char *p = buffer;
   91|       |
   92|    273|  return (((unsigned long)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
   93|    273|}

new_armor_context:
  115|  2.68k|{
  116|  2.68k|  armor_filter_context_t *afx;
  117|  2.68k|  gpg_error_t err;
  118|       |
  119|  2.68k|  afx = xcalloc (1, sizeof *afx);
  ------------------
  |  |  109|  2.68k|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
  120|  2.68k|  if (afx)
  ------------------
  |  Branch (120:7): [True: 2.68k, False: 0]
  ------------------
  121|  2.68k|    {
  122|  2.68k|      err = gcry_md_open (&afx->crc_md, GCRY_MD_CRC24_RFC2440, 0);
  123|  2.68k|      if (err != 0)
  ------------------
  |  Branch (123:11): [True: 0, False: 2.68k]
  ------------------
  124|      0|	{
  125|      0|	  log_error ("gcry_md_open failed for GCRY_MD_CRC24_RFC2440: %s",
  126|      0|		    gpg_strerror (err));
  127|      0|	  xfree (afx);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  128|      0|	  return NULL;
  129|      0|	}
  130|       |
  131|  2.68k|      afx->refcount = 1;
  132|  2.68k|    }
  133|       |
  134|  2.68k|  return afx;
  135|  2.68k|}
release_armor_context:
  141|  14.6k|{
  142|  14.6k|  if (!afx)
  ------------------
  |  Branch (142:7): [True: 9.26k, False: 5.37k]
  ------------------
  143|  9.26k|    return;
  144|  5.37k|  log_assert (afx->refcount);
  145|  5.37k|  if ( --afx->refcount )
  ------------------
  |  Branch (145:8): [True: 2.68k, False: 2.68k]
  ------------------
  146|  2.68k|    return;
  147|  2.68k|  gcry_md_close (afx->crc_md);
  148|  2.68k|  xfree (afx);
  ------------------
  |  |  104|  2.68k|#define xfree(a)         gcry_free ((a))
  ------------------
  149|  2.68k|}
push_armor_filter:
  154|  2.68k|{
  155|  2.68k|  int rc;
  156|       |
  157|  2.68k|  afx->refcount++;
  158|  2.68k|  rc = iobuf_push_filter (iobuf, armor_filter, afx);
  159|  2.68k|  if (rc)
  ------------------
  |  Branch (159:7): [True: 0, False: 2.68k]
  ------------------
  160|      0|    afx->refcount--;
  161|  2.68k|  return rc;
  162|  2.68k|}
use_armor_filter:
  295|  11.9k|{
  296|  11.9k|    byte buf[2];
  297|  11.9k|    int n;
  298|       |
  299|       |    /* fixme: there might be a problem with iobuf_peek */
  300|  11.9k|    n = iobuf_peek (a, buf, 2);
  301|  11.9k|    if( n == -1 )
  ------------------
  |  Branch (301:9): [True: 0, False: 11.9k]
  ------------------
  302|      0|	return 0; /* EOF, doesn't matter whether armored or not */
  303|  11.9k|    if( !n )
  ------------------
  |  Branch (303:9): [True: 0, False: 11.9k]
  ------------------
  304|      0|	return 1; /* can't check it: try armored */
  305|  11.9k|    if (n != 2)
  ------------------
  |  Branch (305:9): [True: 31, False: 11.9k]
  ------------------
  306|     31|	return 0; /* short buffer */
  307|  11.9k|    return is_armored(buf);
  308|  11.9k|}
armor.c:is_armored:
  218|  25.0k|{
  219|  25.0k|  int ctb, pkttype;
  220|  25.0k|  int indeterminate_length_allowed;
  221|       |
  222|  25.0k|    ctb = *buf;
  223|  25.0k|    if( !(ctb & 0x80) )
  ------------------
  |  Branch (223:9): [True: 14.0k, False: 11.0k]
  ------------------
  224|       |      /* The most significant bit of the CTB must be set.  Since it is
  225|       |         cleared, this is not a binary OpenPGP message.  Assume it is
  226|       |         armored.  */
  227|  14.0k|      return 1;
  228|       |
  229|  11.0k|    pkttype =  ctb & 0x40 ? (ctb & 0x3f) : ((ctb>>2)&0xf);
  ------------------
  |  Branch (229:16): [True: 4.47k, False: 6.53k]
  ------------------
  230|  11.0k|    switch( pkttype ) {
  231|    699|      case PKT_PUBKEY_ENC:
  ------------------
  |  Branch (231:7): [True: 699, False: 10.3k]
  ------------------
  232|  3.26k|      case PKT_SIGNATURE:
  ------------------
  |  Branch (232:7): [True: 2.56k, False: 8.44k]
  ------------------
  233|  3.85k|      case PKT_SYMKEY_ENC:
  ------------------
  |  Branch (233:7): [True: 595, False: 10.4k]
  ------------------
  234|  3.96k|      case PKT_ONEPASS_SIG:
  ------------------
  |  Branch (234:7): [True: 107, False: 10.9k]
  ------------------
  235|  4.51k|      case PKT_SECRET_KEY:
  ------------------
  |  Branch (235:7): [True: 545, False: 10.4k]
  ------------------
  236|  4.74k|      case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (236:7): [True: 237, False: 10.7k]
  ------------------
  237|  5.62k|      case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (237:7): [True: 877, False: 10.1k]
  ------------------
  238|  5.82k|      case PKT_MARKER:
  ------------------
  |  Branch (238:7): [True: 197, False: 10.8k]
  ------------------
  239|  6.93k|      case PKT_RING_TRUST:
  ------------------
  |  Branch (239:7): [True: 1.11k, False: 9.89k]
  ------------------
  240|  7.16k|      case PKT_USER_ID:
  ------------------
  |  Branch (240:7): [True: 226, False: 10.7k]
  ------------------
  241|  7.45k|      case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (241:7): [True: 291, False: 10.7k]
  ------------------
  242|  7.97k|      case PKT_ATTRIBUTE:
  ------------------
  |  Branch (242:7): [True: 525, False: 10.4k]
  ------------------
  243|  8.35k|      case PKT_MDC:
  ------------------
  |  Branch (243:7): [True: 375, False: 10.6k]
  ------------------
  244|  8.35k|	indeterminate_length_allowed = 0;
  245|  8.35k|        break;
  246|       |
  247|    138|      case PKT_COMPRESSED:
  ------------------
  |  Branch (247:7): [True: 138, False: 10.8k]
  ------------------
  248|    447|      case PKT_ENCRYPTED:
  ------------------
  |  Branch (248:7): [True: 309, False: 10.7k]
  ------------------
  249|  1.15k|      case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (249:7): [True: 707, False: 10.3k]
  ------------------
  250|  1.32k|      case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (250:7): [True: 167, False: 10.8k]
  ------------------
  251|  1.65k|      case PKT_PLAINTEXT:
  ------------------
  |  Branch (251:7): [True: 333, False: 10.6k]
  ------------------
  252|  1.73k|      case PKT_OLD_COMMENT:
  ------------------
  |  Branch (252:7): [True: 82, False: 10.9k]
  ------------------
  253|  1.84k|      case PKT_COMMENT:
  ------------------
  |  Branch (253:7): [True: 113, False: 10.8k]
  ------------------
  254|  2.15k|      case PKT_GPG_CONTROL:
  ------------------
  |  Branch (254:7): [True: 308, False: 10.7k]
  ------------------
  255|  2.15k|	indeterminate_length_allowed = 1;
  256|  2.15k|        break;
  257|       |
  258|    501|      default:
  ------------------
  |  Branch (258:7): [True: 501, False: 10.5k]
  ------------------
  259|       |        /* Invalid packet type.  */
  260|    501|        return 1;
  261|  11.0k|    }
  262|       |
  263|  10.5k|    if (! indeterminate_length_allowed)
  ------------------
  |  Branch (263:9): [True: 8.35k, False: 2.15k]
  ------------------
  264|       |      /* It is only legal to use an indeterminate length with a few
  265|       |         packet types.  If a packet uses an indeterminate length, but
  266|       |         that is not allowed, then the data is not valid binary
  267|       |         OpenPGP data.  */
  268|  8.35k|      {
  269|  8.35k|        int new_format;
  270|  8.35k|        int indeterminate_length;
  271|       |
  272|  8.35k|        new_format = !! (ctb & (1 << 6));
  273|  8.35k|        if (new_format)
  ------------------
  |  Branch (273:13): [True: 2.46k, False: 5.89k]
  ------------------
  274|  2.46k|          indeterminate_length = (buf[1] >= 224 && buf[1] < 255);
  ------------------
  |  Branch (274:35): [True: 341, False: 2.12k]
  |  Branch (274:52): [True: 226, False: 115]
  ------------------
  275|  5.89k|        else
  276|  5.89k|          indeterminate_length = (ctb & 3) == 3;
  277|       |
  278|  8.35k|        if (indeterminate_length)
  ------------------
  |  Branch (278:13): [True: 946, False: 7.40k]
  ------------------
  279|    946|          return 1;
  280|  8.35k|      }
  281|       |
  282|       |    /* The first CTB seems legit.  It is probably not armored
  283|       |       data.  */
  284|  9.56k|    return 0;
  285|  10.5k|}
armor.c:armor_filter:
 1284|  34.7k|{
 1285|  34.7k|    size_t size = *ret_len;
 1286|  34.7k|    armor_filter_context_t *afx = opaque;
 1287|  34.7k|    int rc=0, c;
 1288|  34.7k|    byte radbuf[3];
 1289|  34.7k|    int  idx, idx2;
 1290|  34.7k|    size_t n=0;
 1291|  34.7k|    u32 crc;
 1292|       |#if 0
 1293|       |    static FILE *fp ;
 1294|       |
 1295|       |    if( !fp ) {
 1296|       |	fp = fopen("armor.out", "w");
 1297|       |	log_assert(fp);
 1298|       |    }
 1299|       |#endif
 1300|       |
 1301|  34.7k|    if( DBG_FILTER )
  ------------------
  |  |  351|  34.7k|#define DBG_FILTER (opt.debug & DBG_FILTER_VALUE)
  |  |  ------------------
  |  |  |  |  335|  34.7k|#define DBG_FILTER_VALUE  8	/* debug internal filter handling */
  |  |  ------------------
  |  |  |  Branch (351:20): [True: 0, False: 34.7k]
  |  |  ------------------
  ------------------
 1302|      0|	log_debug("armor-filter: control: %d\n", control );
 1303|  34.7k|    if( control == IOBUFCTRL_UNDERFLOW && afx->inp_bypass ) {
  ------------------
  |  Branch (1303:9): [True: 29.3k, False: 5.37k]
  |  Branch (1303:43): [True: 1.11k, False: 28.2k]
  ------------------
 1304|  1.11k|	n = 0;
 1305|  1.11k|	if( afx->buffer_len ) {
  ------------------
  |  Branch (1305:6): [True: 519, False: 592]
  ------------------
 1306|       |            /* Copy the data from AFX->BUFFER to BUF.  */
 1307|  1.72M|	    for(; n < size && afx->buffer_pos < afx->buffer_len; n++ )
  ------------------
  |  Branch (1307:12): [True: 1.72M, False: 273]
  |  Branch (1307:24): [True: 1.72M, False: 246]
  ------------------
 1308|  1.72M|		buf[n++] = afx->buffer[afx->buffer_pos++];
 1309|    519|	    if( afx->buffer_pos >= afx->buffer_len )
  ------------------
  |  Branch (1309:10): [True: 255, False: 264]
  ------------------
 1310|    255|		afx->buffer_len = 0;
 1311|    519|	}
 1312|       |        /* If there is still space in BUF, read directly into it.  */
 1313|  1.23M|	for(; n < size; n++ ) {
  ------------------
  |  Branch (1313:8): [True: 1.23M, False: 482]
  ------------------
 1314|  1.23M|	    if( (c=iobuf_get(a)) == -1 )
  ------------------
  |  |  500|  1.23M|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 1.23M]
  |  |  |  Branch (500:24): [True: 629, False: 1.23M]
  |  |  ------------------
  |  |  501|  1.23M|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (1314:10): [True: 629, False: 1.23M]
  ------------------
 1315|    629|		break;
 1316|  1.23M|	    buf[n] = c & 0xff;
 1317|  1.23M|	}
 1318|  1.11k|	if( !n )
  ------------------
  |  Branch (1318:6): [True: 337, False: 774]
  ------------------
 1319|       |            /* We didn't get any data.  EOF.  */
 1320|    337|	    rc = -1;
 1321|  1.11k|	*ret_len = n;
 1322|  1.11k|    }
 1323|  33.6k|    else if( control == IOBUFCTRL_UNDERFLOW ) {
  ------------------
  |  Branch (1323:14): [True: 28.2k, False: 5.37k]
  ------------------
 1324|       |        /* We need some space for the faked packet.  The minmum
 1325|       |         * required size is the PARTIAL_CHUNK size plus a byte for the
 1326|       |         * length itself */
 1327|  28.2k|	if( size < PARTIAL_CHUNK+1 )
  ------------------
  |  |  636|  28.2k|#define PARTIAL_CHUNK 512
  ------------------
  |  Branch (1327:6): [True: 0, False: 28.2k]
  ------------------
 1328|      0|	    BUG(); /* supplied buffer too short */
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1329|       |
 1330|  28.2k|	if( afx->faked )
  ------------------
  |  Branch (1330:6): [True: 7.38k, False: 20.8k]
  ------------------
 1331|  7.38k|	    rc = fake_packet( afx, a, &n, buf, size );
 1332|  20.8k|	else if( !afx->inp_checked ) {
  ------------------
  |  Branch (1332:11): [True: 13.9k, False: 6.90k]
  ------------------
 1333|  13.9k|	    rc = check_input( afx, a );
 1334|  13.9k|	    if( afx->inp_bypass ) {
  ------------------
  |  Branch (1334:10): [True: 362, False: 13.5k]
  ------------------
 1335|   588k|		for(n=0; n < size && afx->buffer_pos < afx->buffer_len; )
  ------------------
  |  Branch (1335:12): [True: 588k, False: 255]
  |  Branch (1335:24): [True: 588k, False: 107]
  ------------------
 1336|   588k|		    buf[n++] = afx->buffer[afx->buffer_pos++];
 1337|    362|		if( afx->buffer_pos >= afx->buffer_len )
  ------------------
  |  Branch (1337:7): [True: 107, False: 255]
  ------------------
 1338|    107|		    afx->buffer_len = 0;
 1339|    362|		if( !n )
  ------------------
  |  Branch (1339:7): [True: 19, False: 343]
  ------------------
 1340|     19|		    rc = -1;
 1341|    362|	    }
 1342|  13.5k|	    else if( afx->faked ) {
  ------------------
  |  Branch (1342:15): [True: 7.17k, False: 6.42k]
  ------------------
 1343|  7.17k|	        unsigned int hashes = afx->hashes;
 1344|  7.17k|                const byte *sesmark;
 1345|  7.17k|                size_t sesmarklen;
 1346|       |
 1347|  7.17k|                sesmark = get_session_marker( &sesmarklen );
 1348|  7.17k|                if ( sesmarklen > 20 )
  ------------------
  |  Branch (1348:22): [True: 0, False: 7.17k]
  ------------------
 1349|      0|                    BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1350|       |
 1351|       |		/* the buffer is at least 15+n*15 bytes long, so it
 1352|       |		 * is easy to construct the packets */
 1353|       |
 1354|  7.17k|		hashes &= 1|2|8|16|32|64;
 1355|  7.17k|		if( !hashes ) {
  ------------------
  |  Branch (1355:7): [True: 5.24k, False: 1.92k]
  ------------------
 1356|  5.24k|		    hashes |= 2;  /* Default to SHA-1. */
 1357|  5.24k|		}
 1358|  7.17k|		n=0;
 1359|       |                /* First a gpg control packet... */
 1360|  7.17k|                buf[n++] = 0xff; /* new format, type 63, 1 length byte */
 1361|  7.17k|                n++;   /* see below */
 1362|  7.17k|                memcpy(buf+n, sesmark, sesmarklen ); n+= sesmarklen;
 1363|  7.17k|                buf[n++] = CTRLPKT_CLEARSIGN_START;
 1364|  7.17k|                buf[n++] = afx->not_dash_escaped? 0:1; /* sigclass */
  ------------------
  |  Branch (1364:28): [True: 709, False: 6.46k]
  ------------------
 1365|  7.17k|                if( hashes & 1 )
  ------------------
  |  Branch (1365:21): [True: 223, False: 6.94k]
  ------------------
 1366|    223|                    buf[n++] = DIGEST_ALGO_RMD160;
 1367|  7.17k|                if( hashes & 2 )
  ------------------
  |  Branch (1367:21): [True: 5.60k, False: 1.56k]
  ------------------
 1368|  5.60k|                    buf[n++] = DIGEST_ALGO_SHA1;
 1369|  7.17k|                if( hashes & 8 )
  ------------------
  |  Branch (1369:21): [True: 339, False: 6.83k]
  ------------------
 1370|    339|                    buf[n++] = DIGEST_ALGO_SHA224;
 1371|  7.17k|                if( hashes & 16 )
  ------------------
  |  Branch (1371:21): [True: 206, False: 6.96k]
  ------------------
 1372|    206|                    buf[n++] = DIGEST_ALGO_SHA256;
 1373|  7.17k|                if( hashes & 32 )
  ------------------
  |  Branch (1373:21): [True: 770, False: 6.40k]
  ------------------
 1374|    770|                    buf[n++] = DIGEST_ALGO_SHA384;
 1375|  7.17k|                if( hashes & 64 )
  ------------------
  |  Branch (1375:21): [True: 241, False: 6.92k]
  ------------------
 1376|    241|                    buf[n++] = DIGEST_ALGO_SHA512;
 1377|  7.17k|                buf[1] = n - 2;
 1378|       |
 1379|       |		/* ...followed by an invented plaintext packet.
 1380|       |		   Amusingly enough, this packet is not compliant with
 1381|       |		   2440 as the initial partial length is less than 512
 1382|       |		   bytes.  Of course, we'll accept it anyway ;) */
 1383|       |
 1384|  7.17k|		buf[n++] = 0xCB; /* new packet format, type 11 */
 1385|  7.17k|		buf[n++] = 0xE1; /* 2^1 == 2 bytes */
 1386|  7.17k|		buf[n++] = 't';  /* canonical text mode */
 1387|  7.17k|		buf[n++] = 0;	 /* namelength */
 1388|  7.17k|		buf[n++] = 0xE2; /* 2^2 == 4 more bytes */
 1389|  7.17k|		memset(buf+n, 0, 4); /* timestamp */
 1390|  7.17k|		n += 4;
 1391|  7.17k|	    }
 1392|  6.42k|	    else if( !rc )
  ------------------
  |  Branch (1392:15): [True: 6.32k, False: 98]
  ------------------
 1393|  6.32k|		rc = radix64_read( afx, a, &n, buf, size );
 1394|  13.9k|	}
 1395|  6.90k|	else
 1396|  6.90k|	    rc = radix64_read( afx, a, &n, buf, size );
 1397|       |#if 0
 1398|       |	if( n )
 1399|       |	    if( fwrite(buf, n, 1, fp ) != 1 )
 1400|       |		BUG();
 1401|       |#endif
 1402|  28.2k|	*ret_len = n;
 1403|  28.2k|    }
 1404|  5.37k|    else if( control == IOBUFCTRL_FLUSH && !afx->cancel ) {
  ------------------
  |  Branch (1404:14): [True: 0, False: 5.37k]
  |  Branch (1404:44): [True: 0, False: 0]
  ------------------
 1405|      0|	if( !afx->status ) { /* write the header line */
  ------------------
  |  Branch (1405:6): [True: 0, False: 0]
  ------------------
 1406|      0|	    const char *s;
 1407|      0|	    strlist_t comment=opt.comments;
 1408|       |
 1409|      0|	    if( afx->what >= DIM(head_strings) )
  ------------------
  |  |   47|      0|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (1409:10): [True: 0, False: 0]
  ------------------
 1410|      0|		log_bug("afx->what=%d", afx->what);
 1411|      0|	    iobuf_writestr(a, "-----");
 1412|      0|	    iobuf_writestr(a, head_strings[afx->what] );
 1413|      0|	    iobuf_writestr(a, "-----" );
 1414|      0|	    iobuf_writestr(a,afx->eol);
 1415|      0|	    if (opt.emit_version)
  ------------------
  |  Branch (1415:10): [True: 0, False: 0]
  ------------------
 1416|      0|	      {
 1417|      0|		iobuf_writestr (a, "Version: "GNUPG_NAME" v");
 1418|      0|                for (s=VERSION; *s && *s != '.'; s++)
  ------------------
  |  |  811|      0|#define VERSION "2.3.9"
  ------------------
  |  Branch (1418:33): [True: 0, False: 0]
  |  Branch (1418:39): [True: 0, False: 0]
  ------------------
 1419|      0|                  iobuf_writebyte (a, *s);
 1420|      0|                if (opt.emit_version > 1 && *s)
  ------------------
  |  Branch (1420:21): [True: 0, False: 0]
  |  Branch (1420:45): [True: 0, False: 0]
  ------------------
 1421|      0|                  {
 1422|      0|                    iobuf_writebyte (a, *s++);
 1423|      0|                    for (; *s && *s != '.'; s++)
  ------------------
  |  Branch (1423:28): [True: 0, False: 0]
  |  Branch (1423:34): [True: 0, False: 0]
  ------------------
 1424|      0|                      iobuf_writebyte (a, *s);
 1425|      0|                    if (opt.emit_version > 2)
  ------------------
  |  Branch (1425:25): [True: 0, False: 0]
  ------------------
 1426|      0|                      {
 1427|      0|                        for (; *s && *s != '-' && !spacep (s); s++)
  ------------------
  |  |  407|      0|#define spacep(p)   (*(p) == ' ' || *(p) == '\t')
  |  |  ------------------
  |  |  |  Branch (407:22): [True: 0, False: 0]
  |  |  |  Branch (407:37): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1427:32): [True: 0, False: 0]
  |  Branch (1427:38): [True: 0, False: 0]
  ------------------
 1428|      0|                          iobuf_writebyte (a, *s);
 1429|      0|                        if (opt.emit_version > 3)
  ------------------
  |  Branch (1429:29): [True: 0, False: 0]
  ------------------
 1430|      0|                          iobuf_writestr (a, " (" PRINTABLE_OS_NAME ")");
 1431|      0|                      }
 1432|      0|                  }
 1433|      0|		iobuf_writestr(a,afx->eol);
 1434|      0|	      }
 1435|       |
 1436|       |	    /* write the comment strings */
 1437|      0|	    for(;comment;comment=comment->next)
  ------------------
  |  Branch (1437:11): [True: 0, False: 0]
  ------------------
 1438|      0|	      {
 1439|      0|		iobuf_writestr(a, "Comment: " );
 1440|      0|		for( s=comment->d; *s; s++ )
  ------------------
  |  Branch (1440:22): [True: 0, False: 0]
  ------------------
 1441|      0|		  {
 1442|      0|		    if( *s == '\n' )
  ------------------
  |  Branch (1442:11): [True: 0, False: 0]
  ------------------
 1443|      0|		      iobuf_writestr(a, "\\n" );
 1444|      0|		    else if( *s == '\r' )
  ------------------
  |  Branch (1444:16): [True: 0, False: 0]
  ------------------
 1445|      0|		      iobuf_writestr(a, "\\r" );
 1446|      0|		    else if( *s == '\v' )
  ------------------
  |  Branch (1446:16): [True: 0, False: 0]
  ------------------
 1447|      0|		      iobuf_writestr(a, "\\v" );
 1448|      0|		    else
 1449|      0|		      iobuf_put(a, *s );
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1450|      0|		  }
 1451|       |
 1452|      0|		iobuf_writestr(a,afx->eol);
 1453|      0|	      }
 1454|       |
 1455|      0|	    if ( afx->hdrlines ) {
  ------------------
  |  Branch (1455:11): [True: 0, False: 0]
  ------------------
 1456|      0|                for ( s = afx->hdrlines; *s; s++ ) {
  ------------------
  |  Branch (1456:42): [True: 0, False: 0]
  ------------------
 1457|       |#ifdef HAVE_DOSISH_SYSTEM
 1458|       |                    if ( *s == '\n' )
 1459|       |                        iobuf_put( a, '\r');
 1460|       |#endif
 1461|      0|                    iobuf_put(a, *s );
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1462|      0|                }
 1463|      0|            }
 1464|       |
 1465|      0|	    iobuf_writestr(a,afx->eol);
 1466|      0|	    afx->status++;
 1467|      0|	    afx->idx = 0;
 1468|      0|	    afx->idx2 = 0;
 1469|      0|	    gcry_md_reset (afx->crc_md);
 1470|      0|	}
 1471|       |
 1472|      0|	if( size ) {
  ------------------
  |  Branch (1472:6): [True: 0, False: 0]
  ------------------
 1473|      0|	    gcry_md_write (afx->crc_md, buf, size);
 1474|      0|	    armor_output_buf_as_radix64 (afx, a, buf, size);
 1475|      0|        }
 1476|      0|    }
 1477|  5.37k|    else if( control == IOBUFCTRL_INIT )
  ------------------
  |  Branch (1477:14): [True: 2.68k, False: 2.68k]
  ------------------
 1478|  2.68k|      {
 1479|  2.68k|	if( !is_initialized )
  ------------------
  |  Branch (1479:6): [True: 1, False: 2.68k]
  ------------------
 1480|      1|	  initialize();
 1481|       |
 1482|       |	/* Figure out what we're using for line endings if the caller
 1483|       |	   didn't specify. */
 1484|  2.68k|	if(afx->eol[0]==0)
  ------------------
  |  Branch (1484:5): [True: 2.68k, False: 0]
  ------------------
 1485|  2.68k|	  {
 1486|       |#ifdef HAVE_DOSISH_SYSTEM
 1487|       |	    afx->eol[0]='\r';
 1488|       |	    afx->eol[1]='\n';
 1489|       |#else
 1490|  2.68k|	    afx->eol[0]='\n';
 1491|  2.68k|#endif
 1492|  2.68k|	  }
 1493|  2.68k|      }
 1494|  2.68k|    else if( control == IOBUFCTRL_CANCEL ) {
  ------------------
  |  Branch (1494:14): [True: 0, False: 2.68k]
  ------------------
 1495|      0|	afx->cancel = 1;
 1496|      0|    }
 1497|  2.68k|    else if( control == IOBUFCTRL_FREE ) {
  ------------------
  |  Branch (1497:14): [True: 2.68k, False: 0]
  ------------------
 1498|  2.68k|	if( afx->cancel )
  ------------------
  |  Branch (1498:6): [True: 0, False: 2.68k]
  ------------------
 1499|      0|	    ;
 1500|  2.68k|	else if( afx->status ) { /* pad, write cecksum, and bottom line */
  ------------------
  |  Branch (1500:11): [True: 0, False: 2.68k]
  ------------------
 1501|      0|	    gcry_md_final (afx->crc_md);
 1502|      0|	    crc = get_afx_crc (afx);
 1503|      0|	    idx = afx->idx;
 1504|      0|	    idx2 = afx->idx2;
 1505|      0|	    if( idx ) {
  ------------------
  |  Branch (1505:10): [True: 0, False: 0]
  ------------------
 1506|      0|		c = bintoasc[(afx->radbuf[0]>>2)&077];
 1507|      0|		iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1508|      0|		if( idx == 1 ) {
  ------------------
  |  Branch (1508:7): [True: 0, False: 0]
  ------------------
 1509|      0|		    c = bintoasc[((afx->radbuf[0] << 4) & 060) & 077];
 1510|      0|		    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1511|      0|		    iobuf_put(a, '=');
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1512|      0|		    iobuf_put(a, '=');
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1513|      0|		}
 1514|      0|		else { /* 2 */
 1515|      0|		    c = bintoasc[(((afx->radbuf[0]<<4)&060)
 1516|      0|                                  |((afx->radbuf[1]>>4)&017))&077];
 1517|      0|		    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1518|      0|		    c = bintoasc[((afx->radbuf[1] << 2) & 074) & 077];
 1519|      0|		    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1520|      0|		    iobuf_put(a, '=');
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1521|      0|		}
 1522|      0|		if( ++idx2 >= (64/4) )
  ------------------
  |  Branch (1522:7): [True: 0, False: 0]
  ------------------
 1523|      0|		  { /* pgp doesn't like 72 here */
 1524|      0|		    iobuf_writestr(a,afx->eol);
 1525|      0|		    idx2=0;
 1526|      0|		  }
 1527|      0|	    }
 1528|       |	    /* may need a linefeed */
 1529|      0|	    if( idx2 )
  ------------------
  |  Branch (1529:10): [True: 0, False: 0]
  ------------------
 1530|      0|	      iobuf_writestr(a,afx->eol);
 1531|       |	    /* write the CRC */
 1532|      0|	    iobuf_put(a, '=');
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1533|      0|	    radbuf[0] = crc >>16;
 1534|      0|	    radbuf[1] = crc >> 8;
 1535|      0|	    radbuf[2] = crc;
 1536|      0|	    c = bintoasc[(*radbuf >> 2) & 077];
 1537|      0|	    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1538|      0|	    c = bintoasc[(((*radbuf<<4)&060)|((radbuf[1] >> 4)&017))&077];
 1539|      0|	    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1540|      0|	    c = bintoasc[(((radbuf[1]<<2)&074)|((radbuf[2]>>6)&03))&077];
 1541|      0|	    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1542|      0|	    c = bintoasc[radbuf[2]&077];
 1543|      0|	    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1544|      0|	    iobuf_writestr(a,afx->eol);
 1545|       |	    /* and the trailer */
 1546|      0|	    if( afx->what >= DIM(tail_strings) )
  ------------------
  |  |   47|      0|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (1546:10): [True: 0, False: 0]
  ------------------
 1547|      0|		log_bug("afx->what=%d", afx->what);
 1548|      0|	    iobuf_writestr(a, "-----");
 1549|      0|	    iobuf_writestr(a, tail_strings[afx->what] );
 1550|      0|	    iobuf_writestr(a, "-----" );
 1551|      0|	    iobuf_writestr(a,afx->eol);
 1552|      0|	}
 1553|  2.68k|	else if( !afx->any_data && !afx->inp_bypass ) {
  ------------------
  |  Branch (1553:11): [True: 1.57k, False: 1.10k]
  |  Branch (1553:29): [True: 1.56k, False: 16]
  ------------------
 1554|  1.56k|	    log_error(_("no valid OpenPGP data found.\n"));
  ------------------
  |  |   28|  1.56k|#  define _(a) gettext (a)
  ------------------
 1555|  1.56k|	    afx->no_openpgp_data = 1;
 1556|  1.56k|	    write_status_text( STATUS_NODATA, "1" );
 1557|  1.56k|	}
 1558|       |        /* Note that in a cleartext signature truncated lines in the
 1559|       |         * plaintext are detected and propagated to the signature
 1560|       |         * checking code by inserting a \f into the plaintext.  We do
 1561|       |         * not use log_info here because some of the truncated lines
 1562|       |         * are harmless.  */
 1563|  2.68k|	if( afx->truncated )
  ------------------
  |  Branch (1563:6): [True: 10, False: 2.67k]
  ------------------
 1564|     10|	    log_info(_("invalid armor: line longer than %d characters\n"),
  ------------------
  |  |   28|     10|#  define _(a) gettext (a)
  ------------------
 1565|     10|		      MAX_LINELEN );
  ------------------
  |  |   38|     10|#define MAX_LINELEN 20000
  ------------------
 1566|       |	/* issue an error to enforce dissemination of correct software */
 1567|  2.68k|	if( afx->qp_detected )
  ------------------
  |  Branch (1567:6): [True: 59, False: 2.62k]
  ------------------
 1568|     59|	    log_error(_("quoted printable character in armor - "
  ------------------
  |  |   28|     59|#  define _(a) gettext (a)
  ------------------
 1569|     59|			"probably a buggy MTA has been used\n") );
 1570|  2.68k|	xfree( afx->buffer );
  ------------------
  |  |  104|  2.68k|#define xfree(a)         gcry_free ((a))
  ------------------
 1571|  2.68k|	afx->buffer = NULL;
 1572|  2.68k|        release_armor_context (afx);
 1573|  2.68k|    }
 1574|      0|    else if( control == IOBUFCTRL_DESC )
  ------------------
  |  Branch (1574:14): [True: 0, False: 0]
  ------------------
 1575|      0|        mem2str (buf, "armor_filter", *ret_len);
 1576|  34.7k|    return rc;
 1577|  34.7k|}
armor.c:fake_packet:
  647|  7.38k|{
  648|  7.38k|    int rc = 0;
  649|  7.38k|    size_t len = 0;
  650|  7.38k|    int lastline = 0;
  651|  7.38k|    unsigned maxlen, n;
  652|  7.38k|    byte *p;
  653|  7.38k|    byte tempbuf[PARTIAL_CHUNK];
  654|  7.38k|    size_t tempbuf_len=0;
  655|  7.38k|    int this_truncated;
  656|       |
  657|  37.4k|    while( !rc && size-len>=(PARTIAL_CHUNK+1)) {
  ------------------
  |  |  636|  30.3k|#define PARTIAL_CHUNK 512
  ------------------
  |  Branch (657:12): [True: 30.3k, False: 7.16k]
  |  Branch (657:19): [True: 30.1k, False: 217]
  ------------------
  658|       |	/* copy what we have in the line buffer */
  659|  30.1k|	if( afx->faked == 1 )
  ------------------
  |  Branch (659:6): [True: 7.16k, False: 22.9k]
  ------------------
  660|  7.16k|	    afx->faked++; /* skip the first (empty) line */
  661|  22.9k|	else
  662|  22.9k|	  {
  663|       |	    /* It's full, so write this partial chunk */
  664|  22.9k|	    if(tempbuf_len==PARTIAL_CHUNK)
  ------------------
  |  |  636|  22.9k|#define PARTIAL_CHUNK 512
  ------------------
  |  Branch (664:9): [True: 1.77k, False: 21.1k]
  ------------------
  665|  1.77k|	      {
  666|  1.77k|		buf[len++]=0xE0+PARTIAL_POW;
  ------------------
  |  |  637|  1.77k|#define PARTIAL_POW   9
  ------------------
  667|  1.77k|		memcpy(&buf[len],tempbuf,PARTIAL_CHUNK);
  ------------------
  |  |  636|  1.77k|#define PARTIAL_CHUNK 512
  ------------------
  668|  1.77k|		len+=PARTIAL_CHUNK;
  ------------------
  |  |  636|  1.77k|#define PARTIAL_CHUNK 512
  ------------------
  669|  1.77k|		tempbuf_len=0;
  670|  1.77k|		continue;
  671|  1.77k|	      }
  672|       |
  673|  1.16M|	    while( tempbuf_len < PARTIAL_CHUNK
  ------------------
  |  |  636|  2.33M|#define PARTIAL_CHUNK 512
  ------------------
  |  Branch (673:13): [True: 1.16M, False: 1.77k]
  ------------------
  674|  1.16M|		   && afx->buffer_pos < afx->buffer_len )
  ------------------
  |  Branch (674:9): [True: 1.14M, False: 19.3k]
  ------------------
  675|  1.14M|	      tempbuf[tempbuf_len++] = afx->buffer[afx->buffer_pos++];
  676|  21.1k|	    if( tempbuf_len==PARTIAL_CHUNK )
  ------------------
  |  |  636|  21.1k|#define PARTIAL_CHUNK 512
  ------------------
  |  Branch (676:10): [True: 1.77k, False: 19.3k]
  ------------------
  677|  1.77k|	      continue;
  678|  21.1k|	  }
  679|       |
  680|       |	/* read the next line */
  681|  26.5k|	maxlen = MAX_LINELEN;
  ------------------
  |  |   38|  26.5k|#define MAX_LINELEN 20000
  ------------------
  682|  26.5k|	afx->buffer_pos = 0;
  683|  26.5k|	afx->buffer_len = iobuf_read_line( a, &afx->buffer,
  684|  26.5k|					   &afx->buffer_size, &maxlen );
  685|  26.5k|	if( !afx->buffer_len ) {
  ------------------
  |  Branch (685:6): [True: 684, False: 25.8k]
  ------------------
  686|    684|	    rc = -1; /* eof (should not happen) */
  687|    684|	    continue;
  688|    684|	}
  689|  25.8k|	if( !maxlen )
  ------------------
  |  Branch (689:6): [True: 11, False: 25.8k]
  ------------------
  690|     11|          {
  691|     11|	    afx->truncated++;
  692|     11|            this_truncated = 1;
  693|     11|          }
  694|  25.8k|        else
  695|  25.8k|          this_truncated = 0;
  696|       |
  697|       |
  698|  25.8k|	p = afx->buffer;
  699|  25.8k|	n = afx->buffer_len;
  700|       |
  701|       |	/* Armor header or dash-escaped line? */
  702|  25.8k|	if(p[0]=='-')
  ------------------
  |  Branch (702:5): [True: 11.3k, False: 14.4k]
  ------------------
  703|  11.3k|	  {
  704|       |	    /* 2440bis-10: When reversing dash-escaping, an
  705|       |	       implementation MUST strip the string "- " if it occurs
  706|       |	       at the beginning of a line, and SHOULD warn on "-" and
  707|       |	       any character other than a space at the beginning of a
  708|       |	       line.  */
  709|       |
  710|  11.3k|	    if(p[1]==' ' && !afx->not_dash_escaped)
  ------------------
  |  Branch (710:9): [True: 613, False: 10.7k]
  |  Branch (710:22): [True: 418, False: 195]
  ------------------
  711|    418|	      {
  712|       |		/* It's a dash-escaped line, so skip over the
  713|       |		   escape. */
  714|    418|		afx->buffer_pos = 2;
  715|    418|	      }
  716|  10.9k|	    else if(p[1]=='-' && p[2]=='-' && p[3]=='-' && p[4]=='-')
  ------------------
  |  Branch (716:14): [True: 9.73k, False: 1.21k]
  |  Branch (716:27): [True: 9.19k, False: 539]
  |  Branch (716:40): [True: 8.92k, False: 275]
  |  Branch (716:53): [True: 8.39k, False: 522]
  ------------------
  717|  8.39k|	      {
  718|       |		/* Five dashes in a row mean it's probably armor
  719|       |		   header. */
  720|  8.39k|		int type = is_armor_header( p, n );
  721|  8.39k|                if (type == 42)
  ------------------
  |  Branch (721:21): [True: 718, False: 7.68k]
  ------------------
  722|    718|                  type = -1;  /* Only OpenPGP armors are expected.  */
  723|  8.39k|		if( afx->not_dash_escaped && type != BEGIN_SIGNATURE )
  ------------------
  |  |   82|  2.54k|#define BEGIN_SIGNATURE 2
  ------------------
  |  Branch (723:7): [True: 2.54k, False: 5.85k]
  |  Branch (723:32): [True: 1.91k, False: 631]
  ------------------
  724|  1.91k|		  ; /* this is okay */
  725|  6.48k|		else
  726|  6.48k|		  {
  727|  6.48k|		    if( type != BEGIN_SIGNATURE )
  ------------------
  |  |   82|  6.48k|#define BEGIN_SIGNATURE 2
  ------------------
  |  Branch (727:11): [True: 5.77k, False: 712]
  ------------------
  728|  5.77k|		      {
  729|  5.77k|			log_info(_("unexpected armor: "));
  ------------------
  |  |   28|  5.77k|#  define _(a) gettext (a)
  ------------------
  730|  5.77k|			es_write_sanitized (log_get_stream (), p, n,
  731|  5.77k|                                            NULL, NULL);
  732|  5.77k|			log_printf ("\n");
  733|  5.77k|		      }
  734|       |
  735|  6.48k|		    lastline = 1;
  736|  6.48k|		    rc = -1;
  737|  6.48k|		  }
  738|  8.39k|	      }
  739|  2.55k|	    else if(!afx->not_dash_escaped)
  ------------------
  |  Branch (739:14): [True: 2.09k, False: 459]
  ------------------
  740|  2.09k|	      {
  741|       |		/* Bad dash-escaping. */
  742|  2.09k|		log_info (_("invalid dash escaped line: "));
  ------------------
  |  |   28|  2.09k|#  define _(a) gettext (a)
  ------------------
  743|  2.09k|		es_write_sanitized (log_get_stream (), p, n, NULL, NULL);
  744|  2.09k|		log_printf ("\n");
  745|  2.09k|	      }
  746|  11.3k|	  }
  747|       |
  748|       |	/* Now handle the end-of-line canonicalization */
  749|  25.8k|	if( !afx->not_dash_escaped || this_truncated)
  ------------------
  |  Branch (749:6): [True: 18.8k, False: 6.97k]
  |  Branch (749:32): [True: 3, False: 6.96k]
  ------------------
  750|  18.8k|	  {
  751|  18.8k|	    int crlf = n > 1 && p[n-2] == '\r' && p[n-1]=='\n';
  ------------------
  |  Branch (751:17): [True: 13.7k, False: 5.10k]
  |  Branch (751:26): [True: 270, False: 13.5k]
  |  Branch (751:44): [True: 269, False: 1]
  ------------------
  752|       |
  753|  18.8k|	    afx->buffer_len=
  754|  18.8k|	      trim_trailing_chars( &p[afx->buffer_pos], n-afx->buffer_pos,
  755|  18.8k|				   " \t\r\n");
  756|  18.8k|	    afx->buffer_len+=afx->buffer_pos;
  757|       |	    /* the buffer is always allocated with enough space to append
  758|       |	     * the removed [CR], LF and a Nul
  759|       |	     * The reason for this complicated procedure is to keep at least
  760|       |	     * the original type of lineending - handling of the removed
  761|       |	     * trailing spaces seems to be impossible in our method
  762|       |	     * of faking a packet; either we have to use a temporary file
  763|       |	     * or calculate the hash here in this module and somehow find
  764|       |	     * a way to send the hash down the processing line (well, a special
  765|       |	     * faked packet could do the job).
  766|       |             *
  767|       |             * To make sure that a truncated line triggers a bad
  768|       |             * signature error we replace a removed LF by a FF or
  769|       |             * append a FF.  Right, this is a hack but better than a
  770|       |             * global variable and way easier than to introduce a new
  771|       |             * control packet or insert a line like "[truncated]\n"
  772|       |             * into the filter output.
  773|       |	     */
  774|  18.8k|	    if( crlf )
  ------------------
  |  Branch (774:10): [True: 269, False: 18.6k]
  ------------------
  775|    269|	      afx->buffer[afx->buffer_len++] = '\r';
  776|  18.8k|	    afx->buffer[afx->buffer_len++] = this_truncated? '\f':'\n';
  ------------------
  |  Branch (776:39): [True: 11, False: 18.8k]
  ------------------
  777|  18.8k|	    afx->buffer[afx->buffer_len] = '\0';
  778|  18.8k|	  }
  779|  25.8k|    }
  780|       |
  781|  7.38k|    if( lastline ) { /* write last (ending) length header */
  ------------------
  |  Branch (781:9): [True: 6.48k, False: 901]
  ------------------
  782|  6.48k|        if(tempbuf_len<192)
  ------------------
  |  Branch (782:12): [True: 5.75k, False: 725]
  ------------------
  783|  5.75k|	  buf[len++]=tempbuf_len;
  784|    725|	else
  785|    725|	  {
  786|    725|	    buf[len++]=((tempbuf_len-192)/256) + 192;
  787|    725|	    buf[len++]=(tempbuf_len-192) % 256;
  788|    725|	  }
  789|  6.48k|	memcpy(&buf[len],tempbuf,tempbuf_len);
  790|  6.48k|	len+=tempbuf_len;
  791|       |
  792|  6.48k|	rc = 0;
  793|  6.48k|	afx->faked = 0;
  794|  6.48k|	afx->in_cleartext = 0;
  795|       |	/* and now read the header lines */
  796|  6.48k|	afx->buffer_pos = 0;
  797|  6.74k|	for(;;) {
  798|  6.74k|	    int i;
  799|       |
  800|       |	    /* read the next line (skip all truncated lines) */
  801|  6.74k|	    do {
  802|  6.74k|		maxlen = MAX_LINELEN;
  ------------------
  |  |   38|  6.74k|#define MAX_LINELEN 20000
  ------------------
  803|  6.74k|		afx->buffer_len = iobuf_read_line( a, &afx->buffer,
  804|  6.74k|						 &afx->buffer_size, &maxlen );
  805|  6.74k|	    } while( !maxlen );
  ------------------
  |  Branch (805:15): [True: 6, False: 6.74k]
  ------------------
  806|  6.74k|	    p = afx->buffer;
  807|  6.74k|	    n = afx->buffer_len;
  808|  6.74k|	    if( !n ) {
  ------------------
  |  Branch (808:10): [True: 57, False: 6.68k]
  ------------------
  809|     57|		rc = -1;
  810|     57|		break; /* eof */
  811|     57|	    }
  812|  6.68k|	    i = parse_header_line( afx, p , n );
  813|  6.68k|	    if( i <= 0 ) {
  ------------------
  |  Branch (813:10): [True: 6.42k, False: 257]
  ------------------
  814|  6.42k|		if( i )
  ------------------
  |  Branch (814:7): [True: 6.01k, False: 409]
  ------------------
  815|  6.01k|		    invalid_armor();
  816|  6.42k|		break;
  817|  6.42k|	    }
  818|  6.68k|	}
  819|  6.48k|	afx->inp_checked = 1;
  820|  6.48k|	gcry_md_reset (afx->crc_md);
  821|  6.48k|	afx->idx = 0;
  822|  6.48k|	afx->radbuf[0] = 0;
  823|  6.48k|    }
  824|       |
  825|  7.38k|    *retn = len;
  826|  7.38k|    return rc;
  827|  7.38k|}
armor.c:is_armor_header:
  393|  35.8k|{
  394|  35.8k|    const char *s;
  395|  35.8k|    byte *save_p, *p;
  396|  35.8k|    int save_c;
  397|  35.8k|    int i;
  398|       |
  399|  35.8k|    if( len < 15 )
  ------------------
  |  Branch (399:9): [True: 16.2k, False: 19.5k]
  ------------------
  400|  16.2k|	return -1; /* too short */
  401|  19.5k|    if( memcmp( line, "-----", 5 ) )
  ------------------
  |  Branch (401:9): [True: 1.75k, False: 17.7k]
  ------------------
  402|  1.75k|	return -1; /* no */
  403|  17.7k|    p = strstr( line+5, "-----");
  404|  17.7k|    if( !p )
  ------------------
  |  Branch (404:9): [True: 621, False: 17.1k]
  ------------------
  405|    621|	return -1;
  406|  17.1k|    save_p = p;
  407|  17.1k|    p += 5;
  408|       |
  409|       |    /* Some Windows environments seem to add whitespace to the end of
  410|       |       the line, so we strip it here.  This becomes strict if
  411|       |       --rfc2440 is set since 2440 reads "The header lines, therefore,
  412|       |       MUST start at the beginning of a line, and MUST NOT have text
  413|       |       following them on the same line."  It is unclear whether "text"
  414|       |       refers to all text or just non-whitespace text.  4880 clarified
  415|       |       this was only non-whitespace text. */
  416|       |
  417|  17.1k|    if(RFC2440)
  ------------------
  |  |  373|  17.1k|#define RFC2440 (opt.compliance==CO_RFC2440)
  |  |  ------------------
  |  |  |  Branch (373:17): [True: 0, False: 17.1k]
  |  |  ------------------
  ------------------
  418|      0|      {
  419|      0|	if( *p == '\r' )
  ------------------
  |  Branch (419:6): [True: 0, False: 0]
  ------------------
  420|      0|	  p++;
  421|      0|	if( *p == '\n' )
  ------------------
  |  Branch (421:6): [True: 0, False: 0]
  ------------------
  422|      0|	  p++;
  423|      0|      }
  424|  17.1k|    else
  425|  34.3k|      while(*p==' ' || *p=='\r' || *p=='\n' || *p=='\t')
  ------------------
  |  Branch (425:13): [True: 207, False: 34.1k]
  |  Branch (425:24): [True: 244, False: 33.9k]
  |  Branch (425:36): [True: 16.5k, False: 17.3k]
  |  Branch (425:48): [True: 236, False: 17.1k]
  ------------------
  426|  17.2k|	p++;
  427|       |
  428|  17.1k|    if( *p )
  ------------------
  |  Branch (428:9): [True: 400, False: 16.7k]
  ------------------
  429|    400|	return -1; /* garbage after dashes */
  430|  16.7k|    save_c = *save_p; *save_p = 0;
  431|  16.7k|    p = line+5;
  432|  60.4k|    for(i=0; (s=head_strings[i]); i++ )
  ------------------
  |  Branch (432:14): [True: 58.3k, False: 2.08k]
  ------------------
  433|  58.3k|	if( !strcmp(s, p) )
  ------------------
  |  Branch (433:6): [True: 14.6k, False: 43.7k]
  ------------------
  434|  14.6k|	    break;
  435|  16.7k|    *save_p = save_c;
  436|  16.7k|    if (!s)
  ------------------
  |  Branch (436:9): [True: 2.08k, False: 14.6k]
  ------------------
  437|  2.08k|      {
  438|  2.08k|        if (!strncmp (p, "BEGIN ", 6))
  ------------------
  |  Branch (438:13): [True: 1.54k, False: 537]
  ------------------
  439|  1.54k|          return 42;
  440|    537|	return -1; /* unknown armor line */
  441|  2.08k|      }
  442|       |
  443|  14.6k|    if( opt.verbose > 1 )
  ------------------
  |  Branch (443:9): [True: 0, False: 14.6k]
  ------------------
  444|      0|	log_info(_("armor: %s\n"), head_strings[i]);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  445|  14.6k|    return i;
  446|  16.7k|}
armor.c:parse_header_line:
  458|  24.2k|{
  459|  24.2k|    byte *p;
  460|  24.2k|    int hashes=0;
  461|  24.2k|    unsigned int len2;
  462|       |
  463|  24.2k|    len2 = length_sans_trailing_ws ( line, len );
  464|  24.2k|    if( !len2 ) {
  ------------------
  |  Branch (464:9): [True: 8.03k, False: 16.1k]
  ------------------
  465|  8.03k|        afx->buffer_pos = len2;  /* (it is not the fine way to do it here) */
  466|  8.03k|	return 0; /* WS only: same as empty line */
  467|  8.03k|    }
  468|       |
  469|       |    /*
  470|       |      This is fussy.  The spec says that a header line is delimited
  471|       |      with a colon-space pair.  This means that a line such as
  472|       |      "Comment: " (with nothing else) is actually legal as an empty
  473|       |      string comment.  However, email and cut-and-paste being what it
  474|       |      is, that trailing space may go away.  Therefore, we accept empty
  475|       |      headers delimited with only a colon.  --rfc2440, as always,
  476|       |      makes this strict and enforces the colon-space pair. -dms
  477|       |    */
  478|       |
  479|  16.1k|    p = strchr( line, ':');
  480|  16.1k|    if (!p && afx->dearmor_state)
  ------------------
  |  Branch (480:9): [True: 9.45k, False: 6.74k]
  |  Branch (480:15): [True: 0, False: 9.45k]
  ------------------
  481|      0|      return 0; /* Special treatment in --dearmor mode.  */
  482|  16.1k|    if( !p || (RFC2440 && p[1]!=' ')
  ------------------
  |  |  373|  13.4k|#define RFC2440 (opt.compliance==CO_RFC2440)
  |  |  ------------------
  |  |  |  Branch (373:17): [True: 0, False: 6.74k]
  |  |  ------------------
  ------------------
  |  Branch (482:9): [True: 9.45k, False: 6.74k]
  |  Branch (482:27): [True: 0, False: 0]
  ------------------
  483|  16.1k|	|| (!RFC2440 && p[1]!=' ' && p[1]!='\n' && p[1]!='\r'))
  ------------------
  |  |  373|  13.4k|#define RFC2440 (opt.compliance==CO_RFC2440)
  ------------------
  |  Branch (483:6): [True: 6.74k, False: 0]
  |  Branch (483:18): [True: 3.67k, False: 3.06k]
  |  Branch (483:31): [True: 913, False: 2.76k]
  |  Branch (483:45): [True: 714, False: 199]
  ------------------
  484|  10.1k|      {
  485|  10.1k|	log_error (_("invalid armor header: "));
  ------------------
  |  |   28|  10.1k|#  define _(a) gettext (a)
  ------------------
  486|  10.1k|	es_write_sanitized (log_get_stream (), line, len, NULL, NULL);
  487|  10.1k|	log_printf ("\n");
  488|  10.1k|	return -1;
  489|  10.1k|      }
  490|       |
  491|       |    /* Chop off the whitespace we detected before */
  492|  6.03k|    len=len2;
  493|  6.03k|    line[len2]='\0';
  494|       |
  495|  6.03k|    if( opt.verbose ) {
  ------------------
  |  Branch (495:9): [True: 0, False: 6.03k]
  ------------------
  496|      0|	log_info(_("armor header: "));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  497|      0|	es_write_sanitized (log_get_stream (), line, len, NULL, NULL);
  498|      0|	log_printf ("\n");
  499|      0|    }
  500|       |
  501|  6.03k|    if (afx->dearmor_mode)
  ------------------
  |  Branch (501:9): [True: 0, False: 6.03k]
  ------------------
  502|      0|      ;
  503|  6.03k|    else if (afx->in_cleartext)
  ------------------
  |  Branch (503:14): [True: 3.04k, False: 2.98k]
  ------------------
  504|  3.04k|      {
  505|  3.04k|	if( (hashes=parse_hash_header( line )) )
  ------------------
  |  Branch (505:6): [True: 1.37k, False: 1.67k]
  ------------------
  506|  1.37k|	  afx->hashes |= hashes;
  507|  1.67k|	else if( strlen(line) > 15 && !memcmp( line, "NotDashEscaped:", 15 ) )
  ------------------
  |  Branch (507:11): [True: 883, False: 794]
  |  Branch (507:32): [True: 504, False: 379]
  ------------------
  508|    504|	  afx->not_dash_escaped = 1;
  509|  1.17k|	else
  510|  1.17k|	  {
  511|  1.17k|	    log_error(_("invalid clearsig header\n"));
  ------------------
  |  |   28|  1.17k|#  define _(a) gettext (a)
  ------------------
  512|  1.17k|	    return -1;
  513|  1.17k|	  }
  514|  3.04k|      }
  515|  2.98k|    else if(!is_armor_tag(line))
  ------------------
  |  Branch (515:13): [True: 1.67k, False: 1.30k]
  ------------------
  516|  1.67k|      {
  517|       |	/* Section 6.2: "Unknown keys should be reported to the user,
  518|       |	   but OpenPGP should continue to process the message."  Note
  519|       |	   that in a clearsigned message this applies to the signature
  520|       |	   part (i.e. "BEGIN PGP SIGNATURE") and not the signed data
  521|       |	   ("BEGIN PGP SIGNED MESSAGE").  The only key allowed in the
  522|       |	   signed data section is "Hash". */
  523|       |
  524|  1.67k|	log_info(_("unknown armor header: "));
  ------------------
  |  |   28|  1.67k|#  define _(a) gettext (a)
  ------------------
  525|  1.67k|	es_write_sanitized (log_get_stream (), line, len, NULL, NULL);
  526|  1.67k|	log_printf ("\n");
  527|  1.67k|      }
  528|       |
  529|  4.86k|    return 1;
  530|  6.03k|}
armor.c:parse_hash_header:
  332|  3.04k|{
  333|  3.04k|    const char *s, *s2;
  334|  3.04k|    unsigned found = 0;
  335|       |
  336|  3.04k|    if( strlen(line) < 6  || strlen(line) > 60 )
  ------------------
  |  Branch (336:9): [True: 211, False: 2.83k]
  |  Branch (336:30): [True: 232, False: 2.60k]
  ------------------
  337|    443|	return 0; /* too short or too long */
  338|  2.60k|    if( memcmp( line, "Hash:", 5 ) )
  ------------------
  |  Branch (338:9): [True: 378, False: 2.22k]
  ------------------
  339|    378|	return 0; /* invalid header */
  340|       |
  341|  4.67k|    for(s=line+5;;s=s2) {
  342|  7.33k|	for(; *s && (*s==' ' || *s == '\t'); s++ )
  ------------------
  |  Branch (342:8): [True: 5.95k, False: 1.37k]
  |  Branch (342:15): [True: 2.57k, False: 3.38k]
  |  Branch (342:26): [True: 87, False: 3.30k]
  ------------------
  343|  2.65k|	    ;
  344|  4.67k|	if( !*s )
  ------------------
  |  Branch (344:6): [True: 1.37k, False: 3.30k]
  ------------------
  345|  1.37k|	    break;
  346|  13.2k|	for(s2=s+1; *s2 && *s2!=' ' && *s2 != '\t' && *s2 != ','; s2++ )
  ------------------
  |  Branch (346:14): [True: 11.7k, False: 1.52k]
  |  Branch (346:21): [True: 11.2k, False: 484]
  |  Branch (346:33): [True: 10.9k, False: 293]
  |  Branch (346:48): [True: 9.95k, False: 994]
  ------------------
  347|  9.95k|	    ;
  348|  3.30k|	if( !strncmp( s, "RIPEMD160", s2-s ) )
  ------------------
  |  Branch (348:6): [True: 368, False: 2.93k]
  ------------------
  349|    368|	    found |= 1;
  350|  2.93k|	else if( !strncmp( s, "SHA1", s2-s ) )
  ------------------
  |  Branch (350:11): [True: 1.06k, False: 1.86k]
  ------------------
  351|  1.06k|	    found |= 2;
  352|  1.86k|	else if( !strncmp( s, "SHA224", s2-s ) )
  ------------------
  |  Branch (352:11): [True: 353, False: 1.51k]
  ------------------
  353|    353|	    found |= 8;
  354|  1.51k|	else if( !strncmp( s, "SHA256", s2-s ) )
  ------------------
  |  Branch (354:11): [True: 207, False: 1.30k]
  ------------------
  355|    207|	    found |= 16;
  356|  1.30k|	else if( !strncmp( s, "SHA384", s2-s ) )
  ------------------
  |  Branch (356:11): [True: 306, False: 1.00k]
  ------------------
  357|    306|	    found |= 32;
  358|  1.00k|	else if( !strncmp( s, "SHA512", s2-s ) )
  ------------------
  |  Branch (358:11): [True: 398, False: 603]
  ------------------
  359|    398|	    found |= 64;
  360|    603|	else
  361|    603|	    return 0;
  362|  3.28k|	for(; *s2 && (*s2==' ' || *s2 == '\t'); s2++ )
  ------------------
  |  Branch (362:8): [True: 1.92k, False: 1.36k]
  |  Branch (362:16): [True: 281, False: 1.63k]
  |  Branch (362:28): [True: 311, False: 1.32k]
  ------------------
  363|    592|	    ;
  364|  2.69k|	if( *s2 && *s2 != ',' )
  ------------------
  |  Branch (364:6): [True: 1.32k, False: 1.36k]
  |  Branch (364:13): [True: 253, False: 1.07k]
  ------------------
  365|    253|	    return 0;
  366|  2.44k|	if( *s2 )
  ------------------
  |  Branch (366:6): [True: 1.07k, False: 1.36k]
  ------------------
  367|  1.07k|	    s2++;
  368|  2.44k|    }
  369|  1.37k|    return found;
  370|  2.22k|}
armor.c:is_armor_tag:
  375|  2.98k|{
  376|  2.98k|  if(strncmp(line,"Version",7)==0
  ------------------
  |  Branch (376:6): [True: 261, False: 2.72k]
  ------------------
  377|  2.98k|     || strncmp(line,"Comment",7)==0
  ------------------
  |  Branch (377:9): [True: 254, False: 2.46k]
  ------------------
  378|  2.98k|     || strncmp(line,"MessageID",9)==0
  ------------------
  |  Branch (378:9): [True: 215, False: 2.25k]
  ------------------
  379|  2.98k|     || strncmp(line,"Hash",4)==0
  ------------------
  |  Branch (379:9): [True: 218, False: 2.03k]
  ------------------
  380|  2.98k|     || strncmp(line,"Charset",7)==0)
  ------------------
  |  Branch (380:9): [True: 359, False: 1.67k]
  ------------------
  381|  1.30k|    return 1;
  382|       |
  383|  1.67k|  return 0;
  384|  2.98k|}
armor.c:invalid_armor:
  315|  6.01k|{
  316|  6.01k|    write_status(STATUS_BADARMOR);
  317|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  318|       |    g10_exit(1); /* stop here */
  319|       |#endif
  320|  6.01k|}
armor.c:check_input:
  537|  13.9k|{
  538|  13.9k|    int rc = 0;
  539|  13.9k|    int i;
  540|  13.9k|    byte *line;
  541|  13.9k|    unsigned len;
  542|  13.9k|    unsigned maxlen;
  543|  13.9k|    int hdr_line = -1;
  544|       |
  545|       |    /* read the first line to see whether this is armored data */
  546|  13.9k|    maxlen = MAX_LINELEN;
  ------------------
  |  |   38|  13.9k|#define MAX_LINELEN 20000
  ------------------
  547|  13.9k|    len = afx->buffer_len = iobuf_read_line( a, &afx->buffer,
  548|  13.9k|					     &afx->buffer_size, &maxlen );
  549|  13.9k|    line = afx->buffer;
  550|  13.9k|    if( !maxlen ) {
  ------------------
  |  Branch (550:9): [True: 33, False: 13.9k]
  ------------------
  551|       |	/* line has been truncated: assume not armored */
  552|     33|	afx->inp_checked = 1;
  553|     33|	afx->inp_bypass = 1;
  554|     33|	return 0;
  555|     33|    }
  556|       |
  557|  13.9k|    if( !len ) {
  ------------------
  |  Branch (557:9): [True: 98, False: 13.8k]
  ------------------
  558|     98|	return -1; /* eof */
  559|     98|    }
  560|       |
  561|       |    /* (the line is always a C string but maybe longer) */
  562|  13.8k|    if( *line == '\n' || ( len && (*line == '\r' && line[1]=='\n') ) )
  ------------------
  |  Branch (562:9): [True: 428, False: 13.3k]
  |  Branch (562:28): [True: 13.3k, False: 0]
  |  Branch (562:36): [True: 542, False: 12.8k]
  |  Branch (562:53): [True: 213, False: 329]
  ------------------
  563|    641|	;
  564|  13.1k|    else if (len >= 2 && !is_armored (line)) {
  ------------------
  |  Branch (564:14): [True: 13.1k, False: 25]
  |  Branch (564:26): [True: 329, False: 12.8k]
  ------------------
  565|    329|	afx->inp_checked = 1;
  566|    329|	afx->inp_bypass = 1;
  567|    329|	return 0;
  568|    329|    }
  569|       |
  570|       |    /* find the armor header */
  571|  27.9k|    while(len) {
  ------------------
  |  Branch (571:11): [True: 27.4k, False: 557]
  ------------------
  572|  27.4k|	i = is_armor_header( line, len );
  573|  27.4k|        if ( i == 42 ) {
  ------------------
  |  Branch (573:14): [True: 828, False: 26.5k]
  ------------------
  574|    828|            if (afx->dearmor_mode) {
  ------------------
  |  Branch (574:17): [True: 0, False: 828]
  ------------------
  575|      0|                afx->dearmor_state = 1;
  576|      0|                break;
  577|      0|            }
  578|    828|        }
  579|  26.5k|        else if (i >= 0
  ------------------
  |  Branch (579:18): [True: 12.9k, False: 13.6k]
  ------------------
  580|  26.5k|                 && !(afx->only_keyblocks && i != 1 && i != 5 && i != 6 )) {
  ------------------
  |  Branch (580:23): [True: 0, False: 12.9k]
  |  Branch (580:46): [True: 0, False: 0]
  |  Branch (580:56): [True: 0, False: 0]
  |  Branch (580:66): [True: 0, False: 0]
  ------------------
  581|  12.9k|	    hdr_line = i;
  582|  12.9k|	    if( hdr_line == BEGIN_SIGNED_MSG_IDX ) {
  ------------------
  |  |   83|  12.9k|#define BEGIN_SIGNED_MSG_IDX 3
  ------------------
  |  Branch (582:10): [True: 7.17k, False: 5.77k]
  ------------------
  583|  7.17k|	        if( afx->in_cleartext ) {
  ------------------
  |  Branch (583:14): [True: 0, False: 7.17k]
  ------------------
  584|      0|		    log_error(_("nested clear text signatures\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  585|      0|		    rc = gpg_error (GPG_ERR_INV_ARMOR);
  586|      0|                }
  587|  7.17k|		afx->in_cleartext = 1;
  588|  7.17k|	    }
  589|  12.9k|	    break;
  590|  12.9k|	}
  591|       |
  592|       |	/* read the next line (skip all truncated lines) */
  593|  14.4k|	do {
  594|  14.4k|	    maxlen = MAX_LINELEN;
  ------------------
  |  |   38|  14.4k|#define MAX_LINELEN 20000
  ------------------
  595|  14.4k|	    afx->buffer_len = iobuf_read_line( a, &afx->buffer,
  596|  14.4k|					       &afx->buffer_size, &maxlen );
  597|  14.4k|	    line = afx->buffer;
  598|  14.4k|	    len = afx->buffer_len;
  599|  14.4k|	} while( !maxlen );
  ------------------
  |  Branch (599:11): [True: 6, False: 14.4k]
  ------------------
  600|  14.4k|    }
  601|       |
  602|       |    /* Parse the header lines.  */
  603|  18.1k|    while(len) {
  ------------------
  |  Branch (603:11): [True: 17.5k, False: 557]
  ------------------
  604|       |	/* Read the next line (skip all truncated lines). */
  605|  17.5k|	do {
  606|  17.5k|	    maxlen = MAX_LINELEN;
  ------------------
  |  |   38|  17.5k|#define MAX_LINELEN 20000
  ------------------
  607|  17.5k|	    afx->buffer_len = iobuf_read_line( a, &afx->buffer,
  608|  17.5k|					       &afx->buffer_size, &maxlen );
  609|  17.5k|	    line = afx->buffer;
  610|  17.5k|	    len = afx->buffer_len;
  611|  17.5k|	} while( !maxlen );
  ------------------
  |  Branch (611:11): [True: 6, False: 17.5k]
  ------------------
  612|       |
  613|  17.5k|	i = parse_header_line( afx, line, len );
  614|  17.5k|	if( i <= 0 ) {
  ------------------
  |  Branch (614:6): [True: 12.9k, False: 4.60k]
  ------------------
  615|  12.9k|	    if (i && RFC2440)
  ------------------
  |  |  373|  5.31k|#define RFC2440 (opt.compliance==CO_RFC2440)
  |  |  ------------------
  |  |  |  Branch (373:17): [True: 0, False: 5.31k]
  |  |  ------------------
  ------------------
  |  Branch (615:10): [True: 5.31k, False: 7.62k]
  ------------------
  616|      0|		rc = GPG_ERR_INV_ARMOR;
  617|  12.9k|	    break;
  618|  12.9k|	}
  619|  17.5k|    }
  620|       |
  621|       |
  622|  13.4k|    if( rc )
  ------------------
  |  Branch (622:9): [True: 0, False: 13.4k]
  ------------------
  623|      0|	invalid_armor();
  624|  13.4k|    else if( afx->in_cleartext )
  ------------------
  |  Branch (624:14): [True: 7.17k, False: 6.32k]
  ------------------
  625|  7.17k|	afx->faked = 1;
  626|  6.32k|    else {
  627|  6.32k|	afx->inp_checked = 1;
  628|  6.32k|	gcry_md_reset (afx->crc_md);
  629|  6.32k|	afx->idx = 0;
  630|  6.32k|	afx->radbuf[0] = 0;
  631|  6.32k|    }
  632|       |
  633|  13.4k|    return rc;
  634|  13.8k|}
armor.c:radix64_read:
  843|  13.2k|{
  844|  13.2k|    byte val;
  845|  13.2k|    int c;
  846|  13.2k|    u32 binc;
  847|  13.2k|    int checkcrc=0;
  848|  13.2k|    int rc = 0;
  849|  13.2k|    size_t n = 0;
  850|  13.2k|    int idx, onlypad=0;
  851|  13.2k|    int skip_fast = 0;
  852|       |
  853|  13.2k|    idx = afx->idx;
  854|  13.2k|    val = afx->radbuf[0];
  855|   427k|    for( n=0; n < size; ) {
  ------------------
  |  Branch (855:15): [True: 426k, False: 173]
  ------------------
  856|       |
  857|   426k|	if( afx->buffer_pos < afx->buffer_len )
  ------------------
  |  Branch (857:6): [True: 413k, False: 13.0k]
  ------------------
  858|   413k|	    c = afx->buffer[afx->buffer_pos++];
  859|  13.0k|	else { /* read the next line */
  860|  13.0k|	    unsigned maxlen = MAX_LINELEN;
  ------------------
  |  |   38|  13.0k|#define MAX_LINELEN 20000
  ------------------
  861|  13.0k|	    afx->buffer_pos = 0;
  862|  13.0k|	    afx->buffer_len = iobuf_read_line( a, &afx->buffer,
  863|  13.0k|					       &afx->buffer_size, &maxlen );
  864|  13.0k|	    if( !maxlen )
  ------------------
  |  Branch (864:10): [True: 4, False: 13.0k]
  ------------------
  865|      4|		afx->truncated++;
  866|  13.0k|	    if( !afx->buffer_len )
  ------------------
  |  Branch (866:10): [True: 1.52k, False: 11.5k]
  ------------------
  867|  1.52k|		break; /* eof */
  868|  11.5k|	    continue;
  869|  13.0k|	}
  870|       |
  871|   415k|      again:
  872|   415k|	binc = asctobin[0][c];
  873|       |
  874|   415k|	if( binc != 0xffffffffUL )
  ------------------
  |  Branch (874:6): [True: 144k, False: 270k]
  ------------------
  875|   144k|	  {
  876|   144k|	    if( idx == 0 && skip_fast == 0
  ------------------
  |  Branch (876:10): [True: 69.1k, False: 75.2k]
  |  Branch (876:22): [True: 64.3k, False: 4.78k]
  ------------------
  877|   144k|		&& afx->buffer_pos + (16 - 1) < afx->buffer_len
  ------------------
  |  Branch (877:6): [True: 47.3k, False: 17.0k]
  ------------------
  878|   144k|		&& n + 12 < size)
  ------------------
  |  Branch (878:6): [True: 46.9k, False: 480]
  ------------------
  879|  46.9k|	      {
  880|       |		/* Fast path for radix64 to binary conversion.  */
  881|  46.9k|		u32 b0,b1,b2,b3;
  882|       |
  883|       |		/* Speculatively load 15 more input bytes.  */
  884|  46.9k|		b0 = binc << (3 * 6);
  885|  46.9k|		b0 |= asctobin[2][afx->buffer[afx->buffer_pos + 0]];
  886|  46.9k|		b0 |= asctobin[1][afx->buffer[afx->buffer_pos + 1]];
  887|  46.9k|		b0 |= asctobin[0][afx->buffer[afx->buffer_pos + 2]];
  888|  46.9k|		b1  = asctobin[3][afx->buffer[afx->buffer_pos + 3]];
  889|  46.9k|		b1 |= asctobin[2][afx->buffer[afx->buffer_pos + 4]];
  890|  46.9k|		b1 |= asctobin[1][afx->buffer[afx->buffer_pos + 5]];
  891|  46.9k|		b1 |= asctobin[0][afx->buffer[afx->buffer_pos + 6]];
  892|  46.9k|		b2  = asctobin[3][afx->buffer[afx->buffer_pos + 7]];
  893|  46.9k|		b2 |= asctobin[2][afx->buffer[afx->buffer_pos + 8]];
  894|  46.9k|		b2 |= asctobin[1][afx->buffer[afx->buffer_pos + 9]];
  895|  46.9k|		b2 |= asctobin[0][afx->buffer[afx->buffer_pos + 10]];
  896|  46.9k|		b3  = asctobin[3][afx->buffer[afx->buffer_pos + 11]];
  897|  46.9k|		b3 |= asctobin[2][afx->buffer[afx->buffer_pos + 12]];
  898|  46.9k|		b3 |= asctobin[1][afx->buffer[afx->buffer_pos + 13]];
  899|  46.9k|		b3 |= asctobin[0][afx->buffer[afx->buffer_pos + 14]];
  900|       |
  901|       |		/* Check if any of the input bytes were invalid. */
  902|  46.9k|		if( (b0 | b1 | b2 | b3) != 0xffffffffUL )
  ------------------
  |  Branch (902:7): [True: 31.6k, False: 15.2k]
  ------------------
  903|  31.6k|		  {
  904|       |		    /* All 16 bytes are valid. */
  905|  31.6k|		    buf[n + 0] = b0 >> (2 * 8);
  906|  31.6k|		    buf[n + 1] = b0 >> (1 * 8);
  907|  31.6k|		    buf[n + 2] = b0 >> (0 * 8);
  908|  31.6k|		    buf[n + 3] = b1 >> (2 * 8);
  909|  31.6k|		    buf[n + 4] = b1 >> (1 * 8);
  910|  31.6k|		    buf[n + 5] = b1 >> (0 * 8);
  911|  31.6k|		    buf[n + 6] = b2 >> (2 * 8);
  912|  31.6k|		    buf[n + 7] = b2 >> (1 * 8);
  913|  31.6k|		    buf[n + 8] = b2 >> (0 * 8);
  914|  31.6k|		    buf[n + 9] = b3 >> (2 * 8);
  915|  31.6k|		    buf[n + 10] = b3 >> (1 * 8);
  916|  31.6k|		    buf[n + 11] = b3 >> (0 * 8);
  917|  31.6k|		    afx->buffer_pos += 16 - 1;
  918|  31.6k|		    n += 12;
  919|  31.6k|		    continue;
  920|  31.6k|		  }
  921|  15.2k|		else if( b0 == 0xffffffffUL )
  ------------------
  |  Branch (921:12): [True: 8.26k, False: 6.94k]
  ------------------
  922|  8.26k|		  {
  923|       |		    /* byte[1..3] have invalid character(s).  Switch to slow
  924|       |		       path.  */
  925|  8.26k|		    skip_fast = 1;
  926|  8.26k|		  }
  927|  6.94k|		else if( b1 == 0xffffffffUL )
  ------------------
  |  Branch (927:12): [True: 3.45k, False: 3.48k]
  ------------------
  928|  3.45k|		  {
  929|       |		    /* byte[4..7] have invalid character(s), first 4 bytes are
  930|       |		       valid.  */
  931|  3.45k|		    buf[n + 0] = b0 >> (2 * 8);
  932|  3.45k|		    buf[n + 1] = b0 >> (1 * 8);
  933|  3.45k|		    buf[n + 2] = b0 >> (0 * 8);
  934|  3.45k|		    afx->buffer_pos += 4 - 1;
  935|  3.45k|		    n += 3;
  936|  3.45k|		    skip_fast = 1;
  937|  3.45k|		    continue;
  938|  3.45k|		  }
  939|  3.48k|		else if( b2 == 0xffffffffUL )
  ------------------
  |  Branch (939:12): [True: 1.73k, False: 1.75k]
  ------------------
  940|  1.73k|		  {
  941|       |		    /* byte[8..11] have invalid character(s), first 8 bytes are
  942|       |		       valid.  */
  943|  1.73k|		    buf[n + 0] = b0 >> (2 * 8);
  944|  1.73k|		    buf[n + 1] = b0 >> (1 * 8);
  945|  1.73k|		    buf[n + 2] = b0 >> (0 * 8);
  946|  1.73k|		    buf[n + 3] = b1 >> (2 * 8);
  947|  1.73k|		    buf[n + 4] = b1 >> (1 * 8);
  948|  1.73k|		    buf[n + 5] = b1 >> (0 * 8);
  949|  1.73k|		    afx->buffer_pos += 8 - 1;
  950|  1.73k|		    n += 6;
  951|  1.73k|		    skip_fast = 1;
  952|  1.73k|		    continue;
  953|  1.73k|		  }
  954|  1.75k|		else /*if( b3 == 0xffffffffUL )*/
  955|  1.75k|		  {
  956|       |		    /* byte[12..15] have invalid character(s), first 12 bytes
  957|       |		       are valid.  */
  958|  1.75k|		    buf[n + 0] = b0 >> (2 * 8);
  959|  1.75k|		    buf[n + 1] = b0 >> (1 * 8);
  960|  1.75k|		    buf[n + 2] = b0 >> (0 * 8);
  961|  1.75k|		    buf[n + 3] = b1 >> (2 * 8);
  962|  1.75k|		    buf[n + 4] = b1 >> (1 * 8);
  963|  1.75k|		    buf[n + 5] = b1 >> (0 * 8);
  964|  1.75k|		    buf[n + 6] = b2 >> (2 * 8);
  965|  1.75k|		    buf[n + 7] = b2 >> (1 * 8);
  966|  1.75k|		    buf[n + 8] = b2 >> (0 * 8);
  967|  1.75k|		    afx->buffer_pos += 12 - 1;
  968|  1.75k|		    n += 9;
  969|  1.75k|		    skip_fast = 1;
  970|  1.75k|		    continue;
  971|  1.75k|		  }
  972|  46.9k|	      }
  973|       |
  974|   105k|	    switch(idx)
  ------------------
  |  Branch (974:13): [True: 0, False: 105k]
  ------------------
  975|   105k|	      {
  976|  30.5k|		case 0: val =  binc << 2; break;
  ------------------
  |  Branch (976:3): [True: 30.5k, False: 75.2k]
  ------------------
  977|  26.4k|		case 1: val |= (binc>>4)&3; buf[n++]=val;val=(binc<<4)&0xf0;break;
  ------------------
  |  Branch (977:3): [True: 26.4k, False: 79.3k]
  ------------------
  978|  24.9k|		case 2: val |= (binc>>2)&15; buf[n++]=val;val=(binc<<6)&0xc0;break;
  ------------------
  |  Branch (978:3): [True: 24.9k, False: 80.8k]
  ------------------
  979|  23.8k|		case 3: val |= binc&0x3f; buf[n++] = val; break;
  ------------------
  |  Branch (979:3): [True: 23.8k, False: 81.9k]
  ------------------
  980|   105k|	      }
  981|   105k|	    idx = (idx+1) % 4;
  982|       |
  983|   105k|	    continue;
  984|   105k|	  }
  985|       |
  986|   270k|	skip_fast = 0;
  987|       |
  988|   270k|	if( c == '\n' || c == ' ' || c == '\r' || c == '\t' )
  ------------------
  |  Branch (988:6): [True: 10.9k, False: 259k]
  |  Branch (988:19): [True: 5.19k, False: 254k]
  |  Branch (988:31): [True: 6.11k, False: 248k]
  |  Branch (988:44): [True: 2.74k, False: 245k]
  ------------------
  989|  24.9k|	    continue;
  990|   245k|	else if( c == '=' ) { /* pad character: stop */
  ------------------
  |  Branch (990:11): [True: 12.7k, False: 232k]
  ------------------
  991|       |	    /* some mailers leave quoted-printable encoded characters
  992|       |	     * so we try to workaround this */
  993|  12.7k|	    if( afx->buffer_pos+2 < afx->buffer_len ) {
  ------------------
  |  Branch (993:10): [True: 5.63k, False: 7.16k]
  ------------------
  994|  5.63k|		int cc1, cc2, cc3;
  995|  5.63k|		cc1 = afx->buffer[afx->buffer_pos];
  996|  5.63k|		cc2 = afx->buffer[afx->buffer_pos+1];
  997|  5.63k|		cc3 = afx->buffer[afx->buffer_pos+2];
  998|  5.63k|		if( isxdigit(cc1) && isxdigit(cc2)
  999|  5.63k|				  && strchr( "=\n\r\t ", cc3 )) {
  ------------------
  |  Branch (999:10): [True: 1.25k, False: 144]
  ------------------
 1000|       |		    /* well it seems to be the case - adjust */
 1001|  1.25k|		    c = isdigit(cc1)? (cc1 - '0'): (ascii_toupper(cc1)-'A'+10);
 1002|  1.25k|		    c <<= 4;
 1003|  1.25k|		    c |= isdigit(cc2)? (cc2 - '0'): (ascii_toupper(cc2)-'A'+10);
 1004|  1.25k|		    afx->buffer_pos += 2;
 1005|  1.25k|		    afx->qp_detected = 1;
 1006|  1.25k|		    goto again;
 1007|  1.25k|		}
 1008|  5.63k|	    }
 1009|       |
 1010|       |            /* Occasionally a bug MTA will leave the = escaped as
 1011|       |               =3D.  If the 4 characters following that are valid
 1012|       |               Radix64 characters and they are following by a new
 1013|       |               line, assume that this is the case and skip the
 1014|       |               3D.  */
 1015|  11.5k|            if (afx->buffer_pos + 6 < afx->buffer_len
  ------------------
  |  Branch (1015:17): [True: 998, False: 10.5k]
  ------------------
 1016|  11.5k|                && afx->buffer[afx->buffer_pos + 0] == '3'
  ------------------
  |  Branch (1016:20): [True: 113, False: 885]
  ------------------
 1017|  11.5k|                && afx->buffer[afx->buffer_pos + 1] == 'D'
  ------------------
  |  Branch (1017:20): [True: 19, False: 94]
  ------------------
 1018|  11.5k|                && asctobin[0][afx->buffer[afx->buffer_pos + 2]] != 0xffffffffUL
  ------------------
  |  Branch (1018:20): [True: 18, False: 1]
  ------------------
 1019|  11.5k|                && asctobin[0][afx->buffer[afx->buffer_pos + 3]] != 0xffffffffUL
  ------------------
  |  Branch (1019:20): [True: 16, False: 2]
  ------------------
 1020|  11.5k|                && asctobin[0][afx->buffer[afx->buffer_pos + 4]] != 0xffffffffUL
  ------------------
  |  Branch (1020:20): [True: 15, False: 1]
  ------------------
 1021|  11.5k|                && asctobin[0][afx->buffer[afx->buffer_pos + 5]] != 0xffffffffUL
  ------------------
  |  Branch (1021:20): [True: 11, False: 4]
  ------------------
 1022|  11.5k|                && afx->buffer[afx->buffer_pos + 6] == '\n')
  ------------------
  |  Branch (1022:20): [True: 0, False: 11]
  ------------------
 1023|      0|              {
 1024|      0|                afx->buffer_pos += 2;
 1025|      0|                afx->qp_detected = 1;
 1026|      0|              }
 1027|       |
 1028|  11.5k|	    if (!n)
  ------------------
  |  Branch (1028:10): [True: 8.60k, False: 2.93k]
  ------------------
 1029|  8.60k|	      onlypad = 1;
 1030|       |
 1031|  11.5k|	    if( idx == 1 )
  ------------------
  |  Branch (1031:10): [True: 3.95k, False: 7.59k]
  ------------------
 1032|  3.95k|		buf[n++] = val;
 1033|  11.5k|	    checkcrc++;
 1034|  11.5k|	    break;
 1035|  12.7k|	}
 1036|   232k|        else if (afx->dearmor_state && c == '-'
  ------------------
  |  Branch (1036:18): [True: 0, False: 232k]
  |  Branch (1036:40): [True: 0, False: 0]
  ------------------
 1037|   232k|                 && afx->buffer_pos + 8 < afx->buffer_len
  ------------------
  |  Branch (1037:21): [True: 0, False: 0]
  ------------------
 1038|   232k|                 && !strncmp (afx->buffer, "-----END ", 8)) {
  ------------------
  |  Branch (1038:21): [True: 0, False: 0]
  ------------------
 1039|      0|            break; /* End in --dearmor mode.  */
 1040|      0|        }
 1041|   232k|	else {
 1042|   232k|	    log_error(_("invalid radix64 character %02X skipped\n"), c);
  ------------------
  |  |   28|   232k|#  define _(a) gettext (a)
  ------------------
 1043|   232k|	    continue;
 1044|   232k|	}
 1045|   270k|    }
 1046|       |
 1047|  13.2k|    afx->idx = idx;
 1048|  13.2k|    afx->radbuf[0] = val;
 1049|       |
 1050|  13.2k|    if( n )
  ------------------
  |  Branch (1050:9): [True: 7.08k, False: 6.14k]
  ------------------
 1051|  7.08k|      gcry_md_write (afx->crc_md, buf, n);
 1052|       |
 1053|  13.2k|    if( checkcrc ) {
  ------------------
  |  Branch (1053:9): [True: 11.5k, False: 1.69k]
  ------------------
 1054|  11.5k|	gcry_md_final (afx->crc_md);
 1055|  11.5k|	afx->any_data = 1;
 1056|  11.5k|	afx->inp_checked=0;
 1057|  11.5k|	afx->faked = 0;
 1058|  15.0k|	for(;;) { /* skip lf and pad characters */
 1059|  15.0k|	    if( afx->buffer_pos < afx->buffer_len )
  ------------------
  |  Branch (1059:10): [True: 14.4k, False: 635]
  ------------------
 1060|  14.4k|		c = afx->buffer[afx->buffer_pos++];
 1061|    635|	    else { /* read the next line */
 1062|    635|		unsigned maxlen = MAX_LINELEN;
  ------------------
  |  |   38|    635|#define MAX_LINELEN 20000
  ------------------
 1063|    635|		afx->buffer_pos = 0;
 1064|    635|		afx->buffer_len = iobuf_read_line( a, &afx->buffer,
 1065|    635|						   &afx->buffer_size, &maxlen );
 1066|    635|		if( !maxlen )
  ------------------
  |  Branch (1066:7): [True: 1, False: 634]
  ------------------
 1067|      1|		    afx->truncated++;
 1068|    635|		if( !afx->buffer_len )
  ------------------
  |  Branch (1068:7): [True: 85, False: 550]
  ------------------
 1069|     85|		    break; /* eof */
 1070|    550|		continue;
 1071|    635|	    }
 1072|  14.4k|	    if( c == '\n' || c == ' ' || c == '\r'
  ------------------
  |  Branch (1072:10): [True: 559, False: 13.8k]
  |  Branch (1072:23): [True: 225, False: 13.6k]
  |  Branch (1072:35): [True: 1.44k, False: 12.1k]
  ------------------
 1073|  14.4k|		|| c == '\t' || c == '=' )
  ------------------
  |  Branch (1073:6): [True: 380, False: 11.7k]
  |  Branch (1073:19): [True: 337, False: 11.4k]
  ------------------
 1074|  2.95k|		continue;
 1075|  11.4k|	    break;
 1076|  14.4k|	}
 1077|  11.5k|	if( !afx->buffer_len )
  ------------------
  |  Branch (1077:6): [True: 85, False: 11.4k]
  ------------------
 1078|     85|	    log_error(_("premature eof (no CRC)\n"));
  ------------------
  |  |   28|     85|#  define _(a) gettext (a)
  ------------------
 1079|  11.4k|	else {
 1080|  11.4k|	    u32 mycrc = 0;
 1081|  11.4k|	    idx = 0;
 1082|  13.1k|	    do {
 1083|  13.1k|		if( (binc = asctobin[0][c]) == 0xffffffffUL )
  ------------------
  |  Branch (1083:7): [True: 10.8k, False: 2.30k]
  ------------------
 1084|  10.8k|		    break;
 1085|  2.30k|		switch(idx) {
  ------------------
  |  Branch (1085:10): [True: 0, False: 2.30k]
  ------------------
 1086|    628|		  case 0: val =  binc << 2; break;
  ------------------
  |  Branch (1086:5): [True: 628, False: 1.67k]
  ------------------
 1087|    580|		  case 1: val |= (binc>>4)&3; mycrc |= val << 16;val=(binc<<4)&0xf0;break;
  ------------------
  |  Branch (1087:5): [True: 580, False: 1.72k]
  ------------------
 1088|    559|		  case 2: val |= (binc>>2)&15; mycrc |= val << 8;val=(binc<<6)&0xc0;break;
  ------------------
  |  Branch (1088:5): [True: 559, False: 1.74k]
  ------------------
 1089|    537|		  case 3: val |= binc&0x3f; mycrc |= val; break;
  ------------------
  |  Branch (1089:5): [True: 537, False: 1.76k]
  ------------------
 1090|  2.30k|		}
 1091|  2.30k|		for(;;) {
 1092|  2.30k|		    if( afx->buffer_pos < afx->buffer_len )
  ------------------
  |  Branch (1092:11): [True: 2.25k, False: 46]
  ------------------
 1093|  2.25k|			c = afx->buffer[afx->buffer_pos++];
 1094|     46|		    else { /* read the next line */
 1095|     46|			unsigned maxlen = MAX_LINELEN;
  ------------------
  |  |   38|     46|#define MAX_LINELEN 20000
  ------------------
 1096|     46|			afx->buffer_pos = 0;
 1097|     46|			afx->buffer_len = iobuf_read_line( a, &afx->buffer,
 1098|     46|							   &afx->buffer_size,
 1099|     46|								&maxlen );
 1100|     46|			if( !maxlen )
  ------------------
  |  Branch (1100:8): [True: 0, False: 46]
  ------------------
 1101|      0|			    afx->truncated++;
 1102|     46|			if( !afx->buffer_len )
  ------------------
  |  Branch (1102:8): [True: 46, False: 0]
  ------------------
 1103|     46|			    break; /* eof */
 1104|      0|			continue;
 1105|     46|		    }
 1106|  2.25k|		    break;
 1107|  2.30k|		}
 1108|  2.30k|		if( !afx->buffer_len )
  ------------------
  |  Branch (1108:7): [True: 46, False: 2.25k]
  ------------------
 1109|     46|		    break; /* eof */
 1110|  2.30k|	    } while( ++idx < 4 );
  ------------------
  |  Branch (1110:15): [True: 1.72k, False: 534]
  ------------------
 1111|  11.4k|	    if( !afx->buffer_len ) {
  ------------------
  |  Branch (1111:10): [True: 46, False: 11.4k]
  ------------------
 1112|     46|		log_info(_("premature eof (in CRC)\n"));
  ------------------
  |  |   28|     46|#  define _(a) gettext (a)
  ------------------
 1113|     46|		rc = invalid_crc();
 1114|     46|	    }
 1115|  11.4k|	    else if( idx == 0 ) {
  ------------------
  |  Branch (1115:15): [True: 10.8k, False: 582]
  ------------------
 1116|       |	        /* No CRC at all is legal ("MAY") */
 1117|  10.8k|	        rc=0;
 1118|  10.8k|	    }
 1119|    582|	    else if( idx != 4 ) {
  ------------------
  |  Branch (1119:15): [True: 48, False: 534]
  ------------------
 1120|     48|		log_info(_("malformed CRC\n"));
  ------------------
  |  |   28|     48|#  define _(a) gettext (a)
  ------------------
 1121|     48|		rc = invalid_crc();
 1122|     48|	    }
 1123|    534|	    else if( mycrc != get_afx_crc (afx) ) {
  ------------------
  |  Branch (1123:15): [True: 92, False: 442]
  ------------------
 1124|     92|		log_info (_("CRC error; %06lX - %06lX\n"),
  ------------------
  |  |   28|     92|#  define _(a) gettext (a)
  ------------------
 1125|     92|				    (ulong)get_afx_crc (afx), (ulong)mycrc);
 1126|     92|		rc = invalid_crc();
 1127|     92|	    }
 1128|    442|	    else {
 1129|    442|		rc = 0;
 1130|       |                /* FIXME: Here we should emit another control packet,
 1131|       |                 * so that we know in mainproc that we are processing
 1132|       |                 * a clearsign message */
 1133|       |#if 0
 1134|       |		for(rc=0;!rc;) {
 1135|       |		    rc = 0 /*check_trailer( &fhdr, c )*/;
 1136|       |		    if( !rc ) {
 1137|       |			if( (c=iobuf_get(a)) == -1 )
 1138|       |			    rc = 2;
 1139|       |		    }
 1140|       |		}
 1141|       |		if( rc == -1 )
 1142|       |		    rc = 0;
 1143|       |		else if( rc == 2 ) {
 1144|       |		    log_error(_("premature eof (in trailer)\n"));
 1145|       |		    rc = GPG_ERR_INV_ARMOR;
 1146|       |		}
 1147|       |		else {
 1148|       |		    log_error(_("error in trailer line\n"));
 1149|       |		    rc = GPG_ERR_INV_ARMOR;
 1150|       |		}
 1151|       |#endif
 1152|    442|	    }
 1153|  11.4k|	}
 1154|  11.5k|    }
 1155|       |
 1156|  13.2k|    if( !n && !onlypad )
  ------------------
  |  Branch (1156:9): [True: 6.14k, False: 7.08k]
  |  Branch (1156:15): [True: 1.21k, False: 4.93k]
  ------------------
 1157|  1.21k|	rc = -1;
 1158|       |
 1159|  13.2k|    *retn = n;
 1160|  13.2k|    return rc;
 1161|  13.2k|}
armor.c:invalid_crc:
  832|    186|{
  833|    186|  if ( opt.ignore_crc_error )
  ------------------
  |  Branch (833:8): [True: 0, False: 186]
  ------------------
  834|      0|    return 0;
  835|    186|  log_inc_errorcount();
  836|    186|  return gpg_error (GPG_ERR_INV_ARMOR);
  837|    186|}
armor.c:initialize:
  170|      1|{
  171|      1|    u32 i;
  172|      1|    const byte *s;
  173|       |
  174|       |    /* Build the helptable for radix64 to bin conversion.  Value 0xffffffff is
  175|       |       used to detect invalid characters.  */
  176|      1|    memset (asctobin, 0xff, sizeof(asctobin));
  177|     65|    for(s=bintoasc,i=0; *s; s++,i++ )
  ------------------
  |  Branch (177:25): [True: 64, False: 1]
  ------------------
  178|     64|      {
  179|     64|	asctobin[0][*s] = i << (0 * 6);
  180|     64|	asctobin[1][*s] = i << (1 * 6);
  181|     64|	asctobin[2][*s] = i << (2 * 6);
  182|     64|	asctobin[3][*s] = i << (3 * 6);
  183|     64|      }
  184|       |
  185|      1|    is_initialized=1;
  186|      1|}
armor.c:get_afx_crc:
  191|    626|{
  192|    626|  const byte *crc_buf;
  193|    626|  u32 crc;
  194|       |
  195|    626|  crc_buf = gcry_md_read (afx->crc_md, GCRY_MD_CRC24_RFC2440);
  196|       |
  197|    626|  crc = crc_buf[0];
  198|    626|  crc <<= 8;
  199|    626|  crc |= crc_buf[1];
  200|    626|  crc <<= 8;
  201|    626|  crc |= crc_buf[2];
  202|       |
  203|    626|  return crc;
  204|    626|}

agent_scd_serialno:
 1444|  58.5k|{
 1445|  58.5k|  int err;
 1446|  58.5k|  char *serialno = NULL;
 1447|  58.5k|  char line[ASSUAN_LINELENGTH];
 1448|       |
 1449|  58.5k|  if (r_serialno)
  ------------------
  |  Branch (1449:7): [True: 0, False: 58.5k]
  ------------------
 1450|      0|    *r_serialno = NULL;
 1451|       |
 1452|  58.5k|  err = start_agent (NULL, (1 | FLAG_FOR_CARD_SUPPRESS_ERRORS));
  ------------------
  |  |  229|  58.5k|#define FLAG_FOR_CARD_SUPPRESS_ERRORS 2
  ------------------
 1453|  58.5k|  if (err)
  ------------------
  |  Branch (1453:7): [True: 58.5k, False: 0]
  ------------------
 1454|  58.5k|    return err;
 1455|       |
 1456|      0|  if (!demand)
  ------------------
  |  Branch (1456:7): [True: 0, False: 0]
  ------------------
 1457|      0|    strcpy (line, "SCD SERIALNO");
 1458|      0|  else
 1459|      0|    snprintf (line, DIM(line), "SCD SERIALNO --demand=%s", demand);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
                  snprintf (line, DIM(line), "SCD SERIALNO --demand=%s", demand);
  ------------------
  |  |   47|      0|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
 1460|       |
 1461|      0|  err = assuan_transact (agent_ctx, line,
 1462|      0|                         NULL, NULL, NULL, NULL,
 1463|      0|                         get_serialno_cb, &serialno);
 1464|      0|  if (err)
  ------------------
  |  Branch (1464:7): [True: 0, False: 0]
  ------------------
 1465|      0|    {
 1466|      0|      xfree (serialno);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1467|      0|      return err;
 1468|      0|    }
 1469|       |
 1470|      0|  if (r_serialno)
  ------------------
  |  Branch (1470:7): [True: 0, False: 0]
  ------------------
 1471|      0|    *r_serialno = serialno;
 1472|      0|  else
 1473|      0|    xfree (serialno);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1474|       |
 1475|      0|  return 0;
 1476|      0|}
free_keypair_info:
 1813|  58.5k|{
 1814|  58.5k|  keypair_info_t l_next;
 1815|       |
 1816|  58.5k|  for (; l; l = l_next)
  ------------------
  |  Branch (1816:10): [True: 0, False: 58.5k]
  ------------------
 1817|      0|    {
 1818|      0|      l_next = l->next;
 1819|      0|      xfree (l->serialno);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1820|      0|      xfree (l->idstr);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1821|      0|      xfree (l);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1822|      0|    }
 1823|  58.5k|}
agent_get_passphrase:
 1960|   118k|{
 1961|   118k|  int rc;
 1962|   118k|  char line[ASSUAN_LINELENGTH];
 1963|   118k|  char *arg1 = NULL;
 1964|   118k|  char *arg2 = NULL;
 1965|   118k|  char *arg3 = NULL;
 1966|   118k|  char *arg4 = NULL;
 1967|   118k|  membuf_t data;
 1968|   118k|  struct default_inq_parm_s dfltparm;
 1969|   118k|  int have_newsymkey;
 1970|       |
 1971|   118k|  memset (&dfltparm, 0, sizeof dfltparm);
 1972|       |
 1973|   118k|  *r_passphrase = NULL;
 1974|       |
 1975|   118k|  rc = start_agent (NULL, 0);
 1976|   118k|  if (rc)
  ------------------
  |  Branch (1976:7): [True: 118k, False: 0]
  ------------------
 1977|   118k|    return rc;
 1978|      0|  dfltparm.ctx = agent_ctx;
 1979|       |
 1980|       |  /* Check that the gpg-agent understands the repeat option.  */
 1981|      0|  if (assuan_transact (agent_ctx,
  ------------------
  |  Branch (1981:7): [True: 0, False: 0]
  ------------------
 1982|      0|                       "GETINFO cmd_has_option GET_PASSPHRASE repeat",
 1983|      0|                       NULL, NULL, NULL, NULL, NULL, NULL))
 1984|      0|    return gpg_error (GPG_ERR_NOT_SUPPORTED);
 1985|      0|  have_newsymkey = !(assuan_transact
 1986|      0|                     (agent_ctx,
 1987|      0|                      "GETINFO cmd_has_option GET_PASSPHRASE newsymkey",
 1988|      0|                      NULL, NULL, NULL, NULL, NULL, NULL));
 1989|       |
 1990|      0|  if (cache_id && *cache_id)
  ------------------
  |  Branch (1990:7): [True: 0, False: 0]
  |  Branch (1990:19): [True: 0, False: 0]
  ------------------
 1991|      0|    if (!(arg1 = percent_plus_escape (cache_id)))
  ------------------
  |  Branch (1991:9): [True: 0, False: 0]
  ------------------
 1992|      0|      goto no_mem;
 1993|      0|  if (err_msg && *err_msg)
  ------------------
  |  Branch (1993:7): [True: 0, False: 0]
  |  Branch (1993:18): [True: 0, False: 0]
  ------------------
 1994|      0|    if (!(arg2 = percent_plus_escape (err_msg)))
  ------------------
  |  Branch (1994:9): [True: 0, False: 0]
  ------------------
 1995|      0|      goto no_mem;
 1996|      0|  if (prompt && *prompt)
  ------------------
  |  Branch (1996:7): [True: 0, False: 0]
  |  Branch (1996:17): [True: 0, False: 0]
  ------------------
 1997|      0|    if (!(arg3 = percent_plus_escape (prompt)))
  ------------------
  |  Branch (1997:9): [True: 0, False: 0]
  ------------------
 1998|      0|      goto no_mem;
 1999|      0|  if (desc_msg && *desc_msg)
  ------------------
  |  Branch (1999:7): [True: 0, False: 0]
  |  Branch (1999:19): [True: 0, False: 0]
  ------------------
 2000|      0|    if (!(arg4 = percent_plus_escape (desc_msg)))
  ------------------
  |  Branch (2000:9): [True: 0, False: 0]
  ------------------
 2001|      0|      goto no_mem;
 2002|       |
 2003|       |  /* CHECK && REPEAT or NEWSYMKEY is here an indication that a new
 2004|       |   * passphrase for symmetric encryption is requested; if the agent
 2005|       |   * supports this we enable the modern API by also passing --newsymkey.  */
 2006|      0|  snprintf (line, DIM(line),
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
                snprintf (line, DIM(line),
  ------------------
  |  |   47|      0|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
 2007|      0|            "GET_PASSPHRASE --data --repeat=%d%s%s -- %s %s %s %s",
 2008|      0|            repeat,
 2009|      0|            ((repeat && check) || newsymkey)? " --check":"",
  ------------------
  |  Branch (2009:15): [True: 0, False: 0]
  |  Branch (2009:25): [True: 0, False: 0]
  |  Branch (2009:35): [True: 0, False: 0]
  ------------------
 2010|      0|            (have_newsymkey && newsymkey)? " --newsymkey":"",
  ------------------
  |  Branch (2010:14): [True: 0, False: 0]
  |  Branch (2010:32): [True: 0, False: 0]
  ------------------
 2011|      0|            arg1? arg1:"X",
  ------------------
  |  Branch (2011:13): [True: 0, False: 0]
  ------------------
 2012|      0|            arg2? arg2:"X",
  ------------------
  |  Branch (2012:13): [True: 0, False: 0]
  ------------------
 2013|      0|            arg3? arg3:"X",
  ------------------
  |  Branch (2013:13): [True: 0, False: 0]
  ------------------
 2014|      0|            arg4? arg4:"X");
  ------------------
  |  Branch (2014:13): [True: 0, False: 0]
  ------------------
 2015|      0|  xfree (arg1);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2016|      0|  xfree (arg2);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2017|      0|  xfree (arg3);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2018|      0|  xfree (arg4);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2019|       |
 2020|      0|  init_membuf_secure (&data, 64);
 2021|      0|  rc = assuan_transact (agent_ctx, line,
 2022|      0|                        put_membuf_cb, &data,
 2023|      0|                        default_inq_cb, &dfltparm,
 2024|      0|                        NULL, NULL);
 2025|       |
 2026|      0|  if (rc)
  ------------------
  |  Branch (2026:7): [True: 0, False: 0]
  ------------------
 2027|      0|    xfree (get_membuf (&data, NULL));
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2028|      0|  else
 2029|      0|    {
 2030|      0|      put_membuf (&data, "", 1);
 2031|      0|      *r_passphrase = get_membuf (&data, NULL);
 2032|      0|      if (!*r_passphrase)
  ------------------
  |  Branch (2032:11): [True: 0, False: 0]
  ------------------
 2033|      0|        rc = gpg_error_from_syserror ();
 2034|      0|    }
 2035|      0|  return rc;
 2036|      0| no_mem:
 2037|      0|  rc = gpg_error_from_syserror ();
 2038|      0|  xfree (arg1);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2039|      0|  xfree (arg2);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2040|      0|  xfree (arg3);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2041|      0|  xfree (arg4);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2042|      0|  return rc;
 2043|      0|}
call-agent.c:start_agent:
  235|   176k|{
  236|   176k|  int rc;
  237|       |
  238|   176k|  (void)ctrl;  /* Not yet used.  */
  239|       |
  240|       |  /* Fixme: We need a context for each thread or serialize the access
  241|       |     to the agent. */
  242|   176k|  if (agent_ctx)
  ------------------
  |  Branch (242:7): [True: 0, False: 176k]
  ------------------
  243|      0|    rc = 0;
  244|   176k|  else
  245|   176k|    {
  246|   176k|      rc = start_new_gpg_agent (&agent_ctx,
  247|   176k|                                GPG_ERR_SOURCE_DEFAULT,
  ------------------
  |  |   34|   176k|#define GPG_ERR_SOURCE_DEFAULT  GPG_ERR_SOURCE_GPG
  ------------------
  248|   176k|                                opt.agent_program,
  249|   176k|                                opt.lc_ctype, opt.lc_messages,
  250|   176k|                                opt.session_env,
  251|   176k|                                opt.autostart, opt.verbose, DBG_IPC,
  ------------------
  |  |  355|   176k|#define DBG_IPC     (opt.debug & DBG_IPC_VALUE)
  |  |  ------------------
  |  |  |  |  342|   176k|#define DBG_IPC_VALUE     1024  /* debug assuan communication */
  |  |  ------------------
  ------------------
  252|   176k|                                NULL, NULL);
  253|   176k|      if (!opt.autostart && gpg_err_code (rc) == GPG_ERR_NO_AGENT)
  ------------------
  |  Branch (253:11): [True: 176k, False: 0]
  |  Branch (253:29): [True: 176k, False: 0]
  ------------------
  254|   176k|        {
  255|   176k|          static int shown;
  256|       |
  257|   176k|          if (!shown)
  ------------------
  |  Branch (257:15): [True: 1, False: 176k]
  ------------------
  258|      1|            {
  259|      1|              shown = 1;
  260|      1|              log_info (_("no gpg-agent running in this session\n"));
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
  261|      1|            }
  262|   176k|        }
  263|      0|      else if (!rc
  ------------------
  |  Branch (263:16): [True: 0, False: 0]
  ------------------
  264|      0|               && !(rc = warn_version_mismatch (agent_ctx, GPG_AGENT_NAME, 0)))
  ------------------
  |  |  143|      0|#define GPG_AGENT_NAME "gpg-agent"
  ------------------
  |  Branch (264:19): [True: 0, False: 0]
  ------------------
  265|      0|        {
  266|       |          /* Tell the agent that we support Pinentry notifications.
  267|       |             No error checking so that it will work also with older
  268|       |             agents.  */
  269|      0|          assuan_transact (agent_ctx, "OPTION allow-pinentry-notify",
  270|      0|                           NULL, NULL, NULL, NULL, NULL, NULL);
  271|       |          /* Tell the agent about what version we are aware.  This is
  272|       |             here used to indirectly enable GPG_ERR_FULLY_CANCELED.  */
  273|      0|          assuan_transact (agent_ctx, "OPTION agent-awareness=2.1.0",
  274|      0|                           NULL, NULL, NULL, NULL, NULL, NULL);
  275|       |          /* Pass on the pinentry mode.  */
  276|      0|          if (opt.pinentry_mode)
  ------------------
  |  Branch (276:15): [True: 0, False: 0]
  ------------------
  277|      0|            {
  278|      0|              char *tmp = xasprintf ("OPTION pinentry-mode=%s",
  279|      0|                                     str_pinentry_mode (opt.pinentry_mode));
  280|      0|              rc = assuan_transact (agent_ctx, tmp,
  281|      0|                               NULL, NULL, NULL, NULL, NULL, NULL);
  282|      0|              xfree (tmp);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  283|      0|              if (rc)
  ------------------
  |  Branch (283:19): [True: 0, False: 0]
  ------------------
  284|      0|                {
  285|      0|                  log_error ("setting pinentry mode '%s' failed: %s\n",
  286|      0|                             str_pinentry_mode (opt.pinentry_mode),
  287|      0|                             gpg_strerror (rc));
  288|      0|                  write_status_error ("set_pinentry_mode", rc);
  289|      0|                }
  290|      0|            }
  291|       |
  292|       |          /* Pass on the request origin.  */
  293|      0|          if (opt.request_origin)
  ------------------
  |  Branch (293:15): [True: 0, False: 0]
  ------------------
  294|      0|            {
  295|      0|              char *tmp = xasprintf ("OPTION pretend-request-origin=%s",
  296|      0|                                     str_request_origin (opt.request_origin));
  297|      0|              rc = assuan_transact (agent_ctx, tmp,
  298|      0|                               NULL, NULL, NULL, NULL, NULL, NULL);
  299|      0|              xfree (tmp);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  300|      0|              if (rc)
  ------------------
  |  Branch (300:19): [True: 0, False: 0]
  ------------------
  301|      0|                {
  302|      0|                  log_error ("setting request origin '%s' failed: %s\n",
  303|      0|                             str_request_origin (opt.request_origin),
  304|      0|                             gpg_strerror (rc));
  305|      0|                  write_status_error ("set_request_origin", rc);
  306|      0|                }
  307|      0|            }
  308|       |
  309|       |          /* In DE_VS mode under Windows we require that the JENT RNG
  310|       |           * is active.  */
  311|       |#ifdef HAVE_W32_SYSTEM
  312|       |          if (!rc && opt.compliance == CO_DE_VS)
  313|       |            {
  314|       |              if (assuan_transact (agent_ctx, "GETINFO jent_active",
  315|       |                                   NULL, NULL, NULL, NULL, NULL, NULL))
  316|       |                {
  317|       |                  rc = gpg_error (GPG_ERR_FORBIDDEN);
  318|       |                  log_error (_("%s is not compliant with %s mode\n"),
  319|       |                             GPG_AGENT_NAME,
  320|       |                             gnupg_compliance_option_string (opt.compliance));
  321|       |                  write_status_error ("random-compliance", rc);
  322|       |                }
  323|       |            }
  324|       |#endif /*HAVE_W32_SYSTEM*/
  325|       |
  326|      0|        }
  327|   176k|    }
  328|       |
  329|   176k|  if (!rc && flag_for_card && !did_early_card_test)
  ------------------
  |  Branch (329:7): [True: 0, False: 176k]
  |  Branch (329:14): [True: 0, False: 0]
  |  Branch (329:31): [True: 0, False: 0]
  ------------------
  330|      0|    {
  331|       |      /* Request the serial number of the card for an early test.  */
  332|      0|      struct agent_card_info_s info;
  333|       |
  334|      0|      memset (&info, 0, sizeof info);
  335|       |
  336|      0|      if (!(flag_for_card & FLAG_FOR_CARD_SUPPRESS_ERRORS))
  ------------------
  |  |  229|      0|#define FLAG_FOR_CARD_SUPPRESS_ERRORS 2
  ------------------
  |  Branch (336:11): [True: 0, False: 0]
  ------------------
  337|      0|        rc = warn_version_mismatch (agent_ctx, SCDAEMON_NAME, 2);
  ------------------
  |  |  719|      0|#define SCDAEMON_NAME "scdaemon"
  ------------------
  338|      0|      if (!rc)
  ------------------
  |  Branch (338:11): [True: 0, False: 0]
  ------------------
  339|      0|        rc = assuan_transact (agent_ctx,
  340|      0|                              opt.flags.use_only_openpgp_card?
  ------------------
  |  Branch (340:31): [True: 0, False: 0]
  ------------------
  341|      0|                              "SCD SERIALNO openpgp" : "SCD SERIALNO",
  342|      0|                              NULL, NULL, NULL, NULL,
  343|      0|                              learn_status_cb, &info);
  344|      0|      if (rc && !(flag_for_card & FLAG_FOR_CARD_SUPPRESS_ERRORS))
  ------------------
  |  |  229|      0|#define FLAG_FOR_CARD_SUPPRESS_ERRORS 2
  ------------------
  |  Branch (344:11): [True: 0, False: 0]
  |  Branch (344:17): [True: 0, False: 0]
  ------------------
  345|      0|        {
  346|      0|          switch (gpg_err_code (rc))
  347|      0|            {
  348|      0|            case GPG_ERR_NOT_SUPPORTED:
  ------------------
  |  Branch (348:13): [True: 0, False: 0]
  ------------------
  349|      0|            case GPG_ERR_NO_SCDAEMON:
  ------------------
  |  Branch (349:13): [True: 0, False: 0]
  ------------------
  350|      0|              write_status_text (STATUS_CARDCTRL, "6");
  351|      0|              break;
  352|      0|            case GPG_ERR_OBJ_TERM_STATE:
  ------------------
  |  Branch (352:13): [True: 0, False: 0]
  ------------------
  353|      0|              write_status_text (STATUS_CARDCTRL, "7");
  354|      0|              break;
  355|      0|            default:
  ------------------
  |  Branch (355:13): [True: 0, False: 0]
  ------------------
  356|      0|              write_status_text (STATUS_CARDCTRL, "4");
  357|      0|              log_info ("selecting card failed: %s\n", gpg_strerror (rc));
  358|      0|              break;
  359|      0|            }
  360|      0|        }
  361|       |
  362|      0|      if (!rc && is_status_enabled () && info.serialno)
  ------------------
  |  Branch (362:11): [True: 0, False: 0]
  |  Branch (362:18): [True: 0, False: 0]
  |  Branch (362:42): [True: 0, False: 0]
  ------------------
  363|      0|        {
  364|      0|          char *buf;
  365|       |
  366|      0|          buf = xasprintf ("3 %s", info.serialno);
  367|      0|          write_status_text (STATUS_CARDCTRL, buf);
  368|      0|          xfree (buf);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  369|      0|        }
  370|       |
  371|      0|      agent_release_card_info (&info);
  372|       |
  373|      0|      if (!rc)
  ------------------
  |  Branch (373:11): [True: 0, False: 0]
  ------------------
  374|      0|        did_early_card_test = 1;
  375|      0|    }
  376|       |
  377|       |
  378|   176k|  return rc;
  379|   176k|}

gpg_dirmngr_deinit_session_data:
  127|  11.9k|{
  128|  11.9k|  dirmngr_local_t dml;
  129|       |
  130|  11.9k|  while ((dml = ctrl->dirmngr_local))
  ------------------
  |  Branch (130:10): [True: 0, False: 11.9k]
  ------------------
  131|      0|    {
  132|      0|      ctrl->dirmngr_local = dml->next;
  133|      0|      if (dml->is_active)
  ------------------
  |  Branch (133:11): [True: 0, False: 0]
  ------------------
  134|      0|        log_error ("oops: trying to cleanup an active dirmngr context\n");
  135|      0|      else
  136|      0|        assuan_release (dml->ctx);
  137|      0|      xfree (dml);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  138|      0|    }
  139|  11.9k|}

keydb_new:
  255|  58.8k|{
  256|  58.8k|  gpg_error_t err;
  257|  58.8k|  KEYDB_HANDLE hd;
  258|       |
  259|  58.8k|  if (DBG_CLOCK)
  ------------------
  |  |  356|  58.8k|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  58.8k|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 58.8k]
  |  |  ------------------
  ------------------
  260|      0|    log_clock ("keydb_new");
  261|       |
  262|  58.8k|  hd = xtrycalloc (1, sizeof *hd);
  ------------------
  |  |   99|  58.8k|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  263|  58.8k|  if (!hd)
  ------------------
  |  Branch (263:7): [True: 0, False: 58.8k]
  ------------------
  264|      0|    {
  265|      0|      err = gpg_error_from_syserror ();
  266|      0|      goto leave;
  267|      0|    }
  268|       |
  269|  58.8k|  if (!opt.use_keyboxd)
  ------------------
  |  Branch (269:7): [True: 58.8k, False: 0]
  ------------------
  270|  58.8k|    {
  271|  58.8k|      err = internal_keydb_init (hd);
  272|  58.8k|      goto leave;
  273|  58.8k|    }
  274|      0|  hd->use_keyboxd = 1;
  275|      0|  hd->ctrl = ctrl;
  276|       |
  277|      0|  err = open_context (ctrl, &hd->kbl);
  278|       |
  279|  58.8k| leave:
  280|  58.8k|  if (err)
  ------------------
  |  Branch (280:7): [True: 0, False: 58.8k]
  ------------------
  281|      0|    {
  282|      0|      int rc;
  283|      0|      log_error (_("error opening key DB: %s\n"), gpg_strerror (err));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  284|      0|      xfree (hd);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  285|      0|      hd = NULL;
  286|      0|      if (!(rc = gpg_err_code_to_errno (err)))
  ------------------
  |  Branch (286:11): [True: 0, False: 0]
  ------------------
  287|      0|        rc = gpg_err_code_to_errno (GPG_ERR_EIO);
  288|      0|      gpg_err_set_errno (rc);
  289|      0|    }
  290|  58.8k|  return hd;
  291|      0|}
keydb_release:
  297|  70.5k|{
  298|  70.5k|  keyboxd_local_t kbl;
  299|       |
  300|  70.5k|  if (!hd)
  ------------------
  |  Branch (300:7): [True: 11.6k, False: 58.8k]
  ------------------
  301|  11.6k|    return;
  302|       |
  303|  58.8k|  if (DBG_CLOCK)
  ------------------
  |  |  356|  58.8k|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  58.8k|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 58.8k]
  |  |  ------------------
  ------------------
  304|      0|    log_clock ("keydb_release");
  305|  58.8k|  if (!hd->use_keyboxd)
  ------------------
  |  Branch (305:7): [True: 58.8k, False: 0]
  ------------------
  306|  58.8k|    internal_keydb_deinit (hd);
  307|      0|  else
  308|      0|    {
  309|      0|      kbl = hd->kbl;
  310|      0|      if (DBG_CLOCK)
  ------------------
  |  |  356|      0|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|      0|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  311|      0|        log_clock ("close_context (found)");
  312|      0|      if (!kbl->is_active)
  ------------------
  |  Branch (312:11): [True: 0, False: 0]
  ------------------
  313|      0|        log_fatal ("closing inactive keyboxd context %p\n", kbl);
  314|      0|      kbl->is_active = 0;
  315|      0|      hd->kbl = NULL;
  316|      0|      hd->ctrl = NULL;
  317|      0|    }
  318|  58.8k|  xfree (hd);
  ------------------
  |  |  104|  58.8k|#define xfree(a)         gcry_free ((a))
  ------------------
  319|  58.8k|}
keydb_search_reset:
  577|  6.92M|{
  578|  6.92M|  gpg_error_t err;
  579|       |
  580|  6.92M|  if (!hd)
  ------------------
  |  Branch (580:7): [True: 0, False: 6.92M]
  ------------------
  581|      0|    return gpg_error (GPG_ERR_INV_ARG);
  582|       |
  583|  6.92M|  if (DBG_CLOCK)
  ------------------
  |  |  356|  6.92M|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  6.92M|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 6.92M]
  |  |  ------------------
  ------------------
  584|      0|    log_clock ("%s", __func__);
  585|  6.92M|  if (DBG_CACHE)
  ------------------
  |  |  352|  6.92M|#define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
  |  |  ------------------
  |  |  |  |  338|  6.92M|#define DBG_CACHE_VALUE   64	/* debug the caching */
  |  |  ------------------
  |  |  |  Branch (352:20): [True: 0, False: 6.92M]
  |  |  ------------------
  ------------------
  586|      0|    log_debug ("%s (hd=%p)", __func__, hd);
  587|       |
  588|  6.92M|  if (!hd->use_keyboxd)
  ------------------
  |  Branch (588:7): [True: 6.92M, False: 0]
  ------------------
  589|  6.92M|    {
  590|  6.92M|      err = internal_keydb_search_reset (hd);
  591|  6.92M|      goto leave;
  592|  6.92M|    }
  593|       |
  594|       |  /* All we need is to tell search that a reset is pending.  Note that
  595|       |   * keydb_new sets this flag as well.  To comply with the
  596|       |   * specification of keydb_delete_keyblock we also need to clear the
  597|       |   * ubid flag so that after a reset a delete can't be performed.  */
  598|      0|  hd->kbl->need_search_reset = 1;
  599|      0|  hd->last_ubid_valid = 0;
  600|      0|  err = 0;
  601|       |
  602|  6.92M| leave:
  603|  6.92M|  return err;
  604|      0|}
keydb_search:
  677|  6.98M|{
  678|  6.98M|  gpg_error_t err;
  679|  6.98M|  int i;
  680|  6.98M|  char line[ASSUAN_LINELENGTH];
  681|  6.98M|  char *buffer;
  682|  6.98M|  size_t len;
  683|       |
  684|  6.98M|  if (!hd)
  ------------------
  |  Branch (684:7): [True: 0, False: 6.98M]
  ------------------
  685|      0|    return gpg_error (GPG_ERR_INV_ARG);
  686|       |
  687|  6.98M|  if (descindex)
  ------------------
  |  Branch (687:7): [True: 0, False: 6.98M]
  ------------------
  688|      0|    *descindex = 0; /* Make sure it is always set on return.  */
  689|       |
  690|  6.98M|  if (DBG_CLOCK)
  ------------------
  |  |  356|  6.98M|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  6.98M|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 6.98M]
  |  |  ------------------
  ------------------
  691|      0|    log_clock ("%s enter", __func__);
  692|       |
  693|  6.98M|  if (DBG_LOOKUP)
  ------------------
  |  |  357|  6.98M|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|  6.98M|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 6.98M]
  |  |  ------------------
  ------------------
  694|      0|    {
  695|      0|      log_debug ("%s: %zu search descriptions:\n", __func__, ndesc);
  696|      0|      for (i = 0; i < ndesc; i ++)
  ------------------
  |  Branch (696:19): [True: 0, False: 0]
  ------------------
  697|      0|        {
  698|      0|          char *t = keydb_search_desc_dump (&desc[i]);
  699|      0|          log_debug ("%s   %d: %s\n", __func__, i, t);
  700|      0|          xfree (t);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  701|      0|        }
  702|      0|    }
  703|       |
  704|  6.98M|  if (!hd->use_keyboxd)
  ------------------
  |  Branch (704:7): [True: 6.98M, False: 0]
  ------------------
  705|  6.98M|    {
  706|  6.98M|      err = internal_keydb_search (hd, desc, ndesc, descindex);
  707|  6.98M|      goto leave;
  708|  6.98M|    }
  709|       |
  710|       |  /* Clear the result objects.  */
  711|      0|  if (hd->kbl->search_result)
  ------------------
  |  Branch (711:7): [True: 0, False: 0]
  ------------------
  712|      0|    {
  713|      0|      iobuf_close (hd->kbl->search_result);
  714|      0|      hd->kbl->search_result = NULL;
  715|      0|    }
  716|       |
  717|       |  /* Check whether this is a NEXT search.  */
  718|      0|  if (!hd->kbl->need_search_reset)
  ------------------
  |  Branch (718:7): [True: 0, False: 0]
  ------------------
  719|      0|    {
  720|       |      /* No reset requested thus continue the search.  The keyboxd
  721|       |       * keeps the context of the search and thus the NEXT operates on
  722|       |       * the last search pattern.  This is how we always used the
  723|       |       * keydb.c functions.  In theory we were able to modify the
  724|       |       * search pattern between searches but that is not anymore
  725|       |       * supported by keyboxd and a cursory check does not show that
  726|       |       * we actually made used of that misfeature.  */
  727|      0|      snprintf (line, sizeof line, "NEXT");
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  728|      0|      goto do_search;
  729|      0|    }
  730|       |
  731|      0|  hd->kbl->need_search_reset = 0;
  732|       |
  733|      0|  if (!ndesc)
  ------------------
  |  Branch (733:7): [True: 0, False: 0]
  ------------------
  734|      0|    {
  735|      0|      err = gpg_error (GPG_ERR_INV_ARG);
  736|      0|      goto leave;
  737|      0|    }
  738|      0|  for (i = 0; i < ndesc; i++)
  ------------------
  |  Branch (738:15): [True: 0, False: 0]
  ------------------
  739|      0|    if (desc->mode == KEYDB_SEARCH_MODE_FIRST)
  ------------------
  |  Branch (739:9): [True: 0, False: 0]
  ------------------
  740|      0|      {
  741|       |        /* If any description has mode FIRST, this item trumps all
  742|       |         * other descriptions.  */
  743|      0|        snprintf (line, sizeof line, "SEARCH --openpgp");
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  744|      0|        goto do_search;
  745|      0|      }
  746|       |
  747|      0|  for ( ; ndesc; desc++, ndesc--)
  ------------------
  |  Branch (747:11): [True: 0, False: 0]
  ------------------
  748|      0|    {
  749|      0|      const char *more = ndesc > 1 ? "--openpgp --more" : "--openpgp";
  ------------------
  |  Branch (749:26): [True: 0, False: 0]
  ------------------
  750|       |
  751|      0|      switch (desc->mode)
  752|      0|        {
  753|      0|        case KEYDB_SEARCH_MODE_EXACT:
  ------------------
  |  Branch (753:9): [True: 0, False: 0]
  ------------------
  754|      0|          snprintf (line, sizeof line, "SEARCH %s -- =%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  755|      0|          break;
  756|       |
  757|      0|        case KEYDB_SEARCH_MODE_SUBSTR:
  ------------------
  |  Branch (757:9): [True: 0, False: 0]
  ------------------
  758|      0|          snprintf (line, sizeof line, "SEARCH %s -- *%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  759|      0|          break;
  760|       |
  761|      0|        case KEYDB_SEARCH_MODE_MAIL:
  ------------------
  |  Branch (761:9): [True: 0, False: 0]
  ------------------
  762|      0|          snprintf (line, sizeof line, "SEARCH %s -- <%s",
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  763|      0|                    more, desc->u.name+(desc->u.name[0] == '<') );
  764|      0|          break;
  765|       |
  766|      0|        case KEYDB_SEARCH_MODE_MAILSUB:
  ------------------
  |  Branch (766:9): [True: 0, False: 0]
  ------------------
  767|      0|          snprintf (line, sizeof line, "SEARCH %s -- @%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  768|      0|          break;
  769|       |
  770|      0|        case KEYDB_SEARCH_MODE_MAILEND:
  ------------------
  |  Branch (770:9): [True: 0, False: 0]
  ------------------
  771|      0|          snprintf (line, sizeof line, "SEARCH %s -- .%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  772|      0|          break;
  773|       |
  774|      0|        case KEYDB_SEARCH_MODE_WORDS:
  ------------------
  |  Branch (774:9): [True: 0, False: 0]
  ------------------
  775|      0|          snprintf (line, sizeof line, "SEARCH %s -- +%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  776|      0|          break;
  777|       |
  778|      0|        case KEYDB_SEARCH_MODE_SHORT_KID:
  ------------------
  |  Branch (778:9): [True: 0, False: 0]
  ------------------
  779|      0|          snprintf (line, sizeof line, "SEARCH %s -- 0x%08lX", more,
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  780|      0|                    (ulong)desc->u.kid[1]);
  781|      0|          break;
  782|       |
  783|      0|        case KEYDB_SEARCH_MODE_LONG_KID:
  ------------------
  |  Branch (783:9): [True: 0, False: 0]
  ------------------
  784|      0|          snprintf (line, sizeof line, "SEARCH %s -- 0x%08lX%08lX", more,
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  785|      0|                    (ulong)desc->u.kid[0], (ulong)desc->u.kid[1]);
  786|      0|          break;
  787|       |
  788|      0|        case KEYDB_SEARCH_MODE_FPR:
  ------------------
  |  Branch (788:9): [True: 0, False: 0]
  ------------------
  789|      0|          {
  790|      0|            unsigned char hexfpr[MAX_FINGERPRINT_LEN * 2 + 1];
  791|      0|            log_assert (desc->fprlen <= MAX_FINGERPRINT_LEN);
  792|      0|            bin2hex (desc->u.fpr, desc->fprlen, hexfpr);
  793|      0|            snprintf (line, sizeof line, "SEARCH %s -- 0x%s", more, hexfpr);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  794|      0|          }
  795|      0|          break;
  796|       |
  797|      0|        case KEYDB_SEARCH_MODE_ISSUER:
  ------------------
  |  Branch (797:9): [True: 0, False: 0]
  ------------------
  798|      0|          snprintf (line, sizeof line, "SEARCH %s -- #/%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  799|      0|          break;
  800|       |
  801|      0|        case KEYDB_SEARCH_MODE_ISSUER_SN:
  ------------------
  |  Branch (801:9): [True: 0, False: 0]
  ------------------
  802|      0|        case KEYDB_SEARCH_MODE_SN:
  ------------------
  |  Branch (802:9): [True: 0, False: 0]
  ------------------
  803|      0|          snprintf (line, sizeof line, "SEARCH %s -- #%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  804|      0|          break;
  805|       |
  806|      0|        case KEYDB_SEARCH_MODE_SUBJECT:
  ------------------
  |  Branch (806:9): [True: 0, False: 0]
  ------------------
  807|      0|          snprintf (line, sizeof line, "SEARCH %s -- /%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  808|      0|          break;
  809|       |
  810|      0|        case KEYDB_SEARCH_MODE_KEYGRIP:
  ------------------
  |  Branch (810:9): [True: 0, False: 0]
  ------------------
  811|      0|          {
  812|      0|            unsigned char hexgrip[KEYGRIP_LEN * 2 + 1];
  813|      0|            bin2hex (desc->u.grip, KEYGRIP_LEN, hexgrip);
  ------------------
  |  |   56|      0|#define KEYGRIP_LEN 20
  ------------------
  814|      0|            snprintf (line, sizeof line, "SEARCH %s -- &%s", more, hexgrip);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  815|      0|          }
  816|      0|          break;
  817|       |
  818|      0|        case KEYDB_SEARCH_MODE_UBID:
  ------------------
  |  Branch (818:9): [True: 0, False: 0]
  ------------------
  819|      0|          {
  820|      0|            unsigned char hexubid[UBID_LEN * 2 + 1];
  821|      0|            bin2hex (desc->u.ubid, UBID_LEN, hexubid);
  ------------------
  |  |   60|      0|#define UBID_LEN    20
  ------------------
  822|      0|            snprintf (line, sizeof line, "SEARCH %s -- ^%s", more, hexubid);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  823|      0|          }
  824|      0|          break;
  825|       |
  826|      0|        case KEYDB_SEARCH_MODE_NEXT:
  ------------------
  |  Branch (826:9): [True: 0, False: 0]
  ------------------
  827|      0|          log_debug ("%s: mode next - we should not get to here!\n", __func__);
  828|      0|          snprintf (line, sizeof line, "NEXT");
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  829|      0|          break;
  830|       |
  831|      0|        case KEYDB_SEARCH_MODE_FIRST:
  ------------------
  |  Branch (831:9): [True: 0, False: 0]
  ------------------
  832|      0|          log_debug ("%s: mode first - we should not get to here!\n", __func__);
  833|       |          /*fallthru*/
  834|      0|        default:
  ------------------
  |  Branch (834:9): [True: 0, False: 0]
  ------------------
  835|      0|          err = gpg_error (GPG_ERR_INV_ARG);
  836|      0|          goto leave;
  837|      0|        }
  838|       |
  839|      0|      if (ndesc > 1)
  ------------------
  |  Branch (839:11): [True: 0, False: 0]
  ------------------
  840|      0|        {
  841|      0|          err = kbx_client_data_simple (hd->kbl->kcd, line);
  842|      0|          if (err)
  ------------------
  |  Branch (842:15): [True: 0, False: 0]
  ------------------
  843|      0|            goto leave;
  844|      0|        }
  845|      0|    }
  846|      0|  while (ndesc);
  ------------------
  |  Branch (846:10): [True: 0, False: 0]
  ------------------
  847|       |
  848|       |
  849|      0| do_search:
  850|      0|  hd->last_ubid_valid = 0;
  851|      0|  err = kbx_client_data_cmd (hd->kbl->kcd, line, search_status_cb, hd);
  852|      0|  if (!err && !(err = kbx_client_data_wait (hd->kbl->kcd, &buffer, &len)))
  ------------------
  |  Branch (852:7): [True: 0, False: 0]
  |  Branch (852:15): [True: 0, False: 0]
  ------------------
  853|      0|    {
  854|      0|      hd->kbl->search_result = iobuf_temp_with_content (buffer, len);
  855|      0|      xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  856|      0|      if (DBG_LOOKUP && hd->last_ubid_valid)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (856:25): [True: 0, False: 0]
  ------------------
  857|      0|        log_printhex (hd->last_ubid, 20, "found UBID (%d,%d):",
  858|      0|                      hd->last_uid_no, hd->last_pk_no);
  859|      0|    }
  860|       |
  861|  6.98M| leave:
  862|  6.98M|  if (DBG_CLOCK)
  ------------------
  |  |  356|  6.98M|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  6.98M|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 6.98M]
  |  |  ------------------
  ------------------
  863|      0|    log_clock ("%s leave (%sfound)", __func__, err? "not ":"");
  ------------------
  |  Branch (863:48): [True: 0, False: 0]
  ------------------
  864|  6.98M|  return err;
  865|      0|}

handle_compressed:
  313|  3.53k|{
  314|  3.53k|    int rc;
  315|       |
  316|  3.53k|    if(check_compress_algo(cd->algorithm))
  ------------------
  |  Branch (316:8): [True: 77, False: 3.45k]
  ------------------
  317|     77|      return GPG_ERR_COMPR_ALGO;
  318|  3.45k|    if(cd->algorithm) {
  ------------------
  |  Branch (318:8): [True: 0, False: 3.45k]
  ------------------
  319|      0|        compress_filter_context_t *cfx;
  320|       |
  321|      0|        cfx = xmalloc_clear (sizeof *cfx);
  ------------------
  |  |  116|      0|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  322|      0|        cfx->release = release_context;
  323|      0|        cfx->algo = cd->algorithm;
  324|      0|        if (push_compress_filter(cd->buf, cfx, cd->algorithm))
  ------------------
  |  Branch (324:13): [True: 0, False: 0]
  ------------------
  325|      0|          xfree (cfx);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  326|      0|    }
  327|  3.45k|    if( callback )
  ------------------
  |  Branch (327:9): [True: 0, False: 3.45k]
  ------------------
  328|      0|	rc = callback(cd->buf, passthru );
  329|  3.45k|    else
  330|  3.45k|      rc = proc_packets (ctrl,procctx, cd->buf);
  331|  3.45k|    cd->buf = NULL;
  332|  3.45k|    return rc;
  333|  3.53k|}

is_status_enabled:
  132|   184k|{
  133|   184k|  return !!statusfp;
  134|   184k|}
write_status:
  139|   485k|{
  140|   485k|    write_status_text( no, NULL );
  141|   485k|}
write_status_strings:
  149|   492k|{
  150|   492k|  va_list arg_ptr;
  151|   492k|  const char *s;
  152|       |
  153|   492k|  if (!statusfp || !status_currently_allowed (no) )
  ------------------
  |  Branch (153:7): [True: 492k, False: 0]
  |  Branch (153:20): [True: 0, False: 0]
  ------------------
  154|   492k|    return;  /* Not enabled or allowed. */
  155|       |
  156|      0|  es_fputs ("[GNUPG:] ", statusfp);
  157|      0|  es_fputs (get_status_string (no), statusfp);
  158|      0|  if ( text )
  ------------------
  |  Branch (158:8): [True: 0, False: 0]
  ------------------
  159|      0|    {
  160|      0|      es_putc ( ' ', statusfp);
  161|      0|      va_start (arg_ptr, text);
  162|      0|      s = text;
  163|      0|      do
  164|      0|        {
  165|      0|          for (; *s; s++)
  ------------------
  |  Branch (165:18): [True: 0, False: 0]
  ------------------
  166|      0|            {
  167|      0|              if (*s == '\n')
  ------------------
  |  Branch (167:19): [True: 0, False: 0]
  ------------------
  168|      0|                es_fputs ("\\n", statusfp);
  169|      0|              else if (*s == '\r')
  ------------------
  |  Branch (169:24): [True: 0, False: 0]
  ------------------
  170|      0|                es_fputs ("\\r", statusfp);
  171|      0|              else
  172|      0|                es_fputc (*(const byte *)s, statusfp);
  173|      0|            }
  174|      0|        }
  175|      0|      while ((s = va_arg (arg_ptr, const char*)));
  ------------------
  |  Branch (175:14): [True: 0, False: 0]
  ------------------
  176|      0|      va_end (arg_ptr);
  177|      0|    }
  178|      0|  es_putc ('\n', statusfp);
  179|      0|  if (es_fflush (statusfp) && opt.exit_on_status_write_error)
  ------------------
  |  Branch (179:7): [True: 0, False: 0]
  |  Branch (179:31): [True: 0, False: 0]
  ------------------
  180|      0|    g10_exit (0);
  181|      0|}
write_status_text:
  230|   492k|{
  231|   492k|  write_status_strings (no, text, NULL);
  232|   492k|}
write_status_error:
  287|  58.5k|{
  288|  58.5k|  if (!statusfp || !status_currently_allowed (STATUS_ERROR))
  ------------------
  |  Branch (288:7): [True: 58.5k, False: 0]
  |  Branch (288:20): [True: 0, False: 0]
  ------------------
  289|  58.5k|    return;  /* Not enabled or allowed. */
  290|       |
  291|      0|  es_fprintf (statusfp, "[GNUPG:] %s %s %u\n",
  292|      0|              get_status_string (STATUS_ERROR), where, err);
  293|      0|  if (es_fflush (statusfp) && opt.exit_on_status_write_error)
  ------------------
  |  Branch (293:7): [True: 0, False: 0]
  |  Branch (293:31): [True: 0, False: 0]
  ------------------
  294|      0|    g10_exit (0);
  295|      0|}
write_status_errcode:
  301|   238k|{
  302|   238k|  if (!statusfp || !status_currently_allowed (STATUS_ERROR))
  ------------------
  |  Branch (302:7): [True: 238k, False: 0]
  |  Branch (302:20): [True: 0, False: 0]
  ------------------
  303|   238k|    return;  /* Not enabled or allowed. */
  304|       |
  305|      0|  es_fprintf (statusfp, "[GNUPG:] %s %s %u\n",
  306|      0|              get_status_string (STATUS_ERROR), where, gpg_err_code (errcode));
  307|      0|  if (es_fflush (statusfp) && opt.exit_on_status_write_error)
  ------------------
  |  Branch (307:7): [True: 0, False: 0]
  |  Branch (307:31): [True: 0, False: 0]
  ------------------
  308|      0|    g10_exit (0);
  309|      0|}

free_symkey_enc:
   76|  48.7k|{
   77|  48.7k|    xfree(enc);
  ------------------
  |  |  104|  48.7k|#define xfree(a)         gcry_free ((a))
  ------------------
   78|  48.7k|}
free_pubkey_enc:
   82|  10.9k|{
   83|  10.9k|    int n, i;
   84|  10.9k|    n = pubkey_get_nenc( enc->pubkey_algo );
   85|  10.9k|    if( !n )
  ------------------
  |  Branch (85:9): [True: 8.76k, False: 2.15k]
  ------------------
   86|  8.76k|	mpi_release(enc->data[0]);
   87|  14.3k|    for(i=0; i < n; i++ )
  ------------------
  |  Branch (87:14): [True: 3.43k, False: 10.9k]
  ------------------
   88|  3.43k|	mpi_release( enc->data[i] );
   89|  10.9k|    xfree(enc);
  ------------------
  |  |  104|  10.9k|#define xfree(a)         gcry_free ((a))
  ------------------
   90|  10.9k|}
free_seckey_enc:
   94|  52.5k|{
   95|  52.5k|  int n, i;
   96|       |
   97|  52.5k|  n = pubkey_get_nsig( sig->pubkey_algo );
   98|  52.5k|  if( !n )
  ------------------
  |  Branch (98:7): [True: 45.1k, False: 7.40k]
  ------------------
   99|  45.1k|    mpi_release(sig->data[0]);
  100|  65.9k|  for(i=0; i < n; i++ )
  ------------------
  |  Branch (100:12): [True: 13.4k, False: 52.5k]
  ------------------
  101|  13.4k|    mpi_release( sig->data[i] );
  102|       |
  103|  52.5k|  xfree(sig->revkey);
  ------------------
  |  |  104|  52.5k|#define xfree(a)         gcry_free ((a))
  ------------------
  104|  52.5k|  xfree(sig->hashed);
  ------------------
  |  |  104|  52.5k|#define xfree(a)         gcry_free ((a))
  ------------------
  105|  52.5k|  xfree(sig->unhashed);
  ------------------
  |  |  104|  52.5k|#define xfree(a)         gcry_free ((a))
  ------------------
  106|       |
  107|  52.5k|  xfree (sig->signers_uid);
  ------------------
  |  |  104|  52.5k|#define xfree(a)         gcry_free ((a))
  ------------------
  108|       |
  109|  52.5k|  xfree(sig);
  ------------------
  |  |  104|  52.5k|#define xfree(a)         gcry_free ((a))
  ------------------
  110|  52.5k|}
release_public_key_parts:
  115|  7.05M|{
  116|  7.05M|  int n, i;
  117|       |
  118|  7.05M|  if (pk->seckey_info)
  ------------------
  |  Branch (118:7): [True: 39.9k, False: 7.01M]
  ------------------
  119|  39.9k|    n = pubkey_get_nskey (pk->pubkey_algo);
  120|  7.01M|  else
  121|  7.01M|    n = pubkey_get_npkey (pk->pubkey_algo);
  122|  7.05M|  if (!n)
  ------------------
  |  Branch (122:7): [True: 6.97M, False: 81.2k]
  ------------------
  123|  6.97M|    mpi_release (pk->pkey[0]);
  124|  7.40M|  for (i=0; i < n; i++ )
  ------------------
  |  Branch (124:13): [True: 351k, False: 7.05M]
  ------------------
  125|   351k|    {
  126|   351k|      mpi_release (pk->pkey[i]);
  127|   351k|      pk->pkey[i] = NULL;
  128|   351k|    }
  129|  7.05M|  if (pk->seckey_info)
  ------------------
  |  Branch (129:7): [True: 39.9k, False: 7.01M]
  ------------------
  130|  39.9k|    {
  131|  39.9k|      xfree (pk->seckey_info);
  ------------------
  |  |  104|  39.9k|#define xfree(a)         gcry_free ((a))
  ------------------
  132|  39.9k|      pk->seckey_info = NULL;
  133|  39.9k|    }
  134|  7.05M|  if (pk->prefs)
  ------------------
  |  Branch (134:7): [True: 0, False: 7.05M]
  ------------------
  135|      0|    {
  136|      0|      xfree (pk->prefs);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  137|      0|      pk->prefs = NULL;
  138|      0|    }
  139|  7.05M|  free_user_id (pk->user_id);
  140|  7.05M|  pk->user_id = NULL;
  141|  7.05M|  if (pk->revkey)
  ------------------
  |  Branch (141:7): [True: 0, False: 7.05M]
  ------------------
  142|      0|    {
  143|      0|      xfree(pk->revkey);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  144|      0|      pk->revkey=NULL;
  145|      0|      pk->numrevkeys=0;
  146|      0|    }
  147|  7.05M|  if (pk->serialno)
  ------------------
  |  Branch (147:7): [True: 0, False: 7.05M]
  ------------------
  148|      0|    {
  149|      0|      xfree (pk->serialno);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  150|      0|      pk->serialno = NULL;
  151|      0|    }
  152|  7.05M|  if (pk->updateurl)
  ------------------
  |  Branch (152:7): [True: 375, False: 7.05M]
  ------------------
  153|    375|    {
  154|    375|      xfree (pk->updateurl);
  ------------------
  |  |  104|    375|#define xfree(a)         gcry_free ((a))
  ------------------
  155|    375|      pk->updateurl = NULL;
  156|    375|    }
  157|  7.05M|}
free_public_key:
  164|  7.05M|{
  165|  7.05M|  if (pk)
  ------------------
  |  Branch (165:7): [True: 7.05M, False: 0]
  ------------------
  166|  7.05M|    {
  167|  7.05M|      release_public_key_parts (pk);
  168|  7.05M|      xfree(pk);
  ------------------
  |  |  104|  7.05M|#define xfree(a)         gcry_free ((a))
  ------------------
  169|  7.05M|    }
  170|  7.05M|}
free_comment:
  304|    783|{
  305|    783|    xfree(rem);
  ------------------
  |  |  104|    783|#define xfree(a)         gcry_free ((a))
  ------------------
  306|    783|}
free_attributes:
  310|  9.47k|{
  311|  9.47k|  if (!uid)
  ------------------
  |  Branch (311:7): [True: 0, False: 9.47k]
  ------------------
  312|      0|    return;
  313|       |
  314|  9.47k|  xfree(uid->attribs);
  ------------------
  |  |  104|  9.47k|#define xfree(a)         gcry_free ((a))
  ------------------
  315|  9.47k|  xfree(uid->attrib_data);
  ------------------
  |  |  104|  9.47k|#define xfree(a)         gcry_free ((a))
  ------------------
  316|       |
  317|  9.47k|  uid->attribs=NULL;
  318|  9.47k|  uid->attrib_data=NULL;
  319|  9.47k|  uid->attrib_len=0;
  320|  9.47k|}
free_user_id:
  324|  7.06M|{
  325|  7.06M|  if (!uid)
  ------------------
  |  Branch (325:7): [True: 7.05M, False: 9.47k]
  ------------------
  326|  7.05M|    return;
  327|       |
  328|  9.47k|  log_assert (uid->ref > 0);
  329|  9.47k|  if (--uid->ref)
  ------------------
  |  Branch (329:7): [True: 0, False: 9.47k]
  ------------------
  330|      0|    return;
  331|       |
  332|  9.47k|  free_attributes(uid);
  333|  9.47k|  xfree (uid->prefs);
  ------------------
  |  |  104|  9.47k|#define xfree(a)         gcry_free ((a))
  ------------------
  334|  9.47k|  xfree (uid->namehash);
  ------------------
  |  |  104|  9.47k|#define xfree(a)         gcry_free ((a))
  ------------------
  335|  9.47k|  xfree (uid->updateurl);
  ------------------
  |  |  104|  9.47k|#define xfree(a)         gcry_free ((a))
  ------------------
  336|  9.47k|  xfree (uid->mbox);
  ------------------
  |  |  104|  9.47k|#define xfree(a)         gcry_free ((a))
  ------------------
  337|  9.47k|  xfree (uid);
  ------------------
  |  |  104|  9.47k|#define xfree(a)         gcry_free ((a))
  ------------------
  338|  9.47k|}
free_compressed:
  342|  3.56k|{
  343|  3.56k|  if (!zd)
  ------------------
  |  Branch (343:7): [True: 0, False: 3.56k]
  ------------------
  344|      0|    return;
  345|       |
  346|  3.56k|  if (zd->buf)
  ------------------
  |  Branch (346:7): [True: 108, False: 3.45k]
  ------------------
  347|    108|    {
  348|       |      /* We need to skip some bytes.  Because don't have any
  349|       |       * information about the length, so we assume this is the last
  350|       |       * packet */
  351|    377|      while (iobuf_read( zd->buf, NULL, 1<<30 ) != -1)
  ------------------
  |  Branch (351:14): [True: 269, False: 108]
  ------------------
  352|    269|        ;
  353|    108|    }
  354|  3.56k|  xfree(zd);
  ------------------
  |  |  104|  3.56k|#define xfree(a)         gcry_free ((a))
  ------------------
  355|  3.56k|}
free_encrypted:
  359|   161k|{
  360|   161k|  if (!ed)
  ------------------
  |  Branch (360:7): [True: 0, False: 161k]
  ------------------
  361|      0|    return;
  362|       |
  363|   161k|  if (ed->buf)
  ------------------
  |  Branch (363:7): [True: 120k, False: 41.0k]
  ------------------
  364|   120k|    {
  365|       |      /* We need to skip some bytes. */
  366|   120k|      if (ed->is_partial)
  ------------------
  |  Branch (366:11): [True: 2.88k, False: 117k]
  ------------------
  367|  2.88k|        {
  368|  3.88k|          while (iobuf_read( ed->buf, NULL, 1<<30 ) != -1)
  ------------------
  |  Branch (368:18): [True: 997, False: 2.88k]
  ------------------
  369|    997|            ;
  370|  2.88k|	}
  371|   117k|      else
  372|   117k|        {
  373|   119k|          while (ed->len)
  ------------------
  |  Branch (373:18): [True: 1.56k, False: 117k]
  ------------------
  374|  1.56k|            {
  375|       |              /* Skip the packet. */
  376|  1.56k|              int n = iobuf_read( ed->buf, NULL, ed->len );
  377|  1.56k|              if (n == -1)
  ------------------
  |  Branch (377:19): [True: 413, False: 1.14k]
  ------------------
  378|    413|                ed->len = 0;
  379|  1.14k|              else
  380|  1.14k|                ed->len -= n;
  381|  1.56k|            }
  382|   117k|	}
  383|   120k|    }
  384|   161k|  xfree (ed);
  ------------------
  |  |  104|   161k|#define xfree(a)         gcry_free ((a))
  ------------------
  385|   161k|}
free_plaintext:
  390|  9.70k|{
  391|  9.70k|  if (!pt)
  ------------------
  |  Branch (391:7): [True: 0, False: 9.70k]
  ------------------
  392|      0|    return;
  393|       |
  394|  9.70k|  if (pt->buf)
  ------------------
  |  Branch (394:7): [True: 9.70k, False: 0]
  ------------------
  395|  9.70k|    { /* We need to skip some bytes.  */
  396|  9.70k|      if (pt->is_partial)
  ------------------
  |  Branch (396:11): [True: 5.38k, False: 4.32k]
  ------------------
  397|  5.38k|        {
  398|  9.15k|          while (iobuf_read( pt->buf, NULL, 1<<30 ) != -1)
  ------------------
  |  Branch (398:18): [True: 3.76k, False: 5.38k]
  ------------------
  399|  3.76k|            ;
  400|  5.38k|        }
  401|  4.32k|      else
  402|  4.32k|        {
  403|  5.72k|          while( pt->len )
  ------------------
  |  Branch (403:18): [True: 1.40k, False: 4.32k]
  ------------------
  404|  1.40k|            { /* Skip the packet.  */
  405|  1.40k|              int n = iobuf_read( pt->buf, NULL, pt->len );
  406|  1.40k|              if (n == -1)
  ------------------
  |  Branch (406:19): [True: 372, False: 1.03k]
  ------------------
  407|    372|                pt->len = 0;
  408|  1.03k|              else
  409|  1.03k|                pt->len -= n;
  410|  1.40k|            }
  411|  4.32k|	}
  412|  9.70k|    }
  413|  9.70k|  xfree (pt);
  ------------------
  |  |  104|  9.70k|#define xfree(a)         gcry_free ((a))
  ------------------
  414|  9.70k|}
free_packet:
  422|  2.96M|{
  423|  2.96M|  if (!pkt || !pkt->pkt.generic)
  ------------------
  |  Branch (423:7): [True: 490k, False: 2.46M]
  |  Branch (423:15): [True: 2.03M, False: 436k]
  ------------------
  424|  2.52M|    {
  425|  2.52M|      if (parsectx && parsectx->last_pkt.pkt.generic)
  ------------------
  |  Branch (425:11): [True: 2.51M, False: 4.09k]
  |  Branch (425:23): [True: 51.0k, False: 2.46M]
  ------------------
  426|  51.0k|        {
  427|  51.0k|          if (parsectx->free_last_pkt)
  ------------------
  |  Branch (427:15): [True: 51.0k, False: 0]
  ------------------
  428|  51.0k|            {
  429|  51.0k|              free_packet (&parsectx->last_pkt, NULL);
  430|  51.0k|              parsectx->free_last_pkt = 0;
  431|  51.0k|            }
  432|  51.0k|          parsectx->last_pkt.pkttype = 0;
  433|  51.0k|          parsectx->last_pkt.pkt.generic = NULL;
  434|  51.0k|        }
  435|  2.52M|      return;
  436|  2.52M|    }
  437|       |
  438|   436k|  if (DBG_MEMORY)
  ------------------
  |  |  361|   436k|#define DBG_MEMORY    memory_debug_mode
  |  |  ------------------
  |  |  |  Branch (361:23): [True: 0, False: 436k]
  |  |  ------------------
  ------------------
  439|      0|    log_debug ("free_packet() type=%d\n", pkt->pkttype);
  440|       |
  441|       |  /* If we have a parser context holding PKT then do not free the
  442|       |   * packet but set a flag that the packet in the parser context is
  443|       |   * now a deep copy.  */
  444|   436k|  if (parsectx && !parsectx->free_last_pkt
  ------------------
  |  Branch (444:7): [True: 205k, False: 231k]
  |  Branch (444:19): [True: 205k, False: 0]
  ------------------
  445|   436k|      && parsectx->last_pkt.pkttype == pkt->pkttype
  ------------------
  |  Branch (445:10): [True: 51.0k, False: 154k]
  ------------------
  446|   436k|      && parsectx->last_pkt.pkt.generic == pkt->pkt.generic)
  ------------------
  |  Branch (446:10): [True: 51.0k, False: 0]
  ------------------
  447|  51.0k|    {
  448|  51.0k|      parsectx->last_pkt = *pkt;
  449|  51.0k|      parsectx->free_last_pkt = 1;
  450|  51.0k|      pkt->pkt.generic = NULL;
  451|  51.0k|      return;
  452|  51.0k|    }
  453|       |
  454|   385k|  switch (pkt->pkttype)
  455|   385k|    {
  456|  52.5k|    case PKT_SIGNATURE:
  ------------------
  |  Branch (456:5): [True: 52.5k, False: 332k]
  ------------------
  457|  52.5k|      free_seckey_enc (pkt->pkt.signature);
  458|  52.5k|      break;
  459|  10.9k|    case PKT_PUBKEY_ENC:
  ------------------
  |  Branch (459:5): [True: 10.9k, False: 374k]
  ------------------
  460|  10.9k|      free_pubkey_enc (pkt->pkt.pubkey_enc);
  461|  10.9k|      break;
  462|  48.7k|    case PKT_SYMKEY_ENC:
  ------------------
  |  Branch (462:5): [True: 48.7k, False: 336k]
  ------------------
  463|  48.7k|      free_symkey_enc (pkt->pkt.symkey_enc);
  464|  48.7k|      break;
  465|  4.54k|    case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (465:5): [True: 4.54k, False: 380k]
  ------------------
  466|  6.83k|    case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (466:5): [True: 2.29k, False: 382k]
  ------------------
  467|  29.1k|    case PKT_SECRET_KEY:
  ------------------
  |  Branch (467:5): [True: 22.3k, False: 362k]
  ------------------
  468|  73.5k|    case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (468:5): [True: 44.3k, False: 340k]
  ------------------
  469|  73.5k|      free_public_key (pkt->pkt.public_key);
  470|  73.5k|      break;
  471|    783|    case PKT_COMMENT:
  ------------------
  |  Branch (471:5): [True: 783, False: 384k]
  ------------------
  472|    783|      free_comment (pkt->pkt.comment);
  473|    783|      break;
  474|  9.47k|    case PKT_USER_ID:
  ------------------
  |  Branch (474:5): [True: 9.47k, False: 375k]
  ------------------
  475|  9.47k|      free_user_id (pkt->pkt.user_id);
  476|  9.47k|      break;
  477|  3.56k|    case PKT_COMPRESSED:
  ------------------
  |  Branch (477:5): [True: 3.56k, False: 381k]
  ------------------
  478|  3.56k|      free_compressed (pkt->pkt.compressed);
  479|  3.56k|      break;
  480|  73.1k|    case PKT_ENCRYPTED:
  ------------------
  |  Branch (480:5): [True: 73.1k, False: 312k]
  ------------------
  481|  94.7k|    case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (481:5): [True: 21.6k, False: 363k]
  ------------------
  482|   161k|    case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (482:5): [True: 66.5k, False: 318k]
  ------------------
  483|   161k|      free_encrypted (pkt->pkt.encrypted);
  484|   161k|      break;
  485|  9.70k|    case PKT_PLAINTEXT:
  ------------------
  |  Branch (485:5): [True: 9.70k, False: 375k]
  ------------------
  486|  9.70k|      free_plaintext (pkt->pkt.plaintext);
  487|  9.70k|      break;
  488|  14.5k|    default:
  ------------------
  |  Branch (488:5): [True: 14.5k, False: 370k]
  ------------------
  489|  14.5k|      xfree (pkt->pkt.generic);
  ------------------
  |  |  104|  14.5k|#define xfree(a)         gcry_free ((a))
  ------------------
  490|  14.5k|      break;
  491|   385k|    }
  492|       |
  493|   385k|  pkt->pkt.generic = NULL;
  494|   385k|}

get_pubkey:
  360|  6.92M|{
  361|  6.92M|  int internal = 0;
  362|  6.92M|  int rc = 0;
  363|       |
  364|  6.92M|#if MAX_PK_CACHE_ENTRIES
  365|  6.92M|  if (pk)
  ------------------
  |  Branch (365:7): [True: 6.92M, False: 0]
  ------------------
  366|  6.92M|    {
  367|       |      /* Try to get it from the cache.  We don't do this when pk is
  368|       |         NULL as it does not guarantee that the user IDs are
  369|       |         cached. */
  370|  6.92M|      pk_cache_entry_t ce;
  371|  6.92M|      for (ce = pk_cache; ce; ce = ce->next)
  ------------------
  |  Branch (371:27): [True: 0, False: 6.92M]
  ------------------
  372|      0|	{
  373|      0|	  if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1])
  ------------------
  |  Branch (373:8): [True: 0, False: 0]
  |  Branch (373:36): [True: 0, False: 0]
  ------------------
  374|       |	    /* XXX: We don't check PK->REQ_USAGE here, but if we don't
  375|       |	       read from the cache, we do check it!  */
  376|      0|	    {
  377|      0|	      copy_public_key (pk, ce->pk);
  378|      0|	      return 0;
  379|      0|	    }
  380|      0|	}
  381|  6.92M|    }
  382|  6.92M|#endif
  383|       |  /* More init stuff.  */
  384|  6.92M|  if (!pk)
  ------------------
  |  Branch (384:7): [True: 0, False: 6.92M]
  ------------------
  385|      0|    {
  386|      0|      internal++;
  387|      0|      pk = xtrycalloc (1, sizeof *pk);
  ------------------
  |  |   99|      0|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  388|      0|      if (!pk)
  ------------------
  |  Branch (388:11): [True: 0, False: 0]
  ------------------
  389|      0|        {
  390|      0|          rc = gpg_error_from_syserror ();
  391|      0|          goto leave;
  392|      0|        }
  393|      0|    }
  394|       |
  395|       |
  396|       |  /* Do a lookup.  */
  397|  6.92M|  {
  398|  6.92M|    struct getkey_ctx_s ctx;
  399|  6.92M|    kbnode_t kb = NULL;
  400|  6.92M|    kbnode_t found_key = NULL;
  401|       |
  402|  6.92M|    memset (&ctx, 0, sizeof ctx);
  403|  6.92M|    ctx.exact = 1; /* Use the key ID exactly as given.  */
  404|  6.92M|    ctx.not_allocated = 1;
  405|       |
  406|  6.92M|    if (ctrl && ctrl->cached_getkey_kdb)
  ------------------
  |  Branch (406:9): [True: 6.92M, False: 0]
  |  Branch (406:17): [True: 6.92M, False: 288]
  ------------------
  407|  6.92M|      {
  408|  6.92M|        ctx.kr_handle = ctrl->cached_getkey_kdb;
  409|  6.92M|        ctrl->cached_getkey_kdb = NULL;
  410|  6.92M|        keydb_search_reset (ctx.kr_handle);
  411|  6.92M|      }
  412|    288|    else
  413|    288|      {
  414|    288|        ctx.kr_handle = keydb_new (ctrl);
  415|    288|        if (!ctx.kr_handle)
  ------------------
  |  Branch (415:13): [True: 0, False: 288]
  ------------------
  416|      0|          {
  417|      0|            rc = gpg_error_from_syserror ();
  418|      0|            goto leave;
  419|      0|          }
  420|    288|      }
  421|  6.92M|    ctx.nitems = 1;
  422|  6.92M|    ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
  423|  6.92M|    ctx.items[0].u.kid[0] = keyid[0];
  424|  6.92M|    ctx.items[0].u.kid[1] = keyid[1];
  425|  6.92M|    ctx.req_usage = pk->req_usage;
  426|  6.92M|    rc = lookup (ctrl, &ctx, 0, &kb, &found_key);
  427|  6.92M|    if (!rc)
  ------------------
  |  Branch (427:9): [True: 0, False: 6.92M]
  ------------------
  428|      0|      {
  429|      0|	pk_from_block (pk, kb, found_key);
  430|      0|      }
  431|  6.92M|    getkey_end (ctrl, &ctx);
  432|  6.92M|    release_kbnode (kb);
  433|  6.92M|  }
  434|  6.92M|  if (!rc)
  ------------------
  |  Branch (434:7): [True: 0, False: 6.92M]
  ------------------
  435|      0|    goto leave;
  436|       |
  437|  6.92M|  rc = GPG_ERR_NO_PUBKEY;
  438|       |
  439|  6.92M|leave:
  440|  6.92M|  if (!rc)
  ------------------
  |  Branch (440:7): [True: 0, False: 6.92M]
  ------------------
  441|      0|    cache_public_key (pk);
  442|  6.92M|  if (internal)
  ------------------
  |  Branch (442:7): [True: 0, False: 6.92M]
  ------------------
  443|      0|    free_public_key (pk);
  444|  6.92M|  return rc;
  445|  6.92M|}
parse_def_secret_key:
 1994|  58.5k|{
 1995|  58.5k|  KEYDB_HANDLE hd = NULL;
 1996|  58.5k|  strlist_t t;
 1997|  58.5k|  static int warned;
 1998|       |
 1999|  58.5k|  for (t = opt.def_secret_key; t; t = t->next)
  ------------------
  |  Branch (1999:32): [True: 0, False: 58.5k]
  ------------------
 2000|      0|    {
 2001|      0|      gpg_error_t err;
 2002|      0|      KEYDB_SEARCH_DESC desc;
 2003|      0|      KBNODE kb;
 2004|      0|      KBNODE node;
 2005|       |
 2006|      0|      err = classify_user_id (t->d, &desc, 1);
 2007|      0|      if (err)
  ------------------
  |  Branch (2007:11): [True: 0, False: 0]
  ------------------
 2008|      0|        {
 2009|      0|          log_error (_("secret key \"%s\" not found: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2010|      0|                     t->d, gpg_strerror (err));
 2011|      0|          if (!opt.quiet)
  ------------------
  |  Branch (2011:15): [True: 0, False: 0]
  ------------------
 2012|      0|            log_info (_("(check argument of option '%s')\n"), "--default-key");
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2013|      0|          continue;
 2014|      0|        }
 2015|       |
 2016|      0|      if (! hd)
  ------------------
  |  Branch (2016:11): [True: 0, False: 0]
  ------------------
 2017|      0|        {
 2018|      0|          hd = keydb_new (ctrl);
 2019|      0|          if (!hd)
  ------------------
  |  Branch (2019:15): [True: 0, False: 0]
  ------------------
 2020|      0|            return NULL;
 2021|      0|        }
 2022|      0|      else
 2023|      0|        keydb_search_reset (hd);
 2024|       |
 2025|       |
 2026|      0|      err = keydb_search (hd, &desc, 1, NULL);
 2027|      0|      if (gpg_err_code (err) == GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (2027:11): [True: 0, False: 0]
  ------------------
 2028|      0|        continue;
 2029|       |
 2030|      0|      if (err)
  ------------------
  |  Branch (2030:11): [True: 0, False: 0]
  ------------------
 2031|      0|        {
 2032|      0|          log_error (_("key \"%s\" not found: %s\n"), t->d, gpg_strerror (err));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2033|      0|          t = NULL;
 2034|      0|          break;
 2035|      0|        }
 2036|       |
 2037|      0|      err = keydb_get_keyblock (hd, &kb);
 2038|      0|      if (err)
  ------------------
  |  Branch (2038:11): [True: 0, False: 0]
  ------------------
 2039|      0|        {
 2040|      0|          log_error (_("error reading keyblock: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2041|      0|                     gpg_strerror (err));
 2042|      0|          continue;
 2043|      0|        }
 2044|       |
 2045|      0|      merge_selfsigs (ctrl, kb);
 2046|       |
 2047|      0|      err = gpg_error (GPG_ERR_NO_SECKEY);
 2048|      0|      node = kb;
 2049|      0|      do
 2050|      0|        {
 2051|      0|          PKT_public_key *pk = node->pkt->pkt.public_key;
 2052|       |
 2053|       |          /* Check if the key is valid.  */
 2054|      0|          if (pk->flags.revoked)
  ------------------
  |  Branch (2054:15): [True: 0, False: 0]
  ------------------
 2055|      0|            {
 2056|      0|              if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2057|      0|                log_debug ("not using %s as default key, %s",
 2058|      0|                           keystr_from_pk (pk), "revoked");
 2059|      0|              continue;
 2060|      0|            }
 2061|      0|          if (pk->has_expired)
  ------------------
  |  Branch (2061:15): [True: 0, False: 0]
  ------------------
 2062|      0|            {
 2063|      0|              if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2064|      0|                log_debug ("not using %s as default key, %s",
 2065|      0|                           keystr_from_pk (pk), "expired");
 2066|      0|              continue;
 2067|      0|            }
 2068|      0|          if (pk_is_disabled (pk))
  ------------------
  |  |  449|      0|  (((a)->flags.disabled_valid)?                                 \
  |  |  ------------------
  |  |  |  Branch (449:3): [True: 0, False: 0]
  |  |  |  Branch (449:4): [True: 0, False: 0]
  |  |  ------------------
  |  |  450|      0|   ((a)->flags.disabled):(cache_disabled_value(ctrl,(a))))
  ------------------
 2069|      0|            {
 2070|      0|              if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2071|      0|                log_debug ("not using %s as default key, %s",
 2072|      0|                           keystr_from_pk (pk), "disabled");
 2073|      0|              continue;
 2074|      0|            }
 2075|       |
 2076|      0|          if (agent_probe_secret_key (ctrl, pk))
  ------------------
  |  Branch (2076:15): [True: 0, False: 0]
  ------------------
 2077|      0|            {
 2078|       |              /* This is a valid key.  */
 2079|      0|              err = 0;
 2080|      0|              break;
 2081|      0|            }
 2082|      0|        }
 2083|      0|      while ((node = find_next_kbnode (node, PKT_PUBLIC_SUBKEY)));
  ------------------
  |  Branch (2083:14): [True: 0, False: 0]
  ------------------
 2084|       |
 2085|      0|      release_kbnode (kb);
 2086|      0|      if (err)
  ------------------
  |  Branch (2086:11): [True: 0, False: 0]
  ------------------
 2087|      0|        {
 2088|      0|          if (! warned && ! opt.quiet)
  ------------------
  |  Branch (2088:15): [True: 0, False: 0]
  |  Branch (2088:27): [True: 0, False: 0]
  ------------------
 2089|      0|            {
 2090|      0|              log_info (_("Warning: not using '%s' as default key: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2091|      0|                        t->d, gpg_strerror (GPG_ERR_NO_SECKEY));
 2092|      0|              print_reported_error (err, GPG_ERR_NO_SECKEY);
 2093|      0|            }
 2094|      0|        }
 2095|      0|      else
 2096|      0|        {
 2097|      0|          if (! warned && ! opt.quiet)
  ------------------
  |  Branch (2097:15): [True: 0, False: 0]
  |  Branch (2097:27): [True: 0, False: 0]
  ------------------
 2098|      0|            log_info (_("using \"%s\" as default secret key for signing\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2099|      0|                      t->d);
 2100|      0|          break;
 2101|      0|        }
 2102|      0|    }
 2103|       |
 2104|  58.5k|  if (! warned && opt.def_secret_key && ! t)
  ------------------
  |  Branch (2104:7): [True: 1, False: 58.5k]
  |  Branch (2104:19): [True: 0, False: 1]
  |  Branch (2104:41): [True: 0, False: 0]
  ------------------
 2105|      0|    log_info (_("all values passed to '%s' ignored\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2106|      0|              "--default-key");
 2107|       |
 2108|  58.5k|  warned = 1;
 2109|       |
 2110|  58.5k|  if (hd)
  ------------------
  |  Branch (2110:7): [True: 0, False: 58.5k]
  ------------------
 2111|      0|    keydb_release (hd);
 2112|       |
 2113|  58.5k|  if (t)
  ------------------
  |  Branch (2113:7): [True: 0, False: 58.5k]
  ------------------
 2114|      0|    return t->d;
 2115|  58.5k|  return NULL;
 2116|  58.5k|}
getkey_bynames:
 2203|  58.5k|{
 2204|  58.5k|  return key_byname (ctrl, retctx, names, pk, want_secret, 1,
 2205|  58.5k|                     ret_keyblock, NULL);
 2206|  58.5k|}
getkey_end:
 2333|  7.04M|{
 2334|  7.04M|  if (ctx)
  ------------------
  |  Branch (2334:7): [True: 6.98M, False: 58.5k]
  ------------------
 2335|  6.98M|    {
 2336|       |#ifdef HAVE_W32_SYSTEM
 2337|       |
 2338|       |      /* FIXME: This creates a big regression for Windows because the
 2339|       |       * keyring is only released after the global ctrl is released.
 2340|       |       * So if an operation does a getkey and then tries to modify the
 2341|       |       * keyring it will fail on Windows with a sharing violation.  We
 2342|       |       * need to modify all keyring write operations to also take the
 2343|       |       * ctrl and close the cached_getkey_kdb handle to make writing
 2344|       |       * work.  See: GnuPG-bug-id: 3097  */
 2345|       |      (void)ctrl;
 2346|       |      keydb_release (ctx->kr_handle);
 2347|       |
 2348|       |#else /*!HAVE_W32_SYSTEM*/
 2349|       |
 2350|  6.98M|      if (ctrl && !ctrl->cached_getkey_kdb)
  ------------------
  |  Branch (2350:11): [True: 6.98M, False: 0]
  |  Branch (2350:19): [True: 6.92M, False: 58.5k]
  ------------------
 2351|  6.92M|        ctrl->cached_getkey_kdb = ctx->kr_handle;
 2352|  58.5k|      else
 2353|  58.5k|        keydb_release (ctx->kr_handle);
 2354|       |
 2355|  6.98M|#endif /*!HAVE_W32_SYSTEM*/
 2356|       |
 2357|  6.98M|      free_strlist (ctx->extra_list);
 2358|  6.98M|      if (!ctx->not_allocated)
  ------------------
  |  Branch (2358:11): [True: 58.5k, False: 6.92M]
  ------------------
 2359|  58.5k|	xfree (ctx);
  ------------------
  |  |  104|  58.5k|#define xfree(a)         gcry_free ((a))
  ------------------
 2360|  6.98M|    }
 2361|  7.04M|}
getkey.c:key_byname:
  775|  58.5k|{
  776|  58.5k|  int rc = 0;
  777|  58.5k|  int n;
  778|  58.5k|  strlist_t r;
  779|  58.5k|  strlist_t namelist_expanded = NULL;
  780|  58.5k|  GETKEY_CTX ctx;
  781|  58.5k|  KBNODE help_kb = NULL;
  782|  58.5k|  KBNODE found_key = NULL;
  783|       |
  784|  58.5k|  if (retctx)
  ------------------
  |  Branch (784:7): [True: 58.5k, False: 0]
  ------------------
  785|  58.5k|    {
  786|       |      /* Reset the returned context in case of error.  */
  787|  58.5k|      log_assert (!ret_kdbhd); /* Not allowed because the handle is stored
  788|       |                                  in the context.  */
  789|      0|      *retctx = NULL;
  790|  58.5k|    }
  791|  58.5k|  if (ret_kdbhd)
  ------------------
  |  Branch (791:7): [True: 0, False: 58.5k]
  ------------------
  792|      0|    *ret_kdbhd = NULL;
  793|       |
  794|  58.5k|  if (!namelist)
  ------------------
  |  Branch (794:7): [True: 58.5k, False: 0]
  ------------------
  795|       |    /* No search terms: iterate over the whole DB.  */
  796|  58.5k|    {
  797|  58.5k|      ctx = xmalloc_clear (sizeof *ctx);
  ------------------
  |  |  116|  58.5k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  798|  58.5k|      ctx->nitems = 1;
  799|  58.5k|      ctx->items[0].mode = KEYDB_SEARCH_MODE_FIRST;
  800|  58.5k|      if (!include_unusable)
  ------------------
  |  Branch (800:11): [True: 0, False: 58.5k]
  ------------------
  801|      0|        {
  802|      0|          ctx->items[0].skipfnc = skip_unusable;
  803|      0|          ctx->items[0].skipfncvalue = ctrl;
  804|      0|        }
  805|  58.5k|    }
  806|      0|  else
  807|      0|    {
  808|      0|      namelist_expanded = expand_group (namelist, 1);
  809|      0|      namelist = namelist_expanded;
  810|       |
  811|       |      /* Build the search context.  */
  812|      0|      for (n = 0, r = namelist; r; r = r->next)
  ------------------
  |  Branch (812:33): [True: 0, False: 0]
  ------------------
  813|      0|	n++;
  814|       |
  815|       |      /* CTX has space for a single search term at the end.  Thus, we
  816|       |	 need to allocate sizeof *CTX plus (n - 1) sizeof
  817|       |	 CTX->ITEMS.  */
  818|      0|      ctx = xmalloc_clear (sizeof *ctx + (n - 1) * sizeof ctx->items);
  ------------------
  |  |  116|      0|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  819|      0|      ctx->nitems = n;
  820|       |
  821|      0|      for (n = 0, r = namelist; r; r = r->next, n++)
  ------------------
  |  Branch (821:33): [True: 0, False: 0]
  ------------------
  822|      0|	{
  823|      0|	  gpg_error_t err;
  824|       |
  825|      0|	  err = classify_user_id (r->d, &ctx->items[n], 1);
  826|       |
  827|      0|	  if (ctx->items[n].exact)
  ------------------
  |  Branch (827:8): [True: 0, False: 0]
  ------------------
  828|      0|	    ctx->exact = 1;
  829|      0|	  if (err)
  ------------------
  |  Branch (829:8): [True: 0, False: 0]
  ------------------
  830|      0|	    {
  831|      0|	      xfree (ctx);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  832|      0|	      rc = gpg_err_code (err); /* FIXME: remove gpg_err_code.  */
  833|      0|	      goto leave;
  834|      0|	    }
  835|      0|	  if (!include_unusable
  ------------------
  |  Branch (835:8): [True: 0, False: 0]
  ------------------
  836|      0|	      && ctx->items[n].mode != KEYDB_SEARCH_MODE_SHORT_KID
  ------------------
  |  Branch (836:11): [True: 0, False: 0]
  ------------------
  837|      0|	      && ctx->items[n].mode != KEYDB_SEARCH_MODE_LONG_KID
  ------------------
  |  Branch (837:11): [True: 0, False: 0]
  ------------------
  838|      0|	      && ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR)
  ------------------
  |  Branch (838:11): [True: 0, False: 0]
  ------------------
  839|      0|            {
  840|      0|              ctx->items[n].skipfnc = skip_unusable;
  841|      0|              ctx->items[n].skipfncvalue = ctrl;
  842|      0|            }
  843|      0|	}
  844|      0|    }
  845|       |
  846|  58.5k|  ctx->want_secret = want_secret;
  847|  58.5k|  ctx->kr_handle = keydb_new (ctrl);
  848|  58.5k|  if (!ctx->kr_handle)
  ------------------
  |  Branch (848:7): [True: 0, False: 58.5k]
  ------------------
  849|      0|    {
  850|      0|      rc = gpg_error_from_syserror ();
  851|      0|      getkey_end (ctrl, ctx);
  852|      0|      goto leave;
  853|      0|    }
  854|       |
  855|  58.5k|  if (!ret_kb)
  ------------------
  |  Branch (855:7): [True: 0, False: 58.5k]
  ------------------
  856|      0|    ret_kb = &help_kb;
  857|       |
  858|  58.5k|  if (pk)
  ------------------
  |  Branch (858:7): [True: 0, False: 58.5k]
  ------------------
  859|      0|    {
  860|      0|      ctx->req_usage = pk->req_usage;
  861|      0|    }
  862|       |
  863|  58.5k|  rc = lookup (ctrl, ctx, want_secret, ret_kb, &found_key);
  864|  58.5k|  if (!rc && pk)
  ------------------
  |  Branch (864:7): [True: 0, False: 58.5k]
  |  Branch (864:14): [True: 0, False: 0]
  ------------------
  865|      0|    {
  866|      0|      pk_from_block (pk, *ret_kb, found_key);
  867|      0|    }
  868|       |
  869|  58.5k|  release_kbnode (help_kb);
  870|       |
  871|  58.5k|  if (retctx) /* Caller wants the context.  */
  ------------------
  |  Branch (871:7): [True: 58.5k, False: 0]
  ------------------
  872|  58.5k|    {
  873|  58.5k|      if (ctx->extra_list)
  ------------------
  |  Branch (873:11): [True: 0, False: 58.5k]
  ------------------
  874|      0|        {
  875|      0|          for (r=ctx->extra_list; r->next; r = r->next)
  ------------------
  |  Branch (875:35): [True: 0, False: 0]
  ------------------
  876|      0|            ;
  877|      0|          r->next = namelist_expanded;
  878|      0|        }
  879|  58.5k|      else
  880|  58.5k|        ctx->extra_list = namelist_expanded;
  881|  58.5k|      namelist_expanded = NULL;
  882|  58.5k|      *retctx = ctx;
  883|  58.5k|    }
  884|      0|  else
  885|      0|    {
  886|      0|      if (ret_kdbhd)
  ------------------
  |  Branch (886:11): [True: 0, False: 0]
  ------------------
  887|      0|	{
  888|      0|	  *ret_kdbhd = ctx->kr_handle;
  889|      0|	  ctx->kr_handle = NULL;
  890|      0|	}
  891|      0|      getkey_end (ctrl, ctx);
  892|      0|    }
  893|       |
  894|  58.5k| leave:
  895|  58.5k|  free_strlist (namelist_expanded);
  896|  58.5k|  return rc;
  897|  58.5k|}
getkey.c:lookup:
 3907|  6.98M|{
 3908|  6.98M|  int rc;
 3909|  6.98M|  int no_suitable_key = 0;
 3910|  6.98M|  KBNODE keyblock = NULL;
 3911|  6.98M|  KBNODE found_key = NULL;
 3912|  6.98M|  unsigned int infoflags;
 3913|       |
 3914|  6.98M|  log_assert (ret_found_key == NULL || ret_keyblock != NULL);
 3915|  6.98M|  if (ret_keyblock)
  ------------------
  |  Branch (3915:7): [True: 6.98M, False: 0]
  ------------------
 3916|  6.98M|    *ret_keyblock = NULL;
 3917|       |
 3918|  6.98M|  for (;;)
 3919|  6.98M|    {
 3920|  6.98M|      rc = keydb_search (ctx->kr_handle, ctx->items, ctx->nitems, NULL);
 3921|  6.98M|      if (rc)
  ------------------
  |  Branch (3921:11): [True: 6.98M, False: 0]
  ------------------
 3922|  6.98M|        break;
 3923|       |
 3924|       |      /* If we are iterating over the entire database, then we need to
 3925|       |       * change from KEYDB_SEARCH_MODE_FIRST, which does an implicit
 3926|       |       * reset, to KEYDB_SEARCH_MODE_NEXT, which gets the next record.  */
 3927|      0|      if (ctx->nitems && ctx->items->mode == KEYDB_SEARCH_MODE_FIRST)
  ------------------
  |  Branch (3927:11): [True: 0, False: 0]
  |  Branch (3927:26): [True: 0, False: 0]
  ------------------
 3928|      0|	ctx->items->mode = KEYDB_SEARCH_MODE_NEXT;
 3929|       |
 3930|      0|      rc = keydb_get_keyblock (ctx->kr_handle, &keyblock);
 3931|      0|      if (rc)
  ------------------
  |  Branch (3931:11): [True: 0, False: 0]
  ------------------
 3932|      0|	{
 3933|      0|	  log_error ("keydb_get_keyblock failed: %s\n", gpg_strerror (rc));
 3934|      0|	  goto skip;
 3935|      0|	}
 3936|       |
 3937|      0|      if (want_secret)
  ------------------
  |  Branch (3937:11): [True: 0, False: 0]
  ------------------
 3938|      0|	{
 3939|      0|	  rc = agent_probe_any_secret_key (ctrl, keyblock);
 3940|      0|	  if (gpg_err_code(rc) == GPG_ERR_NO_SECKEY)
  ------------------
  |  Branch (3940:8): [True: 0, False: 0]
  ------------------
 3941|      0|	    goto skip; /* No secret key available.  */
 3942|      0|	  if (rc)
  ------------------
  |  Branch (3942:8): [True: 0, False: 0]
  ------------------
 3943|      0|	    goto found; /* Unexpected error.  */
 3944|      0|	}
 3945|       |
 3946|       |      /* Warning: node flag bits 0 and 1 should be preserved by
 3947|       |       * merge_selfsigs.  */
 3948|      0|      merge_selfsigs (ctrl, keyblock);
 3949|      0|      found_key = finish_lookup (keyblock, ctx->req_usage, ctx->exact,
 3950|      0|                                 want_secret, &infoflags);
 3951|      0|      print_status_key_considered (keyblock, infoflags);
 3952|      0|      if (found_key)
  ------------------
  |  Branch (3952:11): [True: 0, False: 0]
  ------------------
 3953|      0|	{
 3954|      0|	  no_suitable_key = 0;
 3955|      0|	  goto found;
 3956|      0|	}
 3957|      0|      else
 3958|      0|        {
 3959|      0|          no_suitable_key = 1;
 3960|      0|        }
 3961|       |
 3962|      0|    skip:
 3963|       |      /* Release resources and continue search. */
 3964|      0|      release_kbnode (keyblock);
 3965|      0|      keyblock = NULL;
 3966|       |      /* The keyblock cache ignores the current "file position".
 3967|       |       * Thus, if we request the next result and the cache matches
 3968|       |       * (and it will since it is what we just looked for), we'll get
 3969|       |       * the same entry back!  We can avoid this infinite loop by
 3970|       |       * disabling the cache.  */
 3971|      0|      keydb_disable_caching (ctx->kr_handle);
 3972|      0|    }
 3973|       |
 3974|  6.98M| found:
 3975|  6.98M|  if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (3975:7): [True: 6.98M, False: 0]
  |  Branch (3975:13): [True: 0, False: 6.98M]
  ------------------
 3976|      0|    log_error ("keydb_search failed: %s\n", gpg_strerror (rc));
 3977|       |
 3978|  6.98M|  if (!rc)
  ------------------
  |  Branch (3978:7): [True: 0, False: 6.98M]
  ------------------
 3979|      0|    {
 3980|      0|      if (ret_keyblock)
  ------------------
  |  Branch (3980:11): [True: 0, False: 0]
  ------------------
 3981|      0|        {
 3982|      0|          *ret_keyblock = keyblock; /* Return the keyblock.  */
 3983|      0|          keyblock = NULL;
 3984|      0|        }
 3985|      0|    }
 3986|  6.98M|  else if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND && no_suitable_key)
  ------------------
  |  Branch (3986:12): [True: 6.98M, False: 0]
  |  Branch (3986:54): [True: 0, False: 6.98M]
  ------------------
 3987|      0|    rc = want_secret? GPG_ERR_UNUSABLE_SECKEY : GPG_ERR_UNUSABLE_PUBKEY;
  ------------------
  |  Branch (3987:10): [True: 0, False: 0]
  ------------------
 3988|  6.98M|  else if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (3988:12): [True: 6.98M, False: 0]
  ------------------
 3989|  6.98M|    rc = want_secret? GPG_ERR_NO_SECKEY : GPG_ERR_NO_PUBKEY;
  ------------------
  |  Branch (3989:10): [True: 58.5k, False: 6.92M]
  ------------------
 3990|       |
 3991|  6.98M|  release_kbnode (keyblock);
 3992|       |
 3993|  6.98M|  if (ret_found_key)
  ------------------
  |  Branch (3993:7): [True: 6.98M, False: 0]
  ------------------
 3994|  6.98M|    {
 3995|  6.98M|      if (! rc)
  ------------------
  |  Branch (3995:11): [True: 0, False: 6.98M]
  ------------------
 3996|      0|	*ret_found_key = found_key;
 3997|  6.98M|      else
 3998|  6.98M|	*ret_found_key = NULL;
 3999|  6.98M|    }
 4000|       |
 4001|  6.98M|  return rc;
 4002|  6.98M|}

release_kbnode:
  127|  14.1M|{
  128|  14.1M|    KBNODE n2;
  129|       |
  130|  14.1M|    while( n ) {
  ------------------
  |  Branch (130:12): [True: 0, False: 14.1M]
  ------------------
  131|      0|	n2 = n->next;
  132|      0|	if( !is_cloned_kbnode(n) ) {
  ------------------
  |  |   71|      0|#define is_cloned_kbnode(a)   ((a)->private_flag & 2)
  ------------------
  |  Branch (132:6): [True: 0, False: 0]
  ------------------
  133|      0|            free_packet (n->pkt, NULL);
  134|      0|            xfree( n->pkt );
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  135|      0|	}
  136|      0|	free_node( n );
  137|      0|	n = n2;
  138|      0|    }
  139|  14.1M|}

keydb_add_resource:
  561|      1|{
  562|       |  /* The file named by the URL (i.e., without the prototype).  */
  563|      1|  const char *resname = url;
  564|       |
  565|      1|  char *filename = NULL;
  566|      1|  int create;
  567|      1|  int read_only = !!(flags&KEYDB_RESOURCE_FLAG_READONLY);
  ------------------
  |  |  213|      1|#define KEYDB_RESOURCE_FLAG_READONLY 8  /* Open in read only mode.  */
  ------------------
  568|      1|  int is_default = !!(flags&KEYDB_RESOURCE_FLAG_DEFAULT);
  ------------------
  |  |  212|      1|#define KEYDB_RESOURCE_FLAG_DEFAULT  4  /* The default one.  */
  ------------------
  569|      1|  int is_gpgvdef = !!(flags&KEYDB_RESOURCE_FLAG_GPGVDEF);
  ------------------
  |  |  214|      1|#define KEYDB_RESOURCE_FLAG_GPGVDEF 16  /* Default file for gpgv.  */
  ------------------
  570|      1|  gpg_error_t err = 0;
  571|      1|  KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE;
  572|      1|  void *token;
  573|       |
  574|       |  /* Create the resource if it is the first registered one.  */
  575|      1|  create = (!read_only && !any_registered);
  ------------------
  |  Branch (575:13): [True: 1, False: 0]
  |  Branch (575:27): [True: 1, False: 0]
  ------------------
  576|       |
  577|      1|  if (strlen (resname) > 11 && !strncmp( resname, "gnupg-ring:", 11) )
  ------------------
  |  Branch (577:7): [True: 0, False: 1]
  |  Branch (577:32): [True: 0, False: 0]
  ------------------
  578|      0|    {
  579|      0|      rt = KEYDB_RESOURCE_TYPE_KEYRING;
  580|      0|      resname += 11;
  581|      0|    }
  582|      1|  else if (strlen (resname) > 10 && !strncmp (resname, "gnupg-kbx:", 10) )
  ------------------
  |  Branch (582:12): [True: 1, False: 0]
  |  Branch (582:37): [True: 0, False: 1]
  ------------------
  583|      0|    {
  584|      0|      rt = KEYDB_RESOURCE_TYPE_KEYBOX;
  585|      0|      resname += 10;
  586|      0|    }
  587|      1|#if !defined(HAVE_DRIVE_LETTERS) && !defined(__riscos__)
  588|      1|  else if (strchr (resname, ':'))
  ------------------
  |  Branch (588:12): [True: 0, False: 1]
  ------------------
  589|      0|    {
  590|      0|      log_error ("invalid key resource URL '%s'\n", url );
  591|      0|      err = gpg_error (GPG_ERR_GENERAL);
  592|      0|      goto leave;
  593|      0|    }
  594|      1|#endif /* !HAVE_DRIVE_LETTERS && !__riscos__ */
  595|       |
  596|      1|  if (*resname != DIRSEP_C
  ------------------
  |  |  886|      1|#define DIRSEP_C '/'
  ------------------
  |  Branch (596:7): [True: 1, False: 0]
  ------------------
  597|       |#ifdef HAVE_W32_SYSTEM
  598|       |      && *resname != '/'  /* Fixme: does not handle drive letters.  */
  599|       |#endif
  600|      1|        )
  601|      1|    {
  602|       |      /* Do tilde expansion etc. */
  603|      1|      if (strchr (resname, DIRSEP_C)
  ------------------
  |  |  886|      1|#define DIRSEP_C '/'
  ------------------
  |  Branch (603:11): [True: 0, False: 1]
  ------------------
  604|       |#ifdef HAVE_W32_SYSTEM
  605|       |          || strchr (resname, '/')  /* Windows also accepts this.  */
  606|       |#endif
  607|      1|          )
  608|      0|        filename = make_filename (resname, NULL);
  609|      1|      else
  610|      1|        filename = make_filename (gnupg_homedir (), resname, NULL);
  611|      1|    }
  612|      0|  else
  613|      0|    filename = xstrdup (resname);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  614|       |
  615|       |  /* See whether we can determine the filetype.  */
  616|      1|  if (rt == KEYDB_RESOURCE_TYPE_NONE)
  ------------------
  |  Branch (616:7): [True: 1, False: 0]
  ------------------
  617|      1|    {
  618|      1|      int found, openpgp_flag;
  619|      1|      int pass = 0;
  620|      1|      size_t filenamelen;
  621|       |
  622|      2|    check_again:
  623|      2|      filenamelen = strlen (filename);
  624|      2|      rt = rt_from_file (filename, &found, &openpgp_flag);
  625|      2|      if (found)
  ------------------
  |  Branch (625:11): [True: 0, False: 2]
  ------------------
  626|      0|        {
  627|       |          /* The file exists and we have the resource type in RT.
  628|       |
  629|       |             Now let us check whether in addition to the "pubring.gpg"
  630|       |             a "pubring.kbx with openpgp keys exists.  This is so that
  631|       |             GPG 2.1 will use an existing "pubring.kbx" by default iff
  632|       |             that file has been created or used by 2.1.  This check is
  633|       |             needed because after creation or use of the kbx file with
  634|       |             2.1 an older version of gpg may have created a new
  635|       |             pubring.gpg for its own use.  */
  636|      0|          if (!pass && is_default && rt == KEYDB_RESOURCE_TYPE_KEYRING
  ------------------
  |  Branch (636:15): [True: 0, False: 0]
  |  Branch (636:24): [True: 0, False: 0]
  |  Branch (636:38): [True: 0, False: 0]
  ------------------
  637|      0|              && filenamelen > 4 && !strcmp (filename+filenamelen-4, ".gpg"))
  ------------------
  |  Branch (637:18): [True: 0, False: 0]
  |  Branch (637:37): [True: 0, False: 0]
  ------------------
  638|      0|            {
  639|      0|              strcpy (filename+filenamelen-4, ".kbx");
  640|      0|              if ((rt_from_file (filename, &found, &openpgp_flag)
  ------------------
  |  Branch (640:19): [True: 0, False: 0]
  ------------------
  641|      0|                   == KEYDB_RESOURCE_TYPE_KEYBOX) && found && openpgp_flag)
  ------------------
  |  Branch (641:54): [True: 0, False: 0]
  |  Branch (641:63): [True: 0, False: 0]
  ------------------
  642|      0|                rt = KEYDB_RESOURCE_TYPE_KEYBOX;
  643|      0|              else /* Restore filename */
  644|      0|                strcpy (filename+filenamelen-4, ".gpg");
  645|      0|            }
  646|      0|	}
  647|      2|      else if (!pass && is_gpgvdef
  ------------------
  |  Branch (647:16): [True: 1, False: 1]
  |  Branch (647:25): [True: 0, False: 1]
  ------------------
  648|      2|               && filenamelen > 4 && !strcmp (filename+filenamelen-4, ".kbx"))
  ------------------
  |  Branch (648:19): [True: 0, False: 0]
  |  Branch (648:38): [True: 0, False: 0]
  ------------------
  649|      0|        {
  650|       |          /* Not found but gpgv's default "trustedkeys.kbx" file has
  651|       |             been requested.  We did not found it so now check whether
  652|       |             a "trustedkeys.gpg" file exists and use that instead.  */
  653|      0|          KeydbResourceType rttmp;
  654|       |
  655|      0|          strcpy (filename+filenamelen-4, ".gpg");
  656|      0|          rttmp = rt_from_file (filename, &found, &openpgp_flag);
  657|      0|          if (found
  ------------------
  |  Branch (657:15): [True: 0, False: 0]
  ------------------
  658|      0|              && ((rttmp == KEYDB_RESOURCE_TYPE_KEYBOX && openpgp_flag)
  ------------------
  |  Branch (658:20): [True: 0, False: 0]
  |  Branch (658:59): [True: 0, False: 0]
  ------------------
  659|      0|                  || (rttmp == KEYDB_RESOURCE_TYPE_KEYRING)))
  ------------------
  |  Branch (659:22): [True: 0, False: 0]
  ------------------
  660|      0|            rt = rttmp;
  661|      0|          else /* Restore filename */
  662|      0|            strcpy (filename+filenamelen-4, ".kbx");
  663|      0|        }
  664|      2|      else if (!pass
  ------------------
  |  Branch (664:16): [True: 1, False: 1]
  ------------------
  665|      2|               && is_default && create
  ------------------
  |  Branch (665:19): [True: 1, False: 0]
  |  Branch (665:33): [True: 1, False: 0]
  ------------------
  666|      2|               && filenamelen > 4 && !strcmp (filename+filenamelen-4, ".gpg"))
  ------------------
  |  Branch (666:19): [True: 1, False: 0]
  |  Branch (666:38): [True: 1, False: 0]
  ------------------
  667|      1|        {
  668|       |          /* The file does not exist, the default resource has been
  669|       |             requested, the file shall be created, and the file has a
  670|       |             ".gpg" suffix.  Change the suffix to ".kbx" and try once
  671|       |             more.  This way we achieve that we open an existing
  672|       |             ".gpg" keyring, but create a new keybox file with an
  673|       |             ".kbx" suffix.  */
  674|      1|          strcpy (filename+filenamelen-4, ".kbx");
  675|      1|          pass++;
  676|      1|          goto check_again;
  677|      1|        }
  678|      1|      else /* No file yet: create keybox. */
  679|      1|        rt = KEYDB_RESOURCE_TYPE_KEYBOX;
  680|      2|    }
  681|       |
  682|      1|  switch (rt)
  683|      1|    {
  684|      0|    case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (684:5): [True: 0, False: 1]
  ------------------
  685|      0|      log_error ("unknown type of key resource '%s'\n", url );
  686|      0|      err = gpg_error (GPG_ERR_GENERAL);
  687|      0|      goto leave;
  688|       |
  689|      0|    case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (689:5): [True: 0, False: 1]
  ------------------
  690|      0|      err = maybe_create_keyring_or_box (filename, 0, create);
  691|      0|      if (err)
  ------------------
  |  Branch (691:11): [True: 0, False: 0]
  ------------------
  692|      0|        goto leave;
  693|       |
  694|      0|      if (keyring_register_filename (filename, read_only, &token))
  ------------------
  |  Branch (694:11): [True: 0, False: 0]
  ------------------
  695|      0|        {
  696|      0|          if (used_resources >= MAX_KEYDB_RESOURCES)
  ------------------
  |  |   36|      0|#define MAX_KEYDB_RESOURCES 40
  ------------------
  |  Branch (696:15): [True: 0, False: 0]
  ------------------
  697|      0|            err = gpg_error (GPG_ERR_RESOURCE_LIMIT);
  698|      0|          else
  699|      0|            {
  700|      0|              if ((flags & KEYDB_RESOURCE_FLAG_PRIMARY))
  ------------------
  |  |  211|      0|#define KEYDB_RESOURCE_FLAG_PRIMARY  2  /* The primary resource.  */
  ------------------
  |  Branch (700:19): [True: 0, False: 0]
  ------------------
  701|      0|                primary_keydb = token;
  702|      0|              all_resources[used_resources].type = rt;
  703|      0|              all_resources[used_resources].u.kr = NULL; /* Not used here */
  704|      0|              all_resources[used_resources].token = token;
  705|      0|              used_resources++;
  706|      0|            }
  707|      0|        }
  708|      0|      else
  709|      0|        {
  710|       |          /* This keyring was already registered, so ignore it.
  711|       |             However, we can still mark it as primary even if it was
  712|       |             already registered.  */
  713|      0|          if ((flags & KEYDB_RESOURCE_FLAG_PRIMARY))
  ------------------
  |  |  211|      0|#define KEYDB_RESOURCE_FLAG_PRIMARY  2  /* The primary resource.  */
  ------------------
  |  Branch (713:15): [True: 0, False: 0]
  ------------------
  714|      0|            primary_keydb = token;
  715|      0|        }
  716|      0|      break;
  717|       |
  718|      1|    case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (718:5): [True: 1, False: 0]
  ------------------
  719|      1|      {
  720|      1|        err = maybe_create_keyring_or_box (filename, 1, create);
  721|      1|        if (err)
  ------------------
  |  Branch (721:13): [True: 0, False: 1]
  ------------------
  722|      0|          goto leave;
  723|       |
  724|      1|        err = keybox_register_file (filename, 0, &token);
  725|      1|        if (!err)
  ------------------
  |  Branch (725:13): [True: 1, False: 0]
  ------------------
  726|      1|          {
  727|      1|            if (used_resources >= MAX_KEYDB_RESOURCES)
  ------------------
  |  |   36|      1|#define MAX_KEYDB_RESOURCES 40
  ------------------
  |  Branch (727:17): [True: 0, False: 1]
  ------------------
  728|      0|              err = gpg_error (GPG_ERR_RESOURCE_LIMIT);
  729|      1|            else
  730|      1|              {
  731|      1|                KEYBOX_HANDLE kbxhd;
  732|       |
  733|      1|                if ((flags & KEYDB_RESOURCE_FLAG_PRIMARY))
  ------------------
  |  |  211|      1|#define KEYDB_RESOURCE_FLAG_PRIMARY  2  /* The primary resource.  */
  ------------------
  |  Branch (733:21): [True: 0, False: 1]
  ------------------
  734|      0|                  primary_keydb = token;
  735|      1|                all_resources[used_resources].type = rt;
  736|      1|                all_resources[used_resources].u.kb = NULL; /* Not used here */
  737|      1|                all_resources[used_resources].token = token;
  738|       |
  739|       |                /* Do a compress run if needed and no other user is
  740|       |                 * currently using the keybox. */
  741|      1|                kbxhd = keybox_new_openpgp (token, 0);
  742|      1|                if (kbxhd)
  ------------------
  |  Branch (742:21): [True: 1, False: 0]
  ------------------
  743|      1|                  {
  744|      1|                    if (!keybox_lock (kbxhd, 1, 0))
  ------------------
  |  Branch (744:25): [True: 1, False: 0]
  ------------------
  745|      1|                      {
  746|      1|                        keybox_compress (kbxhd);
  747|      1|                        keybox_lock (kbxhd, 0, 0);
  748|      1|                      }
  749|       |
  750|      1|                    keybox_release (kbxhd);
  751|      1|                  }
  752|       |
  753|      1|                used_resources++;
  754|      1|              }
  755|      1|          }
  756|      0|        else if (gpg_err_code (err) == GPG_ERR_EEXIST)
  ------------------
  |  Branch (756:18): [True: 0, False: 0]
  ------------------
  757|      0|          {
  758|       |            /* Already registered.  We will mark it as the primary key
  759|       |               if requested.  */
  760|      0|            if ((flags & KEYDB_RESOURCE_FLAG_PRIMARY))
  ------------------
  |  |  211|      0|#define KEYDB_RESOURCE_FLAG_PRIMARY  2  /* The primary resource.  */
  ------------------
  |  Branch (760:17): [True: 0, False: 0]
  ------------------
  761|      0|              primary_keydb = token;
  762|      0|          }
  763|      1|      }
  764|      0|      break;
  765|       |
  766|      0|      default:
  ------------------
  |  Branch (766:7): [True: 0, False: 1]
  ------------------
  767|      0|	log_error ("resource type of '%s' not supported\n", url);
  768|      0|	err = gpg_error (GPG_ERR_GENERAL);
  769|      0|	goto leave;
  770|      1|    }
  771|       |
  772|       |  /* fixme: check directory permissions and print a warning */
  773|       |
  774|      1| leave:
  775|      1|  if (err)
  ------------------
  |  Branch (775:7): [True: 0, False: 1]
  ------------------
  776|      0|    {
  777|      0|      log_error (_("keyblock resource '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  778|      0|                 filename, gpg_strerror (err));
  779|      0|      write_status_error ("add_keyblock_resource", err);
  780|      0|    }
  781|      1|  else
  782|      1|    any_registered = 1;
  783|      1|  xfree (filename);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  784|      1|  return err;
  785|      1|}
internal_keydb_init:
  818|  58.8k|{
  819|  58.8k|  gpg_error_t err = 0;
  820|  58.8k|  int i, j;
  821|  58.8k|  int die = 0;
  822|  58.8k|  int reterrno;
  823|       |
  824|  58.8k|  log_assert (!hd->use_keyboxd);
  825|      0|  hd->found = -1;
  826|  58.8k|  hd->saved_found = -1;
  827|  58.8k|  hd->is_reset = 1;
  828|       |
  829|  58.8k|  log_assert (used_resources <= MAX_KEYDB_RESOURCES);
  830|   117k|  for (i=j=0; ! die && i < used_resources; i++)
  ------------------
  |  Branch (830:15): [True: 117k, False: 0]
  |  Branch (830:24): [True: 58.8k, False: 58.8k]
  ------------------
  831|  58.8k|    {
  832|  58.8k|      switch (all_resources[i].type)
  ------------------
  |  Branch (832:15): [True: 0, False: 58.8k]
  ------------------
  833|  58.8k|        {
  834|      0|        case KEYDB_RESOURCE_TYPE_NONE: /* ignore */
  ------------------
  |  Branch (834:9): [True: 0, False: 58.8k]
  ------------------
  835|      0|          break;
  836|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (836:9): [True: 0, False: 58.8k]
  ------------------
  837|      0|          hd->active[j].type   = all_resources[i].type;
  838|      0|          hd->active[j].token  = all_resources[i].token;
  839|      0|          hd->active[j].u.kr = keyring_new (all_resources[i].token);
  840|      0|          if (!hd->active[j].u.kr)
  ------------------
  |  Branch (840:15): [True: 0, False: 0]
  ------------------
  841|      0|            {
  842|      0|              reterrno = errno;
  843|      0|              die = 1;
  844|      0|            }
  845|      0|          j++;
  846|      0|          break;
  847|  58.8k|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (847:9): [True: 58.8k, False: 0]
  ------------------
  848|  58.8k|          hd->active[j].type   = all_resources[i].type;
  849|  58.8k|          hd->active[j].token  = all_resources[i].token;
  850|  58.8k|          hd->active[j].u.kb   = keybox_new_openpgp (all_resources[i].token, 0);
  851|  58.8k|          if (!hd->active[j].u.kb)
  ------------------
  |  Branch (851:15): [True: 0, False: 58.8k]
  ------------------
  852|      0|            {
  853|      0|              reterrno = errno;
  854|      0|              die = 1;
  855|      0|            }
  856|  58.8k|          j++;
  857|  58.8k|          break;
  858|  58.8k|        }
  859|  58.8k|    }
  860|  58.8k|  hd->used = j;
  861|       |
  862|  58.8k|  active_handles++;
  863|  58.8k|  keydb_stats.handles++;
  864|       |
  865|  58.8k|  if (die)
  ------------------
  |  Branch (865:7): [True: 0, False: 58.8k]
  ------------------
  866|      0|    err = gpg_error_from_errno (reterrno);
  867|       |
  868|  58.8k|   return err;
  869|  58.8k|}
internal_keydb_deinit:
  876|  58.8k|{
  877|  58.8k|  int i;
  878|       |
  879|  58.8k|  log_assert (!hd->use_keyboxd);
  880|       |
  881|      0|  log_assert (active_handles > 0);
  882|      0|  active_handles--;
  883|       |
  884|  58.8k|  hd->keep_lock = 0;
  885|  58.8k|  unlock_all (hd);
  886|   117k|  for (i=0; i < hd->used; i++)
  ------------------
  |  Branch (886:13): [True: 58.8k, False: 58.8k]
  ------------------
  887|  58.8k|    {
  888|  58.8k|      switch (hd->active[i].type)
  ------------------
  |  Branch (888:15): [True: 0, False: 58.8k]
  ------------------
  889|  58.8k|        {
  890|      0|        case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (890:9): [True: 0, False: 58.8k]
  ------------------
  891|      0|          break;
  892|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (892:9): [True: 0, False: 58.8k]
  ------------------
  893|      0|          keyring_release (hd->active[i].u.kr);
  894|      0|          break;
  895|  58.8k|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (895:9): [True: 58.8k, False: 0]
  ------------------
  896|  58.8k|          keybox_release (hd->active[i].u.kb);
  897|  58.8k|          break;
  898|  58.8k|        }
  899|  58.8k|    }
  900|       |
  901|  58.8k|  keyblock_cache_clear (hd);
  902|  58.8k|}
internal_keydb_search_reset:
 1682|  6.92M|{
 1683|  6.92M|  gpg_error_t rc = 0;
 1684|  6.92M|  int i;
 1685|       |
 1686|  6.92M|  log_assert (!hd->use_keyboxd);
 1687|       |
 1688|      0|  keyblock_cache_clear (hd);
 1689|       |
 1690|  6.92M|  hd->skipped_long_blobs = 0;
 1691|  6.92M|  hd->current = 0;
 1692|  6.92M|  hd->found = -1;
 1693|       |  /* Now reset all resources.  */
 1694|  13.8M|  for (i=0; !rc && i < hd->used; i++)
  ------------------
  |  Branch (1694:13): [True: 13.8M, False: 0]
  |  Branch (1694:20): [True: 6.92M, False: 6.92M]
  ------------------
 1695|  6.92M|    {
 1696|  6.92M|      switch (hd->active[i].type)
  ------------------
  |  Branch (1696:15): [True: 0, False: 6.92M]
  ------------------
 1697|  6.92M|        {
 1698|      0|        case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1698:9): [True: 0, False: 6.92M]
  ------------------
 1699|      0|          break;
 1700|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1700:9): [True: 0, False: 6.92M]
  ------------------
 1701|      0|          rc = keyring_search_reset (hd->active[i].u.kr);
 1702|      0|          break;
 1703|  6.92M|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1703:9): [True: 6.92M, False: 0]
  ------------------
 1704|  6.92M|          rc = keybox_search_reset (hd->active[i].u.kb);
 1705|  6.92M|          break;
 1706|  6.92M|        }
 1707|  6.92M|    }
 1708|  6.92M|  hd->is_reset = 1;
 1709|  6.92M|  if (!rc)
  ------------------
  |  Branch (1709:7): [True: 6.92M, False: 0]
  ------------------
 1710|  6.92M|    keydb_stats.search_resets++;
 1711|  6.92M|  return rc;
 1712|  6.92M|}
internal_keydb_search:
 1737|  6.98M|{
 1738|  6.98M|  gpg_error_t rc;
 1739|  6.98M|  int was_reset = hd->is_reset;
 1740|       |  /* If an entry is already in the cache, then don't add it again.  */
 1741|  6.98M|  int already_in_cache = 0;
 1742|  6.98M|  int fprlen;
 1743|       |
 1744|  6.98M|  log_assert (!hd->use_keyboxd);
 1745|       |
 1746|  6.98M|  if (!any_registered)
  ------------------
  |  Branch (1746:7): [True: 0, False: 6.98M]
  ------------------
 1747|      0|    {
 1748|      0|      write_status_error ("keydb_search", gpg_error (GPG_ERR_KEYRING_OPEN));
 1749|      0|      return gpg_error (GPG_ERR_NOT_FOUND);
 1750|      0|    }
 1751|       |
 1752|  6.98M|  if (ndesc == 1 && desc[0].mode == KEYDB_SEARCH_MODE_LONG_KID
  ------------------
  |  Branch (1752:7): [True: 6.98M, False: 0]
  |  Branch (1752:21): [True: 6.92M, False: 58.5k]
  ------------------
 1753|  6.98M|      && (already_in_cache = kid_not_found_p (desc[0].u.kid)) == 1 )
  ------------------
  |  Branch (1753:10): [True: 6.92M, False: 389]
  ------------------
 1754|  6.92M|    {
 1755|  6.92M|      if (DBG_CLOCK)
  ------------------
  |  |  356|  6.92M|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  6.92M|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 6.92M]
  |  |  ------------------
  ------------------
 1756|      0|        log_clock ("%s leave (not found, cached)", __func__);
 1757|  6.92M|      keydb_stats.notfound_cached++;
 1758|  6.92M|      return gpg_error (GPG_ERR_NOT_FOUND);
 1759|  6.92M|    }
 1760|       |
 1761|       |  /* NB: If one of the exact search modes below is used in a loop to
 1762|       |     walk over all keys (with the same fingerprint) the caching must
 1763|       |     have been disabled for the handle.  */
 1764|  58.9k|  if (desc[0].mode == KEYDB_SEARCH_MODE_FPR)
  ------------------
  |  Branch (1764:7): [True: 0, False: 58.9k]
  ------------------
 1765|      0|    fprlen = desc[0].fprlen;
 1766|  58.9k|  else
 1767|  58.9k|    fprlen = 0;
 1768|       |
 1769|  58.9k|  if (!hd->no_caching
  ------------------
  |  Branch (1769:7): [True: 58.9k, False: 0]
  ------------------
 1770|  58.9k|      && ndesc == 1
  ------------------
  |  Branch (1770:10): [True: 58.9k, False: 0]
  ------------------
 1771|  58.9k|      && fprlen
  ------------------
  |  Branch (1771:10): [True: 0, False: 58.9k]
  ------------------
 1772|  58.9k|      && hd->keyblock_cache.state == KEYBLOCK_CACHE_FILLED
  ------------------
  |  Branch (1772:10): [True: 0, False: 0]
  ------------------
 1773|  58.9k|      && hd->keyblock_cache.fprlen == fprlen
  ------------------
  |  Branch (1773:10): [True: 0, False: 0]
  ------------------
 1774|  58.9k|      && !memcmp (hd->keyblock_cache.fpr, desc[0].u.fpr, fprlen)
  ------------------
  |  Branch (1774:10): [True: 0, False: 0]
  ------------------
 1775|       |      /* Make sure the current file position occurs before the cached
 1776|       |         result to avoid an infinite loop.  */
 1777|  58.9k|      && (hd->current < hd->keyblock_cache.resource
  ------------------
  |  Branch (1777:11): [True: 0, False: 0]
  ------------------
 1778|      0|          || (hd->current == hd->keyblock_cache.resource
  ------------------
  |  Branch (1778:15): [True: 0, False: 0]
  ------------------
 1779|      0|              && (keybox_offset (hd->active[hd->current].u.kb)
  ------------------
  |  Branch (1779:18): [True: 0, False: 0]
  ------------------
 1780|      0|                  <= hd->keyblock_cache.offset))))
 1781|      0|    {
 1782|       |      /* (DESCINDEX is already set).  */
 1783|      0|      if (DBG_CLOCK)
  ------------------
  |  |  356|      0|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|      0|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1784|      0|        log_clock ("%s leave (cached)", __func__);
 1785|       |
 1786|      0|      hd->current = hd->keyblock_cache.resource;
 1787|       |      /* HD->KEYBLOCK_CACHE.OFFSET is the last byte in the record.
 1788|       |         Seek just beyond that.  */
 1789|      0|      keybox_seek (hd->active[hd->current].u.kb, hd->keyblock_cache.offset + 1);
 1790|      0|      keydb_stats.found_cached++;
 1791|      0|      return 0;
 1792|      0|    }
 1793|       |
 1794|  58.9k|  rc = -1;
 1795|   117k|  while ((rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
  ------------------
  |  Branch (1795:11): [True: 117k, False: 0]
  |  Branch (1795:23): [True: 0, False: 0]
  ------------------
 1796|   117k|         && hd->current >= 0 && hd->current < hd->used)
  ------------------
  |  Branch (1796:13): [True: 117k, False: 0]
  |  Branch (1796:33): [True: 58.9k, False: 58.9k]
  ------------------
 1797|  58.9k|    {
 1798|  58.9k|      if (DBG_LOOKUP)
  ------------------
  |  |  357|  58.9k|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|  58.9k|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 58.9k]
  |  |  ------------------
  ------------------
 1799|      0|        log_debug ("%s: searching %s (resource %d of %d)\n",
 1800|      0|                   __func__,
 1801|      0|                   hd->active[hd->current].type == KEYDB_RESOURCE_TYPE_KEYRING
  ------------------
  |  Branch (1801:20): [True: 0, False: 0]
  ------------------
 1802|      0|                   ? "keyring"
 1803|      0|                   : (hd->active[hd->current].type == KEYDB_RESOURCE_TYPE_KEYBOX
  ------------------
  |  Branch (1803:23): [True: 0, False: 0]
  ------------------
 1804|      0|                      ? "keybox" : "unknown type"),
 1805|      0|                   hd->current, hd->used);
 1806|       |
 1807|  58.9k|       switch (hd->active[hd->current].type)
  ------------------
  |  Branch (1807:16): [True: 0, False: 58.9k]
  ------------------
 1808|  58.9k|        {
 1809|      0|        case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1809:9): [True: 0, False: 58.9k]
  ------------------
 1810|      0|          BUG(); /* we should never see it here */
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1811|      0|          break;
 1812|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1812:9): [True: 0, False: 58.9k]
  ------------------
 1813|      0|          rc = keyring_search (hd->active[hd->current].u.kr, desc,
 1814|      0|                               ndesc, descindex, 1);
 1815|      0|          break;
 1816|  58.9k|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1816:9): [True: 58.9k, False: 0]
  ------------------
 1817|  58.9k|          do
 1818|  58.9k|            rc = keybox_search (hd->active[hd->current].u.kb, desc,
 1819|  58.9k|                                ndesc, KEYBOX_BLOBTYPE_PGP,
 1820|  58.9k|                                descindex, &hd->skipped_long_blobs);
 1821|  58.9k|          while (rc == GPG_ERR_LEGACY_KEY);
  ------------------
  |  Branch (1821:18): [True: 0, False: 58.9k]
  ------------------
 1822|  58.9k|          break;
 1823|  58.9k|        }
 1824|       |
 1825|  58.9k|      if (DBG_LOOKUP)
  ------------------
  |  |  357|  58.9k|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|  58.9k|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 58.9k]
  |  |  ------------------
  ------------------
 1826|      0|        log_debug ("%s: searched %s (resource %d of %d) => %s\n",
 1827|      0|                   __func__,
 1828|      0|                   hd->active[hd->current].type == KEYDB_RESOURCE_TYPE_KEYRING
  ------------------
  |  Branch (1828:20): [True: 0, False: 0]
  ------------------
 1829|      0|                   ? "keyring"
 1830|      0|                   : (hd->active[hd->current].type == KEYDB_RESOURCE_TYPE_KEYBOX
  ------------------
  |  Branch (1830:23): [True: 0, False: 0]
  ------------------
 1831|      0|                      ? "keybox" : "unknown type"),
 1832|      0|                   hd->current, hd->used,
 1833|      0|                   rc == -1 ? "EOF" : gpg_strerror (rc));
  ------------------
  |  Branch (1833:20): [True: 0, False: 0]
  ------------------
 1834|       |
 1835|  58.9k|      if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
  ------------------
  |  Branch (1835:11): [True: 58.9k, False: 0]
  |  Branch (1835:23): [True: 0, False: 0]
  ------------------
 1836|  58.9k|        {
 1837|       |          /* EOF -> switch to next resource */
 1838|  58.9k|          hd->current++;
 1839|  58.9k|        }
 1840|      0|      else if (!rc)
  ------------------
  |  Branch (1840:16): [True: 0, False: 0]
  ------------------
 1841|      0|        hd->found = hd->current;
 1842|  58.9k|    }
 1843|  58.9k|  hd->is_reset = 0;
 1844|       |
 1845|  58.9k|  rc = ((rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
  ------------------
  |  Branch (1845:10): [True: 58.9k, False: 0]
  |  Branch (1845:22): [True: 0, False: 0]
  ------------------
 1846|  58.9k|        ? gpg_error (GPG_ERR_NOT_FOUND)
 1847|  58.9k|        : rc);
 1848|       |
 1849|  58.9k|  keyblock_cache_clear (hd);
 1850|  58.9k|  if (!hd->no_caching
  ------------------
  |  Branch (1850:7): [True: 58.9k, False: 0]
  ------------------
 1851|  58.9k|      && !rc
  ------------------
  |  Branch (1851:10): [True: 0, False: 58.9k]
  ------------------
 1852|  58.9k|      && ndesc == 1
  ------------------
  |  Branch (1852:10): [True: 0, False: 0]
  ------------------
 1853|  58.9k|      && fprlen
  ------------------
  |  Branch (1853:10): [True: 0, False: 0]
  ------------------
 1854|  58.9k|      && hd->active[hd->current].type == KEYDB_RESOURCE_TYPE_KEYBOX)
  ------------------
  |  Branch (1854:10): [True: 0, False: 0]
  ------------------
 1855|      0|    {
 1856|      0|      hd->keyblock_cache.state = KEYBLOCK_CACHE_PREPARED;
 1857|      0|      hd->keyblock_cache.resource = hd->current;
 1858|       |      /* The current offset is at the start of the next record.  Since
 1859|       |         a record is at least 1 byte, we just use offset - 1, which is
 1860|       |         within the record.  */
 1861|      0|      hd->keyblock_cache.offset
 1862|      0|        = keybox_offset (hd->active[hd->current].u.kb) - 1;
 1863|      0|      memcpy (hd->keyblock_cache.fpr, desc[0].u.fpr, fprlen);
 1864|      0|      hd->keyblock_cache.fprlen = fprlen;
 1865|      0|    }
 1866|       |
 1867|  58.9k|  if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND
  ------------------
  |  Branch (1867:7): [True: 58.9k, False: 0]
  ------------------
 1868|  58.9k|      && ndesc == 1
  ------------------
  |  Branch (1868:10): [True: 58.9k, False: 0]
  ------------------
 1869|  58.9k|      && desc[0].mode == KEYDB_SEARCH_MODE_LONG_KID
  ------------------
  |  Branch (1869:10): [True: 389, False: 58.5k]
  ------------------
 1870|  58.9k|      && was_reset
  ------------------
  |  Branch (1870:10): [True: 389, False: 0]
  ------------------
 1871|  58.9k|      && !already_in_cache)
  ------------------
  |  Branch (1871:10): [True: 389, False: 0]
  ------------------
 1872|    389|    kid_not_found_insert (desc[0].u.kid);
 1873|       |
 1874|  58.9k|  if (!rc)
  ------------------
  |  Branch (1874:7): [True: 0, False: 58.9k]
  ------------------
 1875|      0|    keydb_stats.found++;
 1876|  58.9k|  else
 1877|  58.9k|    keydb_stats.notfound++;
 1878|  58.9k|  return rc;
 1879|  58.9k|}
keydb_search_first:
 1889|      1|{
 1890|      1|  gpg_error_t err;
 1891|      1|  KEYDB_SEARCH_DESC desc;
 1892|       |
 1893|      1|  err = keydb_search_reset (hd);
 1894|      1|  if (err)
  ------------------
  |  Branch (1894:7): [True: 0, False: 1]
  ------------------
 1895|      0|    return err;
 1896|       |
 1897|      1|  memset (&desc, 0, sizeof desc);
 1898|      1|  desc.mode = KEYDB_SEARCH_MODE_FIRST;
 1899|      1|  return keydb_search (hd, &desc, 1, NULL);
 1900|      1|}
keydb.c:rt_from_file:
  418|      2|{
  419|      2|  u32 magic;
  420|      2|  unsigned char verbuf[4];
  421|      2|  estream_t fp;
  422|      2|  KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE;
  423|       |
  424|      2|  *r_found = *r_openpgp = 0;
  425|      2|  fp = es_fopen (filename, "rb");
  426|      2|  if (fp)
  ------------------
  |  Branch (426:7): [True: 0, False: 2]
  ------------------
  427|      0|    {
  428|      0|      *r_found = 1;
  429|       |
  430|      0|      if (es_fread (&magic, 4, 1, fp) == 1 )
  ------------------
  |  Branch (430:11): [True: 0, False: 0]
  ------------------
  431|      0|        {
  432|      0|          if (magic == 0x13579ace || magic == 0xce9a5713)
  ------------------
  |  Branch (432:15): [True: 0, False: 0]
  |  Branch (432:38): [True: 0, False: 0]
  ------------------
  433|      0|            ; /* GDBM magic - not anymore supported. */
  434|      0|          else if (es_fread (&verbuf, 4, 1, fp) == 1
  ------------------
  |  Branch (434:20): [True: 0, False: 0]
  ------------------
  435|      0|                   && verbuf[0] == 1
  ------------------
  |  Branch (435:23): [True: 0, False: 0]
  ------------------
  436|      0|                   && es_fread (&magic, 4, 1, fp) == 1
  ------------------
  |  Branch (436:23): [True: 0, False: 0]
  ------------------
  437|      0|                   && !memcmp (&magic, "KBXf", 4))
  ------------------
  |  Branch (437:23): [True: 0, False: 0]
  ------------------
  438|      0|            {
  439|      0|              if ((verbuf[3] & 0x02))
  ------------------
  |  Branch (439:19): [True: 0, False: 0]
  ------------------
  440|      0|                *r_openpgp = 1;
  441|      0|              rt = KEYDB_RESOURCE_TYPE_KEYBOX;
  442|      0|            }
  443|      0|          else
  444|      0|            rt = KEYDB_RESOURCE_TYPE_KEYRING;
  445|      0|        }
  446|      0|      else /* Maybe empty: assume keyring. */
  447|      0|        rt = KEYDB_RESOURCE_TYPE_KEYRING;
  448|       |
  449|      0|      es_fclose (fp);
  450|      0|    }
  451|       |
  452|      2|  return rt;
  453|      2|}
keydb.c:maybe_create_keyring_or_box:
  214|      1|{
  215|      1|  gpg_err_code_t ec;
  216|      1|  dotlock_t lockhd = NULL;
  217|      1|  IOBUF iobuf;
  218|      1|  int rc;
  219|      1|  mode_t oldmask;
  220|      1|  char *last_slash_in_filename;
  221|      1|  char *bak_fname = NULL;
  222|      1|  char *tmp_fname = NULL;
  223|      1|  int save_slash;
  224|       |
  225|       |  /* A quick test whether the filename already exists. */
  226|      1|  if (!gnupg_access (filename, F_OK))
  ------------------
  |  Branch (226:7): [True: 0, False: 1]
  ------------------
  227|      0|    return !gnupg_access (filename, R_OK)? 0 : gpg_error (GPG_ERR_EACCES);
  ------------------
  |  Branch (227:12): [True: 0, False: 0]
  ------------------
  228|       |
  229|       |  /* If we don't want to create a new file at all, there is no need to
  230|       |     go any further - bail out right here.  */
  231|      1|  if (!force_create)
  ------------------
  |  Branch (231:7): [True: 0, False: 1]
  ------------------
  232|      0|    return gpg_error (GPG_ERR_ENOENT);
  233|       |
  234|       |  /* First of all we try to create the home directory.  Note, that we
  235|       |     don't do any locking here because any sane application of gpg
  236|       |     would create the home directory by itself and not rely on gpg's
  237|       |     tricky auto-creation which is anyway only done for certain home
  238|       |     directory name pattern. */
  239|      1|  last_slash_in_filename = strrchr (filename, DIRSEP_C);
  ------------------
  |  |  886|      1|#define DIRSEP_C '/'
  ------------------
  240|       |#if HAVE_W32_SYSTEM
  241|       |  {
  242|       |    /* Windows may either have a slash or a backslash.  Take care of it.  */
  243|       |    char *p = strrchr (filename, '/');
  244|       |    if (!last_slash_in_filename || p > last_slash_in_filename)
  245|       |      last_slash_in_filename = p;
  246|       |  }
  247|       |#endif /*HAVE_W32_SYSTEM*/
  248|      1|  if (!last_slash_in_filename)
  ------------------
  |  Branch (248:7): [True: 0, False: 1]
  ------------------
  249|      0|    return gpg_error (GPG_ERR_ENOENT);  /* No slash at all - should
  250|       |                                           not happen though.  */
  251|      1|  save_slash = *last_slash_in_filename;
  252|      1|  *last_slash_in_filename = 0;
  253|      1|  if (gnupg_access(filename, F_OK))
  ------------------
  |  Branch (253:7): [True: 0, False: 1]
  ------------------
  254|      0|    {
  255|      0|      static int tried;
  256|       |
  257|      0|      if (!tried)
  ------------------
  |  Branch (257:11): [True: 0, False: 0]
  ------------------
  258|      0|        {
  259|      0|          tried = 1;
  260|      0|          try_make_homedir (filename);
  261|      0|        }
  262|      0|      if ((ec = gnupg_access (filename, F_OK)))
  ------------------
  |  Branch (262:11): [True: 0, False: 0]
  ------------------
  263|      0|        {
  264|      0|          rc = gpg_error (ec);
  265|      0|          *last_slash_in_filename = save_slash;
  266|      0|          goto leave;
  267|      0|        }
  268|      0|    }
  269|      1|  *last_slash_in_filename = save_slash;
  270|       |
  271|       |  /* To avoid races with other instances of gpg trying to create or
  272|       |     update the keyring (it is removed during an update for a short
  273|       |     time), we do the next stuff in a locked state. */
  274|      1|  lockhd = dotlock_create (filename, 0);
  275|      1|  if (!lockhd)
  ------------------
  |  Branch (275:7): [True: 0, False: 1]
  ------------------
  276|      0|    {
  277|      0|      rc = gpg_error_from_syserror ();
  278|       |      /* A reason for this to fail is that the directory is not
  279|       |         writable. However, this whole locking stuff does not make
  280|       |         sense if this is the case. An empty non-writable directory
  281|       |         with no keyring is not really useful at all. */
  282|      0|      if (opt.verbose)
  ------------------
  |  Branch (282:11): [True: 0, False: 0]
  ------------------
  283|      0|        log_info ("can't allocate lock for '%s': %s\n",
  284|      0|                  filename, gpg_strerror (rc));
  285|       |
  286|      0|      if (!force_create)
  ------------------
  |  Branch (286:11): [True: 0, False: 0]
  ------------------
  287|      0|        return gpg_error (GPG_ERR_ENOENT);  /* Won't happen.  */
  288|      0|      else
  289|      0|        return rc;
  290|      0|    }
  291|       |
  292|      1|  if ( dotlock_take (lockhd, -1) )
  ------------------
  |  Branch (292:8): [True: 0, False: 1]
  ------------------
  293|      0|    {
  294|      0|      rc = gpg_error_from_syserror ();
  295|       |      /* This is something bad.  Probably a stale lockfile.  */
  296|      0|      log_info ("can't lock '%s': %s\n", filename, gpg_strerror (rc));
  297|      0|      goto leave;
  298|      0|    }
  299|       |
  300|       |  /* Now the real test while we are locked. */
  301|       |
  302|       |  /* Gpg either uses pubring.gpg or pubring.kbx and thus different
  303|       |   * lock files.  Now, when one gpg process is updating a pubring.gpg
  304|       |   * and thus holding the corresponding lock, a second gpg process may
  305|       |   * get to here at the time between the two rename operation used by
  306|       |   * the first process to update pubring.gpg.  The lock taken above
  307|       |   * may not protect the second process if it tries to create a
  308|       |   * pubring.kbx file which would be protected by a different lock
  309|       |   * file.
  310|       |   *
  311|       |   * We can detect this case by checking that the two temporary files
  312|       |   * used by the update code exist at the same time.  In that case we
  313|       |   * do not create a new file but act as if FORCE_CREATE has not been
  314|       |   * given.  Obviously there is a race between our two checks but the
  315|       |   * worst thing is that we won't create a new file, which is better
  316|       |   * than to accidentally creating one.  */
  317|      1|  rc = keybox_tmp_names (filename, is_box, &bak_fname, &tmp_fname);
  318|      1|  if (rc)
  ------------------
  |  Branch (318:7): [True: 0, False: 1]
  ------------------
  319|      0|    goto leave;
  320|       |
  321|      1|  if (!gnupg_access (filename, F_OK))
  ------------------
  |  Branch (321:7): [True: 0, False: 1]
  ------------------
  322|      0|    {
  323|      0|      rc = 0;  /* Okay, we may access the file now.  */
  324|      0|      goto leave;
  325|      0|    }
  326|      1|  if (!gnupg_access (bak_fname, F_OK) && !gnupg_access (tmp_fname, F_OK))
  ------------------
  |  Branch (326:7): [True: 0, False: 1]
  |  Branch (326:42): [True: 0, False: 0]
  ------------------
  327|      0|    {
  328|       |      /* Very likely another process is updating a pubring.gpg and we
  329|       |         should not create a pubring.kbx.  */
  330|      0|      rc = gpg_error (GPG_ERR_ENOENT);
  331|      0|      goto leave;
  332|      0|    }
  333|       |
  334|       |
  335|       |  /* The file does not yet exist, create it now. */
  336|      1|  oldmask = umask (077);
  337|      1|  if (is_secured_filename (filename))
  ------------------
  |  Branch (337:7): [True: 0, False: 1]
  ------------------
  338|      0|    {
  339|      0|      iobuf = NULL;
  340|      0|      gpg_err_set_errno (EPERM);
  341|      0|    }
  342|      1|  else
  343|      1|    iobuf = iobuf_create (filename, 0);
  344|      1|  umask (oldmask);
  345|      1|  if (!iobuf)
  ------------------
  |  Branch (345:7): [True: 0, False: 1]
  ------------------
  346|      0|    {
  347|      0|      rc = gpg_error_from_syserror ();
  348|      0|      if (is_box)
  ------------------
  |  Branch (348:11): [True: 0, False: 0]
  ------------------
  349|      0|        log_error (_("error creating keybox '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  350|      0|                   filename, gpg_strerror (rc));
  351|      0|      else
  352|      0|        log_error (_("error creating keyring '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  353|      0|                   filename, gpg_strerror (rc));
  354|      0|      goto leave;
  355|      0|    }
  356|       |
  357|      1|  iobuf_close (iobuf);
  358|       |  /* Must invalidate that ugly cache */
  359|      1|  iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, filename);
  360|       |
  361|       |  /* Make sure that at least one record is in a new keybox file, so
  362|       |     that the detection magic will work the next time it is used.  */
  363|      1|  if (is_box)
  ------------------
  |  Branch (363:7): [True: 1, False: 0]
  ------------------
  364|      1|    {
  365|      1|      estream_t fp = es_fopen (filename, "wb");
  366|      1|      if (!fp)
  ------------------
  |  Branch (366:11): [True: 0, False: 1]
  ------------------
  367|      0|        rc = gpg_error_from_syserror ();
  368|      1|      else
  369|      1|        {
  370|      1|          rc = _keybox_write_header_blob (fp, 1);
  371|      1|          es_fclose (fp);
  372|      1|        }
  373|      1|      if (rc)
  ------------------
  |  Branch (373:11): [True: 0, False: 1]
  ------------------
  374|      0|        {
  375|      0|          if (is_box)
  ------------------
  |  Branch (375:15): [True: 0, False: 0]
  ------------------
  376|      0|            log_error (_("error creating keybox '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  377|      0|                       filename, gpg_strerror (rc));
  378|      0|          else
  379|      0|            log_error (_("error creating keyring '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  380|      0|                       filename, gpg_strerror (rc));
  381|      0|          goto leave;
  382|      0|        }
  383|      1|    }
  384|       |
  385|      1|  if (!opt.quiet)
  ------------------
  |  Branch (385:7): [True: 1, False: 0]
  ------------------
  386|      1|    {
  387|      1|      if (is_box)
  ------------------
  |  Branch (387:11): [True: 1, False: 0]
  ------------------
  388|      1|        log_info (_("keybox '%s' created\n"), filename);
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
  389|      0|      else
  390|      0|        log_info (_("keyring '%s' created\n"), filename);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  391|      1|    }
  392|       |
  393|      1|  rc = 0;
  394|       |
  395|      1| leave:
  396|      1|  if (lockhd)
  ------------------
  |  Branch (396:7): [True: 1, False: 0]
  ------------------
  397|      1|    {
  398|      1|      dotlock_release (lockhd);
  399|      1|      dotlock_destroy (lockhd);
  400|      1|    }
  401|      1|  xfree (bak_fname);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  402|      1|  xfree (tmp_fname);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  403|      1|  return rc;
  404|      1|}
keydb.c:keyblock_cache_clear:
  195|  7.04M|{
  196|  7.04M|  hd->keyblock_cache.state = KEYBLOCK_CACHE_EMPTY;
  197|  7.04M|  iobuf_close (hd->keyblock_cache.iobuf);
  198|  7.04M|  hd->keyblock_cache.iobuf = NULL;
  199|  7.04M|  hd->keyblock_cache.resource = -1;
  200|  7.04M|  hd->keyblock_cache.offset = -1;
  201|  7.04M|}
keydb.c:unlock_all:
 1035|  58.8k|{
 1036|  58.8k|  int i;
 1037|       |
 1038|  58.8k|  if (!hd->locked || hd->keep_lock)
  ------------------
  |  Branch (1038:7): [True: 58.8k, False: 0]
  |  Branch (1038:22): [True: 0, False: 0]
  ------------------
 1039|  58.8k|    return;
 1040|       |
 1041|      0|  for (i=hd->used-1; i >= 0; i--)
  ------------------
  |  Branch (1041:22): [True: 0, False: 0]
  ------------------
 1042|      0|    {
 1043|      0|      switch (hd->active[i].type)
  ------------------
  |  Branch (1043:15): [True: 0, False: 0]
  ------------------
 1044|      0|        {
 1045|      0|        case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1045:9): [True: 0, False: 0]
  ------------------
 1046|      0|          break;
 1047|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1047:9): [True: 0, False: 0]
  ------------------
 1048|      0|          keyring_lock (hd->active[i].u.kr, 0);
 1049|      0|          break;
 1050|      0|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1050:9): [True: 0, False: 0]
  ------------------
 1051|      0|          keybox_lock (hd->active[i].u.kb, 0, 0);
 1052|      0|          break;
 1053|      0|        }
 1054|      0|    }
 1055|      0|  hd->locked = 0;
 1056|      0|}
keydb.c:kid_not_found_p:
  123|  6.92M|{
  124|  6.92M|  struct kid_not_found_cache_bucket *k;
  125|       |
  126|  22.5M|  for (k = kid_not_found_cache[kid[0] % KID_NOT_FOUND_CACHE_BUCKETS]; k; k = k->next)
  ------------------
  |  |   70|  6.92M|#define KID_NOT_FOUND_CACHE_BUCKETS 256
  ------------------
  |  Branch (126:71): [True: 22.5M, False: 389]
  ------------------
  127|  22.5M|    if (k->kid[0] == kid[0] && k->kid[1] == kid[1])
  ------------------
  |  Branch (127:9): [True: 21.6M, False: 885k]
  |  Branch (127:32): [True: 6.92M, False: 14.7M]
  ------------------
  128|  6.92M|      {
  129|  6.92M|        if (DBG_CACHE)
  ------------------
  |  |  352|  6.92M|#define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
  |  |  ------------------
  |  |  |  |  338|  6.92M|#define DBG_CACHE_VALUE   64	/* debug the caching */
  |  |  ------------------
  |  |  |  Branch (352:20): [True: 0, False: 6.92M]
  |  |  ------------------
  ------------------
  130|      0|          log_debug ("keydb: kid_not_found_p (%08lx%08lx) => not in DB\n",
  131|      0|                     (ulong)kid[0], (ulong)kid[1]);
  132|  6.92M|        return 1;
  133|  6.92M|      }
  134|       |
  135|    389|  if (DBG_CACHE)
  ------------------
  |  |  352|    389|#define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
  |  |  ------------------
  |  |  |  |  338|    389|#define DBG_CACHE_VALUE   64	/* debug the caching */
  |  |  ------------------
  |  |  |  Branch (352:20): [True: 0, False: 389]
  |  |  ------------------
  ------------------
  136|      0|    log_debug ("keydb: kid_not_found_p (%08lx%08lx) => indeterminate\n",
  137|      0|               (ulong)kid[0], (ulong)kid[1]);
  138|    389|  return 0;
  139|  6.92M|}
keydb.c:kid_not_found_insert:
  149|    389|{
  150|    389|  struct kid_not_found_cache_bucket *k;
  151|       |
  152|    389|  if (DBG_CACHE)
  ------------------
  |  |  352|    389|#define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
  |  |  ------------------
  |  |  |  |  338|    389|#define DBG_CACHE_VALUE   64	/* debug the caching */
  |  |  ------------------
  |  |  |  Branch (352:20): [True: 0, False: 389]
  |  |  ------------------
  ------------------
  153|      0|    log_debug ("keydb: kid_not_found_insert (%08lx%08lx)\n",
  154|      0|               (ulong)kid[0], (ulong)kid[1]);
  155|    389|  k = xmalloc (sizeof *k);
  ------------------
  |  |  107|    389|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  156|    389|  k->kid[0] = kid[0];
  157|    389|  k->kid[1] = kid[1];
  158|    389|  k->next = kid_not_found_cache[kid[0] % KID_NOT_FOUND_CACHE_BUCKETS];
  ------------------
  |  |   70|    389|#define KID_NOT_FOUND_CACHE_BUCKETS 256
  ------------------
  159|    389|  kid_not_found_cache[kid[0] % KID_NOT_FOUND_CACHE_BUCKETS] = k;
  ------------------
  |  |   70|    389|#define KID_NOT_FOUND_CACHE_BUCKETS 256
  ------------------
  160|    389|  kid_not_found_stats.count++;
  161|    389|}

hash_public_key:
  146|  46.2k|{
  147|  46.2k|  unsigned int n;
  148|  46.2k|  unsigned int nn[PUBKEY_MAX_NPKEY];
  149|  46.2k|  byte *pp[PUBKEY_MAX_NPKEY];
  150|  46.2k|  int i;
  151|  46.2k|  unsigned int nbits;
  152|  46.2k|  size_t nbytes;
  153|  46.2k|  int npkey = pubkey_get_npkey (pk->pubkey_algo);
  154|  46.2k|  int is_v5 = pk->version == 5;
  155|       |
  156|  46.2k|  n = is_v5? 10 : 6;
  ------------------
  |  Branch (156:7): [True: 2.45k, False: 43.8k]
  ------------------
  157|       |  /* FIXME: We can avoid the extra malloc by calling only the first
  158|       |     mpi_print here which computes the required length and calling the
  159|       |     real mpi_print only at the end.  The speed advantage would only be
  160|       |     for ECC (opaque MPIs) or if we could implement an mpi_print
  161|       |     variant with a callback handler to do the hashing.  */
  162|  46.2k|  if (npkey==0 && pk->pkey[0]
  ------------------
  |  Branch (162:7): [True: 0, False: 46.2k]
  |  Branch (162:19): [True: 0, False: 0]
  ------------------
  163|  46.2k|      && gcry_mpi_get_flag (pk->pkey[0], GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (163:10): [True: 0, False: 0]
  ------------------
  164|      0|    {
  165|      0|      pp[0] = gcry_mpi_get_opaque (pk->pkey[0], &nbits);
  166|      0|      nn[0] = (nbits+7)/8;
  167|      0|      n+=nn[0];
  168|      0|    }
  169|  46.2k|  else
  170|  46.2k|    {
  171|   139k|      for (i=0; i < npkey; i++ )
  ------------------
  |  Branch (171:17): [True: 92.7k, False: 46.2k]
  ------------------
  172|  92.7k|        {
  173|  92.7k|          if (!pk->pkey[i])
  ------------------
  |  Branch (173:15): [True: 0, False: 92.7k]
  ------------------
  174|      0|            {
  175|       |              /* This case may only happen if the parsing of the MPI
  176|       |                 failed but the key was anyway created.  May happen
  177|       |                 during "gpg KEYFILE".  */
  178|      0|              pp[i] = NULL;
  179|      0|              nn[i] = 0;
  180|      0|            }
  181|  92.7k|          else if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (181:20): [True: 24.5k, False: 68.1k]
  ------------------
  182|  24.5k|            {
  183|  24.5k|              const char *p;
  184|  24.5k|              int is_sos = 0;
  185|       |
  186|  24.5k|              if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_USER2))
  ------------------
  |  Branch (186:19): [True: 12.2k, False: 12.3k]
  ------------------
  187|  12.2k|                is_sos = 2;
  188|       |
  189|  24.5k|              p = gcry_mpi_get_opaque (pk->pkey[i], &nbits);
  190|  24.5k|              pp[i] = xmalloc ((nbits+7)/8 + is_sos);
  ------------------
  |  |  107|  24.5k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  191|  24.5k|              if (p)
  ------------------
  |  Branch (191:19): [True: 24.5k, False: 0]
  ------------------
  192|  24.5k|                memcpy (pp[i] + is_sos, p, (nbits+7)/8);
  193|      0|              else
  194|      0|                pp[i] = NULL;
  195|  24.5k|              if (is_sos)
  ------------------
  |  Branch (195:19): [True: 12.2k, False: 12.3k]
  ------------------
  196|  12.2k|                {
  197|  12.2k|                  if (*p)
  ------------------
  |  Branch (197:23): [True: 11.5k, False: 713]
  ------------------
  198|  11.5k|                    {
  199|  11.5k|                      nbits = ((nbits + 7) / 8) * 8;
  200|       |
  201|  11.5k|                      if (nbits >= 8 && !(*p & 0x80))
  ------------------
  |  Branch (201:27): [True: 11.5k, False: 0]
  |  Branch (201:41): [True: 10.5k, False: 930]
  ------------------
  202|  10.5k|                        if (--nbits >= 7 && !(*p & 0x40))
  ------------------
  |  Branch (202:29): [True: 10.5k, False: 0]
  |  Branch (202:45): [True: 8.92k, False: 1.65k]
  ------------------
  203|  8.92k|                          if (--nbits >= 6 && !(*p & 0x20))
  ------------------
  |  Branch (203:31): [True: 8.92k, False: 0]
  |  Branch (203:47): [True: 8.64k, False: 274]
  ------------------
  204|  8.64k|                            if (--nbits >= 5 && !(*p & 0x10))
  ------------------
  |  Branch (204:33): [True: 8.64k, False: 0]
  |  Branch (204:49): [True: 8.35k, False: 296]
  ------------------
  205|  8.35k|                              if (--nbits >= 4 && !(*p & 0x08))
  ------------------
  |  Branch (205:35): [True: 8.35k, False: 0]
  |  Branch (205:51): [True: 7.58k, False: 764]
  ------------------
  206|  7.58k|                                if (--nbits >= 3 && !(*p & 0x04))
  ------------------
  |  Branch (206:37): [True: 7.58k, False: 0]
  |  Branch (206:53): [True: 7.36k, False: 226]
  ------------------
  207|  7.36k|                                  if (--nbits >= 2 && !(*p & 0x02))
  ------------------
  |  Branch (207:39): [True: 7.36k, False: 0]
  |  Branch (207:55): [True: 306, False: 7.05k]
  ------------------
  208|    306|                                    if (--nbits >= 1 && !(*p & 0x01))
  ------------------
  |  Branch (208:41): [True: 306, False: 0]
  |  Branch (208:57): [True: 0, False: 306]
  ------------------
  209|      0|                                      --nbits;
  210|  11.5k|                    }
  211|       |
  212|  12.2k|                  pp[i][0] = (nbits >> 8);
  213|  12.2k|                  pp[i][1] = nbits;
  214|  12.2k|                }
  215|  24.5k|              nn[i] = (nbits+7)/8 + is_sos;
  216|  24.5k|              n += nn[i];
  217|  24.5k|            }
  218|  68.1k|          else
  219|  68.1k|            {
  220|  68.1k|              if (gcry_mpi_print (GCRYMPI_FMT_PGP, NULL, 0,
  ------------------
  |  Branch (220:19): [True: 0, False: 68.1k]
  ------------------
  221|  68.1k|                                  &nbytes, pk->pkey[i]))
  222|      0|                BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  223|  68.1k|              pp[i] = xmalloc (nbytes);
  ------------------
  |  |  107|  68.1k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  224|  68.1k|              if (gcry_mpi_print (GCRYMPI_FMT_PGP, pp[i], nbytes,
  ------------------
  |  Branch (224:19): [True: 0, False: 68.1k]
  ------------------
  225|  68.1k|                                  &nbytes, pk->pkey[i]))
  226|      0|                BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  227|  68.1k|              nn[i] = nbytes;
  228|  68.1k|              n += nn[i];
  229|  68.1k|            }
  230|  92.7k|        }
  231|  46.2k|    }
  232|       |
  233|  46.2k|  if (is_v5)
  ------------------
  |  Branch (233:7): [True: 2.45k, False: 43.8k]
  ------------------
  234|  2.45k|    {
  235|  2.45k|      gcry_md_putc ( md, 0x9a );     /* ctb */
  236|  2.45k|      gcry_md_putc ( md, n >> 24 );  /* 4 byte length header */
  237|  2.45k|      gcry_md_putc ( md, n >> 16 );
  238|  2.45k|      gcry_md_putc ( md, n >>  8 );
  239|  2.45k|      gcry_md_putc ( md, n       );
  240|  2.45k|      gcry_md_putc ( md, pk->version );
  241|  2.45k|    }
  242|  43.8k|  else
  243|  43.8k|    {
  244|  43.8k|      gcry_md_putc ( md, 0x99 );     /* ctb */
  245|  43.8k|      gcry_md_putc ( md, n >> 8 );   /* 2 byte length header */
  246|  43.8k|      gcry_md_putc ( md, n );
  247|  43.8k|      gcry_md_putc ( md, pk->version );
  248|  43.8k|    }
  249|  46.2k|  gcry_md_putc ( md, pk->timestamp >> 24 );
  250|  46.2k|  gcry_md_putc ( md, pk->timestamp >> 16 );
  251|  46.2k|  gcry_md_putc ( md, pk->timestamp >>  8 );
  252|  46.2k|  gcry_md_putc ( md, pk->timestamp       );
  253|       |
  254|  46.2k|  gcry_md_putc ( md, pk->pubkey_algo );
  255|       |
  256|  46.2k|  if (is_v5)
  ------------------
  |  Branch (256:7): [True: 2.45k, False: 43.8k]
  ------------------
  257|  2.45k|    {
  258|  2.45k|      n -= 10;
  259|  2.45k|      gcry_md_putc ( md, n >> 24 );
  260|  2.45k|      gcry_md_putc ( md, n >> 16 );
  261|  2.45k|      gcry_md_putc ( md, n >>  8 );
  262|  2.45k|      gcry_md_putc ( md, n       );
  263|  2.45k|    }
  264|       |
  265|  46.2k|  if(npkey==0 && pk->pkey[0]
  ------------------
  |  Branch (265:6): [True: 0, False: 46.2k]
  |  Branch (265:18): [True: 0, False: 0]
  ------------------
  266|  46.2k|     && gcry_mpi_get_flag (pk->pkey[0], GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (266:9): [True: 0, False: 0]
  ------------------
  267|      0|    {
  268|      0|      if (pp[0])
  ------------------
  |  Branch (268:11): [True: 0, False: 0]
  ------------------
  269|      0|        gcry_md_write (md, pp[0], nn[0]);
  270|      0|    }
  271|  46.2k|  else
  272|  46.2k|    {
  273|   139k|      for(i=0; i < npkey; i++ )
  ------------------
  |  Branch (273:16): [True: 92.7k, False: 46.2k]
  ------------------
  274|  92.7k|        {
  275|  92.7k|          if (pp[i])
  ------------------
  |  Branch (275:15): [True: 92.7k, False: 0]
  ------------------
  276|  92.7k|            gcry_md_write ( md, pp[i], nn[i] );
  277|  92.7k|          xfree(pp[i]);
  ------------------
  |  |  104|  92.7k|#define xfree(a)         gcry_free ((a))
  ------------------
  278|  92.7k|        }
  279|  46.2k|    }
  280|  46.2k|}
format_keyid:
  359|  6.92M|{
  360|  6.92M|  if (! buffer)
  ------------------
  |  Branch (360:7): [True: 0, False: 6.92M]
  ------------------
  361|      0|    {
  362|      0|      len = KEYID_STR_SIZE;
  ------------------
  |  |   41|      0|#define KEYID_STR_SIZE 19
  ------------------
  363|      0|      buffer = xtrymalloc (len);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  364|      0|      if (!buffer)
  ------------------
  |  Branch (364:11): [True: 0, False: 0]
  ------------------
  365|      0|        return NULL;
  366|      0|    }
  367|       |
  368|  6.92M|  if (format == KF_DEFAULT)
  ------------------
  |  Branch (368:7): [True: 0, False: 6.92M]
  ------------------
  369|      0|    format = opt.keyid_format;
  370|  6.92M|  if (format == KF_DEFAULT)
  ------------------
  |  Branch (370:7): [True: 0, False: 6.92M]
  ------------------
  371|      0|    format = KF_NONE;
  372|       |
  373|  6.92M|  switch (format)
  374|  6.92M|    {
  375|      0|    case KF_NONE:
  ------------------
  |  Branch (375:5): [True: 0, False: 6.92M]
  ------------------
  376|      0|      if (len)
  ------------------
  |  Branch (376:11): [True: 0, False: 0]
  ------------------
  377|      0|        *buffer = 0;
  378|      0|      break;
  379|       |
  380|      0|    case KF_SHORT:
  ------------------
  |  Branch (380:5): [True: 0, False: 6.92M]
  ------------------
  381|      0|      snprintf (buffer, len, "%08lX", (ulong)keyid[1]);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  382|      0|      break;
  383|       |
  384|  6.92M|    case KF_LONG:
  ------------------
  |  Branch (384:5): [True: 6.92M, False: 0]
  ------------------
  385|  6.92M|      snprintf (buffer, len, "%08lX%08lX", (ulong)keyid[0], (ulong)keyid[1]);
  ------------------
  |  |   84|  6.92M|#define snprintf gpgrt_snprintf
  ------------------
  386|  6.92M|      break;
  387|       |
  388|      0|    case KF_0xSHORT:
  ------------------
  |  Branch (388:5): [True: 0, False: 6.92M]
  ------------------
  389|      0|      snprintf (buffer, len, "0x%08lX", (ulong)keyid[1]);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  390|      0|      break;
  391|       |
  392|      0|    case KF_0xLONG:
  ------------------
  |  Branch (392:5): [True: 0, False: 6.92M]
  ------------------
  393|      0|      snprintf (buffer, len, "0x%08lX%08lX", (ulong)keyid[0],(ulong)keyid[1]);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  394|      0|      break;
  395|       |
  396|      0|    default:
  ------------------
  |  Branch (396:5): [True: 0, False: 6.92M]
  ------------------
  397|      0|      BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  398|  6.92M|    }
  399|       |
  400|  6.92M|  return buffer;
  401|  6.92M|}
keystr:
  435|  6.92M|{
  436|  6.92M|  static char keyid_str[KEYID_STR_SIZE];
  437|  6.92M|  int format = opt.keyid_format;
  438|       |
  439|  6.92M|  if (format == KF_DEFAULT)
  ------------------
  |  Branch (439:7): [True: 6.92M, False: 0]
  ------------------
  440|  6.92M|    format = KF_NONE;
  441|  6.92M|  if (format == KF_NONE)
  ------------------
  |  Branch (441:7): [True: 6.92M, False: 0]
  ------------------
  442|  6.92M|    format = KF_LONG;
  443|       |
  444|  6.92M|  return format_keyid (keyid, format, keyid_str, sizeof (keyid_str));
  445|  6.92M|}
keyid_from_pk:
  572|  46.2k|{
  573|  46.2k|  u32 dummy_keyid[2];
  574|       |
  575|  46.2k|  if (!keyid)
  ------------------
  |  Branch (575:7): [True: 0, False: 46.2k]
  ------------------
  576|      0|    keyid = dummy_keyid;
  577|       |
  578|  46.2k|  if (!pk->fprlen)
  ------------------
  |  Branch (578:7): [True: 46.2k, False: 0]
  ------------------
  579|  46.2k|    compute_fingerprint (pk);
  580|       |
  581|  46.2k|  keyid[0] = pk->keyid[0];
  582|  46.2k|  keyid[1] = pk->keyid[1];
  583|       |
  584|  46.2k|  if (pk->fprlen == 32)
  ------------------
  |  Branch (584:7): [True: 2.45k, False: 43.8k]
  ------------------
  585|  2.45k|    return keyid[0];
  586|  43.8k|  else
  587|  43.8k|    return keyid[1];
  588|  46.2k|}
keyid.c:compute_fingerprint:
  538|  46.2k|{
  539|  46.2k|  const byte *dp;
  540|  46.2k|  gcry_md_hd_t md;
  541|  46.2k|  size_t len;
  542|       |
  543|  46.2k|  if (gcry_md_open (&md, pk->version == 5 ? GCRY_MD_SHA256 : GCRY_MD_SHA1, 0))
  ------------------
  |  Branch (543:7): [True: 0, False: 46.2k]
  |  Branch (543:26): [True: 2.45k, False: 43.8k]
  ------------------
  544|      0|    BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  545|  46.2k|  hash_public_key (md, pk);
  546|  46.2k|  gcry_md_final (md);
  547|  46.2k|  dp = gcry_md_read (md, 0);
  548|  46.2k|  len = gcry_md_get_algo_dlen (gcry_md_get_algo (md));
  549|  46.2k|  log_assert (len <= MAX_FINGERPRINT_LEN);
  550|      0|  memcpy (pk->fpr, dp, len);
  551|  46.2k|  pk->fprlen = len;
  552|  46.2k|  if (pk->version == 5)
  ------------------
  |  Branch (552:7): [True: 2.45k, False: 43.8k]
  ------------------
  553|  2.45k|    {
  554|  2.45k|      pk->keyid[0] = buf32_to_u32 (dp);
  555|  2.45k|      pk->keyid[1] = buf32_to_u32 (dp+4);
  556|  2.45k|    }
  557|  43.8k|  else
  558|  43.8k|    {
  559|  43.8k|      pk->keyid[0] = buf32_to_u32 (dp+12);
  560|  43.8k|      pk->keyid[1] = buf32_to_u32 (dp+16);
  561|  43.8k|    }
  562|  46.2k|  gcry_md_close( md);
  563|  46.2k|}

public_key_list:
  146|      1|{
  147|      1|#ifndef NO_TRUST_MODELS
  148|      1|  if (opt.with_colons)
  ------------------
  |  Branch (148:7): [True: 0, False: 1]
  ------------------
  149|      0|    {
  150|      0|      byte trust_model, marginals, completes, cert_depth, min_cert_level;
  151|      0|      ulong created, nextcheck;
  152|       |
  153|      0|      read_trust_options (ctrl, &trust_model, &created, &nextcheck,
  154|      0|			  &marginals, &completes, &cert_depth, &min_cert_level);
  155|       |
  156|      0|      es_fprintf (es_stdout, "tru:");
  157|       |
  158|      0|      if (nextcheck && nextcheck <= make_timestamp ())
  ------------------
  |  Branch (158:11): [True: 0, False: 0]
  |  Branch (158:24): [True: 0, False: 0]
  ------------------
  159|      0|	es_fprintf (es_stdout, "o");
  160|      0|      if (trust_model != opt.trust_model)
  ------------------
  |  Branch (160:11): [True: 0, False: 0]
  ------------------
  161|      0|	es_fprintf (es_stdout, "t");
  162|      0|      if (opt.trust_model == TM_PGP || opt.trust_model == TM_CLASSIC
  ------------------
  |  Branch (162:11): [True: 0, False: 0]
  |  Branch (162:40): [True: 0, False: 0]
  ------------------
  163|      0|	  || opt.trust_model == TM_TOFU_PGP)
  ------------------
  |  Branch (163:7): [True: 0, False: 0]
  ------------------
  164|      0|	{
  165|      0|	  if (marginals != opt.marginals_needed)
  ------------------
  |  Branch (165:8): [True: 0, False: 0]
  ------------------
  166|      0|	    es_fprintf (es_stdout, "m");
  167|      0|	  if (completes != opt.completes_needed)
  ------------------
  |  Branch (167:8): [True: 0, False: 0]
  ------------------
  168|      0|	    es_fprintf (es_stdout, "c");
  169|      0|	  if (cert_depth != opt.max_cert_depth)
  ------------------
  |  Branch (169:8): [True: 0, False: 0]
  ------------------
  170|      0|	    es_fprintf (es_stdout, "d");
  171|      0|	  if (min_cert_level != opt.min_cert_level)
  ------------------
  |  Branch (171:8): [True: 0, False: 0]
  ------------------
  172|      0|	    es_fprintf (es_stdout, "l");
  173|      0|	}
  174|       |
  175|      0|      es_fprintf (es_stdout, ":%d:%lu:%lu", trust_model, created, nextcheck);
  176|       |
  177|       |      /* Only show marginals, completes, and cert_depth in the classic
  178|       |         or PGP trust models since they are not meaningful
  179|       |         otherwise. */
  180|       |
  181|      0|      if (trust_model == TM_PGP || trust_model == TM_CLASSIC)
  ------------------
  |  Branch (181:11): [True: 0, False: 0]
  |  Branch (181:36): [True: 0, False: 0]
  ------------------
  182|      0|	es_fprintf (es_stdout, ":%d:%d:%d", marginals, completes, cert_depth);
  183|      0|      es_fprintf (es_stdout, "\n");
  184|      0|    }
  185|      1|#endif /*!NO_TRUST_MODELS*/
  186|       |
  187|       |  /* We need to do the stale check right here because it might need to
  188|       |     update the keyring while we already have the keyring open.  This
  189|       |     is very bad for W32 because of a sharing violation. For real OSes
  190|       |     it might lead to false results if we are later listing a keyring
  191|       |     which is associated with the inode of a deleted file.  */
  192|      1|  check_trustdb_stale (ctrl);
  193|       |
  194|       |#ifdef USE_TOFU
  195|       |  tofu_begin_batch_update (ctrl);
  196|       |#endif
  197|       |
  198|      1|  if (locate_mode)
  ------------------
  |  Branch (198:7): [True: 0, False: 1]
  ------------------
  199|      0|    locate_one (ctrl, list, no_local);
  200|      1|  else if (!list)
  ------------------
  |  Branch (200:12): [True: 1, False: 0]
  ------------------
  201|      1|    list_all (ctrl, 0, opt.with_secret);
  202|      0|  else
  203|      0|    list_one (ctrl, list, 0, opt.with_secret);
  204|       |
  205|       |#ifdef USE_TOFU
  206|       |  tofu_end_batch_update (ctrl);
  207|       |#endif
  208|      1|}
keylist.c:list_all:
  741|      1|{
  742|      1|  KEYDB_HANDLE hd;
  743|      1|  KBNODE keyblock = NULL;
  744|      1|  int rc = 0;
  745|      1|  int any_secret;
  746|      1|  const char *lastresname, *resname;
  747|      1|  struct keylist_context listctx;
  748|       |
  749|      1|  memset (&listctx, 0, sizeof (listctx));
  750|      1|  if (opt.check_sigs)
  ------------------
  |  Branch (750:7): [True: 0, False: 1]
  ------------------
  751|      0|    listctx.check_sigs = 1;
  752|       |
  753|      1|  hd = keydb_new (ctrl);
  754|      1|  if (!hd)
  ------------------
  |  Branch (754:7): [True: 0, False: 1]
  ------------------
  755|      0|    rc = gpg_error_from_syserror ();
  756|      1|  else
  757|      1|    rc = keydb_search_first (hd);
  758|      1|  if (rc)
  ------------------
  |  Branch (758:7): [True: 1, False: 0]
  ------------------
  759|      1|    {
  760|      1|      if (gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (760:11): [True: 0, False: 1]
  ------------------
  761|      0|	log_error ("keydb_search_first failed: %s\n", gpg_strerror (rc));
  762|      1|      goto leave;
  763|      1|    }
  764|       |
  765|      0|  lastresname = NULL;
  766|      0|  do
  767|      0|    {
  768|      0|      if (secret)
  ------------------
  |  Branch (768:11): [True: 0, False: 0]
  ------------------
  769|      0|        glo_ctrl.silence_parse_warnings++;
  770|      0|      rc = keydb_get_keyblock (hd, &keyblock);
  771|      0|      if (secret)
  ------------------
  |  Branch (771:11): [True: 0, False: 0]
  ------------------
  772|      0|        glo_ctrl.silence_parse_warnings--;
  773|      0|      if (rc)
  ------------------
  |  Branch (773:11): [True: 0, False: 0]
  ------------------
  774|      0|	{
  775|      0|          if (gpg_err_code (rc) == GPG_ERR_LEGACY_KEY)
  ------------------
  |  Branch (775:15): [True: 0, False: 0]
  ------------------
  776|      0|            continue;  /* Skip legacy keys.  */
  777|      0|	  log_error ("keydb_get_keyblock failed: %s\n", gpg_strerror (rc));
  778|      0|	  goto leave;
  779|      0|	}
  780|       |
  781|      0|      if (secret || mark_secret)
  ------------------
  |  Branch (781:11): [True: 0, False: 0]
  |  Branch (781:21): [True: 0, False: 0]
  ------------------
  782|      0|        any_secret = !agent_probe_any_secret_key (ctrl, keyblock);
  783|      0|      else
  784|      0|        any_secret = 0;
  785|       |
  786|      0|      if (secret && !any_secret)
  ------------------
  |  Branch (786:11): [True: 0, False: 0]
  |  Branch (786:21): [True: 0, False: 0]
  ------------------
  787|      0|        ; /* Secret key listing requested but this isn't one.  */
  788|      0|      else
  789|      0|        {
  790|      0|          if (!opt.with_colons && !(opt.list_options & LIST_SHOW_ONLY_FPR_MBOX))
  ------------------
  |  |  425|      0|#define LIST_SHOW_ONLY_FPR_MBOX          (1<<12)
  ------------------
  |  Branch (790:15): [True: 0, False: 0]
  |  Branch (790:35): [True: 0, False: 0]
  ------------------
  791|      0|            {
  792|      0|              resname = keydb_get_resource_name (hd);
  793|      0|              if (lastresname != resname)
  ------------------
  |  Branch (793:19): [True: 0, False: 0]
  ------------------
  794|      0|                {
  795|      0|                  int i;
  796|       |
  797|      0|                  es_fprintf (es_stdout, "%s\n", resname);
  798|      0|                  for (i = strlen (resname); i; i--)
  ------------------
  |  Branch (798:46): [True: 0, False: 0]
  ------------------
  799|      0|                    es_putc ('-', es_stdout);
  800|      0|                  es_putc ('\n', es_stdout);
  801|      0|                  lastresname = resname;
  802|      0|                }
  803|      0|            }
  804|      0|          merge_keys_and_selfsig (ctrl, keyblock);
  805|      0|          list_keyblock (ctrl, keyblock, secret, any_secret, opt.fingerprint,
  806|      0|                         &listctx);
  807|      0|        }
  808|      0|      release_kbnode (keyblock);
  809|      0|      keyblock = NULL;
  810|      0|    }
  811|      0|  while (!(rc = keydb_search_next (hd)));
  ------------------
  |  Branch (811:10): [True: 0, False: 0]
  ------------------
  812|      0|  es_fflush (es_stdout);
  813|      0|  if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (813:7): [True: 0, False: 0]
  |  Branch (813:13): [True: 0, False: 0]
  ------------------
  814|      0|    log_error ("keydb_search_next failed: %s\n", gpg_strerror (rc));
  815|      0|  if (keydb_get_skipped_counter (hd))
  ------------------
  |  Branch (815:7): [True: 0, False: 0]
  ------------------
  816|      0|    log_info (ngettext("Warning: %lu key skipped due to its large size\n",
  817|      0|                       "Warning: %lu keys skipped due to their large sizes\n",
  818|      0|                       keydb_get_skipped_counter (hd)),
  819|      0|              keydb_get_skipped_counter (hd));
  820|       |
  821|      0|  if (opt.check_sigs && !opt.with_colons)
  ------------------
  |  Branch (821:7): [True: 0, False: 0]
  |  Branch (821:25): [True: 0, False: 0]
  ------------------
  822|      0|    print_signature_stats (&listctx);
  823|       |
  824|      1| leave:
  825|      1|  keylist_context_release (&listctx);
  826|      1|  release_kbnode (keyblock);
  827|      1|  keydb_release (hd);
  828|      1|}
keylist.c:keylist_context_release:
   92|      1|{
   93|      1|  (void)listctx; /* Nothing to release.  */
   94|      1|}

proc_packets:
 1494|  15.4k|{
 1495|  15.4k|  int rc;
 1496|  15.4k|  CTX c = xmalloc_clear (sizeof *c);
  ------------------
  |  |  116|  15.4k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 1497|       |
 1498|  15.4k|  c->ctrl = ctrl;
 1499|  15.4k|  c->anchor = anchor;
 1500|  15.4k|  rc = do_proc_packets (c, a);
 1501|  15.4k|  xfree (c);
  ------------------
  |  |  104|  15.4k|#define xfree(a)         gcry_free ((a))
  ------------------
 1502|       |
 1503|  15.4k|  return rc;
 1504|  15.4k|}
mainproc.c:do_proc_packets:
 1626|  15.4k|{
 1627|  15.4k|  PACKET *pkt;
 1628|  15.4k|  struct parse_packet_ctx_s parsectx;
 1629|  15.4k|  int rc = 0;
 1630|  15.4k|  int any_data = 0;
 1631|  15.4k|  int newpkt;
 1632|       |
 1633|  15.4k|  rc = check_nesting (c);
 1634|  15.4k|  if (rc)
  ------------------
  |  Branch (1634:7): [True: 1, False: 15.4k]
  ------------------
 1635|      1|    return rc;
 1636|       |
 1637|  15.4k|  pkt = xmalloc( sizeof *pkt );
  ------------------
  |  |  107|  15.4k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1638|  15.4k|  c->iobuf = a;
 1639|  15.4k|  init_packet(pkt);
  ------------------
  |  |  581|  15.4k|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|  15.4k|			    (a)->pkt.generic = NULL;	\
  |  |  583|  15.4k|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1640|  15.4k|  init_parse_packet (&parsectx, a);
  ------------------
  |  |  666|  15.4k|#define init_parse_packet(a,i) do { \
  |  |  667|  15.4k|    (a)->inp = (i);                 \
  |  |  668|  15.4k|    (a)->last_pkt.pkttype = 0;      \
  |  |  669|  15.4k|    (a)->last_pkt.pkt.generic= NULL;\
  |  |  670|  15.4k|    (a)->free_last_pkt = 0;         \
  |  |  671|  15.4k|    (a)->skip_meta = 0;             \
  |  |  672|  15.4k|    (a)->n_parsed_packets = 0;      \
  |  |  673|  15.4k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (673:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1641|  2.41M|  while ((rc=parse_packet (&parsectx, pkt)) != -1)
  ------------------
  |  |  697|  2.41M|	     dbg_parse_packet( (a), (b), __FILE__, __LINE__ )
  ------------------
  |  Branch (1641:10): [True: 2.40M, False: 15.0k]
  ------------------
 1642|  2.40M|    {
 1643|  2.40M|      any_data = 1;
 1644|  2.40M|      if (rc)
  ------------------
  |  Branch (1644:11): [True: 2.12M, False: 280k]
  ------------------
 1645|  2.12M|        {
 1646|  2.12M|          free_packet (pkt, &parsectx);
 1647|       |          /* Stop processing when an invalid packet has been encountered
 1648|       |           * but don't do so when we are doing a --list-packets.  */
 1649|  2.12M|          if (gpg_err_code (rc) == GPG_ERR_INV_PACKET
  ------------------
  |  Branch (1649:15): [True: 2.10M, False: 19.9k]
  ------------------
 1650|  2.12M|              && opt.list_packets == 0)
  ------------------
  |  Branch (1650:18): [True: 0, False: 2.10M]
  ------------------
 1651|      0|            break;
 1652|  2.12M|          continue;
 1653|  2.12M|	}
 1654|   280k|      newpkt = -1;
 1655|   280k|      if (opt.list_packets)
  ------------------
  |  Branch (1655:11): [True: 280k, False: 0]
  ------------------
 1656|   280k|        {
 1657|   280k|          switch (pkt->pkttype)
 1658|   280k|            {
 1659|  7.40k|            case PKT_PUBKEY_ENC:    proc_pubkey_enc (c, pkt); break;
  ------------------
  |  Branch (1659:13): [True: 7.40k, False: 273k]
  ------------------
 1660|  52.8k|            case PKT_SYMKEY_ENC:    proc_symkey_enc (c, pkt); break;
  ------------------
  |  Branch (1660:13): [True: 52.8k, False: 227k]
  ------------------
 1661|  72.4k|            case PKT_ENCRYPTED:
  ------------------
  |  Branch (1661:13): [True: 72.4k, False: 208k]
  ------------------
 1662|  74.0k|            case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (1662:13): [True: 1.66k, False: 278k]
  ------------------
 1663|   120k|            case PKT_ENCRYPTED_AEAD:proc_encrypted (c, pkt); break;
  ------------------
  |  Branch (1663:13): [True: 46.1k, False: 234k]
  ------------------
 1664|  3.53k|            case PKT_COMPRESSED:    rc = proc_compressed (c, pkt); break;
  ------------------
  |  Branch (1664:13): [True: 3.53k, False: 277k]
  ------------------
 1665|  96.4k|            default: newpkt = 0; break;
  ------------------
  |  Branch (1665:13): [True: 96.4k, False: 184k]
  ------------------
 1666|   280k|	    }
 1667|   280k|	}
 1668|      0|      else if (c->sigs_only)
  ------------------
  |  Branch (1668:16): [True: 0, False: 0]
  ------------------
 1669|      0|        {
 1670|      0|          switch (pkt->pkttype)
 1671|      0|            {
 1672|      0|            case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (1672:13): [True: 0, False: 0]
  ------------------
 1673|      0|            case PKT_SECRET_KEY:
  ------------------
  |  Branch (1673:13): [True: 0, False: 0]
  ------------------
 1674|      0|            case PKT_USER_ID:
  ------------------
  |  Branch (1674:13): [True: 0, False: 0]
  ------------------
 1675|      0|            case PKT_SYMKEY_ENC:
  ------------------
  |  Branch (1675:13): [True: 0, False: 0]
  ------------------
 1676|      0|            case PKT_PUBKEY_ENC:
  ------------------
  |  Branch (1676:13): [True: 0, False: 0]
  ------------------
 1677|      0|            case PKT_ENCRYPTED:
  ------------------
  |  Branch (1677:13): [True: 0, False: 0]
  ------------------
 1678|      0|            case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (1678:13): [True: 0, False: 0]
  ------------------
 1679|      0|            case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (1679:13): [True: 0, False: 0]
  ------------------
 1680|      0|              write_status_text( STATUS_UNEXPECTED, "0" );
 1681|      0|              rc = GPG_ERR_UNEXPECTED;
 1682|      0|              goto leave;
 1683|       |
 1684|      0|            case PKT_SIGNATURE:   newpkt = add_signature (c, pkt); break;
  ------------------
  |  Branch (1684:13): [True: 0, False: 0]
  ------------------
 1685|      0|            case PKT_PLAINTEXT:   proc_plaintext (c, pkt); break;
  ------------------
  |  Branch (1685:13): [True: 0, False: 0]
  ------------------
 1686|      0|            case PKT_COMPRESSED:  rc = proc_compressed (c, pkt); break;
  ------------------
  |  Branch (1686:13): [True: 0, False: 0]
  ------------------
 1687|      0|            case PKT_ONEPASS_SIG: newpkt = add_onepass_sig (c, pkt); break;
  ------------------
  |  Branch (1687:13): [True: 0, False: 0]
  ------------------
 1688|      0|            case PKT_GPG_CONTROL: newpkt = add_gpg_control (c, pkt); break;
  ------------------
  |  Branch (1688:13): [True: 0, False: 0]
  ------------------
 1689|      0|            default: newpkt = 0; break;
  ------------------
  |  Branch (1689:13): [True: 0, False: 0]
  ------------------
 1690|      0|	    }
 1691|      0|	}
 1692|      0|      else if (c->encrypt_only)
  ------------------
  |  Branch (1692:16): [True: 0, False: 0]
  ------------------
 1693|      0|        {
 1694|      0|          switch (pkt->pkttype)
 1695|      0|            {
 1696|      0|            case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (1696:13): [True: 0, False: 0]
  ------------------
 1697|      0|            case PKT_SECRET_KEY:
  ------------------
  |  Branch (1697:13): [True: 0, False: 0]
  ------------------
 1698|      0|            case PKT_USER_ID:
  ------------------
  |  Branch (1698:13): [True: 0, False: 0]
  ------------------
 1699|      0|              write_status_text (STATUS_UNEXPECTED, "0");
 1700|      0|              rc = GPG_ERR_UNEXPECTED;
 1701|      0|              goto leave;
 1702|       |
 1703|      0|            case PKT_SIGNATURE:   newpkt = add_signature (c, pkt); break;
  ------------------
  |  Branch (1703:13): [True: 0, False: 0]
  ------------------
 1704|      0|            case PKT_SYMKEY_ENC:  proc_symkey_enc (c, pkt); break;
  ------------------
  |  Branch (1704:13): [True: 0, False: 0]
  ------------------
 1705|      0|            case PKT_PUBKEY_ENC:  proc_pubkey_enc (c, pkt); break;
  ------------------
  |  Branch (1705:13): [True: 0, False: 0]
  ------------------
 1706|      0|            case PKT_ENCRYPTED:
  ------------------
  |  Branch (1706:13): [True: 0, False: 0]
  ------------------
 1707|      0|            case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (1707:13): [True: 0, False: 0]
  ------------------
 1708|      0|            case PKT_ENCRYPTED_AEAD: proc_encrypted (c, pkt); break;
  ------------------
  |  Branch (1708:13): [True: 0, False: 0]
  ------------------
 1709|      0|            case PKT_PLAINTEXT:   proc_plaintext (c, pkt); break;
  ------------------
  |  Branch (1709:13): [True: 0, False: 0]
  ------------------
 1710|      0|            case PKT_COMPRESSED:  rc = proc_compressed (c, pkt); break;
  ------------------
  |  Branch (1710:13): [True: 0, False: 0]
  ------------------
 1711|      0|            case PKT_ONEPASS_SIG: newpkt = add_onepass_sig (c, pkt); break;
  ------------------
  |  Branch (1711:13): [True: 0, False: 0]
  ------------------
 1712|      0|            case PKT_GPG_CONTROL: newpkt = add_gpg_control (c, pkt); break;
  ------------------
  |  Branch (1712:13): [True: 0, False: 0]
  ------------------
 1713|      0|            default: newpkt = 0; break;
  ------------------
  |  Branch (1713:13): [True: 0, False: 0]
  ------------------
 1714|      0|	    }
 1715|      0|	}
 1716|      0|      else
 1717|      0|        {
 1718|      0|          switch (pkt->pkttype)
 1719|      0|            {
 1720|      0|            case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (1720:13): [True: 0, False: 0]
  ------------------
 1721|      0|            case PKT_SECRET_KEY:
  ------------------
  |  Branch (1721:13): [True: 0, False: 0]
  ------------------
 1722|      0|              release_list (c);
 1723|      0|              c->list = new_kbnode (pkt);
 1724|      0|              newpkt = 1;
 1725|      0|              break;
 1726|      0|            case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (1726:13): [True: 0, False: 0]
  ------------------
 1727|      0|            case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (1727:13): [True: 0, False: 0]
  ------------------
 1728|      0|              newpkt = add_subkey (c, pkt);
 1729|      0|              break;
 1730|      0|            case PKT_USER_ID:     newpkt = add_user_id (c, pkt); break;
  ------------------
  |  Branch (1730:13): [True: 0, False: 0]
  ------------------
 1731|      0|            case PKT_SIGNATURE:   newpkt = add_signature (c, pkt); break;
  ------------------
  |  Branch (1731:13): [True: 0, False: 0]
  ------------------
 1732|      0|            case PKT_PUBKEY_ENC:  proc_pubkey_enc (c, pkt); break;
  ------------------
  |  Branch (1732:13): [True: 0, False: 0]
  ------------------
 1733|      0|            case PKT_SYMKEY_ENC:  proc_symkey_enc (c, pkt); break;
  ------------------
  |  Branch (1733:13): [True: 0, False: 0]
  ------------------
 1734|      0|            case PKT_ENCRYPTED:
  ------------------
  |  Branch (1734:13): [True: 0, False: 0]
  ------------------
 1735|      0|            case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (1735:13): [True: 0, False: 0]
  ------------------
 1736|      0|            case PKT_ENCRYPTED_AEAD: proc_encrypted (c, pkt); break;
  ------------------
  |  Branch (1736:13): [True: 0, False: 0]
  ------------------
 1737|      0|            case PKT_PLAINTEXT:   proc_plaintext (c, pkt); break;
  ------------------
  |  Branch (1737:13): [True: 0, False: 0]
  ------------------
 1738|      0|            case PKT_COMPRESSED:  rc = proc_compressed (c, pkt); break;
  ------------------
  |  Branch (1738:13): [True: 0, False: 0]
  ------------------
 1739|      0|            case PKT_ONEPASS_SIG: newpkt = add_onepass_sig (c, pkt); break;
  ------------------
  |  Branch (1739:13): [True: 0, False: 0]
  ------------------
 1740|      0|            case PKT_GPG_CONTROL: newpkt = add_gpg_control(c, pkt); break;
  ------------------
  |  Branch (1740:13): [True: 0, False: 0]
  ------------------
 1741|      0|            case PKT_RING_TRUST:  newpkt = add_ring_trust (c, pkt); break;
  ------------------
  |  Branch (1741:13): [True: 0, False: 0]
  ------------------
 1742|      0|            default: newpkt = 0; break;
  ------------------
  |  Branch (1742:13): [True: 0, False: 0]
  ------------------
 1743|      0|	    }
 1744|      0|	}
 1745|       |
 1746|   280k|      if (rc)
  ------------------
  |  Branch (1746:11): [True: 366, False: 280k]
  ------------------
 1747|    366|        goto leave;
 1748|       |
 1749|       |      /* This is a very ugly construct and frankly, I don't remember why
 1750|       |       * I used it.  Adding the MDC check here is a hack.
 1751|       |       * The right solution is to initiate another context for encrypted
 1752|       |       * packet and not to reuse the current one ...  It works right
 1753|       |       * when there is a compression packet between which adds just
 1754|       |       * an extra layer.
 1755|       |       * Hmmm: Rewrite this whole module here??
 1756|       |       */
 1757|   280k|      if (pkt->pkttype != PKT_SIGNATURE && pkt->pkttype != PKT_MDC)
  ------------------
  |  Branch (1757:11): [True: 242k, False: 37.5k]
  |  Branch (1757:44): [True: 239k, False: 2.97k]
  ------------------
 1758|   239k|        c->any.data = (pkt->pkttype == PKT_PLAINTEXT);
 1759|       |
 1760|   280k|      if (newpkt == -1)
  ------------------
  |  Branch (1760:11): [True: 183k, False: 96.4k]
  ------------------
 1761|   183k|        ;
 1762|  96.4k|      else if (newpkt)
  ------------------
  |  Branch (1762:16): [True: 0, False: 96.4k]
  ------------------
 1763|      0|        {
 1764|      0|          pkt = xmalloc (sizeof *pkt);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1765|      0|          init_packet (pkt);
  ------------------
  |  |  581|      0|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|      0|			    (a)->pkt.generic = NULL;	\
  |  |  583|      0|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1766|      0|	}
 1767|  96.4k|      else
 1768|  96.4k|        free_packet (pkt, &parsectx);
 1769|   280k|    }
 1770|       |
 1771|  15.0k|  if (rc == GPG_ERR_INV_PACKET)
  ------------------
  |  Branch (1771:7): [True: 0, False: 15.0k]
  ------------------
 1772|      0|    write_status_text (STATUS_NODATA, "3");
 1773|       |
 1774|  15.0k|  if (any_data)
  ------------------
  |  Branch (1774:7): [True: 13.8k, False: 1.20k]
  ------------------
 1775|  13.8k|    rc = 0;
 1776|  1.20k|  else if (rc == -1)
  ------------------
  |  Branch (1776:12): [True: 1.20k, False: 0]
  ------------------
 1777|  1.20k|    write_status_text (STATUS_NODATA, "2");
 1778|       |
 1779|       |
 1780|  15.4k| leave:
 1781|  15.4k|  release_list (c);
 1782|  15.4k|  xfree(c->dek);
  ------------------
  |  |  104|  15.4k|#define xfree(a)         gcry_free ((a))
  ------------------
 1783|  15.4k|  free_packet (pkt, &parsectx);
 1784|  15.4k|  deinit_parse_packet (&parsectx);
  ------------------
  |  |  675|  15.4k|#define deinit_parse_packet(a) do { \
  |  |  676|  15.4k|    if ((a)->free_last_pkt)         \
  |  |  ------------------
  |  |  |  Branch (676:9): [True: 0, False: 15.4k]
  |  |  ------------------
  |  |  677|  15.4k|      free_packet (NULL, (a));      \
  |  |  678|  15.4k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (678:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1785|  15.4k|  xfree (pkt);
  ------------------
  |  |  104|  15.4k|#define xfree(a)         gcry_free ((a))
  ------------------
 1786|  15.4k|  free_md_filter_context (&c->mfx);
 1787|  15.4k|  return rc;
 1788|  15.0k|}
mainproc.c:check_nesting:
 1607|  15.4k|{
 1608|  15.4k|  int level;
 1609|       |
 1610|  59.8k|  for (level=0; c; c = c->anchor)
  ------------------
  |  Branch (1610:17): [True: 44.4k, False: 15.4k]
  ------------------
 1611|  44.4k|    level++;
 1612|       |
 1613|  15.4k|  if (level > MAX_NESTING_DEPTH)
  ------------------
  |  |   47|  15.4k|#define MAX_NESTING_DEPTH 32
  ------------------
  |  Branch (1613:7): [True: 1, False: 15.4k]
  ------------------
 1614|      1|    {
 1615|      1|      log_error ("input data with too deeply nested packets\n");
 1616|      1|      write_status_text (STATUS_UNEXPECTED, "1");
 1617|      1|      return GPG_ERR_BAD_DATA;
 1618|      1|    }
 1619|       |
 1620|  15.4k|  return 0;
 1621|  15.4k|}
mainproc.c:proc_pubkey_enc:
  502|  7.40k|{
  503|  7.40k|  PKT_pubkey_enc *enc;
  504|       |
  505|       |  /* Check whether the secret key is available and store in this case.  */
  506|  7.40k|  c->last_was_session_key = 1;
  507|  7.40k|  enc = pkt->pkt.pubkey_enc;
  508|       |  /*printf("enc: encrypted by a pubkey with keyid %08lX\n", enc->keyid[1] );*/
  509|       |  /* Hmmm: why do I have this algo check here - anyway there is
  510|       |   * function to check it. */
  511|  7.40k|  if (opt.verbose)
  ------------------
  |  Branch (511:7): [True: 0, False: 7.40k]
  ------------------
  512|      0|    log_info (_("public key is %s\n"), keystr (enc->keyid));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  513|       |
  514|  7.40k|  if (is_status_enabled ())
  ------------------
  |  Branch (514:7): [True: 0, False: 7.40k]
  ------------------
  515|      0|    {
  516|      0|      char buf[50];
  517|      0|      snprintf (buf, sizeof buf, "%08lX%08lX %d 0",
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  518|      0|                (ulong)enc->keyid[0], (ulong)enc->keyid[1], enc->pubkey_algo);
  519|      0|      write_status_text (STATUS_ENC_TO, buf);
  520|      0|    }
  521|       |
  522|  7.40k|  if (!opt.list_only && !opt.override_session_key)
  ------------------
  |  Branch (522:7): [True: 7.40k, False: 0]
  |  Branch (522:25): [True: 7.40k, False: 0]
  ------------------
  523|  7.40k|    {
  524|  7.40k|      struct pubkey_enc_list *x = xmalloc (sizeof *x);
  ------------------
  |  |  107|  7.40k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  525|       |
  526|  7.40k|      x->keyid[0] = enc->keyid[0];
  527|  7.40k|      x->keyid[1] = enc->keyid[1];
  528|  7.40k|      x->pubkey_algo = enc->pubkey_algo;
  529|  7.40k|      x->result = -1;
  530|  7.40k|      x->data[0] = x->data[1] = NULL;
  531|  7.40k|      if (enc->data[0])
  ------------------
  |  Branch (531:11): [True: 970, False: 6.43k]
  ------------------
  532|    970|        {
  533|    970|          x->data[0] = mpi_copy (enc->data[0]);
  534|    970|          x->data[1] = mpi_copy (enc->data[1]);
  535|    970|        }
  536|  7.40k|      x->next = c->pkenc_list;
  537|  7.40k|      c->pkenc_list = x;
  538|  7.40k|    }
  539|       |
  540|  7.40k|  free_packet(pkt, NULL);
  541|  7.40k|}
mainproc.c:proc_symkey_enc:
  379|  52.8k|{
  380|  52.8k|  gpg_error_t err;
  381|  52.8k|  PKT_symkey_enc *enc;
  382|       |
  383|  52.8k|  enc = pkt->pkt.symkey_enc;
  384|  52.8k|  if (!enc)
  ------------------
  |  Branch (384:7): [True: 4.09k, False: 48.7k]
  ------------------
  385|  4.09k|    log_error ("invalid symkey encrypted packet\n");
  386|  48.7k|  else if(!c->dek)
  ------------------
  |  Branch (386:11): [True: 48.7k, False: 0]
  ------------------
  387|  48.7k|    {
  388|  48.7k|      int algo = enc->cipher_algo;
  389|  48.7k|      const char *s = openpgp_cipher_algo_name (algo);
  390|  48.7k|      const char *a = (enc->aead_algo ? openpgp_aead_algo_name (enc->aead_algo)
  ------------------
  |  Branch (390:24): [True: 1.78k, False: 46.9k]
  ------------------
  391|  48.7k|                       /**/           : "CFB");
  392|       |
  393|  48.7k|      if (!openpgp_cipher_test_algo (algo))
  ------------------
  |  Branch (393:11): [True: 31.6k, False: 17.1k]
  ------------------
  394|  31.6k|        {
  395|  31.6k|          if (!opt.quiet)
  ------------------
  |  Branch (395:15): [True: 31.6k, False: 0]
  ------------------
  396|  31.6k|            {
  397|  31.6k|              if (enc->seskeylen)
  ------------------
  |  Branch (397:19): [True: 22.8k, False: 8.77k]
  ------------------
  398|  22.8k|                log_info (_("%s.%s encrypted session key\n"), s, a );
  ------------------
  |  |   28|  22.8k|#  define _(a) gettext (a)
  ------------------
  399|  8.77k|              else
  400|  8.77k|                log_info (_("%s.%s encrypted data\n"), s, a );
  ------------------
  |  |   28|  8.77k|#  define _(a) gettext (a)
  ------------------
  401|  31.6k|            }
  402|  31.6k|        }
  403|  17.1k|      else
  404|  17.1k|        {
  405|  17.1k|          log_error (_("encrypted with unknown algorithm %d.%s\n"), algo, a);
  ------------------
  |  |   28|  17.1k|#  define _(a) gettext (a)
  ------------------
  406|  17.1k|          s = NULL; /* Force a goto leave.  */
  407|  17.1k|        }
  408|       |
  409|  48.7k|      if (openpgp_md_test_algo (enc->s2k.hash_algo))
  ------------------
  |  Branch (409:11): [True: 38.5k, False: 10.1k]
  ------------------
  410|  38.5k|        {
  411|  38.5k|          log_error(_("passphrase generated with unknown digest"
  ------------------
  |  |   28|  38.5k|#  define _(a) gettext (a)
  ------------------
  412|  38.5k|                      " algorithm %d\n"),enc->s2k.hash_algo);
  413|  38.5k|          s = NULL;
  414|  38.5k|        }
  415|       |
  416|  48.7k|      c->last_was_session_key = 2;
  417|  48.7k|      if (!s || opt.list_only)
  ------------------
  |  Branch (417:11): [True: 40.9k, False: 7.85k]
  |  Branch (417:17): [True: 0, False: 7.85k]
  ------------------
  418|  40.9k|        goto leave;
  419|       |
  420|  7.85k|      if (opt.override_session_key)
  ------------------
  |  Branch (420:11): [True: 0, False: 7.85k]
  ------------------
  421|      0|        {
  422|      0|          c->dek = xmalloc_clear (sizeof *c->dek);
  ------------------
  |  |  116|      0|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  423|      0|          if (get_override_session_key (c->dek, opt.override_session_key))
  ------------------
  |  Branch (423:15): [True: 0, False: 0]
  ------------------
  424|      0|            {
  425|      0|              xfree (c->dek);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  426|      0|              c->dek = NULL;
  427|      0|            }
  428|      0|        }
  429|  7.85k|      else
  430|  7.85k|        {
  431|  7.85k|          c->dek = passphrase_to_dek (algo, &enc->s2k, 0, 0, NULL,
  432|  7.85k|                                      GETPASSWORD_FLAG_SYMDECRYPT, NULL);
  ------------------
  |  |  297|  7.85k|#define GETPASSWORD_FLAG_SYMDECRYPT  1
  ------------------
  433|  7.85k|          if (c->dek)
  ------------------
  |  Branch (433:15): [True: 0, False: 7.85k]
  ------------------
  434|      0|            {
  435|      0|              c->dek->symmetric = 1;
  436|      0|              c->dek->use_aead = enc->aead_algo;
  437|       |
  438|       |              /* FIXME: This doesn't work perfectly if a symmetric key
  439|       |                 comes before a public key in the message - if the
  440|       |                 user doesn't know the passphrase, then there is a
  441|       |                 chance that the "decrypted" algorithm will happen to
  442|       |                 be a valid one, which will make the returned dek
  443|       |                 appear valid, so we won't try any public keys that
  444|       |                 come later. */
  445|      0|              if (enc->seskeylen)
  ------------------
  |  Branch (445:19): [True: 0, False: 0]
  ------------------
  446|      0|                {
  447|      0|                  err = symkey_decrypt_seskey (c->dek,
  448|      0|                                               enc->seskey, enc->seskeylen);
  449|      0|                  if (err)
  ------------------
  |  Branch (449:23): [True: 0, False: 0]
  ------------------
  450|      0|                    {
  451|      0|                      log_info ("decryption of the symmetrically encrypted"
  452|      0|                                 " session key failed: %s\n",
  453|      0|                                 gpg_strerror (err));
  454|      0|                      if (gpg_err_code (err) != GPG_ERR_BAD_KEY
  ------------------
  |  Branch (454:27): [True: 0, False: 0]
  ------------------
  455|      0|                          && gpg_err_code (err) != GPG_ERR_CHECKSUM)
  ------------------
  |  Branch (455:30): [True: 0, False: 0]
  ------------------
  456|      0|                        log_fatal ("process terminated to be bug compatible"
  457|      0|                                   " with GnuPG <= 2.2\n");
  458|      0|                      else
  459|      0|                        write_status_text (STATUS_ERROR,
  460|      0|                                           "symkey_decrypt.maybe_error"
  461|      0|                                           " 11_BAD_PASSPHRASE");
  462|       |
  463|      0|                      if (c->dek->s2k_cacheid[0])
  ------------------
  |  Branch (463:27): [True: 0, False: 0]
  ------------------
  464|      0|                        {
  465|      0|                          if (opt.debug)
  ------------------
  |  Branch (465:31): [True: 0, False: 0]
  ------------------
  466|      0|                            log_debug ("cleared passphrase cached with ID:"
  467|      0|                                       " %s\n", c->dek->s2k_cacheid);
  468|      0|                          passphrase_clear_cache (c->dek->s2k_cacheid);
  469|      0|                        }
  470|      0|                      xfree (c->dek);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  471|      0|                      c->dek = NULL;
  472|      0|                    }
  473|      0|                }
  474|      0|              else
  475|      0|                c->dek->algo_info_printed = 1;
  476|      0|            }
  477|  7.85k|        }
  478|  7.85k|    }
  479|       |
  480|  52.8k| leave:
  481|       |  /* Record infos from the packet.  */
  482|  52.8k|  {
  483|  52.8k|    struct symlist_item  *symitem;
  484|  52.8k|    symitem = xcalloc (1, sizeof *symitem);
  ------------------
  |  |  109|  52.8k|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
  485|  52.8k|    if (enc)
  ------------------
  |  Branch (485:9): [True: 48.7k, False: 4.09k]
  ------------------
  486|  48.7k|      {
  487|  48.7k|        symitem->cipher_algo = enc->cipher_algo;
  488|  48.7k|        symitem->cfb_mode = !enc->aead_algo;
  489|  48.7k|      }
  490|  4.09k|    else
  491|  4.09k|      symitem->other_error = 1;
  492|  52.8k|    symitem->next = c->symenc_list;
  493|  52.8k|    c->symenc_list = symitem;
  494|  52.8k|  }
  495|  52.8k|  c->symkeys++;
  496|  52.8k|  free_packet (pkt, NULL);
  497|  52.8k|}
mainproc.c:proc_encrypted:
  583|   120k|{
  584|   120k|  int result = 0;
  585|   120k|  int early_plaintext = literals_seen;
  586|   120k|  unsigned int compliance_de_vs = 0;
  587|       |
  588|   120k|  if (pkt->pkttype == PKT_ENCRYPTED_AEAD)
  ------------------
  |  Branch (588:7): [True: 46.1k, False: 74.0k]
  ------------------
  589|  46.1k|    c->seen_pkt_encrypted_aead = 1;
  590|   120k|  if (pkt->pkttype == PKT_ENCRYPTED_MDC)
  ------------------
  |  Branch (590:7): [True: 1.66k, False: 118k]
  ------------------
  591|  1.66k|    c->seen_pkt_encrypted_mdc = 1;
  592|       |
  593|   120k|  if (early_plaintext)
  ------------------
  |  Branch (593:7): [True: 120k, False: 1]
  ------------------
  594|   120k|    {
  595|   120k|      log_info (_("WARNING: multiple plaintexts seen\n"));
  ------------------
  |  |   28|   120k|#  define _(a) gettext (a)
  ------------------
  596|   120k|      write_status_errcode ("decryption.early_plaintext", GPG_ERR_BAD_DATA);
  597|       |      /* We fail only later so that we can print some more info first.  */
  598|   120k|    }
  599|       |
  600|   120k|  if (!opt.quiet)
  ------------------
  |  Branch (600:7): [True: 120k, False: 0]
  ------------------
  601|   120k|    {
  602|   120k|      if (c->symkeys>1)
  ------------------
  |  Branch (602:11): [True: 20.5k, False: 99.7k]
  ------------------
  603|  20.5k|        log_info (_("encrypted with %lu passphrases\n"), c->symkeys);
  ------------------
  |  |   28|  20.5k|#  define _(a) gettext (a)
  ------------------
  604|  99.7k|      else if (c->symkeys == 1)
  ------------------
  |  Branch (604:16): [True: 7.70k, False: 92.0k]
  ------------------
  605|  7.70k|        log_info (_("encrypted with 1 passphrase\n"));
  ------------------
  |  |   28|  7.70k|#  define _(a) gettext (a)
  ------------------
  606|   120k|      print_pkenc_list (c->ctrl, c->pkenc_list);
  607|   120k|    }
  608|       |
  609|       |  /* Figure out the session key by looking at all pkenc packets. */
  610|   120k|  if (opt.list_only || c->dek)
  ------------------
  |  Branch (610:7): [True: 0, False: 120k]
  |  Branch (610:24): [True: 0, False: 120k]
  ------------------
  611|      0|    ;
  612|   120k|  else if (opt.override_session_key)
  ------------------
  |  Branch (612:12): [True: 0, False: 120k]
  ------------------
  613|      0|    {
  614|      0|      c->dek = xmalloc_clear (sizeof *c->dek);
  ------------------
  |  |  116|      0|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  615|      0|      result = get_override_session_key (c->dek, opt.override_session_key);
  616|      0|      if (result)
  ------------------
  |  Branch (616:11): [True: 0, False: 0]
  ------------------
  617|      0|        {
  618|      0|          xfree (c->dek);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  619|      0|          c->dek = NULL;
  620|      0|          log_info (_("public key decryption failed: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  621|      0|                    gpg_strerror (result));
  622|      0|          write_status_error ("pkdecrypt_failed", result);
  623|      0|        }
  624|      0|    }
  625|   120k|  else if (c->pkenc_list)
  ------------------
  |  Branch (625:12): [True: 58.5k, False: 61.7k]
  ------------------
  626|  58.5k|    {
  627|  58.5k|      c->dek = xmalloc_secure_clear (sizeof *c->dek);
  ------------------
  |  |  117|  58.5k|#define xmalloc_secure_clear(a) gcry_xcalloc_secure (1, (a))
  ------------------
  628|  58.5k|      result = get_session_key (c->ctrl, c->pkenc_list, c->dek);
  629|  58.5k|      if (is_status_enabled ())
  ------------------
  |  Branch (629:11): [True: 0, False: 58.5k]
  ------------------
  630|      0|        {
  631|      0|          struct pubkey_enc_list *list;
  632|       |
  633|      0|          for (list = c->pkenc_list; list; list = list->next)
  ------------------
  |  Branch (633:38): [True: 0, False: 0]
  ------------------
  634|      0|            if (list->result)
  ------------------
  |  Branch (634:17): [True: 0, False: 0]
  ------------------
  635|      0|              { /* Key was not tried or it caused an error.  */
  636|      0|                char buf[20];
  637|      0|                snprintf (buf, sizeof buf, "%08lX%08lX",
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  638|      0|                          (ulong)list->keyid[0], (ulong)list->keyid[1]);
  639|      0|                write_status_text (STATUS_NO_SECKEY, buf);
  640|      0|              }
  641|      0|        }
  642|       |
  643|  58.5k|      if (result)
  ------------------
  |  Branch (643:11): [True: 58.5k, False: 0]
  ------------------
  644|  58.5k|        {
  645|  58.5k|          log_info (_("public key decryption failed: %s\n"),
  ------------------
  |  |   28|  58.5k|#  define _(a) gettext (a)
  ------------------
  646|  58.5k|                    gpg_strerror (result));
  647|  58.5k|          write_status_error ("pkdecrypt_failed", result);
  648|       |
  649|       |          /* Error: Delete the DEK. */
  650|  58.5k|          xfree (c->dek);
  ------------------
  |  |  104|  58.5k|#define xfree(a)         gcry_free ((a))
  ------------------
  651|  58.5k|          c->dek = NULL;
  652|  58.5k|        }
  653|  58.5k|    }
  654|       |
  655|   120k|  if (c->dek && opt.verbose > 1)
  ------------------
  |  Branch (655:7): [True: 0, False: 120k]
  |  Branch (655:17): [True: 0, False: 0]
  ------------------
  656|      0|    log_info (_("public key encrypted data: good DEK\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  657|       |
  658|   120k|  write_status (STATUS_BEGIN_DECRYPTION);
  659|       |
  660|       |  /*log_debug("dat: %sencrypted data\n", c->dek?"":"conventional ");*/
  661|   120k|  if (opt.list_only)
  ------------------
  |  Branch (661:7): [True: 0, False: 120k]
  ------------------
  662|      0|    result = -1;
  663|   120k|  else if (!c->dek && !c->last_was_session_key)
  ------------------
  |  Branch (663:12): [True: 120k, False: 0]
  |  Branch (663:23): [True: 110k, False: 9.89k]
  ------------------
  664|   110k|    {
  665|   110k|      int algo;
  666|   110k|      STRING2KEY s2kbuf;
  667|   110k|      STRING2KEY *s2k = NULL;
  668|   110k|      int canceled;
  669|       |
  670|   110k|      if (opt.override_session_key)
  ------------------
  |  Branch (670:11): [True: 0, False: 110k]
  ------------------
  671|      0|        {
  672|      0|          c->dek = xmalloc_clear (sizeof *c->dek);
  ------------------
  |  |  116|      0|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  673|      0|          result = get_override_session_key (c->dek, opt.override_session_key);
  674|      0|          if (result)
  ------------------
  |  Branch (674:15): [True: 0, False: 0]
  ------------------
  675|      0|            {
  676|      0|              xfree (c->dek);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  677|      0|              c->dek = NULL;
  678|      0|            }
  679|      0|        }
  680|   110k|      else
  681|   110k|        {
  682|       |          /* Assume this is old style conventional encrypted data. */
  683|   110k|          algo = opt.def_cipher_algo;
  684|   110k|          if (algo)
  ------------------
  |  Branch (684:15): [True: 0, False: 110k]
  ------------------
  685|      0|            log_info (_("assuming %s encrypted data\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  686|      0|                      openpgp_cipher_algo_name (algo));
  687|   110k|          else if (openpgp_cipher_test_algo (CIPHER_ALGO_IDEA))
  ------------------
  |  Branch (687:20): [True: 0, False: 110k]
  ------------------
  688|      0|            {
  689|      0|              algo = opt.def_cipher_algo;
  690|      0|              if (!algo)
  ------------------
  |  Branch (690:19): [True: 0, False: 0]
  ------------------
  691|      0|                algo = opt.s2k_cipher_algo;
  692|      0|              log_info (_("IDEA cipher unavailable, "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  693|      0|                          "optimistically attempting to use %s instead\n"),
  694|      0|                        openpgp_cipher_algo_name (algo));
  695|      0|            }
  696|   110k|          else
  697|   110k|            {
  698|   110k|              algo = CIPHER_ALGO_IDEA;
  699|   110k|              if (!opt.s2k_digest_algo)
  ------------------
  |  Branch (699:19): [True: 110k, False: 0]
  ------------------
  700|   110k|                {
  701|       |                  /* If no digest is given we assume SHA-1. */
  702|   110k|                  s2kbuf.mode = 0;
  703|   110k|                  s2kbuf.hash_algo = DIGEST_ALGO_SHA1;
  704|   110k|                  s2k = &s2kbuf;
  705|   110k|                }
  706|   110k|              log_info (_("assuming %s encrypted data\n"), "IDEA");
  ------------------
  |  |   28|   110k|#  define _(a) gettext (a)
  ------------------
  707|   110k|            }
  708|       |
  709|   110k|          c->dek = passphrase_to_dek (algo, s2k, 0, 0, NULL,
  710|   110k|                                      GETPASSWORD_FLAG_SYMDECRYPT, &canceled);
  ------------------
  |  |  297|   110k|#define GETPASSWORD_FLAG_SYMDECRYPT  1
  ------------------
  711|   110k|          if (c->dek)
  ------------------
  |  Branch (711:15): [True: 0, False: 110k]
  ------------------
  712|      0|            c->dek->algo_info_printed = 1;
  713|   110k|          else if (canceled)
  ------------------
  |  Branch (713:20): [True: 110k, False: 0]
  ------------------
  714|   110k|            result = gpg_error (GPG_ERR_CANCELED);
  715|      0|          else
  716|      0|            result = gpg_error (GPG_ERR_INV_PASSPHRASE);
  717|   110k|        }
  718|   110k|    }
  719|  9.89k|  else if (!c->dek)
  ------------------
  |  Branch (719:12): [True: 9.89k, False: 0]
  ------------------
  720|  9.89k|    {
  721|  9.89k|      if (c->symkeys && !c->pkenc_list)
  ------------------
  |  Branch (721:11): [True: 5.39k, False: 4.49k]
  |  Branch (721:25): [True: 5.08k, False: 307]
  ------------------
  722|  5.08k|        result = gpg_error (GPG_ERR_BAD_KEY);
  723|       |
  724|  9.89k|      if (!result)
  ------------------
  |  Branch (724:11): [True: 0, False: 9.89k]
  ------------------
  725|      0|        result = gpg_error (GPG_ERR_NO_SECKEY);
  726|  9.89k|    }
  727|       |
  728|       |  /* Compute compliance with CO_DE_VS.  */
  729|   120k|  if (!result && (is_status_enabled () || opt.flags.require_compliance)
  ------------------
  |  Branch (729:7): [True: 0, False: 120k]
  |  Branch (729:19): [True: 0, False: 0]
  |  Branch (729:43): [True: 0, False: 0]
  ------------------
  730|       |      /* Overriding session key voids compliance.  */
  731|   120k|      && !opt.override_session_key
  ------------------
  |  Branch (731:10): [True: 0, False: 0]
  ------------------
  732|       |      /* Check symmetric cipher.  */
  733|   120k|      && gnupg_gcrypt_is_compliant (CO_DE_VS)
  ------------------
  |  Branch (733:10): [True: 0, False: 0]
  ------------------
  734|   120k|      && gnupg_cipher_is_compliant (CO_DE_VS, c->dek->algo,
  ------------------
  |  Branch (734:10): [True: 0, False: 0]
  ------------------
  735|      0|                                    GCRY_CIPHER_MODE_CFB))
  736|      0|    {
  737|      0|      struct pubkey_enc_list *i;
  738|      0|      struct symlist_item *si;
  739|      0|      int compliant = 1;
  740|      0|      PKT_public_key *pk = xmalloc (sizeof *pk);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  741|       |
  742|      0|      if ( !(c->pkenc_list || c->symkeys) )
  ------------------
  |  Branch (742:14): [True: 0, False: 0]
  |  Branch (742:31): [True: 0, False: 0]
  ------------------
  743|      0|        log_debug ("%s: where else did the session key come from?\n", __func__);
  744|       |
  745|       |      /* Check that all seen symmetric key packets use compliant
  746|       |       * algos.  This is so that no non-compliant encrypted session
  747|       |       * key can be sneaked in.  */
  748|      0|      for (si = c->symenc_list; si && compliant; si = si->next)
  ------------------
  |  Branch (748:33): [True: 0, False: 0]
  |  Branch (748:39): [True: 0, False: 0]
  ------------------
  749|      0|        {
  750|      0|          if (!si->cfb_mode
  ------------------
  |  Branch (750:15): [True: 0, False: 0]
  ------------------
  751|      0|              || !gnupg_cipher_is_compliant (CO_DE_VS, si->cipher_algo,
  ------------------
  |  Branch (751:18): [True: 0, False: 0]
  ------------------
  752|      0|                                             GCRY_CIPHER_MODE_CFB))
  753|      0|            compliant = 0;
  754|      0|        }
  755|       |
  756|       |      /* Check that every known public key used to encrypt the session key
  757|       |       * is compliant.  */
  758|      0|      for (i = c->pkenc_list; i && compliant; i = i->next)
  ------------------
  |  Branch (758:31): [True: 0, False: 0]
  |  Branch (758:36): [True: 0, False: 0]
  ------------------
  759|      0|        {
  760|      0|          memset (pk, 0, sizeof *pk);
  761|      0|          pk->pubkey_algo = i->pubkey_algo;
  762|      0|          if (!get_pubkey (c->ctrl, pk, i->keyid)
  ------------------
  |  Branch (762:15): [True: 0, False: 0]
  ------------------
  763|      0|              && !gnupg_pk_is_compliant (CO_DE_VS, pk->pubkey_algo, 0,
  ------------------
  |  Branch (763:18): [True: 0, False: 0]
  ------------------
  764|      0|                                         pk->pkey, nbits_from_pk (pk), NULL))
  765|      0|            compliant = 0;
  766|      0|          release_public_key_parts (pk);
  767|      0|        }
  768|       |
  769|      0|      xfree (pk);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  770|       |
  771|      0|      if (compliant)
  ------------------
  |  Branch (771:11): [True: 0, False: 0]
  ------------------
  772|      0|        compliance_de_vs |= 1;
  773|      0|    }
  774|       |
  775|   120k|  if (!result)
  ------------------
  |  Branch (775:7): [True: 0, False: 120k]
  ------------------
  776|      0|    {
  777|      0|      int compl_error;
  778|      0|      result = decrypt_data (c->ctrl, c, pkt->pkt.encrypted, c->dek,
  779|      0|                             &compl_error);
  780|      0|      if (!result && !compl_error)
  ------------------
  |  Branch (780:11): [True: 0, False: 0]
  |  Branch (780:22): [True: 0, False: 0]
  ------------------
  781|      0|        compliance_de_vs |= 2;
  782|      0|    }
  783|       |
  784|       |  /* Trigger the deferred error.  */
  785|   120k|  if (!result && early_plaintext)
  ------------------
  |  Branch (785:7): [True: 0, False: 120k]
  |  Branch (785:18): [True: 0, False: 0]
  ------------------
  786|      0|    result = gpg_error (GPG_ERR_BAD_DATA);
  787|       |
  788|   120k|  if (result == -1)
  ------------------
  |  Branch (788:7): [True: 0, False: 120k]
  ------------------
  789|      0|    ;
  790|   120k|  else if (!result
  ------------------
  |  Branch (790:12): [True: 0, False: 120k]
  ------------------
  791|   120k|           && !opt.ignore_mdc_error
  ------------------
  |  Branch (791:15): [True: 0, False: 0]
  ------------------
  792|   120k|           && !pkt->pkt.encrypted->mdc_method
  ------------------
  |  Branch (792:15): [True: 0, False: 0]
  ------------------
  793|   120k|           && !pkt->pkt.encrypted->aead_algo)
  ------------------
  |  Branch (793:15): [True: 0, False: 0]
  ------------------
  794|      0|    {
  795|       |      /* The message has been decrypted but does not carry an MDC or
  796|       |       * uses AEAD encryption.  --ignore-mdc-error has also not been
  797|       |       * used.  To avoid attacks changing an MDC message to a non-MDC
  798|       |       * message, we fail here.  */
  799|      0|      log_error (_("WARNING: message was not integrity protected\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  800|      0|      if (!pkt->pkt.encrypted->mdc_method
  ------------------
  |  Branch (800:11): [True: 0, False: 0]
  ------------------
  801|      0|          && (openpgp_cipher_get_algo_blklen (c->dek->algo) == 8
  ------------------
  |  |  123|      0|  gcry_cipher_get_algo_blklen(map_cipher_openpgp_to_gcry((_a)))
  ------------------
  |  Branch (801:15): [True: 0, False: 0]
  ------------------
  802|      0|              || c->dek->algo == CIPHER_ALGO_TWOFISH))
  ------------------
  |  Branch (802:18): [True: 0, False: 0]
  ------------------
  803|      0|        {
  804|       |          /* Before 2.2.8 we did not fail hard for a missing MDC if
  805|       |           * one of the old ciphers where used.  Although these cases
  806|       |           * are rare in practice we print a hint on how to decrypt
  807|       |           * such messages.  */
  808|      0|          log_string
  809|      0|            (GPGRT_LOGLVL_INFO,
  810|      0|             _("Hint: If this message was created before the year 2003 it is\n"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  811|      0|               "likely that this message is legitimate.  This is because back\n"
  812|      0|               "then integrity protection was not widely used.\n"));
  813|      0|          log_info (_("Use the option '%s' to decrypt anyway.\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  814|      0|                     "--ignore-mdc-error");
  815|      0|          write_status_errcode ("nomdc_with_legacy_cipher",
  816|      0|                                GPG_ERR_DECRYPT_FAILED);
  817|      0|        }
  818|      0|      log_info (_("decryption forced to fail!\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  819|      0|      write_status (STATUS_DECRYPTION_FAILED);
  820|      0|    }
  821|   120k|  else if (!result || (gpg_err_code (result) == GPG_ERR_BAD_SIGNATURE
  ------------------
  |  Branch (821:12): [True: 0, False: 120k]
  |  Branch (821:24): [True: 0, False: 120k]
  ------------------
  822|   120k|                       && !pkt->pkt.encrypted->aead_algo
  ------------------
  |  Branch (822:27): [True: 0, False: 0]
  ------------------
  823|   120k|                       && opt.ignore_mdc_error))
  ------------------
  |  Branch (823:27): [True: 0, False: 0]
  ------------------
  824|      0|    {
  825|       |      /* All is fine or for an MDC message the MDC failed but the
  826|       |       * --ignore-mdc-error option is active.  For compatibility
  827|       |       * reasons we issue GOODMDC also for AEAD messages.  */
  828|      0|      write_status (STATUS_DECRYPTION_OKAY);
  829|      0|      if (opt.verbose > 1)
  ------------------
  |  Branch (829:11): [True: 0, False: 0]
  ------------------
  830|      0|        log_info(_("decryption okay\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  831|       |
  832|      0|      if (pkt->pkt.encrypted->aead_algo)
  ------------------
  |  Branch (832:11): [True: 0, False: 0]
  ------------------
  833|      0|        {
  834|      0|          write_status (STATUS_GOODMDC);
  835|      0|          compliance_de_vs |= 4;
  836|      0|        }
  837|      0|      else if (pkt->pkt.encrypted->mdc_method && !result)
  ------------------
  |  Branch (837:16): [True: 0, False: 0]
  |  Branch (837:50): [True: 0, False: 0]
  ------------------
  838|      0|        {
  839|      0|          write_status (STATUS_GOODMDC);
  840|      0|          compliance_de_vs |= 4;
  841|      0|        }
  842|      0|      else
  843|      0|        log_info (_("WARNING: message was not integrity protected\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  844|      0|    }
  845|   120k|  else if (gpg_err_code (result) == GPG_ERR_BAD_SIGNATURE
  ------------------
  |  Branch (845:12): [True: 0, False: 120k]
  ------------------
  846|   120k|           || gpg_err_code (result) == GPG_ERR_TRUNCATED)
  ------------------
  |  Branch (846:15): [True: 0, False: 120k]
  ------------------
  847|      0|    {
  848|      0|      glo_ctrl.lasterr = result;
  849|      0|      log_error (_("WARNING: encrypted message has been manipulated!\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  850|      0|      write_status (STATUS_BADMDC);
  851|      0|      write_status (STATUS_DECRYPTION_FAILED);
  852|      0|    }
  853|   120k|  else
  854|   120k|    {
  855|   120k|      if (gpg_err_code (result) == GPG_ERR_BAD_KEY
  ------------------
  |  Branch (855:11): [True: 5.08k, False: 115k]
  ------------------
  856|   120k|          || gpg_err_code (result) == GPG_ERR_CHECKSUM
  ------------------
  |  Branch (856:14): [True: 0, False: 115k]
  ------------------
  857|   120k|          || gpg_err_code (result) == GPG_ERR_CIPHER_ALGO)
  ------------------
  |  Branch (857:14): [True: 0, False: 115k]
  ------------------
  858|  5.08k|        {
  859|  5.08k|          if (c->symkeys)
  ------------------
  |  Branch (859:15): [True: 5.08k, False: 0]
  ------------------
  860|  5.08k|            write_status_text (STATUS_ERROR,
  861|  5.08k|                               "symkey_decrypt.maybe_error"
  862|  5.08k|                               " 11_BAD_PASSPHRASE");
  863|       |
  864|  5.08k|          if (c->dek && *c->dek->s2k_cacheid != '\0')
  ------------------
  |  Branch (864:15): [True: 0, False: 5.08k]
  |  Branch (864:25): [True: 0, False: 0]
  ------------------
  865|      0|            {
  866|      0|              if (opt.debug)
  ------------------
  |  Branch (866:19): [True: 0, False: 0]
  ------------------
  867|      0|                log_debug ("cleared passphrase cached with ID: %s\n",
  868|      0|                           c->dek->s2k_cacheid);
  869|      0|              passphrase_clear_cache (c->dek->s2k_cacheid);
  870|      0|            }
  871|  5.08k|        }
  872|   120k|      glo_ctrl.lasterr = result;
  873|   120k|      write_status (STATUS_DECRYPTION_FAILED);
  874|   120k|      log_error (_("decryption failed: %s\n"), gpg_strerror (result));
  ------------------
  |  |   28|   120k|#  define _(a) gettext (a)
  ------------------
  875|       |      /* Hmmm: does this work when we have encrypted using multiple
  876|       |       * ways to specify the session key (symmmetric and PK). */
  877|   120k|    }
  878|       |
  879|       |
  880|       |  /* If we concluded that the decryption was compliant, issue a
  881|       |   * compliance status before the end of the decryption status.  */
  882|   120k|  if (compliance_de_vs == (4|2|1))
  ------------------
  |  Branch (882:7): [True: 0, False: 120k]
  ------------------
  883|      0|    {
  884|      0|      write_status_strings (STATUS_DECRYPTION_COMPLIANCE_MODE,
  885|      0|                            gnupg_status_compliance_flag (CO_DE_VS),
  886|      0|                            NULL);
  887|      0|    }
  888|       |
  889|   120k|  xfree (c->dek);
  ------------------
  |  |  104|   120k|#define xfree(a)         gcry_free ((a))
  ------------------
  890|   120k|  c->dek = NULL;
  891|   120k|  free_packet (pkt, NULL);
  892|   120k|  c->last_was_session_key = 0;
  893|   120k|  write_status (STATUS_END_DECRYPTION);
  894|       |
  895|       |  /* Bump the counter even if we have not seen a literal data packet
  896|       |   * inside an encryption container.  This acts as a sentinel in case
  897|       |   * a misplace extra literal data packets follows after this
  898|       |   * encrypted packet.  */
  899|   120k|  literals_seen++;
  900|       |
  901|       |  /* The --require-compliance option allows to simplify decryption in
  902|       |   * de-vs compliance mode by just looking at the exit status.  */
  903|   120k|  if (opt.flags.require_compliance
  ------------------
  |  Branch (903:7): [True: 0, False: 120k]
  ------------------
  904|   120k|      && opt.compliance == CO_DE_VS
  ------------------
  |  Branch (904:10): [True: 0, False: 0]
  ------------------
  905|   120k|      && compliance_de_vs != (4|2|1))
  ------------------
  |  Branch (905:10): [True: 0, False: 0]
  ------------------
  906|      0|    {
  907|      0|      log_error (_("operation forced to fail due to"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  908|      0|                   " unfulfilled compliance rules\n"));
  909|      0|      g10_errors_seen = 1;
  910|      0|    }
  911|   120k|}
mainproc.c:print_pkenc_list:
  550|   120k|{
  551|  7.04M|  for (; list; list = list->next)
  ------------------
  |  Branch (551:10): [True: 6.92M, False: 120k]
  ------------------
  552|  6.92M|    {
  553|  6.92M|      PKT_public_key *pk;
  554|  6.92M|      char pkstrbuf[PUBKEY_STRING_SIZE];
  555|  6.92M|      char *p;
  556|       |
  557|  6.92M|      pk = xmalloc_clear (sizeof *pk);
  ------------------
  |  |  116|  6.92M|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  558|       |
  559|  6.92M|      pk->pubkey_algo = list->pubkey_algo;
  560|  6.92M|      if (!get_pubkey (ctrl, pk, list->keyid))
  ------------------
  |  Branch (560:11): [True: 0, False: 6.92M]
  ------------------
  561|      0|        {
  562|      0|          pubkey_string (pk, pkstrbuf, sizeof pkstrbuf);
  563|       |
  564|      0|          log_info (_("encrypted with %s key, ID %s, created %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  565|      0|                    pkstrbuf, keystr_from_pk (pk),
  566|      0|                    strtimestamp (pk->timestamp));
  567|      0|          p = get_user_id_native (ctrl, list->keyid);
  568|      0|          log_printf (_("      \"%s\"\n"), p);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  569|      0|          xfree (p);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  570|      0|        }
  571|  6.92M|      else
  572|  6.92M|        log_info (_("encrypted with %s key, ID %s\n"),
  ------------------
  |  |   28|  6.92M|#  define _(a) gettext (a)
  ------------------
  573|  6.92M|                  openpgp_pk_algo_name (list->pubkey_algo),
  574|  6.92M|                  keystr(list->keyid));
  575|       |
  576|  6.92M|      free_public_key (pk);
  577|  6.92M|    }
  578|   120k|}
mainproc.c:proc_compressed:
 1116|  3.53k|{
 1117|  3.53k|  PKT_compressed *zd = pkt->pkt.compressed;
 1118|  3.53k|  int rc;
 1119|       |
 1120|       |  /*printf("zip: compressed data packet\n");*/
 1121|  3.53k|  if (c->sigs_only)
  ------------------
  |  Branch (1121:7): [True: 0, False: 3.53k]
  ------------------
 1122|      0|    rc = handle_compressed (c->ctrl, c, zd, proc_compressed_cb, c);
 1123|  3.53k|  else if( c->encrypt_only )
  ------------------
  |  Branch (1123:12): [True: 0, False: 3.53k]
  ------------------
 1124|      0|    rc = handle_compressed (c->ctrl, c, zd, proc_encrypt_cb, c);
 1125|  3.53k|  else
 1126|  3.53k|    rc = handle_compressed (c->ctrl, c, zd, NULL, NULL);
 1127|       |
 1128|  3.53k|  if (gpg_err_code (rc) == GPG_ERR_BAD_DATA)
  ------------------
  |  Branch (1128:7): [True: 32, False: 3.50k]
  ------------------
 1129|     32|    {
 1130|     32|      if  (!c->any.uncompress_failed)
  ------------------
  |  Branch (1130:12): [True: 1, False: 31]
  ------------------
 1131|      1|        {
 1132|      1|          CTX cc;
 1133|       |
 1134|     33|          for (cc=c; cc; cc = cc->anchor)
  ------------------
  |  Branch (1134:22): [True: 32, False: 1]
  ------------------
 1135|     32|            cc->any.uncompress_failed = 1;
 1136|      1|          log_error ("uncompressing failed: %s\n", gpg_strerror (rc));
 1137|      1|        }
 1138|     32|    }
 1139|  3.50k|  else if (rc)
  ------------------
  |  Branch (1139:12): [True: 334, False: 3.16k]
  ------------------
 1140|    334|    log_error ("uncompressing failed: %s\n", gpg_strerror (rc));
 1141|       |
 1142|  3.53k|  free_packet (pkt, NULL);
 1143|  3.53k|  c->last_was_session_key = 0;
 1144|  3.53k|  return rc;
 1145|  3.53k|}
mainproc.c:release_list:
  137|  15.4k|{
  138|  15.4k|  proc_tree (c, c->list);
  139|  15.4k|  release_kbnode (c->list);
  140|  22.8k|  while (c->pkenc_list)
  ------------------
  |  Branch (140:10): [True: 7.40k, False: 15.4k]
  ------------------
  141|  7.40k|    {
  142|  7.40k|      struct pubkey_enc_list *tmp = c->pkenc_list->next;
  143|       |
  144|  7.40k|      mpi_release (c->pkenc_list->data[0]);
  145|  7.40k|      mpi_release (c->pkenc_list->data[1]);
  146|  7.40k|      xfree (c->pkenc_list);
  ------------------
  |  |  104|  7.40k|#define xfree(a)         gcry_free ((a))
  ------------------
  147|  7.40k|      c->pkenc_list = tmp;
  148|  7.40k|    }
  149|  15.4k|  c->pkenc_list = NULL;
  150|  68.2k|  while (c->symenc_list)
  ------------------
  |  Branch (150:10): [True: 52.8k, False: 15.4k]
  ------------------
  151|  52.8k|    {
  152|  52.8k|      struct symlist_item *tmp = c->symenc_list->next;
  153|  52.8k|      xfree (c->symenc_list);
  ------------------
  |  |  104|  52.8k|#define xfree(a)         gcry_free ((a))
  ------------------
  154|  52.8k|      c->symenc_list = tmp;
  155|  52.8k|    }
  156|  15.4k|  c->symenc_list = NULL;
  157|  15.4k|  c->list = NULL;
  158|  15.4k|  c->any.data = 0;
  159|  15.4k|  c->any.uncompress_failed = 0;
  160|  15.4k|  c->last_was_session_key = 0;
  161|  15.4k|  c->seen_pkt_encrypted_aead = 0;
  162|  15.4k|  c->seen_pkt_encrypted_mdc = 0;
  163|  15.4k|  xfree (c->dek);
  ------------------
  |  |  104|  15.4k|#define xfree(a)         gcry_free ((a))
  ------------------
  164|  15.4k|  c->dek = NULL;
  165|  15.4k|}
mainproc.c:proc_tree:
 2574|  15.4k|{
 2575|  15.4k|  kbnode_t n1;
 2576|  15.4k|  int rc;
 2577|       |
 2578|  15.4k|  if (opt.list_packets || opt.list_only)
  ------------------
  |  Branch (2578:7): [True: 15.4k, False: 0]
  |  Branch (2578:27): [True: 0, False: 0]
  ------------------
 2579|  15.4k|    return;
 2580|       |
 2581|       |  /* We must skip our special plaintext marker packets here because
 2582|       |     they may be the root packet.  These packets are only used in
 2583|       |     additional checks and skipping them here doesn't matter.  */
 2584|      0|  while (node
  ------------------
  |  Branch (2584:10): [True: 0, False: 0]
  ------------------
 2585|      0|         && node->pkt->pkttype == PKT_GPG_CONTROL
  ------------------
  |  Branch (2585:13): [True: 0, False: 0]
  ------------------
 2586|      0|          && node->pkt->pkt.gpg_control->control == CTRLPKT_PLAINTEXT_MARK)
  ------------------
  |  Branch (2586:14): [True: 0, False: 0]
  ------------------
 2587|      0|    {
 2588|      0|      node = node->next;
 2589|      0|    }
 2590|      0|  if (!node)
  ------------------
  |  Branch (2590:7): [True: 0, False: 0]
  ------------------
 2591|      0|    return;
 2592|       |
 2593|      0|  c->trustletter = ' ';
 2594|      0|  if (node->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (2594:7): [True: 0, False: 0]
  ------------------
 2595|      0|      || node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (2595:10): [True: 0, False: 0]
  ------------------
 2596|      0|    {
 2597|      0|      merge_keys_and_selfsig (c->ctrl, node);
 2598|      0|      list_node (c, node);
 2599|      0|    }
 2600|      0|  else if (node->pkt->pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (2600:12): [True: 0, False: 0]
  ------------------
 2601|      0|    {
 2602|      0|      merge_keys_and_selfsig (c->ctrl, node);
 2603|      0|      list_node (c, node);
 2604|      0|    }
 2605|      0|  else if (node->pkt->pkttype == PKT_ONEPASS_SIG)
  ------------------
  |  Branch (2605:12): [True: 0, False: 0]
  ------------------
 2606|      0|    {
 2607|       |      /* Check all signatures.  */
 2608|      0|      if (!c->any.data)
  ------------------
  |  Branch (2608:11): [True: 0, False: 0]
  ------------------
 2609|      0|        {
 2610|      0|          int use_textmode = 0;
 2611|       |
 2612|      0|          free_md_filter_context (&c->mfx);
 2613|       |          /* Prepare to create all requested message digests.  */
 2614|      0|          rc = gcry_md_open (&c->mfx.md, 0, 0);
 2615|      0|          if (rc)
  ------------------
  |  Branch (2615:15): [True: 0, False: 0]
  ------------------
 2616|      0|            goto hash_err;
 2617|       |
 2618|       |          /* Fixme: why looking for the signature packet and not the
 2619|       |             one-pass packet?  */
 2620|      0|          for (n1 = node; (n1 = find_next_kbnode (n1, PKT_SIGNATURE));)
  ------------------
  |  Branch (2620:27): [True: 0, False: 0]
  ------------------
 2621|      0|            gcry_md_enable (c->mfx.md, n1->pkt->pkt.signature->digest_algo);
 2622|       |
 2623|      0|          if (n1 && n1->pkt->pkt.onepass_sig->sig_class == 0x01)
  ------------------
  |  Branch (2623:15): [True: 0, False: 0]
  |  Branch (2623:21): [True: 0, False: 0]
  ------------------
 2624|      0|            use_textmode = 1;
 2625|       |
 2626|       |          /* Ask for file and hash it. */
 2627|      0|          if (c->sigs_only)
  ------------------
  |  Branch (2627:15): [True: 0, False: 0]
  ------------------
 2628|      0|            {
 2629|      0|              if (c->signed_data.used && c->signed_data.data_fd != -1)
  ------------------
  |  Branch (2629:19): [True: 0, False: 0]
  |  Branch (2629:42): [True: 0, False: 0]
  ------------------
 2630|      0|                rc = hash_datafile_by_fd (c->mfx.md, NULL,
 2631|      0|                                          c->signed_data.data_fd,
 2632|      0|                                          use_textmode);
 2633|      0|              else
 2634|      0|                rc = hash_datafiles (c->mfx.md, NULL,
 2635|      0|                                     c->signed_data.data_names,
 2636|      0|                                     c->sigfilename,
 2637|      0|                                     use_textmode);
 2638|      0|	    }
 2639|      0|          else
 2640|      0|            {
 2641|      0|              rc = ask_for_detached_datafile (c->mfx.md, NULL,
 2642|      0|                                              iobuf_get_real_fname (c->iobuf),
 2643|      0|                                              use_textmode);
 2644|      0|	    }
 2645|       |
 2646|      0|        hash_err:
 2647|      0|          if (rc)
  ------------------
  |  Branch (2647:15): [True: 0, False: 0]
  ------------------
 2648|      0|            {
 2649|      0|              log_error ("can't hash datafile: %s\n", gpg_strerror (rc));
 2650|      0|              return;
 2651|      0|	    }
 2652|      0|	}
 2653|      0|      else if (c->signed_data.used)
  ------------------
  |  Branch (2653:16): [True: 0, False: 0]
  ------------------
 2654|      0|        {
 2655|      0|          log_error (_("not a detached signature\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2656|      0|          return;
 2657|      0|        }
 2658|       |
 2659|      0|      for (n1 = node; (n1 = find_next_kbnode (n1, PKT_SIGNATURE));)
  ------------------
  |  Branch (2659:23): [True: 0, False: 0]
  ------------------
 2660|      0|        check_sig_and_print (c, n1);
 2661|       |
 2662|      0|    }
 2663|      0|  else if (node->pkt->pkttype == PKT_GPG_CONTROL
  ------------------
  |  Branch (2663:12): [True: 0, False: 0]
  ------------------
 2664|      0|           && node->pkt->pkt.gpg_control->control == CTRLPKT_CLEARSIGN_START)
  ------------------
  |  Branch (2664:15): [True: 0, False: 0]
  ------------------
 2665|      0|    {
 2666|       |      /* Clear text signed message.  */
 2667|      0|      if (!c->any.data)
  ------------------
  |  Branch (2667:11): [True: 0, False: 0]
  ------------------
 2668|      0|        {
 2669|      0|          log_error ("cleartext signature without data\n");
 2670|      0|          return;
 2671|      0|        }
 2672|      0|      else if (c->signed_data.used)
  ------------------
  |  Branch (2672:16): [True: 0, False: 0]
  ------------------
 2673|      0|        {
 2674|      0|          log_error (_("not a detached signature\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2675|      0|          return;
 2676|      0|        }
 2677|       |
 2678|      0|      for (n1 = node; (n1 = find_next_kbnode (n1, PKT_SIGNATURE));)
  ------------------
  |  Branch (2678:23): [True: 0, False: 0]
  ------------------
 2679|      0|        check_sig_and_print (c, n1);
 2680|       |
 2681|      0|    }
 2682|      0|  else if (node->pkt->pkttype == PKT_SIGNATURE)
  ------------------
  |  Branch (2682:12): [True: 0, False: 0]
  ------------------
 2683|      0|    {
 2684|      0|      PKT_signature *sig = node->pkt->pkt.signature;
 2685|      0|      int multiple_ok = 1;
 2686|       |
 2687|      0|      n1 = find_next_kbnode (node, PKT_SIGNATURE);
 2688|      0|      if (n1)
  ------------------
  |  Branch (2688:11): [True: 0, False: 0]
  ------------------
 2689|      0|        {
 2690|      0|          byte class = sig->sig_class;
 2691|      0|          byte hash  = sig->digest_algo;
 2692|       |
 2693|      0|          for (; n1; (n1 = find_next_kbnode(n1, PKT_SIGNATURE)))
  ------------------
  |  Branch (2693:18): [True: 0, False: 0]
  ------------------
 2694|      0|            {
 2695|       |              /* We can't currently handle multiple signatures of
 2696|       |               * different classes (we'd pretty much have to run a
 2697|       |               * different hash context for each), but if they are all
 2698|       |               * the same and it is detached signature, we make an
 2699|       |               * exception.  Note that the old code also disallowed
 2700|       |               * multiple signatures if the digest algorithms are
 2701|       |               * different.  We softened this restriction only for
 2702|       |               * detached signatures, to be on the safe side. */
 2703|      0|              if (n1->pkt->pkt.signature->sig_class != class
  ------------------
  |  Branch (2703:19): [True: 0, False: 0]
  ------------------
 2704|      0|                  || (c->any.data
  ------------------
  |  Branch (2704:23): [True: 0, False: 0]
  ------------------
 2705|      0|                      && n1->pkt->pkt.signature->digest_algo != hash))
  ------------------
  |  Branch (2705:26): [True: 0, False: 0]
  ------------------
 2706|      0|                {
 2707|      0|                  multiple_ok = 0;
 2708|      0|                  log_info (_("WARNING: multiple signatures detected.  "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2709|      0|                              "Only the first will be checked.\n"));
 2710|      0|                  break;
 2711|      0|                }
 2712|      0|            }
 2713|      0|        }
 2714|       |
 2715|      0|      if (sig->sig_class != 0x00 && sig->sig_class != 0x01)
  ------------------
  |  Branch (2715:11): [True: 0, False: 0]
  |  Branch (2715:37): [True: 0, False: 0]
  ------------------
 2716|      0|        {
 2717|      0|          log_info(_("standalone signature of class 0x%02x\n"), sig->sig_class);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2718|      0|        }
 2719|      0|      else if (!c->any.data)
  ------------------
  |  Branch (2719:16): [True: 0, False: 0]
  ------------------
 2720|      0|        {
 2721|       |          /* Detached signature */
 2722|      0|          free_md_filter_context (&c->mfx);
 2723|      0|          rc = gcry_md_open (&c->mfx.md, sig->digest_algo, 0);
 2724|      0|          if (rc)
  ------------------
  |  Branch (2724:15): [True: 0, False: 0]
  ------------------
 2725|      0|            goto detached_hash_err;
 2726|       |
 2727|      0|          if (multiple_ok)
  ------------------
  |  Branch (2727:15): [True: 0, False: 0]
  ------------------
 2728|      0|            {
 2729|       |              /* If we have and want to handle multiple signatures we
 2730|       |               * need to enable all hash algorithms for the context.  */
 2731|      0|              for (n1 = node; (n1 = find_next_kbnode (n1, PKT_SIGNATURE)); )
  ------------------
  |  Branch (2731:31): [True: 0, False: 0]
  ------------------
 2732|      0|                if (!openpgp_md_test_algo (n1->pkt->pkt.signature->digest_algo))
  ------------------
  |  Branch (2732:21): [True: 0, False: 0]
  ------------------
 2733|      0|                  gcry_md_enable (c->mfx.md,
 2734|      0|                                  map_md_openpgp_to_gcry
 2735|      0|                                  (n1->pkt->pkt.signature->digest_algo));
 2736|      0|            }
 2737|       |
 2738|      0|          if (RFC2440 || RFC4880)
  ------------------
  |  |  373|      0|#define RFC2440 (opt.compliance==CO_RFC2440)
  |  |  ------------------
  |  |  |  Branch (373:17): [True: 0, False: 0]
  |  |  ------------------
  ------------------
                        if (RFC2440 || RFC4880)
  ------------------
  |  |  374|      0|#define RFC4880 (opt.compliance==CO_RFC4880)
  |  |  ------------------
  |  |  |  Branch (374:17): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2739|      0|            ; /* Strict RFC mode.  */
 2740|      0|          else if (sig->digest_algo == DIGEST_ALGO_SHA1
  ------------------
  |  Branch (2740:20): [True: 0, False: 0]
  ------------------
 2741|      0|                   && sig->pubkey_algo == PUBKEY_ALGO_DSA
  ------------------
  |  Branch (2741:23): [True: 0, False: 0]
  ------------------
 2742|      0|                   && sig->sig_class == 0x01)
  ------------------
  |  Branch (2742:23): [True: 0, False: 0]
  ------------------
 2743|      0|            {
 2744|       |              /* Enable a workaround for a pgp5 bug when the detached
 2745|       |               * signature has been created in textmode.  Note that we
 2746|       |               * do not implement this for multiple signatures with
 2747|       |               * different hash algorithms. */
 2748|      0|              rc = gcry_md_open (&c->mfx.md2, sig->digest_algo, 0);
 2749|      0|              if (rc)
  ------------------
  |  Branch (2749:19): [True: 0, False: 0]
  ------------------
 2750|      0|                goto detached_hash_err;
 2751|      0|	    }
 2752|       |
 2753|       |          /* Here we used to have another hack to work around a pgp
 2754|       |           * 2 bug: It worked by not using the textmode for detached
 2755|       |           * signatures; this would let the first signature check
 2756|       |           * (on md) fail but the second one (on md2), which adds an
 2757|       |           * extra CR would then have produced the "correct" hash.
 2758|       |           * This is very, very ugly hack but it may haved help in
 2759|       |           * some cases (and break others).
 2760|       |           *	 c->mfx.md2? 0 :(sig->sig_class == 0x01)
 2761|       |           */
 2762|       |
 2763|      0|          if (DBG_HASHING)
  ------------------
  |  |  354|      0|#define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
  |  |  ------------------
  |  |  |  |  341|      0|#define DBG_HASHING_VALUE 512	/* debug hashing operations */
  |  |  ------------------
  |  |  |  Branch (354:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2764|      0|            {
 2765|      0|              gcry_md_debug (c->mfx.md, "verify");
 2766|      0|              if (c->mfx.md2)
  ------------------
  |  Branch (2766:19): [True: 0, False: 0]
  ------------------
 2767|      0|                gcry_md_debug (c->mfx.md2, "verify2");
 2768|      0|            }
 2769|       |
 2770|      0|          if (c->sigs_only)
  ------------------
  |  Branch (2770:15): [True: 0, False: 0]
  ------------------
 2771|      0|            {
 2772|      0|              if (c->signed_data.used && c->signed_data.data_fd != -1)
  ------------------
  |  Branch (2772:19): [True: 0, False: 0]
  |  Branch (2772:42): [True: 0, False: 0]
  ------------------
 2773|      0|                rc = hash_datafile_by_fd (c->mfx.md, c->mfx.md2,
 2774|      0|                                          c->signed_data.data_fd,
 2775|      0|                                          (sig->sig_class == 0x01));
 2776|      0|              else
 2777|      0|                rc = hash_datafiles (c->mfx.md, c->mfx.md2,
 2778|      0|                                     c->signed_data.data_names,
 2779|      0|                                     c->sigfilename,
 2780|      0|                                     (sig->sig_class == 0x01));
 2781|      0|	    }
 2782|      0|          else
 2783|      0|            {
 2784|      0|              rc = ask_for_detached_datafile (c->mfx.md, c->mfx.md2,
 2785|      0|                                              iobuf_get_real_fname(c->iobuf),
 2786|      0|                                              (sig->sig_class == 0x01));
 2787|      0|	    }
 2788|       |
 2789|      0|        detached_hash_err:
 2790|      0|          if (rc)
  ------------------
  |  Branch (2790:15): [True: 0, False: 0]
  ------------------
 2791|      0|            {
 2792|      0|              log_error ("can't hash datafile: %s\n", gpg_strerror (rc));
 2793|      0|              return;
 2794|      0|	    }
 2795|      0|	}
 2796|      0|      else if (c->signed_data.used)
  ------------------
  |  Branch (2796:16): [True: 0, False: 0]
  ------------------
 2797|      0|        {
 2798|      0|          log_error (_("not a detached signature\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2799|      0|          return;
 2800|      0|        }
 2801|      0|      else if (!opt.quiet)
  ------------------
  |  Branch (2801:16): [True: 0, False: 0]
  ------------------
 2802|      0|        log_info (_("old style (PGP 2.x) signature\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2803|       |
 2804|      0|      if (multiple_ok)
  ------------------
  |  Branch (2804:11): [True: 0, False: 0]
  ------------------
 2805|      0|        {
 2806|      0|          for (n1 = node; n1; (n1 = find_next_kbnode(n1, PKT_SIGNATURE)))
  ------------------
  |  Branch (2806:27): [True: 0, False: 0]
  ------------------
 2807|      0|	    check_sig_and_print (c, n1);
 2808|      0|        }
 2809|      0|      else
 2810|      0|        check_sig_and_print (c, node);
 2811|       |
 2812|      0|    }
 2813|      0|  else
 2814|      0|    {
 2815|      0|      dump_kbnode (c->list);
 2816|      0|      log_error ("invalid root packet detected in proc_tree()\n");
 2817|      0|      dump_kbnode (node);
 2818|      0|    }
 2819|      0|}

free_md_filter_context:
   67|  15.4k|{
   68|  15.4k|    gcry_md_close(mfx->md);
   69|  15.4k|    gcry_md_close(mfx->md2);
   70|  15.4k|    mfx->md = NULL;
   71|  15.4k|    mfx->md2 = NULL;
   72|  15.4k|    mfx->maxbuf_size = 0;
   73|  15.4k|}

is_secured_filename:
  199|      2|{
  200|       |#ifdef ENABLE_SELINUX_HACKS
  201|       |  struct stat buf;
  202|       |  struct secured_file_item *sf;
  203|       |
  204|       |  if (iobuf_is_pipe_filename (fname) || !*fname)
  205|       |    return 0;
  206|       |
  207|       |  /* Note that we print out a error here and claim that a file is
  208|       |     secure if something went wrong. */
  209|       |  if (gnupg_stat (fname, &buf))
  210|       |    {
  211|       |      if (errno == ENOENT || errno == EPERM || errno == EACCES)
  212|       |        return 0;
  213|       |      log_error (_("fstat of '%s' failed in %s: %s\n"), fname,
  214|       |                 "is_secured_filename", strerror (errno));
  215|       |      return 1;
  216|       |    }
  217|       |/*   log_debug ("is_secured_filename (%s) i=%lu.%lu\n", fname, */
  218|       |/*              (unsigned long)buf.st_dev, (unsigned long)buf.st_ino); */
  219|       |  for (sf=secured_files; sf; sf = sf->next)
  220|       |    {
  221|       |      if (sf->ino == buf.st_ino && sf->dev == buf.st_dev)
  222|       |        return 1; /* Yes.  */
  223|       |    }
  224|       |#else /*!ENABLE_SELINUX_HACKS*/
  225|      2|  (void)fname;
  226|      2|#endif /*!ENABLE_SELINUX_HACKS*/
  227|      2|  return 0; /* No. */
  228|      2|}
map_cipher_openpgp_to_gcry:
  456|   159k|{
  457|   159k|  switch (algo)
  458|   159k|    {
  459|  2.75k|    case CIPHER_ALGO_NONE:        return GCRY_CIPHER_NONE;
  ------------------
  |  Branch (459:5): [True: 2.75k, False: 156k]
  ------------------
  460|       |
  461|      0|#ifdef GPG_USE_IDEA
  462|   113k|    case CIPHER_ALGO_IDEA:        return GCRY_CIPHER_IDEA;
  ------------------
  |  Branch (462:5): [True: 113k, False: 45.5k]
  ------------------
  463|       |#else
  464|       |    case CIPHER_ALGO_IDEA:        return 0;
  465|       |#endif
  466|       |
  467|    206|    case CIPHER_ALGO_3DES:	  return GCRY_CIPHER_3DES;
  ------------------
  |  Branch (467:5): [True: 206, False: 158k]
  ------------------
  468|       |
  469|      0|#ifdef GPG_USE_CAST5
  470|    392|    case CIPHER_ALGO_CAST5:	  return GCRY_CIPHER_CAST5;
  ------------------
  |  Branch (470:5): [True: 392, False: 158k]
  ------------------
  471|       |#else
  472|       |    case CIPHER_ALGO_CAST5:	  return 0;
  473|       |#endif
  474|       |
  475|      0|#ifdef GPG_USE_BLOWFISH
  476|    391|    case CIPHER_ALGO_BLOWFISH:    return GCRY_CIPHER_BLOWFISH;
  ------------------
  |  Branch (476:5): [True: 391, False: 158k]
  ------------------
  477|       |#else
  478|       |    case CIPHER_ALGO_BLOWFISH:    return 0;
  479|       |#endif
  480|       |
  481|      0|#ifdef GPG_USE_AES128
  482|    410|    case CIPHER_ALGO_AES:         return GCRY_CIPHER_AES;
  ------------------
  |  Branch (482:5): [True: 410, False: 158k]
  ------------------
  483|       |#else
  484|       |    case CIPHER_ALGO_AES:         return 0;
  485|       |#endif
  486|       |
  487|      0|#ifdef GPG_USE_AES192
  488|  19.6k|    case CIPHER_ALGO_AES192:      return GCRY_CIPHER_AES192;
  ------------------
  |  Branch (488:5): [True: 19.6k, False: 139k]
  ------------------
  489|       |#else
  490|       |    case CIPHER_ALGO_AES192:      return 0;
  491|       |#endif
  492|       |
  493|      0|#ifdef GPG_USE_AES256
  494|  1.20k|    case CIPHER_ALGO_AES256:      return GCRY_CIPHER_AES256;
  ------------------
  |  Branch (494:5): [True: 1.20k, False: 157k]
  ------------------
  495|       |#else
  496|       |    case CIPHER_ALGO_AES256:      return 0;
  497|       |#endif
  498|       |
  499|      0|#ifdef GPG_USE_TWOFISH
  500|    242|    case CIPHER_ALGO_TWOFISH:     return GCRY_CIPHER_TWOFISH;
  ------------------
  |  Branch (500:5): [True: 242, False: 158k]
  ------------------
  501|       |#else
  502|       |    case CIPHER_ALGO_TWOFISH:     return 0;
  503|       |#endif
  504|       |
  505|      0|#ifdef GPG_USE_CAMELLIA128
  506|    402|    case CIPHER_ALGO_CAMELLIA128: return GCRY_CIPHER_CAMELLIA128;
  ------------------
  |  Branch (506:5): [True: 402, False: 158k]
  ------------------
  507|       |#else
  508|       |    case CIPHER_ALGO_CAMELLIA128: return 0;
  509|       |#endif
  510|       |
  511|      0|#ifdef GPG_USE_CAMELLIA192
  512|    601|    case CIPHER_ALGO_CAMELLIA192: return GCRY_CIPHER_CAMELLIA192;
  ------------------
  |  Branch (512:5): [True: 601, False: 158k]
  ------------------
  513|       |#else
  514|       |    case CIPHER_ALGO_CAMELLIA192: return 0;
  515|       |#endif
  516|       |
  517|      0|#ifdef GPG_USE_CAMELLIA256
  518|  4.86k|    case CIPHER_ALGO_CAMELLIA256: return GCRY_CIPHER_CAMELLIA256;
  ------------------
  |  Branch (518:5): [True: 4.86k, False: 154k]
  ------------------
  519|       |#else
  520|       |    case CIPHER_ALGO_CAMELLIA256: return 0;
  521|       |#endif
  522|  14.4k|    default: return 0;
  ------------------
  |  Branch (522:5): [True: 14.4k, False: 144k]
  ------------------
  523|   159k|    }
  524|   159k|}
openpgp_cipher_blocklen:
  552|  15.6k|{
  553|       |  /* We use the numbers from OpenPGP to be sure that we get the right
  554|       |     block length.  This is so that the packet parsing code works even
  555|       |     for unknown algorithms (for which we assume 8 due to tradition).
  556|       |
  557|       |     NOTE: If you change the returned blocklen above 16, check
  558|       |     the callers because they may use a fixed size buffer of that
  559|       |     size. */
  560|  15.6k|  switch (algo)
  561|  15.6k|    {
  562|  2.28k|    case CIPHER_ALGO_AES:
  ------------------
  |  Branch (562:5): [True: 2.28k, False: 13.3k]
  ------------------
  563|  2.85k|    case CIPHER_ALGO_AES192:
  ------------------
  |  Branch (563:5): [True: 571, False: 15.1k]
  ------------------
  564|  2.86k|    case CIPHER_ALGO_AES256:
  ------------------
  |  Branch (564:5): [True: 5, False: 15.6k]
  ------------------
  565|  3.21k|    case CIPHER_ALGO_TWOFISH:
  ------------------
  |  Branch (565:5): [True: 354, False: 15.3k]
  ------------------
  566|  3.22k|    case CIPHER_ALGO_CAMELLIA128:
  ------------------
  |  Branch (566:5): [True: 7, False: 15.6k]
  ------------------
  567|  3.22k|    case CIPHER_ALGO_CAMELLIA192:
  ------------------
  |  Branch (567:5): [True: 2, False: 15.6k]
  ------------------
  568|  3.22k|    case CIPHER_ALGO_CAMELLIA256:
  ------------------
  |  Branch (568:5): [True: 2, False: 15.6k]
  ------------------
  569|  3.22k|      return 16;
  570|       |
  571|  12.4k|    default:
  ------------------
  |  Branch (571:5): [True: 12.4k, False: 3.22k]
  ------------------
  572|  12.4k|      return 8;
  573|  15.6k|    }
  574|  15.6k|}
openpgp_cipher_test_algo:
  582|   159k|{
  583|   159k|  enum gcry_cipher_algos ga;
  584|       |
  585|   159k|  ga = map_cipher_openpgp_to_gcry (algo);
  586|   159k|  if (!ga)
  ------------------
  |  Branch (586:7): [True: 17.1k, False: 142k]
  ------------------
  587|  17.1k|    return gpg_error (GPG_ERR_CIPHER_ALGO);
  588|       |
  589|   142k|  return gcry_cipher_test_algo (ga);
  590|   159k|}
openpgp_cipher_algo_name:
  597|  48.7k|{
  598|  48.7k|  switch (algo)
  599|  48.7k|    {
  600|  3.24k|    case CIPHER_ALGO_IDEA:        return "IDEA";
  ------------------
  |  Branch (600:5): [True: 3.24k, False: 45.5k]
  ------------------
  601|    206|    case CIPHER_ALGO_3DES:	  return "3DES";
  ------------------
  |  Branch (601:5): [True: 206, False: 48.5k]
  ------------------
  602|    392|    case CIPHER_ALGO_CAST5:	  return "CAST5";
  ------------------
  |  Branch (602:5): [True: 392, False: 48.3k]
  ------------------
  603|    391|    case CIPHER_ALGO_BLOWFISH:    return "BLOWFISH";
  ------------------
  |  Branch (603:5): [True: 391, False: 48.3k]
  ------------------
  604|    410|    case CIPHER_ALGO_AES:         return "AES";
  ------------------
  |  Branch (604:5): [True: 410, False: 48.3k]
  ------------------
  605|  19.6k|    case CIPHER_ALGO_AES192:      return "AES192";
  ------------------
  |  Branch (605:5): [True: 19.6k, False: 29.1k]
  ------------------
  606|  1.20k|    case CIPHER_ALGO_AES256:      return "AES256";
  ------------------
  |  Branch (606:5): [True: 1.20k, False: 47.5k]
  ------------------
  607|    242|    case CIPHER_ALGO_TWOFISH:     return "TWOFISH";
  ------------------
  |  Branch (607:5): [True: 242, False: 48.5k]
  ------------------
  608|    402|    case CIPHER_ALGO_CAMELLIA128: return "CAMELLIA128";
  ------------------
  |  Branch (608:5): [True: 402, False: 48.3k]
  ------------------
  609|    601|    case CIPHER_ALGO_CAMELLIA192: return "CAMELLIA192";
  ------------------
  |  Branch (609:5): [True: 601, False: 48.1k]
  ------------------
  610|  4.86k|    case CIPHER_ALGO_CAMELLIA256: return "CAMELLIA256";
  ------------------
  |  Branch (610:5): [True: 4.86k, False: 43.9k]
  ------------------
  611|  2.75k|    case CIPHER_ALGO_NONE:
  ------------------
  |  Branch (611:5): [True: 2.75k, False: 46.0k]
  ------------------
  612|  17.1k|    default: return "?";
  ------------------
  |  Branch (612:5): [True: 14.4k, False: 34.3k]
  ------------------
  613|  48.7k|    }
  614|  48.7k|}
openpgp_aead_algo_name:
  658|  1.78k|{
  659|  1.78k|  switch (algo)
  ------------------
  |  Branch (659:11): [True: 1.78k, False: 1]
  ------------------
  660|  1.78k|    {
  661|      0|    case AEAD_ALGO_NONE:  break;
  ------------------
  |  Branch (661:5): [True: 0, False: 1.78k]
  ------------------
  662|      1|    case AEAD_ALGO_EAX:   return "EAX";
  ------------------
  |  Branch (662:5): [True: 1, False: 1.78k]
  ------------------
  663|      0|    case AEAD_ALGO_OCB:   return "OCB";
  ------------------
  |  Branch (663:5): [True: 0, False: 1.78k]
  ------------------
  664|  1.78k|    }
  665|       |
  666|  1.78k|  return "?";
  667|  1.78k|}
openpgp_pk_algo_name:
  813|  6.92M|{
  814|  6.92M|  switch (algo)
  815|  6.92M|    {
  816|      0|    case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (816:5): [True: 0, False: 6.92M]
  ------------------
  817|    556|    case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (817:5): [True: 556, False: 6.92M]
  ------------------
  818|    631|    case PUBKEY_ALGO_RSA_S:     return "RSA";
  ------------------
  |  Branch (818:5): [True: 75, False: 6.92M]
  ------------------
  819|      0|    case PUBKEY_ALGO_ELGAMAL:
  ------------------
  |  Branch (819:5): [True: 0, False: 6.92M]
  ------------------
  820|     20|    case PUBKEY_ALGO_ELGAMAL_E: return "ELG";
  ------------------
  |  Branch (820:5): [True: 20, False: 6.92M]
  ------------------
  821|  25.1k|    case PUBKEY_ALGO_DSA:       return "DSA";
  ------------------
  |  Branch (821:5): [True: 25.1k, False: 6.90M]
  ------------------
  822|      5|    case PUBKEY_ALGO_ECDH:      return "ECDH";
  ------------------
  |  Branch (822:5): [True: 5, False: 6.92M]
  ------------------
  823|      0|    case PUBKEY_ALGO_ECDSA:     return "ECDSA";
  ------------------
  |  Branch (823:5): [True: 0, False: 6.92M]
  ------------------
  824|     28|    case PUBKEY_ALGO_EDDSA:     return "EDDSA";
  ------------------
  |  Branch (824:5): [True: 28, False: 6.92M]
  ------------------
  825|  6.89M|    default: return "?";
  ------------------
  |  Branch (825:5): [True: 6.89M, False: 25.8k]
  ------------------
  826|  6.92M|    }
  827|  6.92M|}
map_md_openpgp_to_gcry:
  834|  51.8k|{
  835|  51.8k|  switch (algo)
  836|  51.8k|    {
  837|      0|#ifdef GPG_USE_MD5
  838|  5.54k|    case DIGEST_ALGO_MD5:    return GCRY_MD_MD5;
  ------------------
  |  Branch (838:5): [True: 5.54k, False: 46.3k]
  ------------------
  839|       |#else
  840|       |    case DIGEST_ALGO_MD5:    return 0;
  841|       |#endif
  842|       |
  843|  2.82k|    case DIGEST_ALGO_SHA1:   return GCRY_MD_SHA1;
  ------------------
  |  Branch (843:5): [True: 2.82k, False: 49.0k]
  ------------------
  844|       |
  845|      0|#ifdef GPG_USE_RMD160
  846|  2.01k|    case DIGEST_ALGO_RMD160: return GCRY_MD_RMD160;
  ------------------
  |  Branch (846:5): [True: 2.01k, False: 49.8k]
  ------------------
  847|       |#else
  848|       |    case DIGEST_ALGO_RMD160: return 0;
  849|       |#endif
  850|       |
  851|      0|#ifdef GPG_USE_SHA224
  852|  1.53k|    case DIGEST_ALGO_SHA224: return GCRY_MD_SHA224;
  ------------------
  |  Branch (852:5): [True: 1.53k, False: 50.3k]
  ------------------
  853|       |#else
  854|       |    case DIGEST_ALGO_SHA224: return 0;
  855|       |#endif
  856|       |
  857|    337|    case DIGEST_ALGO_SHA256: return GCRY_MD_SHA256;
  ------------------
  |  Branch (857:5): [True: 337, False: 51.5k]
  ------------------
  858|       |
  859|      0|#ifdef GPG_USE_SHA384
  860|    543|    case DIGEST_ALGO_SHA384: return GCRY_MD_SHA384;
  ------------------
  |  Branch (860:5): [True: 543, False: 51.3k]
  ------------------
  861|       |#else
  862|       |    case DIGEST_ALGO_SHA384: return 0;
  863|       |#endif
  864|       |
  865|      0|#ifdef GPG_USE_SHA512
  866|    256|    case DIGEST_ALGO_SHA512: return GCRY_MD_SHA512;
  ------------------
  |  Branch (866:5): [True: 256, False: 51.5k]
  ------------------
  867|       |#else
  868|       |    case DIGEST_ALGO_SHA512: return 0;
  869|       |#endif
  870|  38.8k|    default: return 0;
  ------------------
  |  Branch (870:5): [True: 38.8k, False: 13.0k]
  ------------------
  871|  51.8k|    }
  872|  51.8k|}
openpgp_md_test_algo:
  879|  48.7k|{
  880|  48.7k|  enum gcry_md_algos ga;
  881|       |
  882|  48.7k|  ga = map_md_openpgp_to_gcry (algo);
  883|  48.7k|  if (!ga)
  ------------------
  |  Branch (883:7): [True: 38.5k, False: 10.1k]
  ------------------
  884|  38.5k|    return gpg_error (GPG_ERR_DIGEST_ALGO);
  885|       |
  886|  10.1k|  return gcry_md_test_algo (ga);
  887|  48.7k|}
check_compress_algo:
 1363|  3.53k|{
 1364|  3.53k|  switch (algo)
 1365|  3.53k|    {
 1366|  3.45k|    case 0: return 0;
  ------------------
  |  Branch (1366:5): [True: 3.45k, False: 77]
  ------------------
 1367|       |#ifdef HAVE_ZIP
 1368|       |    case 1:
 1369|       |    case 2: return 0;
 1370|       |#endif
 1371|       |#ifdef HAVE_BZIP2
 1372|       |    case 3: return 0;
 1373|       |#endif
 1374|     77|    default: return GPG_ERR_COMPR_ALGO;
  ------------------
  |  Branch (1374:5): [True: 77, False: 3.45k]
  ------------------
 1375|  3.53k|    }
 1376|  3.53k|}
pubkey_get_npkey:
 1697|  7.17M|{
 1698|  7.17M|  switch (algo)
 1699|  7.17M|    {
 1700|  15.0k|    case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (1700:5): [True: 15.0k, False: 7.16M]
  ------------------
 1701|  20.4k|    case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (1701:5): [True: 5.43k, False: 7.17M]
  ------------------
 1702|  74.5k|    case PUBKEY_ALGO_RSA_S:     return 2;
  ------------------
  |  Branch (1702:5): [True: 54.0k, False: 7.12M]
  ------------------
 1703|    442|    case PUBKEY_ALGO_ELGAMAL_E: return 3;
  ------------------
  |  Branch (1703:5): [True: 442, False: 7.17M]
  ------------------
 1704|  25.5k|    case PUBKEY_ALGO_DSA:       return 4;
  ------------------
  |  Branch (1704:5): [True: 25.5k, False: 7.15M]
  ------------------
 1705|  4.48k|    case PUBKEY_ALGO_ECDH:      return 3;
  ------------------
  |  Branch (1705:5): [True: 4.48k, False: 7.17M]
  ------------------
 1706|  25.7k|    case PUBKEY_ALGO_ECDSA:     return 2;
  ------------------
  |  Branch (1706:5): [True: 25.7k, False: 7.15M]
  ------------------
 1707|    184|    case PUBKEY_ALGO_ELGAMAL:   return 3;
  ------------------
  |  Branch (1707:5): [True: 184, False: 7.17M]
  ------------------
 1708|  12.8k|    case PUBKEY_ALGO_EDDSA:     return 2;
  ------------------
  |  Branch (1708:5): [True: 12.8k, False: 7.16M]
  ------------------
 1709|  7.03M|    default: return 0;
  ------------------
  |  Branch (1709:5): [True: 7.03M, False: 143k]
  ------------------
 1710|  7.17M|    }
 1711|  7.17M|}
pubkey_get_nskey:
 1717|   107k|{
 1718|   107k|  switch (algo)
 1719|   107k|    {
 1720|  11.8k|    case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (1720:5): [True: 11.8k, False: 95.8k]
  ------------------
 1721|  16.4k|    case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (1721:5): [True: 4.66k, False: 103k]
  ------------------
 1722|  68.3k|    case PUBKEY_ALGO_RSA_S:     return 6;
  ------------------
  |  Branch (1722:5): [True: 51.8k, False: 55.8k]
  ------------------
 1723|     22|    case PUBKEY_ALGO_ELGAMAL_E: return 4;
  ------------------
  |  Branch (1723:5): [True: 22, False: 107k]
  ------------------
 1724|     27|    case PUBKEY_ALGO_DSA:       return 5;
  ------------------
  |  Branch (1724:5): [True: 27, False: 107k]
  ------------------
 1725|  2.33k|    case PUBKEY_ALGO_ECDH:      return 4;
  ------------------
  |  Branch (1725:5): [True: 2.33k, False: 105k]
  ------------------
 1726|  19.5k|    case PUBKEY_ALGO_ECDSA:     return 3;
  ------------------
  |  Branch (1726:5): [True: 19.5k, False: 88.1k]
  ------------------
 1727|     82|    case PUBKEY_ALGO_ELGAMAL:   return 4;
  ------------------
  |  Branch (1727:5): [True: 82, False: 107k]
  ------------------
 1728|  4.98k|    case PUBKEY_ALGO_EDDSA:     return 3;
  ------------------
  |  Branch (1728:5): [True: 4.98k, False: 102k]
  ------------------
 1729|  12.3k|    default: return 0;
  ------------------
  |  Branch (1729:5): [True: 12.3k, False: 95.3k]
  ------------------
 1730|   107k|    }
 1731|   107k|}
pubkey_get_nsig:
 1736|  88.2k|{
 1737|  88.2k|  switch (algo)
 1738|  88.2k|    {
 1739|  1.39k|    case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (1739:5): [True: 1.39k, False: 86.8k]
  ------------------
 1740|  1.50k|    case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (1740:5): [True: 109, False: 88.1k]
  ------------------
 1741|  2.64k|    case PUBKEY_ALGO_RSA_S:     return 1;
  ------------------
  |  Branch (1741:5): [True: 1.14k, False: 87.0k]
  ------------------
 1742|    869|    case PUBKEY_ALGO_ELGAMAL_E: return 0;
  ------------------
  |  Branch (1742:5): [True: 869, False: 87.3k]
  ------------------
 1743|  6.78k|    case PUBKEY_ALGO_DSA:       return 2;
  ------------------
  |  Branch (1743:5): [True: 6.78k, False: 81.4k]
  ------------------
 1744|     92|    case PUBKEY_ALGO_ECDH:      return 0;
  ------------------
  |  Branch (1744:5): [True: 92, False: 88.1k]
  ------------------
 1745|  1.43k|    case PUBKEY_ALGO_ECDSA:     return 2;
  ------------------
  |  Branch (1745:5): [True: 1.43k, False: 86.8k]
  ------------------
 1746|  2.80k|    case PUBKEY_ALGO_ELGAMAL:   return 2;
  ------------------
  |  Branch (1746:5): [True: 2.80k, False: 85.4k]
  ------------------
 1747|    600|    case PUBKEY_ALGO_EDDSA:     return 2;
  ------------------
  |  Branch (1747:5): [True: 600, False: 87.6k]
  ------------------
 1748|  73.0k|    default: return 0;
  ------------------
  |  Branch (1748:5): [True: 73.0k, False: 15.2k]
  ------------------
 1749|  88.2k|    }
 1750|  88.2k|}
pubkey_get_nenc:
 1756|  19.5k|{
 1757|  19.5k|  switch (algo)
 1758|  19.5k|    {
 1759|     34|    case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (1759:5): [True: 34, False: 19.4k]
  ------------------
 1760|    828|    case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (1760:5): [True: 794, False: 18.7k]
  ------------------
 1761|  1.74k|    case PUBKEY_ALGO_RSA_S:     return 1;
  ------------------
  |  Branch (1761:5): [True: 914, False: 18.5k]
  ------------------
 1762|    812|    case PUBKEY_ALGO_ELGAMAL_E: return 2;
  ------------------
  |  Branch (1762:5): [True: 812, False: 18.6k]
  ------------------
 1763|    780|    case PUBKEY_ALGO_DSA:       return 0;
  ------------------
  |  Branch (1763:5): [True: 780, False: 18.7k]
  ------------------
 1764|  1.45k|    case PUBKEY_ALGO_ECDH:      return 2;
  ------------------
  |  Branch (1764:5): [True: 1.45k, False: 18.0k]
  ------------------
 1765|      0|    case PUBKEY_ALGO_ECDSA:     return 0;
  ------------------
  |  Branch (1765:5): [True: 0, False: 19.5k]
  ------------------
 1766|    294|    case PUBKEY_ALGO_ELGAMAL:   return 2;
  ------------------
  |  Branch (1766:5): [True: 294, False: 19.2k]
  ------------------
 1767|      4|    case PUBKEY_ALGO_EDDSA:     return 0;
  ------------------
  |  Branch (1767:5): [True: 4, False: 19.5k]
  ------------------
 1768|  14.4k|    default: return 0;
  ------------------
  |  Branch (1768:5): [True: 14.4k, False: 5.08k]
  ------------------
 1769|  19.5k|    }
 1770|  19.5k|}
mpi_print:
 1831|   121k|{
 1832|   121k|  int n = 0;
 1833|   121k|  size_t nwritten;
 1834|       |
 1835|   121k|  if (!a)
  ------------------
  |  Branch (1835:7): [True: 10.1k, False: 111k]
  ------------------
 1836|  10.1k|    return es_fprintf (fp, "[MPI_NULL]");
 1837|   111k|  if (!mode)
  ------------------
  |  Branch (1837:7): [True: 111k, False: 0]
  ------------------
 1838|   111k|    {
 1839|   111k|      unsigned int n1;
 1840|   111k|      n1 = gcry_mpi_get_nbits(a);
 1841|   111k|      n += es_fprintf (fp, "[%u bits]", n1);
 1842|   111k|    }
 1843|      0|  else if (gcry_mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (1843:12): [True: 0, False: 0]
  ------------------
 1844|      0|    {
 1845|      0|      unsigned int nbits;
 1846|      0|      unsigned char *p = gcry_mpi_get_opaque (a, &nbits);
 1847|      0|      if (!p)
  ------------------
  |  Branch (1847:11): [True: 0, False: 0]
  ------------------
 1848|      0|        n += es_fprintf (fp, "[invalid opaque value]");
 1849|      0|      else
 1850|      0|        {
 1851|      0|          if (!es_write_hexstring (fp, p, (nbits + 7)/8, 0, &nwritten))
  ------------------
  |  Branch (1851:15): [True: 0, False: 0]
  ------------------
 1852|      0|            n += nwritten;
 1853|      0|        }
 1854|      0|    }
 1855|      0|  else
 1856|      0|    {
 1857|      0|      unsigned char *buffer;
 1858|      0|      size_t buflen;
 1859|       |
 1860|      0|      if (gcry_mpi_aprint (GCRYMPI_FMT_USG, &buffer, &buflen, a))
  ------------------
  |  Branch (1860:11): [True: 0, False: 0]
  ------------------
 1861|      0|        BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1862|      0|      if (!es_write_hexstring (fp, buffer, buflen, 0, &nwritten))
  ------------------
  |  Branch (1862:11): [True: 0, False: 0]
  ------------------
 1863|      0|        n += nwritten;
 1864|      0|      gcry_free (buffer);
 1865|      0|    }
 1866|   111k|  return n;
 1867|   111k|}

register_known_notation:
  264|  1.02k|{
  265|  1.02k|  strlist_t sl;
  266|       |
  267|  1.02k|  if (!known_notations_list)
  ------------------
  |  Branch (267:7): [True: 1, False: 1.02k]
  ------------------
  268|      1|    {
  269|      1|      sl = add_to_strlist (&known_notations_list,
  270|      1|                           "preferred-email-encoding@pgp.com");
  271|      1|      sl->flags = 32;  /* Length of the string.  */
  272|      1|    }
  273|  1.02k|  if (!string)
  ------------------
  |  Branch (273:7): [True: 1.02k, False: 0]
  ------------------
  274|  1.02k|    return; /* Only initialized the default known notations.  */
  275|       |
  276|       |  /* In --set-notation we use an exclamation mark to indicate a
  277|       |   * critical notation.  As a convenience skip this here.  */
  278|      0|  if (*string == '!')
  ------------------
  |  Branch (278:7): [True: 0, False: 0]
  ------------------
  279|      0|    string++;
  280|       |
  281|      0|  if (!*string || strlist_find (known_notations_list, string))
  ------------------
  |  Branch (281:7): [True: 0, False: 0]
  |  Branch (281:19): [True: 0, False: 0]
  ------------------
  282|      0|    return; /* Empty string or already registered.  */
  283|       |
  284|      0|  sl = add_to_strlist (&known_notations_list, string);
  285|      0|  sl->flags = strlen (string);
  286|      0|}
set_packet_list_mode:
  291|      1|{
  292|      1|  int old = list_mode;
  293|      1|  list_mode = mode;
  294|       |
  295|       |  /* We use stdout only if invoked by the --list-packets command
  296|       |     but switch to stderr in all other cases.  This breaks the
  297|       |     previous behaviour but that seems to be more of a bug than
  298|       |     intentional.  I don't believe that any application makes use of
  299|       |     this long standing annoying way of printing to stdout except when
  300|       |     doing a --list-packets. If this assumption fails, it will be easy
  301|       |     to add an option for the listing stream.  Note that we initialize
  302|       |     it only once; mainly because there is code which switches
  303|       |     opt.list_mode back to 1 and we want to have all output to the
  304|       |     same stream.  The MPI_PRINT_MODE will be enabled if the
  305|       |     corresponding debug flag is set or if we are in --list-packets
  306|       |     and --verbose is given.
  307|       |
  308|       |     Using stderr is not actually very clean because it bypasses the
  309|       |     logging code but it is a special thing anyway.  I am not sure
  310|       |     whether using log_stream() would be better.  Perhaps we should
  311|       |     enable the list mode only with a special option. */
  312|      1|  if (!listfp)
  ------------------
  |  Branch (312:7): [True: 1, False: 0]
  ------------------
  313|      1|    {
  314|      1|      if (opt.list_packets)
  ------------------
  |  Branch (314:11): [True: 1, False: 0]
  ------------------
  315|      1|        {
  316|      1|          listfp = es_stdout;
  317|      1|          if (opt.verbose)
  ------------------
  |  Branch (317:15): [True: 0, False: 1]
  ------------------
  318|      0|            mpi_print_mode = 1;
  319|      1|        }
  320|      0|      else
  321|      0|        listfp = es_stderr;
  322|       |
  323|      1|      if (DBG_MPI)
  ------------------
  |  |  349|      1|#define DBG_MPI    (opt.debug & DBG_MPI_VALUE)
  |  |  ------------------
  |  |  |  |  332|      1|#define DBG_MPI_VALUE	  2	/* debug mpi details */
  |  |  ------------------
  |  |  |  Branch (349:20): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  324|      0|        mpi_print_mode = 1;
  325|      1|    }
  326|      1|  return old;
  327|      1|}
dbg_parse_packet:
  368|  2.41M|{
  369|  2.41M|  int skip, rc;
  370|       |
  371|  2.41M|  do
  372|  2.42M|    {
  373|  2.42M|      rc = parse (ctx, pkt, 0, NULL, &skip, NULL, 0, "parse", dbg_f, dbg_l);
  374|  2.42M|    }
  375|  2.42M|  while (skip && ! rc);
  ------------------
  |  Branch (375:10): [True: 3.69k, False: 2.41M]
  |  Branch (375:18): [True: 3.68k, False: 9]
  ------------------
  376|  2.41M|  return rc;
  377|  2.41M|}
parse_one_sig_subpkt:
 1739|  27.7k|{
 1740|  27.7k|  switch (type)
 1741|  27.7k|    {
 1742|  1.64k|    case SIGSUBPKT_REV_KEY:
  ------------------
  |  Branch (1742:5): [True: 1.64k, False: 26.0k]
  ------------------
 1743|  1.64k|      if (n < 22)
  ------------------
  |  Branch (1743:11): [True: 260, False: 1.38k]
  ------------------
 1744|    260|	break;
 1745|  1.38k|      return 0;
 1746|    511|    case SIGSUBPKT_SIG_CREATED:
  ------------------
  |  Branch (1746:5): [True: 511, False: 27.2k]
  ------------------
 1747|  2.20k|    case SIGSUBPKT_SIG_EXPIRE:
  ------------------
  |  Branch (1747:5): [True: 1.69k, False: 26.0k]
  ------------------
 1748|  2.20k|    case SIGSUBPKT_KEY_EXPIRE:
  ------------------
  |  Branch (1748:5): [True: 0, False: 27.7k]
  ------------------
 1749|  2.20k|      if (n < 4)
  ------------------
  |  Branch (1749:11): [True: 518, False: 1.68k]
  ------------------
 1750|    518|	break;
 1751|  1.68k|      return 0;
 1752|      0|    case SIGSUBPKT_KEY_FLAGS:
  ------------------
  |  Branch (1752:5): [True: 0, False: 27.7k]
  ------------------
 1753|      0|    case SIGSUBPKT_KS_FLAGS:
  ------------------
  |  Branch (1753:5): [True: 0, False: 27.7k]
  ------------------
 1754|      0|    case SIGSUBPKT_PREF_SYM:
  ------------------
  |  Branch (1754:5): [True: 0, False: 27.7k]
  ------------------
 1755|      0|    case SIGSUBPKT_PREF_AEAD:
  ------------------
  |  Branch (1755:5): [True: 0, False: 27.7k]
  ------------------
 1756|      0|    case SIGSUBPKT_PREF_HASH:
  ------------------
  |  Branch (1756:5): [True: 0, False: 27.7k]
  ------------------
 1757|      0|    case SIGSUBPKT_PREF_COMPR:
  ------------------
  |  Branch (1757:5): [True: 0, False: 27.7k]
  ------------------
 1758|    701|    case SIGSUBPKT_POLICY:
  ------------------
  |  Branch (1758:5): [True: 701, False: 27.0k]
  ------------------
 1759|  1.74k|    case SIGSUBPKT_PREF_KS:
  ------------------
  |  Branch (1759:5): [True: 1.04k, False: 26.6k]
  ------------------
 1760|  1.74k|    case SIGSUBPKT_FEATURES:
  ------------------
  |  Branch (1760:5): [True: 0, False: 27.7k]
  ------------------
 1761|  3.01k|    case SIGSUBPKT_REGEXP:
  ------------------
  |  Branch (1761:5): [True: 1.27k, False: 26.4k]
  ------------------
 1762|  3.01k|    case SIGSUBPKT_ATTST_SIGS:
  ------------------
  |  Branch (1762:5): [True: 0, False: 27.7k]
  ------------------
 1763|  3.01k|      return 0;
 1764|      0|    case SIGSUBPKT_SIGNATURE:
  ------------------
  |  Branch (1764:5): [True: 0, False: 27.7k]
  ------------------
 1765|  1.37k|    case SIGSUBPKT_EXPORTABLE:
  ------------------
  |  Branch (1765:5): [True: 1.37k, False: 26.3k]
  ------------------
 1766|  3.88k|    case SIGSUBPKT_REVOCABLE:
  ------------------
  |  Branch (1766:5): [True: 2.50k, False: 25.2k]
  ------------------
 1767|  3.88k|    case SIGSUBPKT_REVOC_REASON:
  ------------------
  |  Branch (1767:5): [True: 0, False: 27.7k]
  ------------------
 1768|  3.88k|      if (!n)
  ------------------
  |  Branch (1768:11): [True: 1.59k, False: 2.28k]
  ------------------
 1769|  1.59k|	break;
 1770|  2.28k|      return 0;
 1771|    503|    case SIGSUBPKT_ISSUER:	/* issuer key ID */
  ------------------
  |  Branch (1771:5): [True: 503, False: 27.2k]
  ------------------
 1772|    503|      if (n < 8)
  ------------------
  |  Branch (1772:11): [True: 303, False: 200]
  ------------------
 1773|    303|	break;
 1774|    200|      return 0;
 1775|  1.27k|    case SIGSUBPKT_ISSUER_FPR:	/* issuer key fingerprint */
  ------------------
  |  Branch (1775:5): [True: 1.27k, False: 26.4k]
  ------------------
 1776|  1.27k|      if (n < 21)
  ------------------
  |  Branch (1776:11): [True: 235, False: 1.04k]
  ------------------
 1777|    235|	break;
 1778|  1.04k|      return 0;
 1779|  2.61k|    case SIGSUBPKT_NOTATION:
  ------------------
  |  Branch (1779:5): [True: 2.61k, False: 25.1k]
  ------------------
 1780|       |      /* minimum length needed, and the subpacket must be well-formed
 1781|       |         where the name length and value length all fit inside the
 1782|       |         packet. */
 1783|  2.61k|      if (n < 8
  ------------------
  |  Branch (1783:11): [True: 1.69k, False: 920]
  ------------------
 1784|  2.61k|	  || 8 + ((buffer[4] << 8) | buffer[5]) +
  ------------------
  |  Branch (1784:7): [True: 373, False: 547]
  ------------------
 1785|    920|	  ((buffer[6] << 8) | buffer[7]) != n)
 1786|  2.07k|	break;
 1787|    547|      return 0;
 1788|      0|    case SIGSUBPKT_PRIMARY_UID:
  ------------------
  |  Branch (1788:5): [True: 0, False: 27.7k]
  ------------------
 1789|      0|      if (n != 1)
  ------------------
  |  Branch (1789:11): [True: 0, False: 0]
  ------------------
 1790|      0|	break;
 1791|      0|      return 0;
 1792|  3.54k|    case SIGSUBPKT_TRUST:
  ------------------
  |  Branch (1792:5): [True: 3.54k, False: 24.1k]
  ------------------
 1793|  3.54k|      if (n != 2)
  ------------------
  |  Branch (1793:11): [True: 979, False: 2.56k]
  ------------------
 1794|    979|	break;
 1795|  2.56k|      return 0;
 1796|  2.40k|    case SIGSUBPKT_KEY_BLOCK:
  ------------------
  |  Branch (1796:5): [True: 2.40k, False: 25.3k]
  ------------------
 1797|  2.40k|      if (n && buffer[0])
  ------------------
  |  Branch (1797:11): [True: 882, False: 1.52k]
  |  Branch (1797:16): [True: 502, False: 380]
  ------------------
 1798|    502|        return -1; /* Unknown version - ignore.  */
 1799|  1.90k|      if (n < 50)
  ------------------
  |  Branch (1799:11): [True: 1.82k, False: 82]
  ------------------
 1800|  1.82k|	break;  /* Definitely too short to carry a key block.  */
 1801|     82|      return 0;
 1802|  6.62k|    default:
  ------------------
  |  Branch (1802:5): [True: 6.62k, False: 21.0k]
  ------------------
 1803|  6.62k|      return 0;
 1804|  27.7k|    }
 1805|  7.78k|  return -2;
 1806|  27.7k|}
enum_sig_subpkt:
 1885|   595k|{
 1886|   595k|  const byte *buffer;
 1887|   595k|  int buflen;
 1888|   595k|  int type;
 1889|   595k|  int critical_dummy;
 1890|   595k|  int offset;
 1891|   595k|  size_t n;
 1892|   595k|  const subpktarea_t *pktbuf = want_hashed? sig->hashed : sig->unhashed;
  ------------------
  |  Branch (1892:32): [True: 478k, False: 117k]
  ------------------
 1893|   595k|  int seq = 0;
 1894|   595k|  int reqseq = start ? *start : 0;
  ------------------
  |  Branch (1894:16): [True: 4.64k, False: 590k]
  ------------------
 1895|       |
 1896|   595k|  if (!critical)
  ------------------
  |  Branch (1896:7): [True: 595k, False: 0]
  ------------------
 1897|   595k|    critical = &critical_dummy;
 1898|       |
 1899|   595k|  if (!pktbuf || reqseq == -1)
  ------------------
  |  Branch (1899:7): [True: 140k, False: 455k]
  |  Branch (1899:18): [True: 0, False: 455k]
  ------------------
 1900|   140k|    {
 1901|   140k|      static char dummy[] = "x";
 1902|       |      /* Return a value different from NULL to indicate that
 1903|       |       * there is no critical bit we do not understand.  */
 1904|   140k|      return reqtype ==	SIGSUBPKT_TEST_CRITICAL ? dummy : NULL;
  ------------------
  |  Branch (1904:14): [True: 15.2k, False: 124k]
  ------------------
 1905|   140k|    }
 1906|   455k|  buffer = pktbuf->data;
 1907|   455k|  buflen = pktbuf->len;
 1908|  1.23M|  while (buflen)
  ------------------
  |  Branch (1908:10): [True: 1.04M, False: 197k]
  ------------------
 1909|  1.04M|    {
 1910|  1.04M|      n = *buffer++;
 1911|  1.04M|      buflen--;
 1912|  1.04M|      if (n == 255) /* 4 byte length header.  */
  ------------------
  |  Branch (1912:11): [True: 46.2k, False: 994k]
  ------------------
 1913|  46.2k|	{
 1914|  46.2k|	  if (buflen < 4)
  ------------------
  |  Branch (1914:8): [True: 34.7k, False: 11.5k]
  ------------------
 1915|  34.7k|	    goto too_short;
 1916|  11.5k|	  n = buf32_to_size_t (buffer);
 1917|  11.5k|	  buffer += 4;
 1918|  11.5k|	  buflen -= 4;
 1919|  11.5k|	}
 1920|   994k|      else if (n >= 192) /* 4 byte special encoded length header.  */
  ------------------
  |  Branch (1920:16): [True: 64.8k, False: 930k]
  ------------------
 1921|  64.8k|	{
 1922|  64.8k|	  if (buflen < 2)
  ------------------
  |  Branch (1922:8): [True: 50.9k, False: 13.8k]
  ------------------
 1923|  50.9k|	    goto too_short;
 1924|  13.8k|	  n = ((n - 192) << 8) + *buffer + 192;
 1925|  13.8k|	  buffer++;
 1926|  13.8k|	  buflen--;
 1927|  13.8k|	}
 1928|   955k|      if (buflen < n)
  ------------------
  |  Branch (1928:11): [True: 101k, False: 853k]
  ------------------
 1929|   101k|	goto too_short;
 1930|   853k|      if (!buflen)
  ------------------
  |  Branch (1930:11): [True: 27.5k, False: 826k]
  ------------------
 1931|  27.5k|        goto no_type_byte;
 1932|   826k|      type = *buffer;
 1933|   826k|      if (type & 0x80)
  ------------------
  |  Branch (1933:11): [True: 343k, False: 482k]
  ------------------
 1934|   343k|	{
 1935|   343k|	  type &= 0x7f;
 1936|   343k|	  *critical = 1;
 1937|   343k|	}
 1938|   482k|      else
 1939|   482k|	*critical = 0;
 1940|   826k|      if (!(++seq > reqseq))
  ------------------
  |  Branch (1940:11): [True: 5.90k, False: 820k]
  ------------------
 1941|  5.90k|	;
 1942|   820k|      else if (reqtype == SIGSUBPKT_TEST_CRITICAL)
  ------------------
  |  Branch (1942:16): [True: 55.1k, False: 765k]
  ------------------
 1943|  55.1k|	{
 1944|  55.1k|	  if (*critical)
  ------------------
  |  Branch (1944:8): [True: 24.4k, False: 30.7k]
  ------------------
 1945|  24.4k|	    {
 1946|  24.4k|	      if (n - 1 > buflen + 1)
  ------------------
  |  Branch (1946:12): [True: 1.09k, False: 23.3k]
  ------------------
 1947|  1.09k|		goto too_short;
 1948|  23.3k|	      if (!can_handle_critical (buffer + 1, n - 1, type))
  ------------------
  |  Branch (1948:12): [True: 8.94k, False: 14.3k]
  ------------------
 1949|  8.94k|		{
 1950|  8.94k|		  if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (1950:9): [True: 0, False: 8.94k]
  |  Branch (1950:24): [True: 0, False: 0]
  ------------------
 1951|      0|		    log_info (_("subpacket of type %d has "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1952|      0|				"critical bit set\n"), type);
 1953|  8.94k|		  if (start)
  ------------------
  |  Branch (1953:9): [True: 0, False: 8.94k]
  ------------------
 1954|      0|		    *start = seq;
 1955|  8.94k|		  return NULL;	/* This is an error.  */
 1956|  8.94k|		}
 1957|  23.3k|	    }
 1958|  55.1k|	}
 1959|   765k|      else if (reqtype < 0) /* List packets.  */
  ------------------
  |  Branch (1959:16): [True: 71.2k, False: 694k]
  ------------------
 1960|  71.2k|	dump_sig_subpkt (reqtype == SIGSUBPKT_LIST_HASHED,
 1961|  71.2k|			 type, *critical, buffer, buflen, n, sig->digest_algo);
 1962|   694k|      else if (type == reqtype) /* Found.  */
  ------------------
  |  Branch (1962:16): [True: 32.6k, False: 661k]
  ------------------
 1963|  32.6k|	{
 1964|  32.6k|	  buffer++;
 1965|  32.6k|	  n--;
 1966|  32.6k|	  if (n > buflen)
  ------------------
  |  Branch (1966:8): [True: 4.95k, False: 27.7k]
  ------------------
 1967|  4.95k|	    goto too_short;
 1968|  27.7k|	  if (ret_n)
  ------------------
  |  Branch (1968:8): [True: 14.3k, False: 13.3k]
  ------------------
 1969|  14.3k|	    *ret_n = n;
 1970|  27.7k|	  offset = parse_one_sig_subpkt (buffer, n, type);
 1971|  27.7k|	  switch (offset)
 1972|  27.7k|	    {
 1973|  7.78k|	    case -2:
  ------------------
  |  Branch (1973:6): [True: 7.78k, False: 19.9k]
  ------------------
 1974|  7.78k|	      log_error ("subpacket of type %d too short\n", type);
 1975|  7.78k|	      return NULL;
 1976|    502|	    case -1:
  ------------------
  |  Branch (1976:6): [True: 502, False: 27.2k]
  ------------------
 1977|    502|	      return NULL;
 1978|  19.4k|	    default:
  ------------------
  |  Branch (1978:6): [True: 19.4k, False: 8.28k]
  ------------------
 1979|  19.4k|	      break;
 1980|  27.7k|	    }
 1981|  19.4k|	  if (start)
  ------------------
  |  Branch (1981:8): [True: 1.38k, False: 18.0k]
  ------------------
 1982|  1.38k|	    *start = seq;
 1983|  19.4k|	  return buffer + offset;
 1984|  27.7k|	}
 1985|   783k|      buffer += n;
 1986|   783k|      buflen -= n;
 1987|   783k|    }
 1988|   197k|  if (reqtype == SIGSUBPKT_TEST_CRITICAL)
  ------------------
  |  Branch (1988:7): [True: 13.0k, False: 184k]
  ------------------
 1989|       |    /* Returning NULL means we found a subpacket with the critical bit
 1990|       |       set that we don't grok.  We've iterated over all the subpackets
 1991|       |       and haven't found such a packet so we need to return a non-NULL
 1992|       |       value.  */
 1993|  13.0k|    return buffer;
 1994|       |
 1995|       |  /* Critical bit we don't understand. */
 1996|   184k|  if (start)
  ------------------
  |  Branch (1996:7): [True: 1.31k, False: 183k]
  ------------------
 1997|  1.31k|    *start = -1;
 1998|   184k|  return NULL;	/* End of packets; not found.  */
 1999|       |
 2000|   193k| too_short:
 2001|   193k|  if (opt.debug && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (2001:7): [True: 0, False: 193k]
  |  Branch (2001:20): [True: 0, False: 0]
  ------------------
 2002|      0|    {
 2003|      0|      es_fflush (es_stdout);
 2004|      0|      log_printhex (pktbuf->data, pktbuf->len > 16? 16 : pktbuf->len,
  ------------------
  |  Branch (2004:35): [True: 0, False: 0]
  ------------------
 2005|      0|                    "buffer shorter than subpacket (%zu/%d/%zu); dump:",
 2006|      0|                    pktbuf->len, buflen, n);
 2007|      0|    }
 2008|       |
 2009|   193k|  if (start)
  ------------------
  |  Branch (2009:7): [True: 1.34k, False: 191k]
  ------------------
 2010|  1.34k|    *start = -1;
 2011|   193k|  return NULL;
 2012|       |
 2013|  27.5k| no_type_byte:
 2014|  27.5k|  if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (2014:7): [True: 0, False: 27.5k]
  |  Branch (2014:22): [True: 0, False: 0]
  ------------------
 2015|      0|    log_info ("type octet missing in subpacket\n");
 2016|  27.5k|  if (start)
  ------------------
  |  Branch (2016:7): [True: 297, False: 27.2k]
  ------------------
 2017|    297|    *start = -1;
 2018|  27.5k|  return NULL;
 2019|   197k|}
parse_sig_subpkt:
 2025|   590k|{
 2026|   590k|  return enum_sig_subpkt (sig, want_hashed, reqtype, ret_n, NULL, NULL);
 2027|   590k|}
parse_sig_subpkt2:
 2032|  66.7k|{
 2033|  66.7k|  const byte *p;
 2034|       |
 2035|  66.7k|  p = parse_sig_subpkt (sig, 1, reqtype, NULL);
 2036|  66.7k|  if (!p)
  ------------------
  |  Branch (2036:7): [True: 66.1k, False: 601]
  ------------------
 2037|  66.1k|    p = parse_sig_subpkt (sig, 0, reqtype, NULL);
 2038|  66.7k|  return p;
 2039|  66.7k|}
parse_revkeys:
 2045|  3.26k|{
 2046|  3.26k|  const byte *revkey;
 2047|  3.26k|  int seq = 0;
 2048|  3.26k|  size_t len;
 2049|       |
 2050|  3.26k|  if (sig->sig_class != 0x1F)
  ------------------
  |  Branch (2050:7): [True: 0, False: 3.26k]
  ------------------
 2051|      0|    return;
 2052|       |
 2053|  4.64k|  while ((revkey = enum_sig_subpkt (sig, 1, SIGSUBPKT_REV_KEY,
  ------------------
  |  Branch (2053:10): [True: 1.38k, False: 3.26k]
  ------------------
 2054|  4.64k|                                    &len, &seq, NULL)))
 2055|  1.38k|    {
 2056|       |      /* Consider only valid packets.  They must have a length of
 2057|       |       * either 2+20 or 2+32 octets and bit 7 of the class octet must
 2058|       |       * be set.  */
 2059|  1.38k|      if ((len == 22 || len == 34)
  ------------------
  |  Branch (2059:12): [True: 671, False: 710]
  |  Branch (2059:25): [True: 511, False: 199]
  ------------------
 2060|  1.38k|          && (revkey[0] & 0x80))
  ------------------
  |  Branch (2060:14): [True: 220, False: 962]
  ------------------
 2061|    220|	{
 2062|    220|	  sig->revkey = xrealloc (sig->revkey,
  ------------------
  |  |  111|    220|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 2063|    220|				  sizeof (struct revocation_key) *
 2064|    220|				  (sig->numrevkeys + 1));
 2065|       |
 2066|    220|	  sig->revkey[sig->numrevkeys].class = revkey[0];
 2067|    220|	  sig->revkey[sig->numrevkeys].algid = revkey[1];
 2068|    220|          len -= 2;
 2069|    220|	  sig->revkey[sig->numrevkeys].fprlen = len;
 2070|    220|	  memcpy (sig->revkey[sig->numrevkeys].fpr, revkey+2, len);
 2071|    220|	  memset (sig->revkey[sig->numrevkeys].fpr+len, 0,
 2072|    220|                  sizeof (sig->revkey[sig->numrevkeys].fpr) - len);
 2073|    220|	  sig->numrevkeys++;
 2074|    220|	}
 2075|  1.38k|    }
 2076|  3.26k|}
parse_signature:
 2082|  52.5k|{
 2083|  52.5k|  int md5_len = 0;
 2084|  52.5k|  unsigned n;
 2085|  52.5k|  int is_v4or5 = 0;
 2086|  52.5k|  int rc = 0;
 2087|  52.5k|  int i, ndata;
 2088|       |
 2089|  52.5k|  if (pktlen < 16)
  ------------------
  |  Branch (2089:7): [True: 5.96k, False: 46.5k]
  ------------------
 2090|  5.96k|    {
 2091|  5.96k|      log_error ("packet(%d) too short\n", pkttype);
 2092|  5.96k|      if (list_mode)
  ------------------
  |  Branch (2092:11): [True: 5.96k, False: 0]
  ------------------
 2093|  5.96k|        es_fputs (":signature packet: [too short]\n", listfp);
 2094|  5.96k|      goto leave;
 2095|  5.96k|    }
 2096|  46.5k|  sig->version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  46.5k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  46.5k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 46.5k]
  |  |  |  |  |  Branch (500:24): [True: 260, False: 46.2k]
  |  |  |  |  ------------------
  |  |  |  |  501|  46.5k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2097|  46.5k|  pktlen--;
 2098|  46.5k|  if (sig->version == 4 || sig->version == 5)
  ------------------
  |  Branch (2098:7): [True: 23.5k, False: 22.9k]
  |  Branch (2098:28): [True: 18.9k, False: 3.99k]
  ------------------
 2099|  42.5k|    is_v4or5 = 1;
 2100|  3.99k|  else if (sig->version != 2 && sig->version != 3)
  ------------------
  |  Branch (2100:12): [True: 2.70k, False: 1.29k]
  |  Branch (2100:33): [True: 1.32k, False: 1.38k]
  ------------------
 2101|  1.32k|    {
 2102|  1.32k|      log_error ("packet(%d) with unknown version %d\n",
 2103|  1.32k|		 pkttype, sig->version);
 2104|  1.32k|      if (list_mode)
  ------------------
  |  Branch (2104:11): [True: 1.32k, False: 0]
  ------------------
 2105|  1.32k|        es_fputs (":signature packet: [unknown version]\n", listfp);
 2106|  1.32k|      rc = gpg_error (GPG_ERR_INV_PACKET);
 2107|  1.32k|      goto leave;
 2108|  1.32k|    }
 2109|       |
 2110|  45.2k|  if (!is_v4or5)
  ------------------
  |  Branch (2110:7): [True: 2.67k, False: 42.5k]
  ------------------
 2111|  2.67k|    {
 2112|  2.67k|      if (pktlen == 0)
  ------------------
  |  Branch (2112:11): [True: 0, False: 2.67k]
  ------------------
 2113|      0|	goto underflow;
 2114|  2.67k|      md5_len = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  2.67k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  2.67k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 2.67k]
  |  |  |  |  |  Branch (500:24): [True: 415, False: 2.25k]
  |  |  |  |  ------------------
  |  |  |  |  501|  2.67k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2115|  2.67k|      pktlen--;
 2116|  2.67k|    }
 2117|  45.2k|  if (pktlen == 0)
  ------------------
  |  Branch (2117:7): [True: 0, False: 45.2k]
  ------------------
 2118|      0|    goto underflow;
 2119|  45.2k|  sig->sig_class = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  45.2k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  45.2k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 45.2k]
  |  |  |  |  |  Branch (500:24): [True: 543, False: 44.6k]
  |  |  |  |  ------------------
  |  |  |  |  501|  45.2k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2120|  45.2k|  pktlen--;
 2121|  45.2k|  if (!is_v4or5)
  ------------------
  |  Branch (2121:7): [True: 2.67k, False: 42.5k]
  ------------------
 2122|  2.67k|    {
 2123|  2.67k|      if (pktlen < 12)
  ------------------
  |  Branch (2123:11): [True: 0, False: 2.67k]
  ------------------
 2124|      0|	goto underflow;
 2125|  2.67k|      sig->timestamp = read_32 (inp);
 2126|  2.67k|      pktlen -= 4;
 2127|  2.67k|      sig->keyid[0] = read_32 (inp);
 2128|  2.67k|      pktlen -= 4;
 2129|  2.67k|      sig->keyid[1] = read_32 (inp);
 2130|  2.67k|      pktlen -= 4;
 2131|  2.67k|    }
 2132|  45.2k|  if (pktlen < 2)
  ------------------
  |  Branch (2132:7): [True: 643, False: 44.5k]
  ------------------
 2133|    643|    goto underflow;
 2134|  44.5k|  sig->pubkey_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  44.5k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  44.5k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 44.5k]
  |  |  |  |  |  Branch (500:24): [True: 290, False: 44.2k]
  |  |  |  |  ------------------
  |  |  |  |  501|  44.5k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2135|  44.5k|  pktlen--;
 2136|  44.5k|  sig->digest_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  44.5k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  44.5k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 44.5k]
  |  |  |  |  |  Branch (500:24): [True: 541, False: 44.0k]
  |  |  |  |  ------------------
  |  |  |  |  501|  44.5k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2137|  44.5k|  pktlen--;
 2138|  44.5k|  sig->flags.exportable = 1;
 2139|  44.5k|  sig->flags.revocable = 1;
 2140|  44.5k|  if (is_v4or5) /* Read subpackets.  */
  ------------------
  |  Branch (2140:7): [True: 42.5k, False: 2.02k]
  ------------------
 2141|  42.5k|    {
 2142|  42.5k|      if (pktlen < 2)
  ------------------
  |  Branch (2142:11): [True: 0, False: 42.5k]
  ------------------
 2143|      0|	goto underflow;
 2144|  42.5k|      n = read_16 (inp);
 2145|  42.5k|      pktlen -= 2;  /* Length of hashed data. */
 2146|  42.5k|      if (pktlen < n)
  ------------------
  |  Branch (2146:11): [True: 3.45k, False: 39.1k]
  ------------------
 2147|  3.45k|	goto underflow;
 2148|  39.1k|      if (n > 10000)
  ------------------
  |  Branch (2148:11): [True: 251, False: 38.8k]
  ------------------
 2149|    251|	{
 2150|    251|	  log_error ("signature packet: hashed data too long\n");
 2151|    251|          if (list_mode)
  ------------------
  |  Branch (2151:15): [True: 251, False: 0]
  ------------------
 2152|    251|            es_fputs (":signature packet: [hashed data too long]\n", listfp);
 2153|    251|	  rc = GPG_ERR_INV_PACKET;
 2154|    251|	  goto leave;
 2155|    251|	}
 2156|  38.8k|      if (n)
  ------------------
  |  Branch (2156:11): [True: 33.1k, False: 5.68k]
  ------------------
 2157|  33.1k|	{
 2158|  33.1k|	  sig->hashed = xmalloc (sizeof (*sig->hashed) + n - 1);
  ------------------
  |  |  107|  33.1k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 2159|  33.1k|	  sig->hashed->size = n;
 2160|  33.1k|	  sig->hashed->len = n;
 2161|  33.1k|	  if (iobuf_read (inp, sig->hashed->data, n) != n)
  ------------------
  |  Branch (2161:8): [True: 305, False: 32.8k]
  ------------------
 2162|    305|	    {
 2163|    305|	      log_error ("premature eof while reading "
 2164|    305|			 "hashed signature data\n");
 2165|    305|              if (list_mode)
  ------------------
  |  Branch (2165:19): [True: 305, False: 0]
  ------------------
 2166|    305|                es_fputs (":signature packet: [premature eof]\n", listfp);
 2167|    305|	      rc = -1;
 2168|    305|	      goto leave;
 2169|    305|	    }
 2170|  32.8k|	  pktlen -= n;
 2171|  32.8k|	}
 2172|  38.5k|      if (pktlen < 2)
  ------------------
  |  Branch (2172:11): [True: 220, False: 38.3k]
  ------------------
 2173|    220|	goto underflow;
 2174|  38.3k|      n = read_16 (inp);
 2175|  38.3k|      pktlen -= 2;  /* Length of unhashed data.  */
 2176|  38.3k|      if (pktlen < n)
  ------------------
  |  Branch (2176:11): [True: 2.69k, False: 35.6k]
  ------------------
 2177|  2.69k|	goto underflow;
 2178|  35.6k|      if (n > 10000)
  ------------------
  |  Branch (2178:11): [True: 227, False: 35.4k]
  ------------------
 2179|    227|	{
 2180|    227|	  log_error ("signature packet: unhashed data too long\n");
 2181|    227|          if (list_mode)
  ------------------
  |  Branch (2181:15): [True: 227, False: 0]
  ------------------
 2182|    227|            es_fputs (":signature packet: [unhashed data too long]\n", listfp);
 2183|    227|	  rc = GPG_ERR_INV_PACKET;
 2184|    227|	  goto leave;
 2185|    227|	}
 2186|  35.4k|      if (n)
  ------------------
  |  Branch (2186:11): [True: 11.2k, False: 24.1k]
  ------------------
 2187|  11.2k|	{
 2188|  11.2k|	  sig->unhashed = xmalloc (sizeof (*sig->unhashed) + n - 1);
  ------------------
  |  |  107|  11.2k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 2189|  11.2k|	  sig->unhashed->size = n;
 2190|  11.2k|	  sig->unhashed->len = n;
 2191|  11.2k|	  if (iobuf_read (inp, sig->unhashed->data, n) != n)
  ------------------
  |  Branch (2191:8): [True: 799, False: 10.4k]
  ------------------
 2192|    799|	    {
 2193|    799|	      log_error ("premature eof while reading "
 2194|    799|			 "unhashed signature data\n");
 2195|    799|              if (list_mode)
  ------------------
  |  Branch (2195:19): [True: 799, False: 0]
  ------------------
 2196|    799|                es_fputs (":signature packet: [premature eof]\n", listfp);
 2197|    799|	      rc = -1;
 2198|    799|	      goto leave;
 2199|    799|	    }
 2200|  10.4k|	  pktlen -= n;
 2201|  10.4k|	}
 2202|  35.4k|    }
 2203|       |
 2204|  36.6k|  if (pktlen < 2)
  ------------------
  |  Branch (2204:7): [True: 905, False: 35.7k]
  ------------------
 2205|    905|    goto underflow;
 2206|  35.7k|  sig->digest_start[0] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  35.7k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  35.7k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 35.7k]
  |  |  |  |  |  Branch (500:24): [True: 1.56k, False: 34.1k]
  |  |  |  |  ------------------
  |  |  |  |  501|  35.7k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2207|  35.7k|  pktlen--;
 2208|  35.7k|  sig->digest_start[1] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  35.7k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  35.7k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 35.7k]
  |  |  |  |  |  Branch (500:24): [True: 1.47k, False: 34.2k]
  |  |  |  |  ------------------
  |  |  |  |  501|  35.7k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2209|  35.7k|  pktlen--;
 2210|       |
 2211|  35.7k|  if (is_v4or5 && sig->pubkey_algo)  /* Extract required information.  */
  ------------------
  |  Branch (2211:7): [True: 34.5k, False: 1.14k]
  |  Branch (2211:19): [True: 33.6k, False: 963]
  ------------------
 2212|  33.6k|    {
 2213|  33.6k|      const byte *p;
 2214|  33.6k|      size_t len;
 2215|       |
 2216|       |      /* Set sig->flags.unknown_critical if there is a critical bit
 2217|       |       * set for packets which we do not understand.  */
 2218|  33.6k|      if (!parse_sig_subpkt (sig, 1, SIGSUBPKT_TEST_CRITICAL, NULL)
  ------------------
  |  Branch (2218:11): [True: 17.2k, False: 16.3k]
  ------------------
 2219|  33.6k|	  || !parse_sig_subpkt (sig, 0, SIGSUBPKT_TEST_CRITICAL, NULL))
  ------------------
  |  Branch (2219:7): [True: 4.33k, False: 11.9k]
  ------------------
 2220|  21.6k|	sig->flags.unknown_critical = 1;
 2221|       |
 2222|  33.6k|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_SIG_CREATED, NULL);
 2223|  33.6k|      if (p)
  ------------------
  |  Branch (2223:11): [True: 264, False: 33.3k]
  ------------------
 2224|    264|	sig->timestamp = buf32_to_u32 (p);
 2225|  33.3k|      else if (!(sig->pubkey_algo >= 100 && sig->pubkey_algo <= 110)
  ------------------
  |  Branch (2225:18): [True: 10.6k, False: 22.6k]
  |  Branch (2225:45): [True: 2.15k, False: 8.51k]
  ------------------
 2226|  33.3k|	       && opt.verbose > 1 && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (2226:12): [True: 0, False: 31.2k]
  |  Branch (2226:31): [True: 0, False: 0]
  ------------------
 2227|      0|        log_info ("signature packet without timestamp\n");
 2228|       |
 2229|       |      /* Set the key id.  We first try the issuer fingerprint and if
 2230|       |       * it is a v4 signature the fallback to the issuer.  Note that
 2231|       |       * only the issuer packet is also searched in the unhashed area.  */
 2232|  33.6k|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_ISSUER_FPR, &len);
 2233|  33.6k|      if (p && len == 21 && p[0] == 4)
  ------------------
  |  Branch (2233:11): [True: 1.04k, False: 32.5k]
  |  Branch (2233:16): [True: 451, False: 592]
  |  Branch (2233:29): [True: 256, False: 195]
  ------------------
 2234|    256|        {
 2235|    256|          sig->keyid[0] = buf32_to_u32 (p + 1 + 12);
 2236|    256|	  sig->keyid[1] = buf32_to_u32 (p + 1 + 16);
 2237|    256|	}
 2238|  33.3k|      else if (p && len == 33 && p[0] == 5)
  ------------------
  |  Branch (2238:16): [True: 787, False: 32.5k]
  |  Branch (2238:21): [True: 479, False: 308]
  |  Branch (2238:34): [True: 272, False: 207]
  ------------------
 2239|    272|        {
 2240|    272|          sig->keyid[0] = buf32_to_u32 (p + 1 );
 2241|    272|	  sig->keyid[1] = buf32_to_u32 (p + 1 + 4);
 2242|    272|	}
 2243|  33.0k|      else if ((p = parse_sig_subpkt2 (sig, SIGSUBPKT_ISSUER)))
  ------------------
  |  Branch (2243:16): [True: 200, False: 32.8k]
  ------------------
 2244|    200|        {
 2245|    200|          sig->keyid[0] = buf32_to_u32 (p);
 2246|    200|	  sig->keyid[1] = buf32_to_u32 (p + 4);
 2247|    200|	}
 2248|  32.8k|      else if (!(sig->pubkey_algo >= 100 && sig->pubkey_algo <= 110)
  ------------------
  |  Branch (2248:18): [True: 10.3k, False: 22.4k]
  |  Branch (2248:45): [True: 2.15k, False: 8.23k]
  ------------------
 2249|  32.8k|	       && opt.verbose > 1 && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (2249:12): [True: 0, False: 30.7k]
  |  Branch (2249:31): [True: 0, False: 0]
  ------------------
 2250|      0|	log_info ("signature packet without keyid\n");
 2251|       |
 2252|  33.6k|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_SIG_EXPIRE, NULL);
 2253|  33.6k|      if (p && buf32_to_u32 (p))
  ------------------
  |  Branch (2253:11): [True: 1.42k, False: 32.2k]
  |  Branch (2253:16): [True: 749, False: 673]
  ------------------
 2254|    749|	sig->expiredate = sig->timestamp + buf32_to_u32 (p);
 2255|  33.6k|      if (sig->expiredate && sig->expiredate <= make_timestamp ())
  ------------------
  |  Branch (2255:11): [True: 749, False: 32.8k]
  |  Branch (2255:30): [True: 381, False: 368]
  ------------------
 2256|    381|	sig->flags.expired = 1;
 2257|       |
 2258|  33.6k|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_POLICY, NULL);
 2259|  33.6k|      if (p)
  ------------------
  |  Branch (2259:11): [True: 701, False: 32.9k]
  ------------------
 2260|    701|	sig->flags.policy_url = 1;
 2261|       |
 2262|  33.6k|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_PREF_KS, NULL);
 2263|  33.6k|      if (p)
  ------------------
  |  Branch (2263:11): [True: 1.04k, False: 32.5k]
  ------------------
 2264|  1.04k|	sig->flags.pref_ks = 1;
 2265|       |
 2266|  33.6k|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_SIGNERS_UID, &len);
 2267|  33.6k|      if (p && len)
  ------------------
  |  Branch (2267:11): [True: 6.62k, False: 26.9k]
  |  Branch (2267:16): [True: 6.24k, False: 381]
  ------------------
 2268|  6.24k|        {
 2269|  6.24k|          char *mbox;
 2270|       |
 2271|  6.24k|          sig->signers_uid = try_make_printable_string (p, len, 0);
 2272|  6.24k|          if (!sig->signers_uid)
  ------------------
  |  Branch (2272:15): [True: 0, False: 6.24k]
  ------------------
 2273|      0|            {
 2274|      0|              rc = gpg_error_from_syserror ();
 2275|      0|              goto leave;
 2276|      0|            }
 2277|  6.24k|          mbox = mailbox_from_userid (sig->signers_uid, 0);
 2278|  6.24k|          if (mbox)
  ------------------
  |  Branch (2278:15): [True: 759, False: 5.48k]
  ------------------
 2279|    759|            {
 2280|    759|              xfree (sig->signers_uid);
  ------------------
  |  |  104|    759|#define xfree(a)         gcry_free ((a))
  ------------------
 2281|    759|              sig->signers_uid = mbox;
 2282|    759|            }
 2283|  6.24k|        }
 2284|       |
 2285|  33.6k|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_KEY_BLOCK, NULL);
 2286|  33.6k|      if (p)
  ------------------
  |  Branch (2286:11): [True: 82, False: 33.5k]
  ------------------
 2287|     82|        sig->flags.key_block = 1;
 2288|       |
 2289|  33.6k|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_NOTATION, NULL);
 2290|  33.6k|      if (p)
  ------------------
  |  Branch (2290:11): [True: 547, False: 33.0k]
  ------------------
 2291|    547|	sig->flags.notation = 1;
 2292|       |
 2293|  33.6k|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_REVOCABLE, NULL);
 2294|  33.6k|      if (p && *p == 0)
  ------------------
  |  Branch (2294:11): [True: 1.61k, False: 32.0k]
  |  Branch (2294:16): [True: 1.11k, False: 496]
  ------------------
 2295|  1.11k|	sig->flags.revocable = 0;
 2296|       |
 2297|  33.6k|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_TRUST, &len);
 2298|  33.6k|      if (p && len == 2)
  ------------------
  |  Branch (2298:11): [True: 2.56k, False: 31.0k]
  |  Branch (2298:16): [True: 2.56k, False: 0]
  ------------------
 2299|  2.56k|	{
 2300|  2.56k|	  sig->trust_depth = p[0];
 2301|  2.56k|	  sig->trust_value = p[1];
 2302|       |
 2303|       |	  /* Only look for a regexp if there is also a trust
 2304|       |	     subpacket. */
 2305|  2.56k|	  sig->trust_regexp =
 2306|  2.56k|	    parse_sig_subpkt (sig, 1, SIGSUBPKT_REGEXP, &len);
 2307|       |
 2308|       |	  /* If the regular expression is of 0 length, there is no
 2309|       |	     regular expression. */
 2310|  2.56k|	  if (len == 0)
  ------------------
  |  Branch (2310:8): [True: 1.27k, False: 1.29k]
  ------------------
 2311|  1.27k|	    sig->trust_regexp = NULL;
 2312|  2.56k|	}
 2313|       |
 2314|       |      /* We accept the exportable subpacket from either the hashed or
 2315|       |         unhashed areas as older versions of gpg put it in the
 2316|       |         unhashed area.  In theory, anyway, we should never see this
 2317|       |         packet off of a local keyring. */
 2318|       |
 2319|  33.6k|      p = parse_sig_subpkt2 (sig, SIGSUBPKT_EXPORTABLE);
 2320|  33.6k|      if (p && *p == 0)
  ------------------
  |  Branch (2320:11): [True: 675, False: 32.9k]
  |  Branch (2320:16): [True: 269, False: 406]
  ------------------
 2321|    269|	sig->flags.exportable = 0;
 2322|       |
 2323|       |      /* Find all revocation keys.  */
 2324|  33.6k|      if (sig->sig_class == 0x1F)
  ------------------
  |  Branch (2324:11): [True: 3.26k, False: 30.3k]
  ------------------
 2325|  3.26k|	parse_revkeys (sig);
 2326|  33.6k|    }
 2327|       |
 2328|  35.7k|  if (list_mode)
  ------------------
  |  Branch (2328:7): [True: 35.7k, False: 0]
  ------------------
 2329|  35.7k|    {
 2330|  35.7k|      es_fprintf (listfp, ":signature packet: algo %d, keyid %08lX%08lX\n"
 2331|  35.7k|                  "\tversion %d, created %lu, md5len %d, sigclass 0x%02x\n"
 2332|  35.7k|                  "\tdigest algo %d, begin of digest %02x %02x\n",
 2333|  35.7k|                  sig->pubkey_algo,
 2334|  35.7k|                  (ulong) sig->keyid[0], (ulong) sig->keyid[1],
 2335|  35.7k|                  sig->version, (ulong) sig->timestamp, md5_len, sig->sig_class,
 2336|  35.7k|                  sig->digest_algo, sig->digest_start[0], sig->digest_start[1]);
 2337|  35.7k|      if (is_v4or5)
  ------------------
  |  Branch (2337:11): [True: 34.5k, False: 1.14k]
  ------------------
 2338|  34.5k|	{
 2339|  34.5k|	  parse_sig_subpkt (sig, 1, SIGSUBPKT_LIST_HASHED, NULL);
 2340|  34.5k|	  parse_sig_subpkt (sig, 0, SIGSUBPKT_LIST_UNHASHED, NULL);
 2341|  34.5k|	}
 2342|  35.7k|    }
 2343|       |
 2344|  35.7k|  ndata = pubkey_get_nsig (sig->pubkey_algo);
 2345|  35.7k|  if (!ndata)
  ------------------
  |  Branch (2345:7): [True: 28.8k, False: 6.85k]
  ------------------
 2346|  28.8k|    {
 2347|  28.8k|      if (list_mode)
  ------------------
  |  Branch (2347:11): [True: 28.8k, False: 0]
  ------------------
 2348|  28.8k|	es_fprintf (listfp, "\tunknown algorithm %d\n", sig->pubkey_algo);
 2349|  28.8k|      unknown_pubkey_warning (sig->pubkey_algo);
 2350|       |
 2351|       |      /* We store the plain material in data[0], so that we are able
 2352|       |       * to write it back with build_packet().  */
 2353|  28.8k|      if (pktlen > (5 * MAX_EXTERN_MPI_BITS / 8))
  ------------------
  |  |   42|  28.8k|#define MAX_EXTERN_MPI_BITS 16384
  ------------------
  |  Branch (2353:11): [True: 333, False: 28.5k]
  ------------------
 2354|    333|	{
 2355|       |	  /* We include a limit to avoid too trivial DoS attacks by
 2356|       |	     having gpg allocate too much memory.  */
 2357|    333|	  log_error ("signature packet: too much data\n");
 2358|    333|	  rc = GPG_ERR_INV_PACKET;
 2359|    333|	}
 2360|  28.5k|      else
 2361|  28.5k|	{
 2362|  28.5k|          void *tmpp;
 2363|       |
 2364|  28.5k|          tmpp = read_rest (inp, pktlen);
 2365|  28.5k|	  sig->data[0] = gcry_mpi_set_opaque (NULL, tmpp, tmpp? pktlen * 8 : 0);
  ------------------
  |  Branch (2365:52): [True: 17.0k, False: 11.5k]
  ------------------
 2366|  28.5k|	  pktlen = 0;
 2367|  28.5k|	}
 2368|  28.8k|    }
 2369|  6.85k|  else
 2370|  6.85k|    {
 2371|  19.3k|      for (i = 0; i < ndata; i++)
  ------------------
  |  Branch (2371:19): [True: 12.4k, False: 6.85k]
  ------------------
 2372|  12.4k|	{
 2373|  12.4k|	  n = pktlen;
 2374|  12.4k|          if (sig->pubkey_algo == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (2374:15): [True: 1.41k, False: 11.0k]
  ------------------
 2375|  12.4k|              || sig->pubkey_algo == PUBKEY_ALGO_EDDSA)
  ------------------
  |  Branch (2375:18): [True: 598, False: 10.4k]
  ------------------
 2376|  2.01k|            sig->data[i] = sos_read (inp, &n, 0);
 2377|  10.4k|          else
 2378|  10.4k|            sig->data[i] = mpi_read (inp, &n, 0);
 2379|  12.4k|	  pktlen -= n;
 2380|  12.4k|	  if (list_mode)
  ------------------
  |  Branch (2380:8): [True: 12.4k, False: 0]
  ------------------
 2381|  12.4k|	    {
 2382|  12.4k|	      es_fprintf (listfp, "\tdata: ");
 2383|  12.4k|	      mpi_print (listfp, sig->data[i], mpi_print_mode);
 2384|  12.4k|	      es_putc ('\n', listfp);
 2385|  12.4k|	    }
 2386|  12.4k|	  if (!sig->data[i])
  ------------------
  |  Branch (2386:8): [True: 6.39k, False: 6.06k]
  ------------------
 2387|  6.39k|	    rc = GPG_ERR_INV_PACKET;
 2388|  12.4k|	}
 2389|  6.85k|    }
 2390|       |
 2391|  44.5k| leave:
 2392|  44.5k|  iobuf_skip_rest (inp, pktlen, 0);
 2393|  44.5k|  return rc;
 2394|       |
 2395|  7.91k| underflow:
 2396|  7.91k|  log_error ("packet(%d) too short\n", pkttype);
 2397|  7.91k|  if (list_mode)
  ------------------
  |  Branch (2397:7): [True: 7.91k, False: 0]
  ------------------
 2398|  7.91k|    es_fputs (":signature packet: [too short]\n", listfp);
 2399|       |
 2400|  7.91k|  iobuf_skip_rest (inp, pktlen, 0);
 2401|       |
 2402|  7.91k|  return GPG_ERR_INV_PACKET;
 2403|  35.7k|}
parse_attribute_subpkts:
 3018|  6.10k|{
 3019|  6.10k|  size_t n;
 3020|  6.10k|  int count = 0;
 3021|  6.10k|  struct user_attribute *attribs = NULL;
 3022|  6.10k|  const byte *buffer = uid->attrib_data;
 3023|  6.10k|  int buflen = uid->attrib_len;
 3024|  6.10k|  byte type;
 3025|       |
 3026|  6.10k|  xfree (uid->attribs);
  ------------------
  |  |  104|  6.10k|#define xfree(a)         gcry_free ((a))
  ------------------
 3027|       |
 3028|  23.7k|  while (buflen)
  ------------------
  |  Branch (3028:10): [True: 20.4k, False: 3.23k]
  ------------------
 3029|  20.4k|    {
 3030|  20.4k|      n = *buffer++;
 3031|  20.4k|      buflen--;
 3032|  20.4k|      if (n == 255)  /* 4 byte length header.  */
  ------------------
  |  Branch (3032:11): [True: 1.09k, False: 19.3k]
  ------------------
 3033|  1.09k|	{
 3034|  1.09k|	  if (buflen < 4)
  ------------------
  |  Branch (3034:8): [True: 229, False: 866]
  ------------------
 3035|    229|	    goto too_short;
 3036|    866|	  n = buf32_to_size_t (buffer);
 3037|    866|	  buffer += 4;
 3038|    866|	  buflen -= 4;
 3039|    866|	}
 3040|  19.3k|      else if (n >= 192)  /* 2 byte special encoded length header.  */
  ------------------
  |  Branch (3040:16): [True: 670, False: 18.7k]
  ------------------
 3041|    670|	{
 3042|    670|	  if (buflen < 2)
  ------------------
  |  Branch (3042:8): [True: 364, False: 306]
  ------------------
 3043|    364|	    goto too_short;
 3044|    306|	  n = ((n - 192) << 8) + *buffer + 192;
 3045|    306|	  buffer++;
 3046|    306|	  buflen--;
 3047|    306|	}
 3048|  19.8k|      if (buflen < n)
  ------------------
  |  Branch (3048:11): [True: 1.80k, False: 18.0k]
  ------------------
 3049|  1.80k|	goto too_short;
 3050|       |
 3051|  18.0k|      if (!n)
  ------------------
  |  Branch (3051:11): [True: 471, False: 17.6k]
  ------------------
 3052|    471|        {
 3053|       |          /* Too short to encode the subpacket type.  */
 3054|    471|          if (opt.verbose)
  ------------------
  |  Branch (3054:15): [True: 0, False: 471]
  ------------------
 3055|      0|            log_info ("attribute subpacket too short\n");
 3056|    471|          break;
 3057|    471|        }
 3058|       |
 3059|  17.6k|      attribs = xrealloc (attribs,
  ------------------
  |  |  111|  17.6k|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 3060|  17.6k|                          (count + 1) * sizeof (struct user_attribute));
 3061|  17.6k|      memset (&attribs[count], 0, sizeof (struct user_attribute));
 3062|       |
 3063|  17.6k|      type = *buffer;
 3064|  17.6k|      buffer++;
 3065|  17.6k|      buflen--;
 3066|  17.6k|      n--;
 3067|       |
 3068|  17.6k|      attribs[count].type = type;
 3069|  17.6k|      attribs[count].data = buffer;
 3070|  17.6k|      attribs[count].len = n;
 3071|  17.6k|      buffer += n;
 3072|  17.6k|      buflen -= n;
 3073|  17.6k|      count++;
 3074|  17.6k|    }
 3075|       |
 3076|  3.70k|  uid->attribs = attribs;
 3077|  3.70k|  uid->numattribs = count;
 3078|  3.70k|  return count;
 3079|       |
 3080|  2.39k| too_short:
 3081|  2.39k|  if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (3081:7): [True: 0, False: 2.39k]
  |  Branch (3081:22): [True: 0, False: 0]
  ------------------
 3082|      0|    log_info ("buffer shorter than attribute subpacket\n");
 3083|  2.39k|  uid->attribs = attribs;
 3084|  2.39k|  uid->numattribs = count;
 3085|  2.39k|  return count;
 3086|  6.10k|}
make_attribute_uidname:
 3139|  6.10k|{
 3140|  6.10k|  log_assert (max_namelen > 70);
 3141|  6.10k|  if (uid->numattribs <= 0)
  ------------------
  |  Branch (3141:7): [True: 3.18k, False: 2.91k]
  ------------------
 3142|  3.18k|    sprintf (uid->name, "[bad attribute packet of size %lu]",
 3143|  3.18k|	     uid->attrib_len);
 3144|  2.91k|  else if (uid->numattribs > 1)
  ------------------
  |  Branch (3144:12): [True: 233, False: 2.68k]
  ------------------
 3145|    233|    sprintf (uid->name, "[%d attributes of size %lu]",
 3146|    233|	     uid->numattribs, uid->attrib_len);
 3147|  2.68k|  else
 3148|  2.68k|    {
 3149|       |      /* Only one attribute, so list it as the "user id" */
 3150|       |
 3151|  2.68k|      if (uid->attribs->type == ATTRIB_IMAGE)
  ------------------
  |  |  263|  2.68k|#define ATTRIB_IMAGE 1
  ------------------
  |  Branch (3151:11): [True: 2.13k, False: 552]
  ------------------
 3152|  2.13k|	{
 3153|  2.13k|	  u32 len;
 3154|  2.13k|	  byte type;
 3155|       |
 3156|  2.13k|	  if (parse_image_header (uid->attribs, &type, &len))
  ------------------
  |  Branch (3156:8): [True: 790, False: 1.34k]
  ------------------
 3157|    790|	    sprintf (uid->name, "[%.20s image of size %lu]",
 3158|    790|		     image_type_to_string (type, 1), (ulong) len);
 3159|  1.34k|	  else
 3160|  1.34k|	    sprintf (uid->name, "[invalid image]");
 3161|  2.13k|	}
 3162|    552|      else
 3163|    552|	sprintf (uid->name, "[unknown attribute of size %lu]",
 3164|    552|		 (ulong) uid->attribs->len);
 3165|  2.68k|    }
 3166|       |
 3167|  6.10k|  uid->len = strlen (uid->name);
 3168|  6.10k|}
parse-packet.c:parse:
  631|  2.42M|{
  632|  2.42M|  int rc = 0;
  633|  2.42M|  iobuf_t inp;
  634|  2.42M|  int c, ctb, pkttype, lenbytes;
  635|  2.42M|  unsigned long pktlen;
  636|  2.42M|  byte hdr[8];
  637|  2.42M|  int hdrlen;
  638|  2.42M|  int new_ctb = 0, partial = 0;
  639|  2.42M|  int with_uid = (onlykeypkts == 2);
  640|  2.42M|  off_t pos;
  641|       |
  642|  2.42M|  *skip = 0;
  643|  2.42M|  inp = ctx->inp;
  644|       |
  645|  2.43M| again:
  646|  2.43M|  log_assert (!pkt->pkt.generic);
  647|  2.43M|  if (retpos || list_mode)
  ------------------
  |  Branch (647:7): [True: 0, False: 2.43M]
  |  Branch (647:17): [True: 2.43M, False: 0]
  ------------------
  648|  2.43M|    {
  649|  2.43M|      pos = iobuf_tell (inp);
  650|  2.43M|      if (retpos)
  ------------------
  |  Branch (650:11): [True: 0, False: 2.43M]
  ------------------
  651|      0|        *retpos = pos;
  652|  2.43M|    }
  653|      0|  else
  654|      0|    pos = 0; /* (silence compiler warning) */
  655|       |
  656|       |  /* The first byte of a packet is the so-called tag.  The highest bit
  657|       |     must be set.  */
  658|  2.43M|  if ((ctb = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|  2.43M|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 2.43M]
  |  |  |  Branch (500:24): [True: 20.9k, False: 2.41M]
  |  |  ------------------
  |  |  501|  2.43M|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (658:7): [True: 13.9k, False: 2.42M]
  ------------------
  659|  13.9k|    {
  660|  13.9k|      rc = -1;
  661|  13.9k|      goto leave;
  662|  13.9k|    }
  663|  2.42M|  hdrlen = 0;
  664|  2.42M|  hdr[hdrlen++] = ctb;
  665|       |
  666|  2.42M|  if (!(ctb & 0x80))
  ------------------
  |  Branch (666:7): [True: 1.87M, False: 550k]
  ------------------
  667|  1.87M|    {
  668|  1.87M|      log_error ("%s: invalid packet (ctb=%02x)\n", iobuf_where (inp), ctb);
  ------------------
  |  |  630|  1.87M|#define iobuf_where(a)	"[don't know]"
  ------------------
  669|  1.87M|      rc = gpg_error (GPG_ERR_INV_PACKET);
  670|  1.87M|      goto leave;
  671|  1.87M|    }
  672|       |
  673|       |  /* Immediately following the header is the length.  There are two
  674|       |     formats: the old format and the new format.  If bit 6 (where the
  675|       |     least significant bit is bit 0) is set in the tag, then we are
  676|       |     dealing with a new format packet.  Otherwise, it is an old format
  677|       |     packet.  */
  678|   550k|  pktlen = 0;
  679|   550k|  new_ctb = !!(ctb & 0x40);
  680|   550k|  if (new_ctb)
  ------------------
  |  Branch (680:7): [True: 259k, False: 290k]
  ------------------
  681|   259k|    {
  682|       |      /* Get the packet's type.  This is encoded in the 6 least
  683|       |	 significant bits of the tag.  */
  684|   259k|      pkttype = ctb & 0x3f;
  685|       |
  686|       |      /* Extract the packet's length.  New format packets have 4 ways
  687|       |	 to encode the packet length.  The value of the first byte
  688|       |	 determines the encoding and partially determines the length.
  689|       |	 See section 4.2.2 of RFC 4880 for details.  */
  690|   259k|      if ((c = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|   259k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 259k]
  |  |  |  Branch (500:24): [True: 1.53k, False: 258k]
  |  |  ------------------
  |  |  501|   259k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (690:11): [True: 1.44k, False: 258k]
  ------------------
  691|  1.44k|	{
  692|  1.44k|	  log_error ("%s: 1st length byte missing\n", iobuf_where (inp));
  ------------------
  |  |  630|  1.44k|#define iobuf_where(a)	"[don't know]"
  ------------------
  693|  1.44k|	  rc = gpg_error (GPG_ERR_INV_PACKET);
  694|  1.44k|	  goto leave;
  695|  1.44k|	}
  696|       |
  697|       |
  698|   258k|      hdr[hdrlen++] = c;
  699|   258k|      if (c < 192)
  ------------------
  |  Branch (699:11): [True: 210k, False: 48.1k]
  ------------------
  700|   210k|        pktlen = c;
  701|  48.1k|      else if (c < 224)
  ------------------
  |  Branch (701:16): [True: 3.57k, False: 44.6k]
  ------------------
  702|  3.57k|        {
  703|  3.57k|          pktlen = (c - 192) * 256;
  704|  3.57k|          if ((c = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|  3.57k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 3.57k]
  |  |  |  Branch (500:24): [True: 248, False: 3.32k]
  |  |  ------------------
  |  |  501|  3.57k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (704:15): [True: 239, False: 3.33k]
  ------------------
  705|    239|            {
  706|    239|              log_error ("%s: 2nd length byte missing\n",
  707|    239|                         iobuf_where (inp));
  ------------------
  |  |  630|    239|#define iobuf_where(a)	"[don't know]"
  ------------------
  708|    239|              rc = gpg_error (GPG_ERR_INV_PACKET);
  709|    239|              goto leave;
  710|    239|            }
  711|  3.33k|          hdr[hdrlen++] = c;
  712|  3.33k|          pktlen += c + 192;
  713|  3.33k|        }
  714|  44.6k|      else if (c == 255)
  ------------------
  |  Branch (714:16): [True: 3.05k, False: 41.5k]
  ------------------
  715|  3.05k|        {
  716|  3.05k|	  int i;
  717|  3.05k|	  char value[4];
  718|       |
  719|  14.3k|	  for (i = 0; i < 4; i ++)
  ------------------
  |  Branch (719:16): [True: 11.5k, False: 2.81k]
  ------------------
  720|  11.5k|            {
  721|  11.5k|              if ((c = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|  11.5k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 11.5k]
  |  |  |  Branch (500:24): [True: 515, False: 11.0k]
  |  |  ------------------
  |  |  501|  11.5k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (721:19): [True: 246, False: 11.3k]
  ------------------
  722|    246|                {
  723|    246|                  log_error ("%s: 4 byte length invalid\n", iobuf_where (inp));
  ------------------
  |  |  630|    246|#define iobuf_where(a)	"[don't know]"
  ------------------
  724|    246|                  rc = gpg_error (GPG_ERR_INV_PACKET);
  725|    246|                  goto leave;
  726|    246|                }
  727|  11.3k|              value[i] = hdr[hdrlen++] = c;
  728|  11.3k|            }
  729|       |
  730|  2.81k|	  pktlen = buf32_to_ulong (value);
  731|  2.81k|        }
  732|  41.5k|      else /* Partial body length.  */
  733|  41.5k|        {
  734|  41.5k|          switch (pkttype)
  735|  41.5k|            {
  736|  3.98k|            case PKT_PLAINTEXT:
  ------------------
  |  Branch (736:13): [True: 3.98k, False: 37.5k]
  ------------------
  737|  4.96k|            case PKT_ENCRYPTED:
  ------------------
  |  Branch (737:13): [True: 977, False: 40.5k]
  ------------------
  738|  22.8k|            case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (738:13): [True: 17.8k, False: 23.6k]
  ------------------
  739|  33.7k|            case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (739:13): [True: 10.9k, False: 30.5k]
  ------------------
  740|  34.8k|            case PKT_COMPRESSED:
  ------------------
  |  Branch (740:13): [True: 1.08k, False: 40.4k]
  ------------------
  741|  34.8k|              iobuf_set_partial_body_length_mode (inp, c & 0xff);
  742|  34.8k|              pktlen = 0;	/* To indicate partial length.  */
  743|  34.8k|              partial = 1;
  744|  34.8k|              break;
  745|       |
  746|  6.68k|            default:
  ------------------
  |  Branch (746:13): [True: 6.68k, False: 34.8k]
  ------------------
  747|  6.68k|              log_error ("%s: partial length invalid for"
  748|  6.68k|                         " packet type %d\n", iobuf_where (inp), pkttype);
  ------------------
  |  |  630|  6.68k|#define iobuf_where(a)	"[don't know]"
  ------------------
  749|  6.68k|              rc = gpg_error (GPG_ERR_INV_PACKET);
  750|  6.68k|              goto leave;
  751|  41.5k|            }
  752|  41.5k|        }
  753|       |
  754|   258k|    }
  755|   290k|  else
  756|       |    /* This is an old format packet.  */
  757|   290k|    {
  758|       |      /* Extract the packet's type.  This is encoded in bits 2-5.  */
  759|   290k|      pkttype = (ctb >> 2) & 0xf;
  760|       |
  761|       |      /* The type of length encoding is encoded in bits 0-1 of the
  762|       |	 tag.  */
  763|   290k|      lenbytes = ((ctb & 3) == 3) ? 0 : (1 << (ctb & 3));
  ------------------
  |  Branch (763:18): [True: 48.8k, False: 242k]
  ------------------
  764|   290k|      if (!lenbytes)
  ------------------
  |  Branch (764:11): [True: 48.8k, False: 242k]
  ------------------
  765|  48.8k|	{
  766|  48.8k|	  pktlen = 0;	/* Don't know the value.  */
  767|       |	  /* This isn't really partial, but we can treat it the same
  768|       |	     in a "read until the end" sort of way.  */
  769|  48.8k|	  partial = 1;
  770|  48.8k|	  if (pkttype != PKT_ENCRYPTED && pkttype != PKT_PLAINTEXT
  ------------------
  |  Branch (770:8): [True: 48.1k, False: 711]
  |  Branch (770:36): [True: 46.7k, False: 1.39k]
  ------------------
  771|  48.8k|	      && pkttype != PKT_COMPRESSED)
  ------------------
  |  Branch (771:11): [True: 45.4k, False: 1.30k]
  ------------------
  772|  45.4k|	    {
  773|  45.4k|	      log_error ("%s: indeterminate length for invalid"
  774|  45.4k|			 " packet type %d\n", iobuf_where (inp), pkttype);
  ------------------
  |  |  630|  45.4k|#define iobuf_where(a)	"[don't know]"
  ------------------
  775|  45.4k|	      rc = gpg_error (GPG_ERR_INV_PACKET);
  776|  45.4k|	      goto leave;
  777|  45.4k|	    }
  778|  48.8k|	}
  779|   242k|      else
  780|   242k|	{
  781|   504k|	  for (; lenbytes; lenbytes--)
  ------------------
  |  Branch (781:11): [True: 263k, False: 241k]
  ------------------
  782|   263k|	    {
  783|   263k|	      pktlen <<= 8;
  784|   263k|	      c = iobuf_get (inp);
  ------------------
  |  |  500|   263k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 263k]
  |  |  |  Branch (500:24): [True: 633, False: 262k]
  |  |  ------------------
  |  |  501|   263k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  785|   263k|	      if (c == -1)
  ------------------
  |  Branch (785:12): [True: 591, False: 262k]
  ------------------
  786|    591|		{
  787|    591|		  log_error ("%s: length invalid\n", iobuf_where (inp));
  ------------------
  |  |  630|    591|#define iobuf_where(a)	"[don't know]"
  ------------------
  788|    591|		  rc = gpg_error (GPG_ERR_INV_PACKET);
  789|    591|		  goto leave;
  790|    591|		}
  791|   262k|	      pktlen |= hdr[hdrlen++] = c;
  792|   262k|	    }
  793|   242k|	}
  794|   290k|    }
  795|       |
  796|       |  /* Sometimes the decompressing layer enters an error state in which
  797|       |     it simply outputs 0xff for every byte read.  If we have a stream
  798|       |     of 0xff bytes, then it will be detected as a new format packet
  799|       |     with type 63 and a 4-byte encoded length that is 4G-1.  Since
  800|       |     packets with type 63 are private and we use them as a control
  801|       |     packet, which won't be 4 GB, we reject such packets as
  802|       |     invalid.  */
  803|   496k|  if (pkttype == 63 && pktlen == 0xFFFFFFFF)
  ------------------
  |  Branch (803:7): [True: 25.8k, False: 470k]
  |  Branch (803:24): [True: 1.65k, False: 24.1k]
  ------------------
  804|  1.65k|    {
  805|       |      /* With some probability this is caused by a problem in the
  806|       |       * the uncompressing layer - in some error cases it just loops
  807|       |       * and spits out 0xff bytes. */
  808|  1.65k|      log_error ("%s: garbled packet detected\n", iobuf_where (inp));
  ------------------
  |  |  630|  1.65k|#define iobuf_where(a)	"[don't know]"
  ------------------
  809|  1.65k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  810|  1.65k|      rc = gpg_error (GPG_ERR_INV_PACKET);
  811|  1.65k|      goto leave;
  812|       |#else
  813|       |      g10_exit (2);
  814|       |#endif
  815|  1.65k|    }
  816|       |
  817|   494k|  if (out && pkttype)
  ------------------
  |  Branch (817:7): [True: 0, False: 494k]
  |  Branch (817:14): [True: 0, False: 0]
  ------------------
  818|      0|    {
  819|       |      /* This type of copying won't work if the packet uses a partial
  820|       |	 body length.  (In other words, this only works if HDR is
  821|       |	 actually the length.)  Currently, no callers require this
  822|       |	 functionality so we just log this as an error.  */
  823|      0|      if (partial)
  ------------------
  |  Branch (823:11): [True: 0, False: 0]
  ------------------
  824|      0|	{
  825|      0|	  log_error ("parse: Can't copy partial packet.  Aborting.\n");
  826|      0|	  rc = gpg_error (GPG_ERR_INV_PACKET);
  827|      0|	  goto leave;
  828|      0|	}
  829|       |
  830|      0|      rc = iobuf_write (out, hdr, hdrlen);
  831|      0|      if (!rc)
  ------------------
  |  Branch (831:11): [True: 0, False: 0]
  ------------------
  832|      0|	rc = copy_packet (inp, out, pkttype, pktlen, partial);
  833|      0|      goto leave;
  834|      0|    }
  835|       |
  836|   494k|  if (with_uid && pkttype == PKT_USER_ID)
  ------------------
  |  Branch (836:7): [True: 0, False: 494k]
  |  Branch (836:19): [True: 0, False: 0]
  ------------------
  837|       |    /* If ONLYKEYPKTS is set to 2, then we never skip user id packets,
  838|       |       even if DO_SKIP is set.  */
  839|      0|    ;
  840|   494k|  else if (do_skip
  ------------------
  |  Branch (840:12): [True: 0, False: 494k]
  ------------------
  841|       |	   /* type==0 is not allowed.  This is an invalid packet.  */
  842|   494k|	   || !pkttype
  ------------------
  |  Branch (842:8): [True: 3.69k, False: 490k]
  ------------------
  843|       |	   /* When ONLYKEYPKTS is set, we don't skip keys.  */
  844|   494k|	   || (onlykeypkts && pkttype != PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (844:9): [True: 0, False: 490k]
  |  Branch (844:24): [True: 0, False: 0]
  ------------------
  845|   490k|	       && pkttype != PKT_PUBLIC_KEY
  ------------------
  |  Branch (845:12): [True: 0, False: 0]
  ------------------
  846|   490k|	       && pkttype != PKT_SECRET_SUBKEY && pkttype != PKT_SECRET_KEY))
  ------------------
  |  Branch (846:12): [True: 0, False: 0]
  |  Branch (846:44): [True: 0, False: 0]
  ------------------
  847|  3.69k|    {
  848|  3.69k|      iobuf_skip_rest (inp, pktlen, partial);
  849|  3.69k|      *skip = 1;
  850|  3.69k|      rc = 0;
  851|  3.69k|      goto leave;
  852|  3.69k|    }
  853|       |
  854|   490k|  if (DBG_PACKET)
  ------------------
  |  |  348|   490k|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|   490k|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 490k]
  |  |  ------------------
  ------------------
  855|      0|    {
  856|      0|#if DEBUG_PARSE_PACKET
  857|      0|      log_debug ("parse_packet(iob=%d): type=%d length=%lu%s (%s.%s.%d)\n",
  858|      0|		 iobuf_id (inp), pkttype, pktlen, new_ctb ? " (new_ctb)" : "",
  ------------------
  |  |  635|      0|#define iobuf_id(a)	((a)->no)
  ------------------
  |  Branch (858:37): [True: 0, False: 0]
  ------------------
  859|      0|		 dbg_w, dbg_f, dbg_l);
  860|       |#else
  861|       |      log_debug ("parse_packet(iob=%d): type=%d length=%lu%s\n",
  862|       |		 iobuf_id (inp), pkttype, pktlen,
  863|       |		 new_ctb ? " (new_ctb)" : "");
  864|       |#endif
  865|      0|    }
  866|       |
  867|   490k|  if (list_mode)
  ------------------
  |  Branch (867:7): [True: 490k, False: 0]
  ------------------
  868|   490k|    es_fprintf (listfp, "# off=%lu ctb=%02x tag=%d hlen=%d plen=%lu%s%s\n",
  869|   490k|                (unsigned long)pos, ctb, pkttype, hdrlen, pktlen,
  870|   490k|                partial? (new_ctb ? " partial" : " indeterminate") :"",
  ------------------
  |  Branch (870:17): [True: 38.2k, False: 452k]
  |  Branch (870:27): [True: 34.8k, False: 3.41k]
  ------------------
  871|   490k|                new_ctb? " new-ctb":"");
  ------------------
  |  Branch (871:17): [True: 249k, False: 241k]
  ------------------
  872|       |
  873|       |  /* Count it.  */
  874|   490k|  ctx->n_parsed_packets++;
  875|       |
  876|   490k|  pkt->pkttype = pkttype;
  877|   490k|  rc = GPG_ERR_UNKNOWN_PACKET;	/* default error */
  878|   490k|  switch (pkttype)
  879|   490k|    {
  880|  4.54k|    case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (880:5): [True: 4.54k, False: 486k]
  ------------------
  881|  6.83k|    case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (881:5): [True: 2.29k, False: 488k]
  ------------------
  882|  29.1k|    case PKT_SECRET_KEY:
  ------------------
  |  Branch (882:5): [True: 22.3k, False: 468k]
  ------------------
  883|  73.5k|    case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (883:5): [True: 44.3k, False: 446k]
  ------------------
  884|  73.5k|      pkt->pkt.public_key = xmalloc_clear (sizeof *pkt->pkt.public_key);
  ------------------
  |  |  116|  73.5k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  885|  73.5k|      rc = parse_key (inp, pkttype, pktlen, hdr, hdrlen, pkt);
  886|  73.5k|      break;
  887|  82.9k|    case PKT_SYMKEY_ENC:
  ------------------
  |  Branch (887:5): [True: 82.9k, False: 407k]
  ------------------
  888|  82.9k|      rc = parse_symkeyenc (inp, pkttype, pktlen, pkt);
  889|  82.9k|      break;
  890|  10.9k|    case PKT_PUBKEY_ENC:
  ------------------
  |  Branch (890:5): [True: 10.9k, False: 479k]
  ------------------
  891|  10.9k|      rc = parse_pubkeyenc (inp, pkttype, pktlen, pkt);
  892|  10.9k|      break;
  893|  52.5k|    case PKT_SIGNATURE:
  ------------------
  |  Branch (893:5): [True: 52.5k, False: 438k]
  ------------------
  894|  52.5k|      pkt->pkt.signature = xmalloc_clear (sizeof *pkt->pkt.signature);
  ------------------
  |  |  116|  52.5k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  895|  52.5k|      rc = parse_signature (inp, pkttype, pktlen, pkt->pkt.signature);
  896|  52.5k|      break;
  897|  4.68k|    case PKT_ONEPASS_SIG:
  ------------------
  |  Branch (897:5): [True: 4.68k, False: 486k]
  ------------------
  898|  4.68k|      pkt->pkt.onepass_sig = xmalloc_clear (sizeof *pkt->pkt.onepass_sig);
  ------------------
  |  |  116|  4.68k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  899|  4.68k|      rc = parse_onepass_sig (inp, pkttype, pktlen, pkt->pkt.onepass_sig);
  900|  4.68k|      break;
  901|  3.75k|    case PKT_USER_ID:
  ------------------
  |  Branch (901:5): [True: 3.75k, False: 487k]
  ------------------
  902|  3.75k|      rc = parse_user_id (inp, pkttype, pktlen, pkt);
  903|  3.75k|      break;
  904|  6.30k|    case PKT_ATTRIBUTE:
  ------------------
  |  Branch (904:5): [True: 6.30k, False: 484k]
  ------------------
  905|  6.30k|      pkt->pkttype = pkttype = PKT_USER_ID;	/* we store it in the userID */
  906|  6.30k|      rc = parse_attribute (inp, pkttype, pktlen, pkt);
  907|  6.30k|      break;
  908|  1.14k|    case PKT_OLD_COMMENT:
  ------------------
  |  Branch (908:5): [True: 1.14k, False: 489k]
  ------------------
  909|  2.06k|    case PKT_COMMENT:
  ------------------
  |  Branch (909:5): [True: 921, False: 489k]
  ------------------
  910|  2.06k|      rc = parse_comment (inp, pkttype, pktlen, pkt);
  911|  2.06k|      break;
  912|  16.4k|    case PKT_RING_TRUST:
  ------------------
  |  Branch (912:5): [True: 16.4k, False: 474k]
  ------------------
  913|  16.4k|      {
  914|  16.4k|        rc = parse_ring_trust (ctx, pktlen);
  915|  16.4k|        if (!rc)
  ------------------
  |  Branch (915:13): [True: 16.4k, False: 0]
  ------------------
  916|  16.4k|          goto again; /* Directly read the next packet.  */
  917|  16.4k|      }
  918|      0|      break;
  919|  10.3k|    case PKT_PLAINTEXT:
  ------------------
  |  Branch (919:5): [True: 10.3k, False: 480k]
  ------------------
  920|  10.3k|      rc = parse_plaintext (inp, pkttype, pktlen, pkt, new_ctb, partial);
  921|  10.3k|      break;
  922|  3.56k|    case PKT_COMPRESSED:
  ------------------
  |  Branch (922:5): [True: 3.56k, False: 487k]
  ------------------
  923|  3.56k|      rc = parse_compressed (inp, pkttype, pktlen, pkt, new_ctb);
  924|  3.56k|      break;
  925|  73.1k|    case PKT_ENCRYPTED:
  ------------------
  |  Branch (925:5): [True: 73.1k, False: 417k]
  ------------------
  926|  94.7k|    case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (926:5): [True: 21.6k, False: 469k]
  ------------------
  927|  94.7k|      rc = parse_encrypted (inp, pkttype, pktlen, pkt, new_ctb, partial);
  928|  94.7k|      break;
  929|  5.07k|    case PKT_MDC:
  ------------------
  |  Branch (929:5): [True: 5.07k, False: 485k]
  ------------------
  930|  5.07k|      rc = parse_mdc (inp, pkttype, pktlen, pkt, new_ctb);
  931|  5.07k|      break;
  932|  66.5k|    case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (932:5): [True: 66.5k, False: 424k]
  ------------------
  933|  66.5k|      rc = parse_encrypted_aead (inp, pkttype, pktlen, pkt, partial);
  934|  66.5k|      break;
  935|  24.1k|    case PKT_GPG_CONTROL:
  ------------------
  |  Branch (935:5): [True: 24.1k, False: 466k]
  ------------------
  936|  24.1k|      rc = parse_gpg_control (inp, pkttype, pktlen, pkt, partial);
  937|  24.1k|      break;
  938|  14.9k|    case PKT_MARKER:
  ------------------
  |  Branch (938:5): [True: 14.9k, False: 475k]
  ------------------
  939|  14.9k|      rc = parse_marker (inp, pkttype, pktlen);
  940|  14.9k|      break;
  941|  18.0k|    default:
  ------------------
  |  Branch (941:5): [True: 18.0k, False: 472k]
  ------------------
  942|       |      /* Unknown packet.  Skip it.  */
  943|  18.0k|      skip_packet (inp, pkttype, pktlen, partial);
  944|  18.0k|      break;
  945|   490k|    }
  946|       |
  947|       |  /* Store a shallow copy of certain packets in the context.  */
  948|   474k|  free_packet (NULL, ctx);
  949|   474k|  if (!rc && (pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (949:7): [True: 281k, False: 192k]
  |  Branch (949:15): [True: 2.31k, False: 279k]
  ------------------
  950|   281k|              || pkttype == PKT_SECRET_KEY
  ------------------
  |  Branch (950:18): [True: 1.76k, False: 277k]
  ------------------
  951|   281k|              || pkttype == PKT_USER_ID
  ------------------
  |  Branch (951:18): [True: 9.47k, False: 268k]
  ------------------
  952|   281k|              || pkttype == PKT_ATTRIBUTE
  ------------------
  |  Branch (952:18): [True: 0, False: 268k]
  ------------------
  953|   281k|              || pkttype == PKT_SIGNATURE))
  ------------------
  |  Branch (953:18): [True: 37.5k, False: 230k]
  ------------------
  954|  51.0k|    {
  955|  51.0k|      ctx->last_pkt = *pkt;
  956|  51.0k|    }
  957|       |
  958|  2.42M| leave:
  959|       |  /* FIXME: We leak in case of an error (see the xmalloc's above).  */
  960|  2.42M|  if (!rc && iobuf_error (inp))
  ------------------
  |  |  454|   285k|#define iobuf_error(a)	      ((a)->error)
  |  |  ------------------
  |  |  |  Branch (454:30): [True: 1.14k, False: 284k]
  |  |  ------------------
  ------------------
  |  Branch (960:7): [True: 285k, False: 2.13M]
  ------------------
  961|  1.14k|    rc = GPG_ERR_INV_KEYRING;
  962|       |
  963|       |  /* FIXME: We use only the error code for now to avoid problems with
  964|       |     callers which have not been checked to always use gpg_err_code()
  965|       |     when comparing error codes.  */
  966|  2.42M|  return rc == -1? -1 : gpg_err_code (rc);
  ------------------
  |  Branch (966:10): [True: 15.0k, False: 2.40M]
  ------------------
  967|   474k|}
parse-packet.c:parse_key:
 2462|  73.5k|{
 2463|  73.5k|  gpg_error_t err = 0;
 2464|  73.5k|  int i, version, algorithm;
 2465|  73.5k|  unsigned long timestamp, expiredate, max_expiredate;
 2466|  73.5k|  int npkey, nskey;
 2467|  73.5k|  u32 keyid[2];
 2468|  73.5k|  PKT_public_key *pk;
 2469|  73.5k|  int is_v5;
 2470|  73.5k|  unsigned int pkbytes; /* For v5 keys: Number of bytes in the public
 2471|       |                         * key material.  For v4 keys: 0.  */
 2472|       |
 2473|  73.5k|  (void) hdr;
 2474|       |
 2475|  73.5k|  pk = pkt->pkt.public_key; /* PK has been cleared. */
 2476|       |
 2477|  73.5k|  version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  73.5k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  73.5k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 73.5k]
  |  |  |  |  |  Branch (500:24): [True: 320, False: 73.2k]
  |  |  |  |  ------------------
  |  |  |  |  501|  73.5k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2478|  73.5k|  pktlen--;
 2479|  73.5k|  if (pkttype == PKT_PUBLIC_SUBKEY && version == '#')
  ------------------
  |  Branch (2479:7): [True: 2.29k, False: 71.2k]
  |  Branch (2479:39): [True: 702, False: 1.58k]
  ------------------
 2480|    702|    {
 2481|       |      /* Early versions of G10 used the old PGP comments packets;
 2482|       |       * luckily all those comments are started by a hash.  */
 2483|    702|      if (list_mode)
  ------------------
  |  Branch (2483:11): [True: 702, False: 0]
  ------------------
 2484|    702|	{
 2485|    702|	  es_fprintf (listfp, ":rfc1991 comment packet: \"");
 2486|   540k|	  for (; pktlen; pktlen--)
  ------------------
  |  Branch (2486:11): [True: 540k, False: 403]
  ------------------
 2487|   540k|	    {
 2488|   540k|	      int c;
 2489|   540k|	      c = iobuf_get (inp);
  ------------------
  |  |  500|   540k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 540k]
  |  |  |  Branch (500:24): [True: 301, False: 540k]
  |  |  ------------------
  |  |  501|   540k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 2490|   540k|              if (c == -1)
  ------------------
  |  Branch (2490:19): [True: 299, False: 540k]
  ------------------
 2491|    299|                break; /* Ooops: shorter than indicated.  */
 2492|   540k|	      if (c >= ' ' && c <= 'z')
  ------------------
  |  Branch (2492:12): [True: 407k, False: 132k]
  |  Branch (2492:24): [True: 336k, False: 70.9k]
  ------------------
 2493|   336k|		es_putc (c, listfp);
 2494|   203k|	      else
 2495|   203k|		es_fprintf (listfp, "\\x%02x", c);
 2496|   540k|	    }
 2497|    702|	  es_fprintf (listfp, "\"\n");
 2498|    702|	}
 2499|    702|      iobuf_skip_rest (inp, pktlen, 0);
 2500|    702|      return 0;
 2501|    702|    }
 2502|  72.8k|  else if (version == 4)
  ------------------
  |  Branch (2502:12): [True: 65.3k, False: 7.53k]
  ------------------
 2503|  65.3k|    is_v5 = 0;
 2504|  7.53k|  else if (version == 5)
  ------------------
  |  Branch (2504:12): [True: 3.51k, False: 4.02k]
  ------------------
 2505|  3.51k|    is_v5 = 1;
 2506|  4.02k|  else if (version == 2 || version == 3)
  ------------------
  |  Branch (2506:12): [True: 387, False: 3.63k]
  |  Branch (2506:28): [True: 365, False: 3.27k]
  ------------------
 2507|    752|    {
 2508|       |      /* Not anymore supported since 2.1.  Use an older gpg version
 2509|       |       * (i.e. gpg 1.4) to parse v3 packets.  */
 2510|    752|      if (opt.verbose > 1 && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (2510:11): [True: 0, False: 752]
  |  Branch (2510:30): [True: 0, False: 0]
  ------------------
 2511|      0|        log_info ("packet(%d) with obsolete version %d\n", pkttype, version);
 2512|    752|      if (list_mode)
  ------------------
  |  Branch (2512:11): [True: 752, False: 0]
  ------------------
 2513|    752|        es_fprintf (listfp, ":key packet: [obsolete version %d]\n", version);
 2514|    752|      pk->version = version;
 2515|    752|      err = gpg_error (GPG_ERR_LEGACY_KEY);
 2516|    752|      goto leave;
 2517|    752|    }
 2518|  3.27k|  else
 2519|  3.27k|    {
 2520|  3.27k|      log_error ("packet(%d) with unknown version %d\n", pkttype, version);
 2521|  3.27k|      if (list_mode)
  ------------------
  |  Branch (2521:11): [True: 3.27k, False: 0]
  ------------------
 2522|  3.27k|        es_fputs (":key packet: [unknown version]\n", listfp);
 2523|  3.27k|      err = gpg_error (GPG_ERR_INV_PACKET);
 2524|  3.27k|      goto leave;
 2525|  3.27k|    }
 2526|       |
 2527|  68.8k|  if (pktlen < (is_v5? 15:11))
  ------------------
  |  Branch (2527:7): [True: 834, False: 67.9k]
  |  Branch (2527:17): [True: 3.51k, False: 65.3k]
  ------------------
 2528|    834|    {
 2529|    834|      log_error ("packet(%d) too short\n", pkttype);
 2530|    834|      if (list_mode)
  ------------------
  |  Branch (2530:11): [True: 834, False: 0]
  ------------------
 2531|    834|        es_fputs (":key packet: [too short]\n", listfp);
 2532|    834|      err = gpg_error (GPG_ERR_INV_PACKET);
 2533|    834|      goto leave;
 2534|    834|    }
 2535|  67.9k|  else if (pktlen > MAX_KEY_PACKET_LENGTH)
  ------------------
  |  |   37|  67.9k|#define MAX_KEY_PACKET_LENGTH     (256 * 1024)
  ------------------
  |  Branch (2535:12): [True: 239, False: 67.7k]
  ------------------
 2536|    239|    {
 2537|    239|      log_error ("packet(%d) too large\n", pkttype);
 2538|    239|      if (list_mode)
  ------------------
  |  Branch (2538:11): [True: 239, False: 0]
  ------------------
 2539|    239|        es_fputs (":key packet: [too large]\n", listfp);
 2540|    239|      err = gpg_error (GPG_ERR_INV_PACKET);
 2541|    239|      goto leave;
 2542|    239|    }
 2543|       |
 2544|  67.7k|  timestamp = read_32 (inp);
 2545|  67.7k|  pktlen -= 4;
 2546|  67.7k|  expiredate = 0;		/* have to get it from the selfsignature */
 2547|  67.7k|  max_expiredate = 0;
 2548|  67.7k|  algorithm = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  67.7k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  67.7k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 67.7k]
  |  |  |  |  |  Branch (500:24): [True: 353, False: 67.4k]
  |  |  |  |  ------------------
  |  |  |  |  501|  67.7k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2549|  67.7k|  pktlen--;
 2550|  67.7k|  if (is_v5)
  ------------------
  |  Branch (2550:7): [True: 3.28k, False: 64.4k]
  ------------------
 2551|  3.28k|    {
 2552|  3.28k|      pkbytes = read_32 (inp);
 2553|  3.28k|      pktlen -= 4;
 2554|  3.28k|    }
 2555|  64.4k|  else
 2556|  64.4k|    pkbytes = 0;
 2557|       |
 2558|  67.7k|  if (list_mode)
  ------------------
  |  Branch (2558:7): [True: 67.7k, False: 0]
  ------------------
 2559|  67.7k|    {
 2560|  67.7k|      es_fprintf (listfp, ":%s key packet:\n"
 2561|  67.7k|                  "\tversion %d, algo %d, created %lu, expires %lu",
 2562|  67.7k|                  pkttype == PKT_PUBLIC_KEY ? "public" :
  ------------------
  |  Branch (2562:19): [True: 3.43k, False: 64.3k]
  ------------------
 2563|  67.7k|                  pkttype == PKT_SECRET_KEY ? "secret" :
  ------------------
  |  Branch (2563:19): [True: 21.5k, False: 42.7k]
  ------------------
 2564|  64.3k|                  pkttype == PKT_PUBLIC_SUBKEY ? "public sub" :
  ------------------
  |  Branch (2564:19): [True: 734, False: 42.0k]
  ------------------
 2565|  42.7k|                  pkttype == PKT_SECRET_SUBKEY ? "secret sub" : "??",
  ------------------
  |  Branch (2565:19): [True: 42.0k, False: 0]
  ------------------
 2566|  67.7k|                  version, algorithm, timestamp, expiredate);
 2567|  67.7k|      if (is_v5)
  ------------------
  |  Branch (2567:11): [True: 3.28k, False: 64.4k]
  ------------------
 2568|  3.28k|        es_fprintf (listfp, ", pkbytes %u\n", pkbytes);
 2569|  64.4k|      else
 2570|  64.4k|        es_fprintf (listfp, "\n");
 2571|  67.7k|    }
 2572|       |
 2573|  67.7k|  pk->timestamp = timestamp;
 2574|  67.7k|  pk->expiredate = expiredate;
 2575|  67.7k|  pk->max_expiredate = max_expiredate;
 2576|  67.7k|  pk->hdrbytes = hdrlen;
 2577|  67.7k|  pk->version = version;
 2578|  67.7k|  pk->flags.primary = (pkttype == PKT_PUBLIC_KEY || pkttype == PKT_SECRET_KEY);
  ------------------
  |  Branch (2578:24): [True: 3.43k, False: 64.3k]
  |  Branch (2578:53): [True: 21.5k, False: 42.7k]
  ------------------
 2579|  67.7k|  pk->pubkey_algo = algorithm;
 2580|       |
 2581|  67.7k|  nskey = pubkey_get_nskey (algorithm);
 2582|  67.7k|  npkey = pubkey_get_npkey (algorithm);
 2583|  67.7k|  if (!npkey)
  ------------------
  |  Branch (2583:7): [True: 12.3k, False: 55.4k]
  ------------------
 2584|  12.3k|    {
 2585|  12.3k|      if (list_mode)
  ------------------
  |  Branch (2585:11): [True: 12.3k, False: 0]
  ------------------
 2586|  12.3k|	es_fprintf (listfp, "\tunknown algorithm %d\n", algorithm);
 2587|  12.3k|      unknown_pubkey_warning (algorithm);
 2588|  12.3k|    }
 2589|       |
 2590|  67.7k|  if (!npkey)
  ------------------
  |  Branch (2590:7): [True: 12.3k, False: 55.4k]
  ------------------
 2591|  12.3k|    {
 2592|       |      /* Unknown algorithm - put data into an opaque MPI.  */
 2593|  12.3k|      void *tmpp = read_rest (inp, pktlen);
 2594|       |      /* Current gcry_mpi_cmp does not handle a (NULL,n>0) nicely and
 2595|       |       * thus we avoid to create such an MPI.  */
 2596|  12.3k|      pk->pkey[0] = gcry_mpi_set_opaque (NULL, tmpp, tmpp? pktlen * 8 : 0);
  ------------------
  |  Branch (2596:54): [True: 11.8k, False: 538]
  ------------------
 2597|  12.3k|      pktlen = 0;
 2598|  12.3k|      goto leave;
 2599|  12.3k|    }
 2600|  55.4k|  else
 2601|  55.4k|    {
 2602|   155k|      for (i = 0; i < npkey; i++)
  ------------------
  |  Branch (2602:19): [True: 109k, False: 46.2k]
  ------------------
 2603|   109k|        {
 2604|   109k|          if (    (algorithm == PUBKEY_ALGO_ECDSA && (i == 0))
  ------------------
  |  Branch (2604:20): [True: 23.7k, False: 85.6k]
  |  Branch (2604:54): [True: 12.2k, False: 11.5k]
  ------------------
 2605|   109k|               || (algorithm == PUBKEY_ALGO_EDDSA && (i == 0))
  ------------------
  |  Branch (2605:20): [True: 9.23k, False: 87.9k]
  |  Branch (2605:54): [True: 4.77k, False: 4.46k]
  ------------------
 2606|   109k|               || (algorithm == PUBKEY_ALGO_ECDH  && (i == 0 || i == 2)))
  ------------------
  |  Branch (2606:20): [True: 4.94k, False: 87.4k]
  |  Branch (2606:55): [True: 2.21k, False: 2.72k]
  |  Branch (2606:65): [True: 650, False: 2.07k]
  ------------------
 2607|  19.8k|            {
 2608|       |              /* Read the OID (i==0) or the KDF params (i==2).  */
 2609|  19.8k|              size_t n;
 2610|  19.8k|	      err = read_size_body (inp, pktlen, &n, pk->pkey+i);
 2611|  19.8k|              pktlen -= n;
 2612|  19.8k|            }
 2613|  89.5k|          else
 2614|  89.5k|            {
 2615|  89.5k|              unsigned int n = pktlen;
 2616|  89.5k|              if (algorithm == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (2616:19): [True: 11.5k, False: 78.0k]
  ------------------
 2617|  89.5k|                  || algorithm == PUBKEY_ALGO_EDDSA
  ------------------
  |  Branch (2617:22): [True: 4.46k, False: 73.5k]
  ------------------
 2618|  89.5k|                  || algorithm == PUBKEY_ALGO_ECDH)
  ------------------
  |  Branch (2618:22): [True: 2.07k, False: 71.5k]
  ------------------
 2619|  18.0k|                pk->pkey[i] = sos_read (inp, &n, 0);
 2620|  71.5k|              else
 2621|  71.5k|                pk->pkey[i] = mpi_read (inp, &n, 0);
 2622|  89.5k|              pktlen -= n;
 2623|  89.5k|              if (!pk->pkey[i])
  ------------------
  |  Branch (2623:19): [True: 7.42k, False: 82.1k]
  ------------------
 2624|  7.42k|                err = gpg_error (GPG_ERR_INV_PACKET);
 2625|  89.5k|            }
 2626|   109k|          if (err)
  ------------------
  |  Branch (2626:15): [True: 9.14k, False: 100k]
  ------------------
 2627|  9.14k|            goto leave;
 2628|   100k|          if (list_mode)
  ------------------
  |  Branch (2628:15): [True: 100k, False: 0]
  ------------------
 2629|   100k|            {
 2630|   100k|              es_fprintf (listfp, "\tpkey[%d]: ", i);
 2631|   100k|              mpi_print (listfp, pk->pkey[i], mpi_print_mode);
 2632|   100k|              if ((algorithm == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (2632:20): [True: 20.1k, False: 80.1k]
  ------------------
 2633|   100k|                   || algorithm == PUBKEY_ALGO_EDDSA
  ------------------
  |  Branch (2633:23): [True: 7.94k, False: 72.2k]
  ------------------
 2634|   100k|                   || algorithm == PUBKEY_ALGO_ECDH) && i==0)
  ------------------
  |  Branch (2634:23): [True: 2.84k, False: 69.3k]
  |  Branch (2634:57): [True: 18.0k, False: 12.8k]
  ------------------
 2635|  18.0k|                {
 2636|  18.0k|                  char *curve = openpgp_oid_to_str (pk->pkey[0]);
 2637|  18.0k|                  const char *name = openpgp_oid_to_curve (curve, 0);
 2638|  18.0k|                  es_fprintf (listfp, " %s (%s)", name?name:"", curve);
  ------------------
  |  Branch (2638:51): [True: 2.20k, False: 15.8k]
  ------------------
 2639|  18.0k|                  xfree (curve);
  ------------------
  |  |  104|  18.0k|#define xfree(a)         gcry_free ((a))
  ------------------
 2640|  18.0k|                }
 2641|   100k|              es_putc ('\n', listfp);
 2642|   100k|            }
 2643|   100k|        }
 2644|  55.4k|    }
 2645|  46.2k|  if (list_mode)
  ------------------
  |  Branch (2645:7): [True: 46.2k, False: 0]
  ------------------
 2646|  46.2k|    keyid_from_pk (pk, keyid);
 2647|       |
 2648|  46.2k|  if (pkttype == PKT_SECRET_KEY || pkttype == PKT_SECRET_SUBKEY)
  ------------------
  |  Branch (2648:7): [True: 16.8k, False: 29.4k]
  |  Branch (2648:36): [True: 27.8k, False: 1.60k]
  ------------------
 2649|  44.6k|    {
 2650|  44.6k|      struct seckey_info *ski;
 2651|  44.6k|      byte temp[16];
 2652|  44.6k|      size_t snlen = 0;
 2653|  44.6k|      unsigned int skbytes;
 2654|       |
 2655|  44.6k|      if (pktlen < 1)
  ------------------
  |  Branch (2655:11): [True: 4.73k, False: 39.9k]
  ------------------
 2656|  4.73k|        {
 2657|  4.73k|          err = gpg_error (GPG_ERR_INV_PACKET);
 2658|  4.73k|          goto leave;
 2659|  4.73k|        }
 2660|       |
 2661|  39.9k|      pk->seckey_info = ski = xtrycalloc (1, sizeof *ski);
  ------------------
  |  |   99|  39.9k|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
 2662|  39.9k|      if (!pk->seckey_info)
  ------------------
  |  Branch (2662:11): [True: 0, False: 39.9k]
  ------------------
 2663|      0|        {
 2664|      0|          err = gpg_error_from_syserror ();
 2665|      0|          goto leave;
 2666|      0|        }
 2667|       |
 2668|  39.9k|      ski->algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  39.9k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  39.9k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 39.9k]
  |  |  |  |  |  Branch (500:24): [True: 653, False: 39.2k]
  |  |  |  |  ------------------
  |  |  |  |  501|  39.9k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2669|  39.9k|      pktlen--;
 2670|       |
 2671|  39.9k|      if (is_v5)
  ------------------
  |  Branch (2671:11): [True: 2.24k, False: 37.6k]
  ------------------
 2672|  2.24k|        {
 2673|  2.24k|          unsigned int protcount = 0;
 2674|       |
 2675|       |          /* Read the one octet count of the following key-protection
 2676|       |           * material.  Only required in case of unknown values. */
 2677|  2.24k|          if (!pktlen)
  ------------------
  |  Branch (2677:15): [True: 732, False: 1.51k]
  ------------------
 2678|    732|            {
 2679|    732|              err = gpg_error (GPG_ERR_INV_PACKET);
 2680|    732|              goto leave;
 2681|    732|            }
 2682|  1.51k|          protcount = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.51k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.51k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.51k]
  |  |  |  |  |  Branch (500:24): [True: 262, False: 1.25k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.51k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2683|  1.51k|          pktlen--;
 2684|  1.51k|          if (list_mode)
  ------------------
  |  Branch (2684:15): [True: 1.51k, False: 0]
  ------------------
 2685|  1.51k|            es_fprintf (listfp, "\tprotbytes: %u\n", protcount);
 2686|  1.51k|        }
 2687|       |
 2688|  39.2k|      if (ski->algo)
  ------------------
  |  Branch (2688:11): [True: 29.0k, False: 10.1k]
  ------------------
 2689|  29.0k|	{
 2690|  29.0k|	  ski->is_protected = 1;
 2691|  29.0k|	  ski->s2k.count = 0;
 2692|  29.0k|	  if (ski->algo == 254 || ski->algo == 255)
  ------------------
  |  Branch (2692:8): [True: 2.65k, False: 26.3k]
  |  Branch (2692:28): [True: 16.7k, False: 9.65k]
  ------------------
 2693|  19.3k|	    {
 2694|  19.3k|              if (pktlen < 3)
  ------------------
  |  Branch (2694:19): [True: 7.30k, False: 12.0k]
  ------------------
 2695|  7.30k|		{
 2696|  7.30k|		  err = gpg_error (GPG_ERR_INV_PACKET);
 2697|  7.30k|		  goto leave;
 2698|  7.30k|		}
 2699|       |
 2700|  12.0k|              ski->sha1chk = (ski->algo == 254);
 2701|  12.0k|	      ski->algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  12.0k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  12.0k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 12.0k]
  |  |  |  |  |  Branch (500:24): [True: 291, False: 11.7k]
  |  |  |  |  ------------------
  |  |  |  |  501|  12.0k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2702|  12.0k|	      pktlen--;
 2703|       |	      /* Note that a ski->algo > 110 is illegal, but I'm not
 2704|       |	       * erroring out here as otherwise there would be no way
 2705|       |	       * to delete such a key.  */
 2706|  12.0k|	      ski->s2k.mode = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  12.0k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  12.0k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 12.0k]
  |  |  |  |  |  Branch (500:24): [True: 305, False: 11.7k]
  |  |  |  |  ------------------
  |  |  |  |  501|  12.0k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2707|  12.0k|	      pktlen--;
 2708|  12.0k|	      ski->s2k.hash_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  12.0k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  12.0k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 12.0k]
  |  |  |  |  |  Branch (500:24): [True: 576, False: 11.4k]
  |  |  |  |  ------------------
  |  |  |  |  501|  12.0k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2709|  12.0k|	      pktlen--;
 2710|       |	      /* Check for the special GNU extension.  */
 2711|  12.0k|	      if (ski->s2k.mode == 101)
  ------------------
  |  Branch (2711:12): [True: 5.63k, False: 6.42k]
  ------------------
 2712|  5.63k|		{
 2713|  27.5k|		  for (i = 0; i < 4 && pktlen; i++, pktlen--)
  ------------------
  |  Branch (2713:17): [True: 22.3k, False: 5.19k]
  |  Branch (2713:26): [True: 21.8k, False: 444]
  ------------------
 2714|  21.8k|		    temp[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  21.8k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  21.8k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 21.8k]
  |  |  |  |  |  Branch (500:24): [True: 282, False: 21.6k]
  |  |  |  |  ------------------
  |  |  |  |  501|  21.8k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2715|  5.63k|		  if (i < 4 || memcmp (temp, "GNU", 3))
  ------------------
  |  Branch (2715:9): [True: 444, False: 5.19k]
  |  Branch (2715:18): [True: 638, False: 4.55k]
  ------------------
 2716|  1.08k|		    {
 2717|  1.08k|		      if (list_mode)
  ------------------
  |  Branch (2717:13): [True: 1.08k, False: 0]
  ------------------
 2718|  1.08k|			es_fprintf (listfp, "\tunknown S2K %d\n",
 2719|  1.08k|                                    ski->s2k.mode);
 2720|  1.08k|		      err = gpg_error (GPG_ERR_INV_PACKET);
 2721|  1.08k|		      goto leave;
 2722|  1.08k|		    }
 2723|       |		  /* Here we know that it is a GNU extension.  What
 2724|       |		   * follows is the GNU protection mode: All values
 2725|       |		   * have special meanings and they are mapped to MODE
 2726|       |		   * with a base of 1000.  */
 2727|  4.55k|		  ski->s2k.mode = 1000 + temp[3];
 2728|  4.55k|		}
 2729|       |
 2730|       |              /* Read the salt.  */
 2731|  10.9k|	      if (ski->s2k.mode == 3 || ski->s2k.mode == 1)
  ------------------
  |  Branch (2731:12): [True: 3.07k, False: 7.90k]
  |  Branch (2731:34): [True: 948, False: 6.95k]
  ------------------
 2732|  4.02k|		{
 2733|  33.9k|		  for (i = 0; i < 8 && pktlen; i++, pktlen--)
  ------------------
  |  Branch (2733:17): [True: 30.3k, False: 3.63k]
  |  Branch (2733:26): [True: 29.9k, False: 388]
  ------------------
 2734|  29.9k|		    temp[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  29.9k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  29.9k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 29.9k]
  |  |  |  |  |  Branch (500:24): [True: 600, False: 29.3k]
  |  |  |  |  ------------------
  |  |  |  |  501|  29.9k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2735|  4.02k|                  if (i < 8)
  ------------------
  |  Branch (2735:23): [True: 388, False: 3.63k]
  ------------------
 2736|    388|                    {
 2737|    388|		      err = gpg_error (GPG_ERR_INV_PACKET);
 2738|    388|		      goto leave;
 2739|    388|                    }
 2740|  3.63k|		  memcpy (ski->s2k.salt, temp, 8);
 2741|  3.63k|		}
 2742|       |
 2743|       |              /* Check the mode.  */
 2744|  10.5k|	      switch (ski->s2k.mode)
 2745|  10.5k|		{
 2746|    823|		case 0:
  ------------------
  |  Branch (2746:3): [True: 823, False: 9.76k]
  ------------------
 2747|    823|		  if (list_mode)
  ------------------
  |  Branch (2747:9): [True: 823, False: 0]
  ------------------
 2748|    823|		    es_fprintf (listfp, "\tsimple S2K");
 2749|    823|		  break;
 2750|    594|		case 1:
  ------------------
  |  Branch (2750:3): [True: 594, False: 9.99k]
  ------------------
 2751|    594|		  if (list_mode)
  ------------------
  |  Branch (2751:9): [True: 594, False: 0]
  ------------------
 2752|    594|		    es_fprintf (listfp, "\tsalted S2K");
 2753|    594|		  break;
 2754|  3.04k|		case 3:
  ------------------
  |  Branch (2754:3): [True: 3.04k, False: 7.54k]
  ------------------
 2755|  3.04k|		  if (list_mode)
  ------------------
  |  Branch (2755:9): [True: 3.04k, False: 0]
  ------------------
 2756|  3.04k|		    es_fprintf (listfp, "\titer+salt S2K");
 2757|  3.04k|		  break;
 2758|    267|		case 1001:
  ------------------
  |  Branch (2758:3): [True: 267, False: 10.3k]
  ------------------
 2759|    267|		  if (list_mode)
  ------------------
  |  Branch (2759:9): [True: 267, False: 0]
  ------------------
 2760|    267|		    es_fprintf (listfp, "\tgnu-dummy");
 2761|    267|		  break;
 2762|  3.54k|		case 1002:
  ------------------
  |  Branch (2762:3): [True: 3.54k, False: 7.04k]
  ------------------
 2763|  3.54k|		  if (list_mode)
  ------------------
  |  Branch (2763:9): [True: 3.54k, False: 0]
  ------------------
 2764|  3.54k|		    es_fprintf (listfp, "\tgnu-divert-to-card");
 2765|  3.54k|		  break;
 2766|    511|		case 1003:
  ------------------
  |  Branch (2766:3): [True: 511, False: 10.0k]
  ------------------
 2767|    511|		  if (list_mode)
  ------------------
  |  Branch (2767:9): [True: 511, False: 0]
  ------------------
 2768|    511|		    es_fprintf (listfp, "\tgnu-mode1003");
 2769|    511|		  break;
 2770|  1.80k|		default:
  ------------------
  |  Branch (2770:3): [True: 1.80k, False: 8.78k]
  ------------------
 2771|  1.80k|		  if (list_mode)
  ------------------
  |  Branch (2771:9): [True: 1.80k, False: 0]
  ------------------
 2772|  1.80k|		    es_fprintf (listfp, "\tunknown %sS2K %d\n",
 2773|  1.80k|                                ski->s2k.mode < 1000 ? "" : "GNU ",
  ------------------
  |  Branch (2773:33): [True: 1.57k, False: 231]
  ------------------
 2774|  1.80k|                                ski->s2k.mode);
 2775|  1.80k|		  err = gpg_error (GPG_ERR_INV_PACKET);
 2776|  1.80k|		  goto leave;
 2777|  10.5k|		}
 2778|       |
 2779|       |              /* Print some info.  */
 2780|  8.78k|	      if (list_mode && ski->s2k.mode != 1003)
  ------------------
  |  Branch (2780:12): [True: 8.78k, False: 0]
  |  Branch (2780:25): [True: 8.27k, False: 511]
  ------------------
 2781|  8.27k|		{
 2782|  8.27k|		  es_fprintf (listfp, ", algo: %d,%s hash: %d",
 2783|  8.27k|                              ski->algo,
 2784|  8.27k|                              ski->sha1chk ? " SHA1 protection,"
  ------------------
  |  Branch (2784:31): [True: 1.15k, False: 7.11k]
  ------------------
 2785|  8.27k|                              : " simple checksum,", ski->s2k.hash_algo);
 2786|  8.27k|		  if (ski->s2k.mode == 1 || ski->s2k.mode == 3)
  ------------------
  |  Branch (2786:9): [True: 594, False: 7.67k]
  |  Branch (2786:31): [True: 3.04k, False: 4.63k]
  ------------------
 2787|  3.63k|		    {
 2788|  3.63k|		      es_fprintf (listfp, ", salt: ");
 2789|  3.63k|                      es_write_hexstring (listfp, ski->s2k.salt, 8, 0, NULL);
 2790|  3.63k|		    }
 2791|  8.27k|                }
 2792|  8.78k|              if (list_mode)
  ------------------
  |  Branch (2792:19): [True: 8.78k, False: 0]
  ------------------
 2793|  8.78k|                es_putc ('\n', listfp);
 2794|       |
 2795|       |              /* Read remaining protection parameters.  */
 2796|  8.78k|	      if (ski->s2k.mode == 3)
  ------------------
  |  Branch (2796:12): [True: 3.04k, False: 5.74k]
  ------------------
 2797|  3.04k|		{
 2798|  3.04k|		  if (pktlen < 1)
  ------------------
  |  Branch (2798:9): [True: 243, False: 2.79k]
  ------------------
 2799|    243|		    {
 2800|    243|		      err = gpg_error (GPG_ERR_INV_PACKET);
 2801|    243|		      goto leave;
 2802|    243|		    }
 2803|  2.79k|		  ski->s2k.count = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  2.79k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  2.79k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 2.79k]
  |  |  |  |  |  Branch (500:24): [True: 242, False: 2.55k]
  |  |  |  |  ------------------
  |  |  |  |  501|  2.79k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2804|  2.79k|		  pktlen--;
 2805|  2.79k|		  if (list_mode)
  ------------------
  |  Branch (2805:9): [True: 2.79k, False: 0]
  ------------------
 2806|  2.79k|		    es_fprintf (listfp, "\tprotect count: %lu (%lu)\n",
 2807|  2.79k|                                (ulong)S2K_DECODE_COUNT ((ulong)ski->s2k.count),
  ------------------
  |  |  210|  2.79k|#define S2K_DECODE_COUNT(_val) ((16ul + ((_val) & 15)) << (((_val) >> 4) + 6))
  ------------------
 2808|  2.79k|                                (ulong) ski->s2k.count);
 2809|  2.79k|		}
 2810|  5.74k|	      else if (ski->s2k.mode == 1002)
  ------------------
  |  Branch (2810:17): [True: 3.54k, False: 2.19k]
  ------------------
 2811|  3.54k|		{
 2812|       |		  /* Read the serial number. */
 2813|  3.54k|		  if (pktlen < 1)
  ------------------
  |  Branch (2813:9): [True: 396, False: 3.15k]
  ------------------
 2814|    396|		    {
 2815|    396|		      err = gpg_error (GPG_ERR_INV_PACKET);
 2816|    396|		      goto leave;
 2817|    396|		    }
 2818|  3.15k|		  snlen = iobuf_get (inp);
  ------------------
  |  |  500|  3.15k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 3.15k]
  |  |  |  Branch (500:24): [True: 481, False: 2.66k]
  |  |  ------------------
  |  |  501|  3.15k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 2819|  3.15k|		  pktlen--;
 2820|  3.15k|		  if (pktlen < snlen || snlen == (size_t)(-1))
  ------------------
  |  Branch (2820:9): [True: 2.12k, False: 1.02k]
  |  Branch (2820:27): [True: 0, False: 1.02k]
  ------------------
 2821|  2.12k|		    {
 2822|  2.12k|		      err = gpg_error (GPG_ERR_INV_PACKET);
 2823|  2.12k|		      goto leave;
 2824|  2.12k|		    }
 2825|  3.15k|		}
 2826|  8.78k|	    }
 2827|  9.65k|	  else /* Old version; no S2K, so we set mode to 0, hash MD5.  */
 2828|  9.65k|	    {
 2829|       |              /* Note that a ski->algo > 110 is illegal, but I'm not
 2830|       |                 erroring on it here as otherwise there would be no
 2831|       |                 way to delete such a key.  */
 2832|  9.65k|	      ski->s2k.mode = 0;
 2833|  9.65k|	      ski->s2k.hash_algo = DIGEST_ALGO_MD5;
 2834|  9.65k|	      if (list_mode)
  ------------------
  |  Branch (2834:12): [True: 9.65k, False: 0]
  ------------------
 2835|  9.65k|		es_fprintf (listfp, "\tprotect algo: %d  (hash algo: %d)\n",
 2836|  9.65k|                            ski->algo, ski->s2k.hash_algo);
 2837|  9.65k|	    }
 2838|       |
 2839|       |	  /* It is really ugly that we don't know the size
 2840|       |	   * of the IV here in cases we are not aware of the algorithm.
 2841|       |	   * so a
 2842|       |	   *   ski->ivlen = cipher_get_blocksize (ski->algo);
 2843|       |	   * won't work.  The only solution I see is to hardwire it.
 2844|       |	   * NOTE: if you change the ivlen above 16, don't forget to
 2845|       |	   * enlarge temp.
 2846|       |           * FIXME: For v5 keys we can deduce this info!
 2847|       |           */
 2848|  15.6k|	  ski->ivlen = openpgp_cipher_blocklen (ski->algo);
 2849|  15.6k|	  log_assert (ski->ivlen <= sizeof (temp));
 2850|       |
 2851|  15.6k|	  if (ski->s2k.mode == 1001 || ski->s2k.mode == 1003)
  ------------------
  |  Branch (2851:8): [True: 267, False: 15.4k]
  |  Branch (2851:33): [True: 511, False: 14.8k]
  ------------------
 2852|    778|	    ski->ivlen = 0;
 2853|  14.8k|	  else if (ski->s2k.mode == 1002)
  ------------------
  |  Branch (2853:13): [True: 1.02k, False: 13.8k]
  ------------------
 2854|  1.02k|	    ski->ivlen = snlen < 16 ? snlen : 16;
  ------------------
  |  Branch (2854:19): [True: 325, False: 701]
  ------------------
 2855|       |
 2856|  15.6k|	  if (pktlen < ski->ivlen)
  ------------------
  |  Branch (2856:8): [True: 5.72k, False: 9.95k]
  ------------------
 2857|  5.72k|	    {
 2858|  5.72k|              err = gpg_error (GPG_ERR_INV_PACKET);
 2859|  5.72k|	      goto leave;
 2860|  5.72k|	    }
 2861|  86.8k|	  for (i = 0; i < ski->ivlen; i++, pktlen--)
  ------------------
  |  Branch (2861:16): [True: 76.8k, False: 9.95k]
  ------------------
 2862|  76.8k|	    temp[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  86.8k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  76.8k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 76.8k]
  |  |  |  |  |  Branch (500:24): [True: 1.34k, False: 75.5k]
  |  |  |  |  ------------------
  |  |  |  |  501|  76.8k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2863|  9.95k|	  if (list_mode && ski->s2k.mode != 1003)
  ------------------
  |  Branch (2863:8): [True: 9.95k, False: 0]
  |  Branch (2863:21): [True: 9.44k, False: 511]
  ------------------
 2864|  9.44k|	    {
 2865|  9.44k|	      es_fprintf (listfp,
 2866|  9.44k|                          ski->s2k.mode == 1002 ? "\tserial-number: "
  ------------------
  |  Branch (2866:27): [True: 1.02k, False: 8.41k]
  ------------------
 2867|  9.44k|                          : "\tprotect IV: ");
 2868|  86.2k|	      for (i = 0; i < ski->ivlen; i++)
  ------------------
  |  Branch (2868:20): [True: 76.8k, False: 9.44k]
  ------------------
 2869|  76.8k|		es_fprintf (listfp, " %02x", temp[i]);
 2870|  9.44k|	      es_putc ('\n', listfp);
 2871|  9.44k|	    }
 2872|  9.95k|	  memcpy (ski->iv, temp, ski->ivlen);
 2873|  9.95k|	}
 2874|       |
 2875|       |      /* Skip count of secret key material.  */
 2876|  20.1k|      if (is_v5)
  ------------------
  |  Branch (2876:11): [True: 1.17k, False: 18.9k]
  ------------------
 2877|  1.17k|        {
 2878|  1.17k|          if (pktlen < 4)
  ------------------
  |  Branch (2878:15): [True: 730, False: 449]
  ------------------
 2879|    730|            {
 2880|    730|              err = gpg_error (GPG_ERR_INV_PACKET);
 2881|    730|              goto leave;
 2882|    730|            }
 2883|    449|          skbytes = read_32 (inp);
 2884|    449|          pktlen -= 4;
 2885|    449|          if (list_mode)
  ------------------
  |  Branch (2885:15): [True: 449, False: 0]
  ------------------
 2886|    449|            es_fprintf (listfp, "\tskbytes: %u\n", skbytes);
 2887|    449|        }
 2888|       |
 2889|       |      /* It does not make sense to read it into secure memory.
 2890|       |       * If the user is so careless, not to protect his secret key,
 2891|       |       * we can assume, that he operates an open system :=(.
 2892|       |       * So we put the key into secure memory when we unprotect it. */
 2893|  19.4k|      if (ski->s2k.mode == 1001 || ski->s2k.mode == 1002)
  ------------------
  |  Branch (2893:11): [True: 267, False: 19.1k]
  |  Branch (2893:36): [True: 1.02k, False: 18.1k]
  ------------------
 2894|  1.29k|	{
 2895|       |	  /* Better set some dummy stuff here.  */
 2896|  1.29k|	  pk->pkey[npkey] = gcry_mpi_set_opaque (NULL,
 2897|  1.29k|						 xstrdup ("dummydata"),
  ------------------
  |  |  112|  1.29k|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 2898|  1.29k|						 10 * 8);
 2899|  1.29k|	  pktlen = 0;
 2900|  1.29k|	}
 2901|  18.1k|      else if (ski->s2k.mode == 1003)
  ------------------
  |  Branch (2901:16): [True: 511, False: 17.6k]
  ------------------
 2902|    511|	{
 2903|    511|          void *tmpp;
 2904|       |
 2905|    511|	  if (pktlen < 2) /* At least two bytes for parenthesis.  */
  ------------------
  |  Branch (2905:8): [True: 210, False: 301]
  ------------------
 2906|    210|	    {
 2907|    210|              err = gpg_error (GPG_ERR_INV_PACKET);
 2908|    210|	      goto leave;
 2909|    210|	    }
 2910|       |
 2911|    301|          tmpp = read_rest (inp, pktlen);
 2912|    301|          if (list_mode)
  ------------------
  |  Branch (2912:15): [True: 301, False: 0]
  ------------------
 2913|    301|            {
 2914|    301|              if (mpi_print_mode)
  ------------------
  |  Branch (2914:19): [True: 0, False: 301]
  ------------------
 2915|      0|                {
 2916|      0|                  char *tmpsxp = canon_sexp_to_string (tmpp, pktlen);
 2917|      0|                  es_fprintf (listfp, "\tskey[%d]: %s\n", npkey,
 2918|      0|                              tmpsxp? trim_trailing_spaces (tmpsxp)
  ------------------
  |  Branch (2918:31): [True: 0, False: 0]
  ------------------
 2919|      0|                              /*  */: "[invalid S-expression]");
 2920|      0|                  xfree (tmpsxp);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2921|      0|                }
 2922|    301|              else
 2923|    301|                es_fprintf (listfp, "\tskey[%d]: [s-expression %lu octets]\n",
 2924|    301|                            npkey, pktlen);
 2925|    301|            }
 2926|    301|	  pk->pkey[npkey] = gcry_mpi_set_opaque (NULL,
 2927|    301|						 tmpp, tmpp? pktlen * 8 : 0);
  ------------------
  |  Branch (2927:14): [True: 210, False: 91]
  ------------------
 2928|    301|          pktlen = 0;
 2929|    301|	}
 2930|  17.6k|      else if (ski->is_protected)
  ------------------
  |  Branch (2930:16): [True: 7.70k, False: 9.90k]
  ------------------
 2931|  7.70k|	{
 2932|  7.70k|          void *tmpp;
 2933|       |
 2934|  7.70k|	  if (pktlen < 2) /* At least two bytes for the length.  */
  ------------------
  |  Branch (2934:8): [True: 804, False: 6.89k]
  ------------------
 2935|    804|	    {
 2936|    804|              err = gpg_error (GPG_ERR_INV_PACKET);
 2937|    804|	      goto leave;
 2938|    804|	    }
 2939|       |
 2940|       |	  /* Ugly: The length is encrypted too, so we read all stuff
 2941|       |	   * up to the end of the packet into the first SKEY
 2942|       |	   * element.
 2943|       |           * FIXME: We can do better for v5 keys.  */
 2944|       |
 2945|  6.89k|          tmpp = read_rest (inp, pktlen);
 2946|  6.89k|	  pk->pkey[npkey] = gcry_mpi_set_opaque (NULL,
 2947|  6.89k|						 tmpp, tmpp? pktlen * 8 : 0);
  ------------------
  |  Branch (2947:14): [True: 6.58k, False: 311]
  ------------------
 2948|       |          /* Mark that MPI as protected - we need this information for
 2949|       |           * importing a key.  The OPAQUE flag can't be used because
 2950|       |           * we also store public EdDSA values in opaque MPIs.  */
 2951|  6.89k|          if (pk->pkey[npkey])
  ------------------
  |  Branch (2951:15): [True: 6.89k, False: 0]
  ------------------
 2952|  6.89k|            gcry_mpi_set_flag (pk->pkey[npkey], GCRYMPI_FLAG_USER1);
 2953|  6.89k|	  pktlen = 0;
 2954|  6.89k|	  if (list_mode)
  ------------------
  |  Branch (2954:8): [True: 6.89k, False: 0]
  ------------------
 2955|  6.89k|            es_fprintf (listfp, "\tskey[%d]: [v4 protected]\n", npkey);
 2956|  6.89k|	}
 2957|  9.90k|      else
 2958|  9.90k|	{
 2959|       |          /* Not encrypted.  */
 2960|  17.1k|	  for (i = npkey; i < nskey; i++)
  ------------------
  |  Branch (2960:20): [True: 15.4k, False: 1.69k]
  ------------------
 2961|  15.4k|	    {
 2962|  15.4k|              unsigned int n;
 2963|       |
 2964|  15.4k|              if (pktlen < 2) /* At least two bytes for the length.  */
  ------------------
  |  Branch (2964:19): [True: 8.20k, False: 7.20k]
  ------------------
 2965|  8.20k|                {
 2966|  8.20k|                  err = gpg_error (GPG_ERR_INV_PACKET);
 2967|  8.20k|                  goto leave;
 2968|  8.20k|                }
 2969|  7.20k|              n = pktlen;
 2970|  7.20k|              if (algorithm == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (2970:19): [True: 267, False: 6.93k]
  ------------------
 2971|  7.20k|                  || algorithm == PUBKEY_ALGO_EDDSA
  ------------------
  |  Branch (2971:22): [True: 200, False: 6.73k]
  ------------------
 2972|  7.20k|                  || algorithm == PUBKEY_ALGO_ECDH)
  ------------------
  |  Branch (2972:22): [True: 68, False: 6.66k]
  ------------------
 2973|    535|                pk->pkey[i] = sos_read (inp, &n, 0);
 2974|  6.66k|              else
 2975|  6.66k|                pk->pkey[i] = mpi_read (inp, &n, 0);
 2976|  7.20k|              pktlen -= n;
 2977|  7.20k|              if (list_mode)
  ------------------
  |  Branch (2977:19): [True: 7.20k, False: 0]
  ------------------
 2978|  7.20k|                {
 2979|  7.20k|                  es_fprintf (listfp, "\tskey[%d]: ", i);
 2980|  7.20k|                  mpi_print (listfp, pk->pkey[i], mpi_print_mode);
 2981|  7.20k|                  es_putc ('\n', listfp);
 2982|  7.20k|                }
 2983|       |
 2984|  7.20k|	      if (!pk->pkey[i])
  ------------------
  |  Branch (2984:12): [True: 3.76k, False: 3.43k]
  ------------------
 2985|  3.76k|		err = gpg_error (GPG_ERR_INV_PACKET);
 2986|  7.20k|	    }
 2987|  1.69k|	  if (err)
  ------------------
  |  Branch (2987:8): [True: 1.09k, False: 605]
  ------------------
 2988|  1.09k|	    goto leave;
 2989|       |
 2990|    605|	  if (pktlen < 2)
  ------------------
  |  Branch (2990:8): [True: 317, False: 288]
  ------------------
 2991|    317|	    {
 2992|    317|              err = gpg_error (GPG_ERR_INV_PACKET);
 2993|    317|	      goto leave;
 2994|    317|	    }
 2995|    288|	  ski->csum = read_16 (inp);
 2996|    288|	  pktlen -= 2;
 2997|    288|	  if (list_mode)
  ------------------
  |  Branch (2997:8): [True: 288, False: 0]
  ------------------
 2998|    288|            es_fprintf (listfp, "\tchecksum: %04hx\n", ski->csum);
 2999|    288|	}
 3000|  19.4k|    }
 3001|       |
 3002|       |  /* Note that KEYID below has been initialized above in list_mode.  */
 3003|  10.3k|  if (list_mode)
  ------------------
  |  Branch (3003:7): [True: 10.3k, False: 0]
  ------------------
 3004|  10.3k|    es_fprintf (listfp, "\tkeyid: %08lX%08lX\n",
 3005|  10.3k|                (ulong) keyid[0], (ulong) keyid[1]);
 3006|       |
 3007|  72.8k| leave:
 3008|  72.8k|  iobuf_skip_rest (inp, pktlen, 0);
 3009|  72.8k|  return err;
 3010|  10.3k|}
parse-packet.c:read_size_body:
 1117|  20.3k|{
 1118|  20.3k|  char buffer[256];
 1119|  20.3k|  char *tmpbuf;
 1120|  20.3k|  int i, c, nbytes;
 1121|       |
 1122|  20.3k|  *r_nread = 0;
 1123|  20.3k|  *r_data = NULL;
 1124|       |
 1125|  20.3k|  if (!pktlen)
  ------------------
  |  Branch (1125:7): [True: 382, False: 19.9k]
  ------------------
 1126|    382|    return gpg_error (GPG_ERR_INV_PACKET);
 1127|  19.9k|  c = iobuf_readbyte (inp);
 1128|  19.9k|  if (c < 0)
  ------------------
  |  Branch (1128:7): [True: 88, False: 19.8k]
  ------------------
 1129|     88|    return gpg_error (GPG_ERR_INV_PACKET);
 1130|  19.8k|  pktlen--;
 1131|  19.8k|  ++*r_nread;
 1132|  19.8k|  nbytes = c;
 1133|  19.8k|  if (nbytes < 2 || nbytes > 254)
  ------------------
  |  Branch (1133:7): [True: 446, False: 19.4k]
  |  Branch (1133:21): [True: 302, False: 19.1k]
  ------------------
 1134|    748|    return gpg_error (GPG_ERR_INV_PACKET);
 1135|  19.1k|  if (nbytes > pktlen)
  ------------------
  |  Branch (1135:7): [True: 304, False: 18.8k]
  ------------------
 1136|    304|    return gpg_error (GPG_ERR_INV_PACKET);
 1137|       |
 1138|  18.8k|  buffer[0] = nbytes;
 1139|       |
 1140|   107k|  for (i = 0; i < nbytes; i++)
  ------------------
  |  Branch (1140:15): [True: 89.4k, False: 18.5k]
  ------------------
 1141|  89.4k|    {
 1142|  89.4k|      c = iobuf_get (inp);
  ------------------
  |  |  500|  89.4k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 89.4k]
  |  |  |  Branch (500:24): [True: 243, False: 89.1k]
  |  |  ------------------
  |  |  501|  89.4k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 1143|  89.4k|      if (c < 0)
  ------------------
  |  Branch (1143:11): [True: 242, False: 89.1k]
  ------------------
 1144|    242|        return gpg_error (GPG_ERR_INV_PACKET);
 1145|  89.1k|      ++*r_nread;
 1146|  89.1k|      buffer[1+i] = c;
 1147|  89.1k|    }
 1148|       |
 1149|  18.5k|  tmpbuf = xtrymalloc (1 + nbytes);
  ------------------
  |  |   97|  18.5k|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 1150|  18.5k|  if (!tmpbuf)
  ------------------
  |  Branch (1150:7): [True: 0, False: 18.5k]
  ------------------
 1151|      0|    return gpg_error_from_syserror ();
 1152|  18.5k|  memcpy (tmpbuf, buffer, 1 + nbytes);
 1153|  18.5k|  *r_data = gcry_mpi_set_opaque (NULL, tmpbuf, 8 * (1 + nbytes));
 1154|  18.5k|  if (!*r_data)
  ------------------
  |  Branch (1154:7): [True: 0, False: 18.5k]
  ------------------
 1155|      0|    {
 1156|      0|      xfree (tmpbuf);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1157|      0|      return gpg_error_from_syserror ();
 1158|      0|    }
 1159|  18.5k|  return 0;
 1160|  18.5k|}
parse-packet.c:parse_symkeyenc:
 1207|  82.9k|{
 1208|  82.9k|  PKT_symkey_enc *k;
 1209|  82.9k|  int rc = 0;
 1210|  82.9k|  int i, version, s2kmode, cipher_algo, aead_algo, hash_algo, seskeylen, minlen;
 1211|       |
 1212|  82.9k|  if (pktlen < 4)
  ------------------
  |  Branch (1212:7): [True: 26.7k, False: 56.2k]
  ------------------
 1213|  26.7k|    goto too_short;
 1214|  56.2k|  version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  56.2k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  56.2k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 56.2k]
  |  |  |  |  |  Branch (500:24): [True: 260, False: 56.0k]
  |  |  |  |  ------------------
  |  |  |  |  501|  56.2k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1215|  56.2k|  pktlen--;
 1216|  56.2k|  if (version == 4)
  ------------------
  |  Branch (1216:7): [True: 51.7k, False: 4.54k]
  ------------------
 1217|  51.7k|    ;
 1218|  4.54k|  else if (version == 5)
  ------------------
  |  Branch (1218:12): [True: 2.50k, False: 2.04k]
  ------------------
 1219|  2.50k|    ;
 1220|  2.04k|  else
 1221|  2.04k|    {
 1222|  2.04k|      log_error ("packet(%d) with unknown version %d\n", pkttype, version);
 1223|  2.04k|      if (list_mode)
  ------------------
  |  Branch (1223:11): [True: 2.04k, False: 0]
  ------------------
 1224|  2.04k|        es_fprintf (listfp, ":symkey enc packet: [unknown version]\n");
 1225|  2.04k|      rc = gpg_error (GPG_ERR_INV_PACKET);
 1226|  2.04k|      goto leave;
 1227|  2.04k|    }
 1228|  54.2k|  if (pktlen > 200)
  ------------------
  |  Branch (1228:7): [True: 230, False: 53.9k]
  ------------------
 1229|    230|    {				/* (we encode the seskeylen in a byte) */
 1230|    230|      log_error ("packet(%d) too large\n", pkttype);
 1231|    230|      if (list_mode)
  ------------------
  |  Branch (1231:11): [True: 230, False: 0]
  ------------------
 1232|    230|        es_fprintf (listfp, ":symkey enc packet: [too large]\n");
 1233|    230|      rc = gpg_error (GPG_ERR_INV_PACKET);
 1234|    230|      goto leave;
 1235|    230|    }
 1236|  53.9k|  cipher_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  53.9k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  53.9k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 53.9k]
  |  |  |  |  |  Branch (500:24): [True: 240, False: 53.7k]
  |  |  |  |  ------------------
  |  |  |  |  501|  53.9k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1237|  53.9k|  pktlen--;
 1238|  53.9k|  if (version == 5)
  ------------------
  |  Branch (1238:7): [True: 2.48k, False: 51.5k]
  ------------------
 1239|  2.48k|    {
 1240|  2.48k|      aead_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  2.48k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  2.48k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 2.48k]
  |  |  |  |  |  Branch (500:24): [True: 212, False: 2.27k]
  |  |  |  |  ------------------
  |  |  |  |  501|  2.48k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1241|  2.48k|      pktlen--;
 1242|  2.48k|    }
 1243|  51.5k|  else
 1244|  51.5k|    aead_algo = 0;
 1245|  53.9k|  if (pktlen < 2)
  ------------------
  |  Branch (1245:7): [True: 520, False: 53.4k]
  ------------------
 1246|    520|    goto too_short;
 1247|  53.4k|  s2kmode = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  53.4k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  53.4k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 53.4k]
  |  |  |  |  |  Branch (500:24): [True: 267, False: 53.2k]
  |  |  |  |  ------------------
  |  |  |  |  501|  53.4k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1248|  53.4k|  pktlen--;
 1249|  53.4k|  hash_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  53.4k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  53.4k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 53.4k]
  |  |  |  |  |  Branch (500:24): [True: 1.10k, False: 52.3k]
  |  |  |  |  ------------------
  |  |  |  |  501|  53.4k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1250|  53.4k|  pktlen--;
 1251|  53.4k|  switch (s2kmode)
 1252|  53.4k|    {
 1253|  17.5k|    case 0: /* Simple S2K.  */
  ------------------
  |  Branch (1253:5): [True: 17.5k, False: 35.9k]
  ------------------
 1254|  17.5k|      minlen = 0;
 1255|  17.5k|      break;
 1256|  26.3k|    case 1: /* Salted S2K.  */
  ------------------
  |  Branch (1256:5): [True: 26.3k, False: 27.1k]
  ------------------
 1257|  26.3k|      minlen = 8;
 1258|  26.3k|      break;
 1259|  5.47k|    case 3: /* Iterated+salted S2K.  */
  ------------------
  |  Branch (1259:5): [True: 5.47k, False: 48.0k]
  ------------------
 1260|  5.47k|      minlen = 9;
 1261|  5.47k|      break;
 1262|  4.10k|    default:
  ------------------
  |  Branch (1262:5): [True: 4.10k, False: 49.3k]
  ------------------
 1263|  4.10k|      log_error ("unknown S2K mode %d\n", s2kmode);
 1264|  4.10k|      if (list_mode)
  ------------------
  |  Branch (1264:11): [True: 4.10k, False: 0]
  ------------------
 1265|  4.10k|        es_fprintf (listfp, ":symkey enc packet: [unknown S2K mode]\n");
 1266|  4.10k|      goto leave;
 1267|  53.4k|    }
 1268|  49.3k|  if (minlen > pktlen)
  ------------------
  |  Branch (1268:7): [True: 578, False: 48.7k]
  ------------------
 1269|    578|    {
 1270|    578|      log_error ("packet with S2K %d too short\n", s2kmode);
 1271|    578|      if (list_mode)
  ------------------
  |  Branch (1271:11): [True: 578, False: 0]
  ------------------
 1272|    578|        es_fprintf (listfp, ":symkey enc packet: [too short]\n");
 1273|    578|      rc = gpg_error (GPG_ERR_INV_PACKET);
 1274|    578|      goto leave;
 1275|    578|    }
 1276|  48.7k|  seskeylen = pktlen - minlen;
 1277|  48.7k|  k = packet->pkt.symkey_enc = xmalloc_clear (sizeof *packet->pkt.symkey_enc
  ------------------
  |  |  116|  48.7k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 1278|  48.7k|					      + seskeylen - 1);
 1279|  48.7k|  k->version = version;
 1280|  48.7k|  k->cipher_algo = cipher_algo;
 1281|  48.7k|  k->aead_algo = aead_algo;
 1282|  48.7k|  k->s2k.mode = s2kmode;
 1283|  48.7k|  k->s2k.hash_algo = hash_algo;
 1284|  48.7k|  if (s2kmode == 1 || s2kmode == 3)
  ------------------
  |  Branch (1284:7): [True: 26.1k, False: 22.6k]
  |  Branch (1284:23): [True: 5.13k, False: 17.5k]
  ------------------
 1285|  31.2k|    {
 1286|   281k|      for (i = 0; i < 8 && pktlen; i++, pktlen--)
  ------------------
  |  Branch (1286:19): [True: 249k, False: 31.2k]
  |  Branch (1286:28): [True: 249k, False: 0]
  ------------------
 1287|   249k|	k->s2k.salt[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|   249k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|   249k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 249k]
  |  |  |  |  |  Branch (500:24): [True: 995, False: 248k]
  |  |  |  |  ------------------
  |  |  |  |  501|   249k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1288|  31.2k|    }
 1289|  48.7k|  if (s2kmode == 3)
  ------------------
  |  Branch (1289:7): [True: 5.13k, False: 43.6k]
  ------------------
 1290|  5.13k|    {
 1291|  5.13k|      k->s2k.count = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  5.13k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  5.13k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 5.13k]
  |  |  |  |  |  Branch (500:24): [True: 294, False: 4.84k]
  |  |  |  |  ------------------
  |  |  |  |  501|  5.13k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1292|  5.13k|      pktlen--;
 1293|  5.13k|    }
 1294|  48.7k|  k->seskeylen = seskeylen;
 1295|  48.7k|  if (k->seskeylen)
  ------------------
  |  Branch (1295:7): [True: 25.7k, False: 23.0k]
  ------------------
 1296|  25.7k|    {
 1297|  77.3k|      for (i = 0; i < seskeylen && pktlen; i++, pktlen--)
  ------------------
  |  Branch (1297:19): [True: 51.5k, False: 25.7k]
  |  Branch (1297:36): [True: 51.5k, False: 0]
  ------------------
 1298|  51.5k|	k->seskey[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  51.5k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  51.5k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 51.5k]
  |  |  |  |  |  Branch (500:24): [True: 10.4k, False: 41.0k]
  |  |  |  |  ------------------
  |  |  |  |  501|  51.5k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1299|       |
 1300|       |      /* What we're watching out for here is a session key decryptor
 1301|       |         with no salt.  The RFC says that using salt for this is a
 1302|       |         MUST. */
 1303|  25.7k|      if (s2kmode != 1 && s2kmode != 3)
  ------------------
  |  Branch (1303:11): [True: 4.40k, False: 21.3k]
  |  Branch (1303:27): [True: 2.96k, False: 1.43k]
  ------------------
 1304|  2.96k|	log_info (_("WARNING: potentially insecure symmetrically"
  ------------------
  |  |   28|  2.96k|#  define _(a) gettext (a)
  ------------------
 1305|  2.96k|		    " encrypted session key\n"));
 1306|  25.7k|    }
 1307|  48.7k|  log_assert (!pktlen);
 1308|       |
 1309|  48.7k|  if (list_mode)
  ------------------
  |  Branch (1309:7): [True: 48.7k, False: 0]
  ------------------
 1310|  48.7k|    {
 1311|  48.7k|      es_fprintf (listfp,
 1312|  48.7k|                  ":symkey enc packet: version %d, cipher %d, aead %d,"
 1313|  48.7k|                  " s2k %d, hash %d",
 1314|  48.7k|                  version, cipher_algo, aead_algo, s2kmode, hash_algo);
 1315|  48.7k|      if (seskeylen)
  ------------------
  |  Branch (1315:11): [True: 25.7k, False: 23.0k]
  ------------------
 1316|  25.7k|        {
 1317|       |          /* To compute the size of the session key we need to know
 1318|       |           * the size of the AEAD nonce which we may not know.  Thus
 1319|       |           * we show only the size of the entire encrypted session
 1320|       |           * key.  */
 1321|  25.7k|          if (aead_algo)
  ------------------
  |  Branch (1321:15): [True: 1.78k, False: 23.9k]
  ------------------
 1322|  1.78k|            es_fprintf (listfp, ", encrypted seskey %d bytes", seskeylen);
 1323|  23.9k|          else
 1324|  23.9k|            es_fprintf (listfp, ", seskey %d bits", (seskeylen - 1) * 8);
 1325|  25.7k|        }
 1326|  48.7k|      es_fprintf (listfp, "\n");
 1327|  48.7k|      if (s2kmode == 1 || s2kmode == 3)
  ------------------
  |  Branch (1327:11): [True: 26.1k, False: 22.6k]
  |  Branch (1327:27): [True: 5.13k, False: 17.5k]
  ------------------
 1328|  31.2k|	{
 1329|  31.2k|	  es_fprintf (listfp, "\tsalt ");
 1330|  31.2k|          es_write_hexstring (listfp, k->s2k.salt, 8, 0, NULL);
 1331|  31.2k|	  if (s2kmode == 3)
  ------------------
  |  Branch (1331:8): [True: 5.13k, False: 26.1k]
  ------------------
 1332|  5.13k|	    es_fprintf (listfp, ", count %lu (%lu)",
 1333|  5.13k|                        S2K_DECODE_COUNT ((ulong) k->s2k.count),
  ------------------
  |  |  210|  5.13k|#define S2K_DECODE_COUNT(_val) ((16ul + ((_val) & 15)) << (((_val) >> 4) + 6))
  ------------------
 1334|  5.13k|                        (ulong) k->s2k.count);
 1335|  31.2k|	  es_fprintf (listfp, "\n");
 1336|  31.2k|	}
 1337|  48.7k|    }
 1338|       |
 1339|  82.9k| leave:
 1340|  82.9k|  iobuf_skip_rest (inp, pktlen, 0);
 1341|  82.9k|  return rc;
 1342|       |
 1343|  27.2k| too_short:
 1344|  27.2k|  log_error ("packet(%d) too short\n", pkttype);
 1345|  27.2k|  if (list_mode)
  ------------------
  |  Branch (1345:7): [True: 27.2k, False: 0]
  ------------------
 1346|  27.2k|    es_fprintf (listfp, ":symkey enc packet: [too short]\n");
 1347|  27.2k|  rc = gpg_error (GPG_ERR_INV_PACKET);
 1348|  27.2k|  goto leave;
 1349|  48.7k|}
parse-packet.c:parse_pubkeyenc:
 1355|  10.9k|{
 1356|  10.9k|  int rc = 0;
 1357|  10.9k|  int i, ndata;
 1358|  10.9k|  PKT_pubkey_enc *k;
 1359|       |
 1360|  10.9k|  k = packet->pkt.pubkey_enc = xmalloc_clear (sizeof *packet->pkt.pubkey_enc);
  ------------------
  |  |  116|  10.9k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 1361|  10.9k|  if (pktlen < 12)
  ------------------
  |  Branch (1361:7): [True: 1.30k, False: 9.61k]
  ------------------
 1362|  1.30k|    {
 1363|  1.30k|      log_error ("packet(%d) too short\n", pkttype);
 1364|  1.30k|      if (list_mode)
  ------------------
  |  Branch (1364:11): [True: 1.30k, False: 0]
  ------------------
 1365|  1.30k|        es_fputs (":pubkey enc packet: [too short]\n", listfp);
 1366|  1.30k|      rc = gpg_error (GPG_ERR_INV_PACKET);
 1367|  1.30k|      goto leave;
 1368|  1.30k|    }
 1369|  9.61k|  k->version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  9.61k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  9.61k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 9.61k]
  |  |  |  |  |  Branch (500:24): [True: 460, False: 9.15k]
  |  |  |  |  ------------------
  |  |  |  |  501|  9.61k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1370|  9.61k|  pktlen--;
 1371|  9.61k|  if (k->version != 2 && k->version != 3)
  ------------------
  |  Branch (1371:7): [True: 3.30k, False: 6.31k]
  |  Branch (1371:26): [True: 1.01k, False: 2.28k]
  ------------------
 1372|  1.01k|    {
 1373|  1.01k|      log_error ("packet(%d) with unknown version %d\n", pkttype, k->version);
 1374|  1.01k|      if (list_mode)
  ------------------
  |  Branch (1374:11): [True: 1.01k, False: 0]
  ------------------
 1375|  1.01k|        es_fputs (":pubkey enc packet: [unknown version]\n", listfp);
 1376|  1.01k|      rc = gpg_error (GPG_ERR_INV_PACKET);
 1377|  1.01k|      goto leave;
 1378|  1.01k|    }
 1379|  8.59k|  k->keyid[0] = read_32 (inp);
 1380|  8.59k|  pktlen -= 4;
 1381|  8.59k|  k->keyid[1] = read_32 (inp);
 1382|  8.59k|  pktlen -= 4;
 1383|  8.59k|  k->pubkey_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  8.59k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  8.59k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 8.59k]
  |  |  |  |  |  Branch (500:24): [True: 259, False: 8.33k]
  |  |  |  |  ------------------
  |  |  |  |  501|  8.59k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1384|  8.59k|  pktlen--;
 1385|  8.59k|  k->throw_keyid = 0;  /* Only used as flag for build_packet.  */
 1386|  8.59k|  if (list_mode)
  ------------------
  |  Branch (1386:7): [True: 8.59k, False: 0]
  ------------------
 1387|  8.59k|    es_fprintf (listfp,
 1388|  8.59k|                ":pubkey enc packet: version %d, algo %d, keyid %08lX%08lX\n",
 1389|  8.59k|                k->version, k->pubkey_algo, (ulong) k->keyid[0],
 1390|  8.59k|                (ulong) k->keyid[1]);
 1391|       |
 1392|  8.59k|  ndata = pubkey_get_nenc (k->pubkey_algo);
 1393|  8.59k|  if (!ndata)
  ------------------
  |  Branch (1393:7): [True: 6.44k, False: 2.15k]
  ------------------
 1394|  6.44k|    {
 1395|  6.44k|      if (list_mode)
  ------------------
  |  Branch (1395:11): [True: 6.44k, False: 0]
  ------------------
 1396|  6.44k|	es_fprintf (listfp, "\tunsupported algorithm %d\n", k->pubkey_algo);
 1397|  6.44k|      unknown_pubkey_warning (k->pubkey_algo);
 1398|  6.44k|      k->data[0] = NULL; /* No need to store the encrypted data.  */
 1399|  6.44k|    }
 1400|  2.15k|  else
 1401|  2.15k|    {
 1402|  4.02k|      for (i = 0; i < ndata; i++)
  ------------------
  |  Branch (1402:19): [True: 3.05k, False: 971]
  ------------------
 1403|  3.05k|        {
 1404|  3.05k|          if (k->pubkey_algo == PUBKEY_ALGO_ECDH)
  ------------------
  |  Branch (1404:15): [True: 1.17k, False: 1.87k]
  ------------------
 1405|  1.17k|            {
 1406|  1.17k|              if (i == 1)
  ------------------
  |  Branch (1406:19): [True: 448, False: 727]
  ------------------
 1407|    448|                {
 1408|    448|                  size_t n;
 1409|    448|                  rc = read_size_body (inp, pktlen, &n, k->data+i);
 1410|    448|                  pktlen -= n;
 1411|    448|                }
 1412|    727|              else
 1413|    727|                {
 1414|    727|                  int n = pktlen;
 1415|    727|                  k->data[i] = sos_read (inp, &n, 0);
 1416|    727|                  pktlen -= n;
 1417|    727|                  if (!k->data[i])
  ------------------
  |  Branch (1417:23): [True: 279, False: 448]
  ------------------
 1418|    279|                    rc = gpg_error (GPG_ERR_INV_PACKET);
 1419|    727|                }
 1420|  1.17k|            }
 1421|  1.87k|          else
 1422|  1.87k|            {
 1423|  1.87k|	      int n = pktlen;
 1424|  1.87k|              k->data[i] = mpi_read (inp, &n, 0);
 1425|  1.87k|              pktlen -= n;
 1426|  1.87k|              if (!k->data[i])
  ------------------
  |  Branch (1426:19): [True: 853, False: 1.02k]
  ------------------
 1427|    853|                rc = gpg_error (GPG_ERR_INV_PACKET);
 1428|  1.87k|            }
 1429|  3.05k|          if (rc)
  ------------------
  |  Branch (1429:15): [True: 1.18k, False: 1.87k]
  ------------------
 1430|  1.18k|            goto leave;
 1431|  1.87k|          if (list_mode)
  ------------------
  |  Branch (1431:15): [True: 1.87k, False: 0]
  ------------------
 1432|  1.87k|            {
 1433|  1.87k|              es_fprintf (listfp, "\tdata: ");
 1434|  1.87k|              mpi_print (listfp, k->data[i], mpi_print_mode);
 1435|  1.87k|              es_putc ('\n', listfp);
 1436|  1.87k|            }
 1437|  1.87k|        }
 1438|  2.15k|    }
 1439|       |
 1440|  10.9k| leave:
 1441|  10.9k|  iobuf_skip_rest (inp, pktlen, 0);
 1442|  10.9k|  return rc;
 1443|  8.59k|}
parse-packet.c:parse_onepass_sig:
 2409|  4.68k|{
 2410|  4.68k|  int version;
 2411|  4.68k|  int rc = 0;
 2412|       |
 2413|  4.68k|  if (pktlen < 13)
  ------------------
  |  Branch (2413:7): [True: 746, False: 3.94k]
  ------------------
 2414|    746|    {
 2415|    746|      log_error ("packet(%d) too short\n", pkttype);
 2416|    746|      if (list_mode)
  ------------------
  |  Branch (2416:11): [True: 746, False: 0]
  ------------------
 2417|    746|        es_fputs (":onepass_sig packet: [too short]\n", listfp);
 2418|    746|      rc = gpg_error (GPG_ERR_INV_PACKET);
 2419|    746|      goto leave;
 2420|    746|    }
 2421|  3.94k|  version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  3.94k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  3.94k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 3.94k]
  |  |  |  |  |  Branch (500:24): [True: 227, False: 3.71k]
  |  |  |  |  ------------------
  |  |  |  |  501|  3.94k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2422|  3.94k|  pktlen--;
 2423|  3.94k|  if (version != 3)
  ------------------
  |  Branch (2423:7): [True: 554, False: 3.38k]
  ------------------
 2424|    554|    {
 2425|    554|      log_error ("onepass_sig with unknown version %d\n", version);
 2426|    554|      if (list_mode)
  ------------------
  |  Branch (2426:11): [True: 554, False: 0]
  ------------------
 2427|    554|        es_fputs (":onepass_sig packet: [unknown version]\n", listfp);
 2428|    554|      rc = gpg_error (GPG_ERR_INV_PACKET);
 2429|    554|      goto leave;
 2430|    554|    }
 2431|  3.38k|  ops->sig_class = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  3.38k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  3.38k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 3.38k]
  |  |  |  |  |  Branch (500:24): [True: 378, False: 3.00k]
  |  |  |  |  ------------------
  |  |  |  |  501|  3.38k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2432|  3.38k|  pktlen--;
 2433|  3.38k|  ops->digest_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  3.38k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  3.38k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 3.38k]
  |  |  |  |  |  Branch (500:24): [True: 218, False: 3.16k]
  |  |  |  |  ------------------
  |  |  |  |  501|  3.38k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2434|  3.38k|  pktlen--;
 2435|  3.38k|  ops->pubkey_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  3.38k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  3.38k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 3.38k]
  |  |  |  |  |  Branch (500:24): [True: 489, False: 2.89k]
  |  |  |  |  ------------------
  |  |  |  |  501|  3.38k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2436|  3.38k|  pktlen--;
 2437|  3.38k|  ops->keyid[0] = read_32 (inp);
 2438|  3.38k|  pktlen -= 4;
 2439|  3.38k|  ops->keyid[1] = read_32 (inp);
 2440|  3.38k|  pktlen -= 4;
 2441|  3.38k|  ops->last = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  3.38k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  3.38k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 3.38k]
  |  |  |  |  |  Branch (500:24): [True: 123, False: 3.26k]
  |  |  |  |  ------------------
  |  |  |  |  501|  3.38k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2442|  3.38k|  pktlen--;
 2443|  3.38k|  if (list_mode)
  ------------------
  |  Branch (2443:7): [True: 3.38k, False: 0]
  ------------------
 2444|  3.38k|    es_fprintf (listfp,
 2445|  3.38k|                ":onepass_sig packet: keyid %08lX%08lX\n"
 2446|  3.38k|                "\tversion %d, sigclass 0x%02x, digest %d, pubkey %d, "
 2447|  3.38k|                "last=%d\n",
 2448|  3.38k|                (ulong) ops->keyid[0], (ulong) ops->keyid[1],
 2449|  3.38k|                version, ops->sig_class,
 2450|  3.38k|                ops->digest_algo, ops->pubkey_algo, ops->last);
 2451|       |
 2452|       |
 2453|  4.68k| leave:
 2454|  4.68k|  iobuf_skip_rest (inp, pktlen, 0);
 2455|  4.68k|  return rc;
 2456|  3.38k|}
parse-packet.c:parse_user_id:
 3091|  3.75k|{
 3092|  3.75k|  byte *p;
 3093|       |
 3094|       |  /* Cap the size of a user ID at 2k: a value absurdly large enough
 3095|       |     that there is no sane user ID string (which is printable text
 3096|       |     as of RFC2440bis) that won't fit in it, but yet small enough to
 3097|       |     avoid allocation problems.  A large pktlen may not be
 3098|       |     allocatable, and a very large pktlen could actually cause our
 3099|       |     allocation to wrap around in xmalloc to a small number. */
 3100|       |
 3101|  3.75k|  if (pktlen > MAX_UID_PACKET_LENGTH)
  ------------------
  |  |   38|  3.75k|#define MAX_UID_PACKET_LENGTH     (  2 * 1024)
  ------------------
  |  Branch (3101:7): [True: 378, False: 3.37k]
  ------------------
 3102|    378|    {
 3103|    378|      log_error ("packet(%d) too large\n", pkttype);
 3104|    378|      if (list_mode)
  ------------------
  |  Branch (3104:11): [True: 378, False: 0]
  ------------------
 3105|    378|        es_fprintf (listfp, ":user ID packet: [too large]\n");
 3106|    378|      iobuf_skip_rest (inp, pktlen, 0);
 3107|    378|      return GPG_ERR_INV_PACKET;
 3108|    378|    }
 3109|       |
 3110|  3.37k|  packet->pkt.user_id = xmalloc_clear (sizeof *packet->pkt.user_id + pktlen);
  ------------------
  |  |  116|  3.37k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 3111|  3.37k|  packet->pkt.user_id->len = pktlen;
 3112|  3.37k|  packet->pkt.user_id->ref = 1;
 3113|       |
 3114|  3.37k|  p = packet->pkt.user_id->name;
 3115|   106k|  for (; pktlen; pktlen--, p++)
  ------------------
  |  Branch (3115:10): [True: 102k, False: 3.37k]
  ------------------
 3116|   102k|    *p = iobuf_get_noeof (inp);
  ------------------
  |  |  502|   106k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|   102k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 102k]
  |  |  |  |  |  Branch (500:24): [True: 31.3k, False: 71.5k]
  |  |  |  |  ------------------
  |  |  |  |  501|   102k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3117|  3.37k|  *p = 0;
 3118|       |
 3119|  3.37k|  if (list_mode)
  ------------------
  |  Branch (3119:7): [True: 3.37k, False: 0]
  ------------------
 3120|  3.37k|    {
 3121|  3.37k|      int n = packet->pkt.user_id->len;
 3122|  3.37k|      es_fprintf (listfp, ":user ID packet: \"");
 3123|       |      /* fixme: Hey why don't we replace this with es_write_sanitized?? */
 3124|   106k|      for (p = packet->pkt.user_id->name; n; p++, n--)
  ------------------
  |  Branch (3124:43): [True: 102k, False: 3.37k]
  ------------------
 3125|   102k|	{
 3126|   102k|	  if (*p >= ' ' && *p <= 'z')
  ------------------
  |  Branch (3126:8): [True: 66.7k, False: 36.1k]
  |  Branch (3126:21): [True: 14.1k, False: 52.6k]
  ------------------
 3127|  14.1k|	    es_putc (*p, listfp);
 3128|  88.7k|	  else
 3129|  88.7k|	    es_fprintf (listfp, "\\x%02x", *p);
 3130|   102k|	}
 3131|  3.37k|      es_fprintf (listfp, "\"\n");
 3132|  3.37k|    }
 3133|  3.37k|  return 0;
 3134|  3.75k|}
parse-packet.c:parse_attribute:
 3174|  6.30k|{
 3175|  6.30k|  byte *p;
 3176|       |
 3177|  6.30k|  (void) pkttype;
 3178|       |
 3179|       |  /* We better cap the size of an attribute packet to make DoS not too
 3180|       |     easy.  16MB should be more then enough for one attribute packet
 3181|       |     (ie. a photo).  */
 3182|  6.30k|  if (pktlen > MAX_ATTR_PACKET_LENGTH)
  ------------------
  |  |   40|  6.30k|#define MAX_ATTR_PACKET_LENGTH    ( 16 * 1024*1024)
  ------------------
  |  Branch (3182:7): [True: 203, False: 6.10k]
  ------------------
 3183|    203|    {
 3184|    203|      log_error ("packet(%d) too large\n", pkttype);
 3185|    203|      if (list_mode)
  ------------------
  |  Branch (3185:11): [True: 203, False: 0]
  ------------------
 3186|    203|        es_fprintf (listfp, ":attribute packet: [too large]\n");
 3187|    203|      iobuf_skip_rest (inp, pktlen, 0);
 3188|    203|      return GPG_ERR_INV_PACKET;
 3189|    203|    }
 3190|       |
 3191|  6.10k|#define EXTRA_UID_NAME_SPACE 71
 3192|  6.10k|  packet->pkt.user_id = xmalloc_clear (sizeof *packet->pkt.user_id
  ------------------
  |  |  116|  6.10k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 3193|  6.10k|				       + EXTRA_UID_NAME_SPACE);
 3194|  6.10k|  packet->pkt.user_id->ref = 1;
 3195|  6.10k|  packet->pkt.user_id->attrib_data = xmalloc (pktlen? pktlen:1);
  ------------------
  |  |  107|  12.2k|#define xmalloc(a)       gcry_xmalloc ((a))
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 5.59k, False: 511]
  |  |  ------------------
  ------------------
 3196|  6.10k|  packet->pkt.user_id->attrib_len = pktlen;
 3197|       |
 3198|  6.10k|  p = packet->pkt.user_id->attrib_data;
 3199|  1.05G|  for (; pktlen; pktlen--, p++)
  ------------------
  |  Branch (3199:10): [True: 1.05G, False: 6.10k]
  ------------------
 3200|  1.05G|    *p = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.05G|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.05G|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.05G]
  |  |  |  |  |  Branch (500:24): [True: 1.05G, False: 84.4k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.05G|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3201|       |
 3202|       |  /* Now parse out the individual attribute subpackets.  This is
 3203|       |     somewhat pointless since there is only one currently defined
 3204|       |     attribute type (jpeg), but it is correct by the spec. */
 3205|  6.10k|  parse_attribute_subpkts (packet->pkt.user_id);
 3206|       |
 3207|  6.10k|  make_attribute_uidname (packet->pkt.user_id, EXTRA_UID_NAME_SPACE);
  ------------------
  |  | 3191|  6.10k|#define EXTRA_UID_NAME_SPACE 71
  ------------------
 3208|       |
 3209|  6.10k|  if (list_mode)
  ------------------
  |  Branch (3209:7): [True: 6.10k, False: 0]
  ------------------
 3210|  6.10k|    {
 3211|  6.10k|      es_fprintf (listfp, ":attribute packet: %s\n", packet->pkt.user_id->name);
 3212|  6.10k|    }
 3213|  6.10k|  return 0;
 3214|  6.30k|}
parse-packet.c:parse_comment:
 3219|  2.06k|{
 3220|  2.06k|  byte *p;
 3221|       |
 3222|       |  /* Cap comment packet at a reasonable value to avoid an integer
 3223|       |     overflow in the malloc below.  Comment packets are actually not
 3224|       |     anymore define my OpenPGP and we even stopped to use our
 3225|       |     private comment packet.  */
 3226|  2.06k|  if (pktlen > MAX_COMMENT_PACKET_LENGTH)
  ------------------
  |  |   39|  2.06k|#define MAX_COMMENT_PACKET_LENGTH ( 64 * 1024)
  ------------------
  |  Branch (3226:7): [True: 141, False: 1.92k]
  ------------------
 3227|    141|    {
 3228|    141|      log_error ("packet(%d) too large\n", pkttype);
 3229|    141|      if (list_mode)
  ------------------
  |  Branch (3229:11): [True: 141, False: 0]
  ------------------
 3230|    141|        es_fprintf (listfp, ":%scomment packet: [too large]\n",
 3231|    141|                    pkttype == PKT_OLD_COMMENT ? "OpenPGP draft " : "");
  ------------------
  |  Branch (3231:21): [True: 3, False: 138]
  ------------------
 3232|    141|      iobuf_skip_rest (inp, pktlen, 0);
 3233|    141|      return GPG_ERR_INV_PACKET;
 3234|    141|    }
 3235|  1.92k|  packet->pkt.comment = xmalloc (sizeof *packet->pkt.comment + pktlen - 1);
  ------------------
  |  |  107|  1.92k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 3236|  1.92k|  packet->pkt.comment->len = pktlen;
 3237|  1.92k|  p = packet->pkt.comment->data;
 3238|   816k|  for (; pktlen; pktlen--, p++)
  ------------------
  |  Branch (3238:10): [True: 814k, False: 1.92k]
  ------------------
 3239|   814k|    *p = iobuf_get_noeof (inp);
  ------------------
  |  |  502|   816k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|   814k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 814k]
  |  |  |  |  |  Branch (500:24): [True: 731k, False: 83.0k]
  |  |  |  |  ------------------
  |  |  |  |  501|   814k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3240|       |
 3241|  1.92k|  if (list_mode)
  ------------------
  |  Branch (3241:7): [True: 1.92k, False: 0]
  ------------------
 3242|  1.92k|    {
 3243|  1.92k|      int n = packet->pkt.comment->len;
 3244|  1.92k|      es_fprintf (listfp, ":%scomment packet: \"", pkttype == PKT_OLD_COMMENT ?
  ------------------
  |  Branch (3244:52): [True: 1.14k, False: 783]
  ------------------
 3245|  1.14k|                  "OpenPGP draft " : "");
 3246|   816k|      for (p = packet->pkt.comment->data; n; p++, n--)
  ------------------
  |  Branch (3246:43): [True: 814k, False: 1.92k]
  ------------------
 3247|   814k|	{
 3248|   814k|	  if (*p >= ' ' && *p <= 'z')
  ------------------
  |  Branch (3248:8): [True: 764k, False: 50.4k]
  |  Branch (3248:21): [True: 15.7k, False: 748k]
  ------------------
 3249|  15.7k|	    es_putc (*p, listfp);
 3250|   798k|	  else
 3251|   798k|	    es_fprintf (listfp, "\\x%02x", *p);
 3252|   814k|	}
 3253|  1.92k|      es_fprintf (listfp, "\"\n");
 3254|  1.92k|    }
 3255|  1.92k|  return 0;
 3256|  2.06k|}
parse-packet.c:parse_ring_trust:
 3265|  16.4k|{
 3266|  16.4k|  gpg_error_t err;
 3267|  16.4k|  iobuf_t inp = ctx->inp;
 3268|  16.4k|  PKT_ring_trust rt = {0};
 3269|  16.4k|  int c;
 3270|  16.4k|  int not_gpg = 0;
 3271|       |
 3272|  16.4k|  if (!pktlen)
  ------------------
  |  Branch (3272:7): [True: 4.92k, False: 11.4k]
  ------------------
 3273|  4.92k|    {
 3274|  4.92k|      if (list_mode)
  ------------------
  |  Branch (3274:11): [True: 4.92k, False: 0]
  ------------------
 3275|  4.92k|	es_fprintf (listfp, ":trust packet: empty\n");
 3276|  4.92k|      err = 0;
 3277|  4.92k|      goto leave;
 3278|  4.92k|    }
 3279|       |
 3280|  11.4k|  c = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  11.4k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  11.4k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 11.4k]
  |  |  |  |  |  Branch (500:24): [True: 355, False: 11.1k]
  |  |  |  |  ------------------
  |  |  |  |  501|  11.4k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3281|  11.4k|  pktlen--;
 3282|  11.4k|  rt.trustval = c;
 3283|  11.4k|  if (pktlen)
  ------------------
  |  Branch (3283:7): [True: 10.8k, False: 652]
  ------------------
 3284|  10.8k|    {
 3285|  10.8k|      if (!c)
  ------------------
  |  Branch (3285:11): [True: 3.46k, False: 7.37k]
  ------------------
 3286|  3.46k|        {
 3287|  3.46k|          c = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  3.46k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  3.46k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 3.46k]
  |  |  |  |  |  Branch (500:24): [True: 202, False: 3.26k]
  |  |  |  |  ------------------
  |  |  |  |  501|  3.46k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3288|       |          /* We require that bit 7 of the sigcache is 0 (easier
 3289|       |           * eof handling).  */
 3290|  3.46k|          if (!(c & 0x80))
  ------------------
  |  Branch (3290:15): [True: 2.97k, False: 494]
  ------------------
 3291|  2.97k|            rt.sigcache = c;
 3292|  3.46k|        }
 3293|  7.37k|      else
 3294|  7.37k|        iobuf_get_noeof (inp);  /* Dummy read.  */
  ------------------
  |  |  502|  7.37k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  7.37k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 7.37k]
  |  |  |  |  |  Branch (500:24): [True: 325, False: 7.05k]
  |  |  |  |  ------------------
  |  |  |  |  501|  7.37k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3295|  10.8k|      pktlen--;
 3296|  10.8k|    }
 3297|       |
 3298|       |  /* Next is the optional subtype.  */
 3299|  11.4k|  if (pktlen > 3)
  ------------------
  |  Branch (3299:7): [True: 7.66k, False: 3.82k]
  ------------------
 3300|  7.66k|    {
 3301|  7.66k|      char tmp[4];
 3302|  7.66k|      tmp[0] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  7.66k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  7.66k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 7.66k]
  |  |  |  |  |  Branch (500:24): [True: 310, False: 7.35k]
  |  |  |  |  ------------------
  |  |  |  |  501|  7.66k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3303|  7.66k|      tmp[1] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  7.66k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  7.66k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 7.66k]
  |  |  |  |  |  Branch (500:24): [True: 378, False: 7.29k]
  |  |  |  |  ------------------
  |  |  |  |  501|  7.66k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3304|  7.66k|      tmp[2] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  7.66k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  7.66k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 7.66k]
  |  |  |  |  |  Branch (500:24): [True: 595, False: 7.07k]
  |  |  |  |  ------------------
  |  |  |  |  501|  7.66k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3305|  7.66k|      tmp[3] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  7.66k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  7.66k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 7.66k]
  |  |  |  |  |  Branch (500:24): [True: 392, False: 7.27k]
  |  |  |  |  ------------------
  |  |  |  |  501|  7.66k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3306|  7.66k|      pktlen -= 4;
 3307|  7.66k|      if (!memcmp (tmp, "gpg", 3))
  ------------------
  |  Branch (3307:11): [True: 5.09k, False: 2.57k]
  ------------------
 3308|  5.09k|        rt.subtype = tmp[3];
 3309|  2.57k|      else
 3310|  2.57k|        not_gpg = 1;
 3311|  7.66k|    }
 3312|       |  /* If it is a key or uid subtype read the remaining data.  */
 3313|  11.4k|  if ((rt.subtype == RING_TRUST_KEY || rt.subtype == RING_TRUST_UID)
  ------------------
  |  |  517|  22.9k|#define RING_TRUST_KEY 1  /* A KEYORG on a primary key.      */
  ------------------
                if ((rt.subtype == RING_TRUST_KEY || rt.subtype == RING_TRUST_UID)
  ------------------
  |  |  518|  8.65k|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
  |  Branch (3313:8): [True: 2.84k, False: 8.65k]
  |  Branch (3313:40): [True: 1.59k, False: 7.05k]
  ------------------
 3314|  11.4k|      && pktlen >= 6 )
  ------------------
  |  Branch (3314:10): [True: 2.55k, False: 1.87k]
  ------------------
 3315|  2.55k|    {
 3316|  2.55k|      int i;
 3317|  2.55k|      unsigned int namelen;
 3318|       |
 3319|  2.55k|      rt.keyorg = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  2.55k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  2.55k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 2.55k]
  |  |  |  |  |  Branch (500:24): [True: 275, False: 2.28k]
  |  |  |  |  ------------------
  |  |  |  |  501|  2.55k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3320|  2.55k|      pktlen--;
 3321|  2.55k|      rt.keyupdate = read_32 (inp);
 3322|  2.55k|      pktlen -= 4;
 3323|  2.55k|      namelen = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  2.55k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  2.55k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 2.55k]
  |  |  |  |  |  Branch (500:24): [True: 317, False: 2.24k]
  |  |  |  |  ------------------
  |  |  |  |  501|  2.55k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3324|  2.55k|      pktlen--;
 3325|  2.55k|      if (namelen && pktlen)
  ------------------
  |  Branch (3325:11): [True: 1.59k, False: 960]
  |  Branch (3325:22): [True: 941, False: 658]
  ------------------
 3326|    941|        {
 3327|    941|          rt.url = xtrymalloc (namelen + 1);
  ------------------
  |  |   97|    941|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 3328|    941|          if (!rt.url)
  ------------------
  |  Branch (3328:15): [True: 0, False: 941]
  ------------------
 3329|      0|            {
 3330|      0|              err = gpg_error_from_syserror ();
 3331|      0|              goto leave;
 3332|      0|            }
 3333|  14.0k|          for (i = 0; pktlen && i < namelen; pktlen--, i++)
  ------------------
  |  Branch (3333:23): [True: 13.1k, False: 889]
  |  Branch (3333:33): [True: 13.0k, False: 52]
  ------------------
 3334|  13.0k|            rt.url[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  14.0k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  13.0k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 13.0k]
  |  |  |  |  |  Branch (500:24): [True: 11.1k, False: 1.89k]
  |  |  |  |  ------------------
  |  |  |  |  501|  13.0k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3335|    941|          rt.url[i] = 0;
 3336|    941|        }
 3337|  2.55k|    }
 3338|       |
 3339|  11.4k|  if (list_mode)
  ------------------
  |  Branch (3339:7): [True: 11.4k, False: 0]
  ------------------
 3340|  11.4k|    {
 3341|  11.4k|      if (rt.subtype == RING_TRUST_SIG)
  ------------------
  |  |  516|  11.4k|#define RING_TRUST_SIG 0  /* The classical signature cache.  */
  ------------------
  |  Branch (3341:11): [True: 6.39k, False: 5.09k]
  ------------------
 3342|  6.39k|        es_fprintf (listfp, ":trust packet: sig flag=%02x sigcache=%02x\n",
 3343|  6.39k|                    rt.trustval, rt.sigcache);
 3344|  5.09k|      else if (rt.subtype == RING_TRUST_UID || rt.subtype == RING_TRUST_KEY)
  ------------------
  |  |  518|  10.1k|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
                    else if (rt.subtype == RING_TRUST_UID || rt.subtype == RING_TRUST_KEY)
  ------------------
  |  |  517|  3.50k|#define RING_TRUST_KEY 1  /* A KEYORG on a primary key.      */
  ------------------
  |  Branch (3344:16): [True: 1.59k, False: 3.50k]
  |  Branch (3344:48): [True: 2.84k, False: 660]
  ------------------
 3345|  4.43k|        {
 3346|  4.43k|          unsigned char *p;
 3347|       |
 3348|  4.43k|          es_fprintf (listfp, ":trust packet: %s upd=%lu src=%d%s",
 3349|  4.43k|                      (rt.subtype == RING_TRUST_UID? "uid" : "key"),
  ------------------
  |  |  518|  4.43k|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
  |  Branch (3349:24): [True: 1.59k, False: 2.84k]
  ------------------
 3350|  4.43k|                      (unsigned long)rt.keyupdate,
 3351|  4.43k|                      rt.keyorg,
 3352|  4.43k|                      (rt.url? " url=":""));
  ------------------
  |  Branch (3352:24): [True: 941, False: 3.49k]
  ------------------
 3353|  4.43k|          if (rt.url)
  ------------------
  |  Branch (3353:15): [True: 941, False: 3.49k]
  ------------------
 3354|    941|            {
 3355|  12.7k|              for (p = rt.url; *p; p++)
  ------------------
  |  Branch (3355:32): [True: 11.8k, False: 941]
  ------------------
 3356|  11.8k|                {
 3357|  11.8k|                  if (*p >= ' ' && *p <= 'z')
  ------------------
  |  Branch (3357:23): [True: 11.2k, False: 617]
  |  Branch (3357:36): [True: 407, False: 10.8k]
  ------------------
 3358|    407|                    es_putc (*p, listfp);
 3359|  11.4k|                  else
 3360|  11.4k|                    es_fprintf (listfp, "\\x%02x", *p);
 3361|  11.8k|                }
 3362|    941|            }
 3363|  4.43k|          es_putc ('\n', listfp);
 3364|  4.43k|        }
 3365|    660|      else if (not_gpg)
  ------------------
  |  Branch (3365:16): [True: 0, False: 660]
  ------------------
 3366|      0|        es_fprintf (listfp, ":trust packet: not created by gpg\n");
 3367|    660|      else
 3368|    660|        es_fprintf (listfp, ":trust packet: subtype=%02x\n",
 3369|    660|                    rt.subtype);
 3370|  11.4k|    }
 3371|       |
 3372|       |  /* Now transfer the data to the respective packet.  Do not do this
 3373|       |   * if SKIP_META is set.  */
 3374|  11.4k|  if (!ctx->last_pkt.pkt.generic || ctx->skip_meta)
  ------------------
  |  Branch (3374:7): [True: 7.06k, False: 4.43k]
  |  Branch (3374:37): [True: 0, False: 4.43k]
  ------------------
 3375|  7.06k|    ;
 3376|  4.43k|  else if (rt.subtype == RING_TRUST_SIG
  ------------------
  |  |  516|  8.86k|#define RING_TRUST_SIG 0  /* The classical signature cache.  */
  ------------------
  |  Branch (3376:12): [True: 2.28k, False: 2.15k]
  ------------------
 3377|  4.43k|           && ctx->last_pkt.pkttype == PKT_SIGNATURE)
  ------------------
  |  Branch (3377:15): [True: 1.90k, False: 372]
  ------------------
 3378|  1.90k|    {
 3379|  1.90k|      PKT_signature *sig = ctx->last_pkt.pkt.signature;
 3380|       |
 3381|  1.90k|      if ((rt.sigcache & 1))
  ------------------
  |  Branch (3381:11): [True: 1.42k, False: 483]
  ------------------
 3382|  1.42k|        {
 3383|  1.42k|          sig->flags.checked = 1;
 3384|  1.42k|          sig->flags.valid = !!(rt.sigcache & 2);
 3385|  1.42k|        }
 3386|  1.90k|    }
 3387|  2.52k|  else if (rt.subtype == RING_TRUST_UID
  ------------------
  |  |  518|  5.04k|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
  |  Branch (3387:12): [True: 913, False: 1.61k]
  ------------------
 3388|  2.52k|           && (ctx->last_pkt.pkttype == PKT_USER_ID
  ------------------
  |  Branch (3388:16): [True: 333, False: 580]
  ------------------
 3389|    913|               || ctx->last_pkt.pkttype == PKT_ATTRIBUTE))
  ------------------
  |  Branch (3389:19): [True: 0, False: 580]
  ------------------
 3390|    333|    {
 3391|    333|      PKT_user_id *uid = ctx->last_pkt.pkt.user_id;
 3392|       |
 3393|    333|      uid->keyorg = rt.keyorg;
 3394|    333|      uid->keyupdate = rt.keyupdate;
 3395|    333|      uid->updateurl = rt.url;
 3396|    333|      rt.url = NULL;
 3397|    333|    }
 3398|  2.19k|  else if (rt.subtype == RING_TRUST_KEY
  ------------------
  |  |  517|  4.38k|#define RING_TRUST_KEY 1  /* A KEYORG on a primary key.      */
  ------------------
  |  Branch (3398:12): [True: 948, False: 1.24k]
  ------------------
 3399|  2.19k|           && (ctx->last_pkt.pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (3399:16): [True: 368, False: 580]
  ------------------
 3400|    948|               || ctx->last_pkt.pkttype == PKT_SECRET_KEY))
  ------------------
  |  Branch (3400:19): [True: 348, False: 232]
  ------------------
 3401|    716|    {
 3402|    716|      PKT_public_key *pk = ctx->last_pkt.pkt.public_key;
 3403|       |
 3404|    716|      pk->keyorg = rt.keyorg;
 3405|    716|      pk->keyupdate = rt.keyupdate;
 3406|    716|      pk->updateurl = rt.url;
 3407|    716|      rt.url = NULL;
 3408|    716|    }
 3409|       |
 3410|  11.4k|  err = 0;
 3411|       |
 3412|  16.4k| leave:
 3413|  16.4k|  xfree (rt.url);
  ------------------
  |  |  104|  16.4k|#define xfree(a)         gcry_free ((a))
  ------------------
 3414|  16.4k|  free_packet (NULL, ctx); /* This sets ctx->last_pkt to NULL.  */
 3415|  16.4k|  iobuf_skip_rest (inp, pktlen, 0);
 3416|  16.4k|  return err;
 3417|  11.4k|}
parse-packet.c:parse_plaintext:
 3423|  10.3k|{
 3424|  10.3k|  int rc = 0;
 3425|  10.3k|  int mode, namelen;
 3426|  10.3k|  PKT_plaintext *pt;
 3427|  10.3k|  byte *p;
 3428|  10.3k|  int c, i;
 3429|       |
 3430|  10.3k|  if (!partial && pktlen < 6)
  ------------------
  |  Branch (3430:7): [True: 5.00k, False: 5.38k]
  |  Branch (3430:19): [True: 678, False: 4.32k]
  ------------------
 3431|    678|    {
 3432|    678|      log_error ("packet(%d) too short (%lu)\n", pkttype, (ulong) pktlen);
 3433|    678|      if (list_mode)
  ------------------
  |  Branch (3433:11): [True: 678, False: 0]
  ------------------
 3434|    678|        es_fputs (":literal data packet: [too short]\n", listfp);
 3435|    678|      rc = gpg_error (GPG_ERR_INV_PACKET);
 3436|    678|      goto leave;
 3437|    678|    }
 3438|  9.70k|  mode = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  9.70k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  9.70k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 9.70k]
  |  |  |  |  |  Branch (500:24): [True: 4.12k, False: 5.58k]
  |  |  |  |  ------------------
  |  |  |  |  501|  9.70k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3439|  9.70k|  if (pktlen)
  ------------------
  |  Branch (3439:7): [True: 4.32k, False: 5.38k]
  ------------------
 3440|  4.32k|    pktlen--;
 3441|  9.70k|  namelen = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  9.70k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  9.70k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 9.70k]
  |  |  |  |  |  Branch (500:24): [True: 424, False: 9.28k]
  |  |  |  |  ------------------
  |  |  |  |  501|  9.70k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3442|  9.70k|  if (pktlen)
  ------------------
  |  Branch (3442:7): [True: 4.32k, False: 5.38k]
  ------------------
 3443|  4.32k|    pktlen--;
 3444|       |  /* Note that namelen will never exceed 255 bytes. */
 3445|  9.70k|  pt = pkt->pkt.plaintext =
 3446|  9.70k|    xmalloc (sizeof *pkt->pkt.plaintext + namelen - 1);
  ------------------
  |  |  107|  9.70k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 3447|  9.70k|  pt->new_ctb = new_ctb;
 3448|  9.70k|  pt->mode = mode;
 3449|  9.70k|  pt->namelen = namelen;
 3450|  9.70k|  pt->is_partial = partial;
 3451|  9.70k|  if (pktlen)
  ------------------
  |  Branch (3451:7): [True: 4.32k, False: 5.38k]
  ------------------
 3452|  4.32k|    {
 3453|  75.0k|      for (i = 0; pktlen > 4 && i < namelen; pktlen--, i++)
  ------------------
  |  Branch (3453:19): [True: 71.8k, False: 3.17k]
  |  Branch (3453:33): [True: 70.6k, False: 1.15k]
  ------------------
 3454|  70.6k|	pt->name[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  70.6k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  70.6k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 70.6k]
  |  |  |  |  |  Branch (500:24): [True: 25.6k, False: 45.0k]
  |  |  |  |  ------------------
  |  |  |  |  501|  70.6k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3455|  4.32k|    }
 3456|  5.38k|  else
 3457|  5.38k|    {
 3458|  8.82k|      for (i = 0; i < namelen; i++)
  ------------------
  |  Branch (3458:19): [True: 3.66k, False: 5.16k]
  ------------------
 3459|  3.66k|	if ((c = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|  3.66k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 3.66k]
  |  |  |  Branch (500:24): [True: 354, False: 3.30k]
  |  |  ------------------
  |  |  501|  3.66k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (3459:6): [True: 227, False: 3.43k]
  ------------------
 3460|    227|	  break;
 3461|  3.43k|	else
 3462|  3.43k|	  pt->name[i] = c;
 3463|  5.38k|    }
 3464|       |  /* Fill up NAME so that a check with valgrind won't complain about
 3465|       |   * reading from uninitialized memory.  This case may be triggred by
 3466|       |   * corrupted packets.  */
 3467|   660k|  for (; i < namelen; i++)
  ------------------
  |  Branch (3467:10): [True: 650k, False: 9.70k]
  ------------------
 3468|   650k|    pt->name[i] = 0;
 3469|       |
 3470|  9.70k|  pt->timestamp = read_32 (inp);
 3471|  9.70k|  if (pktlen)
  ------------------
  |  Branch (3471:7): [True: 4.32k, False: 5.38k]
  ------------------
 3472|  4.32k|    pktlen -= 4;
 3473|  9.70k|  pt->len = pktlen;
 3474|  9.70k|  pt->buf = inp;
 3475|       |
 3476|  9.70k|  if (list_mode)
  ------------------
  |  Branch (3476:7): [True: 9.70k, False: 0]
  ------------------
 3477|  9.70k|    {
 3478|  9.70k|      es_fprintf (listfp, ":literal data packet:\n"
 3479|  9.70k|                  "\tmode %c (%X), created %lu, name=\"",
 3480|  9.70k|                  mode >= ' ' && mode < 'z' ? mode : '?', mode,
  ------------------
  |  Branch (3480:19): [True: 6.46k, False: 3.24k]
  |  Branch (3480:34): [True: 4.76k, False: 1.69k]
  ------------------
 3481|  9.70k|                  (ulong) pt->timestamp);
 3482|   734k|      for (p = pt->name, i = 0; i < namelen; p++, i++)
  ------------------
  |  Branch (3482:33): [True: 724k, False: 9.70k]
  ------------------
 3483|   724k|	{
 3484|   724k|	  if (*p >= ' ' && *p <= 'z')
  ------------------
  |  Branch (3484:8): [True: 55.2k, False: 669k]
  |  Branch (3484:21): [True: 9.98k, False: 45.2k]
  ------------------
 3485|  9.98k|	    es_putc (*p, listfp);
 3486|   714k|	  else
 3487|   714k|	    es_fprintf (listfp, "\\x%02x", *p);
 3488|   724k|	}
 3489|  9.70k|      es_fprintf (listfp, "\",\n\traw data: ");
 3490|  9.70k|      if (partial)
  ------------------
  |  Branch (3490:11): [True: 5.38k, False: 4.32k]
  ------------------
 3491|  5.38k|	es_fprintf (listfp, "unknown length\n");
 3492|  4.32k|      else
 3493|  4.32k|	es_fprintf (listfp, "%lu bytes\n", (ulong) pt->len);
 3494|  9.70k|    }
 3495|       |
 3496|  10.3k| leave:
 3497|  10.3k|  return rc;
 3498|  9.70k|}
parse-packet.c:parse_compressed:
 3504|  3.56k|{
 3505|  3.56k|  PKT_compressed *zd;
 3506|       |
 3507|       |  /* PKTLEN is here 0, but data follows (this should be the last
 3508|       |     object in a file or the compress algorithm should know the
 3509|       |     length).  */
 3510|  3.56k|  (void) pkttype;
 3511|  3.56k|  (void) pktlen;
 3512|       |
 3513|  3.56k|  zd = pkt->pkt.compressed = xmalloc (sizeof *pkt->pkt.compressed);
  ------------------
  |  |  107|  3.56k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 3514|  3.56k|  zd->algorithm = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  3.56k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  3.56k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 3.56k]
  |  |  |  |  |  Branch (500:24): [True: 1.09k, False: 2.46k]
  |  |  |  |  ------------------
  |  |  |  |  501|  3.56k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3515|  3.56k|  zd->len = 0;			/* not used */
 3516|  3.56k|  zd->new_ctb = new_ctb;
 3517|  3.56k|  zd->buf = inp;
 3518|  3.56k|  if (list_mode)
  ------------------
  |  Branch (3518:7): [True: 3.56k, False: 0]
  ------------------
 3519|  3.56k|    es_fprintf (listfp, ":compressed packet: algo=%d\n", zd->algorithm);
 3520|  3.56k|  return 0;
 3521|  3.56k|}
parse-packet.c:parse_encrypted:
 3527|  94.7k|{
 3528|  94.7k|  int rc = 0;
 3529|  94.7k|  PKT_encrypted *ed;
 3530|  94.7k|  unsigned long orig_pktlen = pktlen;
 3531|       |
 3532|  94.7k|  ed = pkt->pkt.encrypted = xmalloc (sizeof *pkt->pkt.encrypted);
  ------------------
  |  |  107|  94.7k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 3533|       |  /* ed->len is set below.  */
 3534|  94.7k|  ed->extralen = 0;  /* Unknown here; only used in build_packet.  */
 3535|  94.7k|  ed->buf = NULL;
 3536|  94.7k|  ed->new_ctb = new_ctb;
 3537|  94.7k|  ed->is_partial = partial;
 3538|  94.7k|  ed->aead_algo = 0;
 3539|  94.7k|  ed->cipher_algo = 0; /* Only used with AEAD.  */
 3540|  94.7k|  ed->chunkbyte = 0;   /* Only used with AEAD.  */
 3541|  94.7k|  if (pkttype == PKT_ENCRYPTED_MDC)
  ------------------
  |  Branch (3541:7): [True: 21.6k, False: 73.1k]
  ------------------
 3542|  21.6k|    {
 3543|       |      /* Fixme: add some pktlen sanity checks.  */
 3544|  21.6k|      int version;
 3545|       |
 3546|  21.6k|      version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  21.6k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  21.6k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 21.6k]
  |  |  |  |  |  Branch (500:24): [True: 17.9k, False: 3.69k]
  |  |  |  |  ------------------
  |  |  |  |  501|  21.6k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3547|  21.6k|      if (orig_pktlen)
  ------------------
  |  Branch (3547:11): [True: 2.56k, False: 19.0k]
  ------------------
 3548|  2.56k|	pktlen--;
 3549|  21.6k|      if (version != 1)
  ------------------
  |  Branch (3549:11): [True: 19.8k, False: 1.73k]
  ------------------
 3550|  19.8k|	{
 3551|  19.8k|	  log_error ("encrypted_mdc packet with unknown version %d\n",
 3552|  19.8k|		     version);
 3553|  19.8k|          if (list_mode)
  ------------------
  |  Branch (3553:15): [True: 19.8k, False: 0]
  ------------------
 3554|  19.8k|            es_fputs (":encrypted data packet: [unknown version]\n", listfp);
 3555|       |	  /*skip_rest(inp, pktlen); should we really do this? */
 3556|  19.8k|	  rc = gpg_error (GPG_ERR_INV_PACKET);
 3557|  19.8k|	  goto leave;
 3558|  19.8k|	}
 3559|  1.73k|      ed->mdc_method = DIGEST_ALGO_SHA1;
 3560|  1.73k|    }
 3561|  73.1k|  else
 3562|  73.1k|    ed->mdc_method = 0;
 3563|       |
 3564|       |  /* A basic sanity check.  We need at least an 8 byte IV plus the 2
 3565|       |     detection bytes.  Note that we don't known the algorithm and thus
 3566|       |     we may only check against the minimum blocksize.  */
 3567|  74.9k|  if (orig_pktlen && pktlen < 10)
  ------------------
  |  Branch (3567:7): [True: 1.68k, False: 73.2k]
  |  Branch (3567:22): [True: 776, False: 911]
  ------------------
 3568|    776|    {
 3569|       |      /* Actually this is blocksize+2.  */
 3570|    776|      log_error ("packet(%d) too short\n", pkttype);
 3571|    776|      if (list_mode)
  ------------------
  |  Branch (3571:11): [True: 776, False: 0]
  ------------------
 3572|    776|        es_fputs (":encrypted data packet: [too short]\n", listfp);
 3573|    776|      rc = GPG_ERR_INV_PACKET;
 3574|    776|      iobuf_skip_rest (inp, pktlen, partial);
 3575|    776|      goto leave;
 3576|    776|    }
 3577|       |
 3578|       |  /* Store the remaining length of the encrypted data (i.e. without
 3579|       |     the MDC version number but with the IV etc.).  This value is
 3580|       |     required during decryption.  */
 3581|  74.1k|  ed->len = pktlen;
 3582|       |
 3583|  74.1k|  if (list_mode)
  ------------------
  |  Branch (3583:7): [True: 74.1k, False: 0]
  ------------------
 3584|  74.1k|    {
 3585|  74.1k|      if (orig_pktlen)
  ------------------
  |  Branch (3585:11): [True: 911, False: 73.2k]
  ------------------
 3586|    911|	es_fprintf (listfp, ":encrypted data packet:\n\tlength: %lu\n",
 3587|    911|                    orig_pktlen);
 3588|  73.2k|      else
 3589|  73.2k|	es_fprintf (listfp, ":encrypted data packet:\n\tlength: unknown\n");
 3590|  74.1k|      if (ed->mdc_method)
  ------------------
  |  Branch (3590:11): [True: 1.69k, False: 72.4k]
  ------------------
 3591|  1.69k|	es_fprintf (listfp, "\tmdc_method: %d\n", ed->mdc_method);
 3592|  74.1k|    }
 3593|       |
 3594|  74.1k|  ed->buf = inp;
 3595|       |
 3596|  94.7k| leave:
 3597|  94.7k|  return rc;
 3598|  74.1k|}
parse-packet.c:parse_mdc:
 3607|  5.07k|{
 3608|  5.07k|  int rc = 0;
 3609|  5.07k|  PKT_mdc *mdc;
 3610|  5.07k|  byte *p;
 3611|       |
 3612|  5.07k|  (void) pkttype;
 3613|       |
 3614|  5.07k|  mdc = pkt->pkt.mdc = xmalloc (sizeof *pkt->pkt.mdc);
  ------------------
  |  |  107|  5.07k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 3615|  5.07k|  if (list_mode)
  ------------------
  |  Branch (3615:7): [True: 5.07k, False: 0]
  ------------------
 3616|  5.07k|    es_fprintf (listfp, ":mdc packet: length=%lu\n", pktlen);
 3617|  5.07k|  if (!new_ctb || pktlen != 20)
  ------------------
  |  Branch (3617:7): [True: 0, False: 5.07k]
  |  Branch (3617:19): [True: 2.10k, False: 2.97k]
  ------------------
 3618|  2.10k|    {
 3619|  2.10k|      log_error ("mdc_packet with invalid encoding\n");
 3620|  2.10k|      rc = gpg_error (GPG_ERR_INV_PACKET);
 3621|  2.10k|      goto leave;
 3622|  2.10k|    }
 3623|  2.97k|  p = mdc->hash;
 3624|  62.4k|  for (; pktlen; pktlen--, p++)
  ------------------
  |  Branch (3624:10): [True: 59.4k, False: 2.97k]
  ------------------
 3625|  59.4k|    *p = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  62.4k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  59.4k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 59.4k]
  |  |  |  |  |  Branch (500:24): [True: 729, False: 58.7k]
  |  |  |  |  ------------------
  |  |  |  |  501|  59.4k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3626|       |
 3627|  5.07k| leave:
 3628|  5.07k|  return rc;
 3629|  2.97k|}
parse-packet.c:parse_encrypted_aead:
 3635|  66.5k|{
 3636|  66.5k|  int rc = 0;
 3637|  66.5k|  PKT_encrypted *ed;
 3638|  66.5k|  unsigned long orig_pktlen = pktlen;
 3639|  66.5k|  int version;
 3640|       |
 3641|  66.5k|  ed = pkt->pkt.encrypted = xtrymalloc (sizeof *pkt->pkt.encrypted);
  ------------------
  |  |   97|  66.5k|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 3642|  66.5k|  if (!ed)
  ------------------
  |  Branch (3642:7): [True: 0, False: 66.5k]
  ------------------
 3643|      0|    return gpg_error_from_syserror ();
 3644|  66.5k|  ed->len = 0;
 3645|  66.5k|  ed->extralen = 0;  /* (only used in build_packet.)  */
 3646|  66.5k|  ed->buf = NULL;
 3647|  66.5k|  ed->new_ctb = 1;   /* (packet number requires a new CTB anyway.)  */
 3648|  66.5k|  ed->is_partial = partial;
 3649|  66.5k|  ed->mdc_method = 0;
 3650|       |  /* A basic sanity check.  We need one version byte, one algo byte,
 3651|       |   * one aead algo byte, one chunkbyte, at least 15 byte IV.  */
 3652|  66.5k|  if (orig_pktlen && pktlen < 19)
  ------------------
  |  Branch (3652:7): [True: 4.42k, False: 62.1k]
  |  Branch (3652:22): [True: 2.69k, False: 1.73k]
  ------------------
 3653|  2.69k|    {
 3654|  2.69k|      log_error ("packet(%d) too short\n", pkttype);
 3655|  2.69k|      if (list_mode)
  ------------------
  |  Branch (3655:11): [True: 2.69k, False: 0]
  ------------------
 3656|  2.69k|        es_fputs (":aead encrypted packet: [too short]\n", listfp);
 3657|  2.69k|      rc = gpg_error (GPG_ERR_INV_PACKET);
 3658|  2.69k|      iobuf_skip_rest (inp, pktlen, partial);
 3659|  2.69k|      goto leave;
 3660|  2.69k|    }
 3661|       |
 3662|  63.8k|  version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  63.8k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  63.8k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 63.8k]
  |  |  |  |  |  Branch (500:24): [True: 11.0k, False: 52.8k]
  |  |  |  |  ------------------
  |  |  |  |  501|  63.8k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3663|  63.8k|  if (orig_pktlen)
  ------------------
  |  Branch (3663:7): [True: 1.73k, False: 62.1k]
  ------------------
 3664|  1.73k|    pktlen--;
 3665|  63.8k|  if (version != 1)
  ------------------
  |  Branch (3665:7): [True: 17.6k, False: 46.1k]
  ------------------
 3666|  17.6k|    {
 3667|  17.6k|      log_error ("aead encrypted packet with unknown version %d\n",
 3668|  17.6k|                 version);
 3669|  17.6k|      if (list_mode)
  ------------------
  |  Branch (3669:11): [True: 17.6k, False: 0]
  ------------------
 3670|  17.6k|        es_fputs (":aead encrypted packet: [unknown version]\n", listfp);
 3671|       |      /*skip_rest(inp, pktlen); should we really do this? */
 3672|  17.6k|      rc = gpg_error (GPG_ERR_INV_PACKET);
 3673|  17.6k|      goto leave;
 3674|  17.6k|    }
 3675|       |
 3676|  46.1k|  ed->cipher_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  46.1k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  46.1k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 46.1k]
  |  |  |  |  |  Branch (500:24): [True: 93, False: 46.0k]
  |  |  |  |  ------------------
  |  |  |  |  501|  46.1k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3677|  46.1k|  if (orig_pktlen)
  ------------------
  |  Branch (3677:7): [True: 261, False: 45.9k]
  ------------------
 3678|    261|    pktlen--;
 3679|  46.1k|  ed->aead_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  46.1k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  46.1k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 46.1k]
  |  |  |  |  |  Branch (500:24): [True: 285, False: 45.9k]
  |  |  |  |  ------------------
  |  |  |  |  501|  46.1k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3680|  46.1k|  if (orig_pktlen)
  ------------------
  |  Branch (3680:7): [True: 261, False: 45.9k]
  ------------------
 3681|    261|    pktlen--;
 3682|  46.1k|  ed->chunkbyte = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  46.1k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  46.1k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 46.1k]
  |  |  |  |  |  Branch (500:24): [True: 361, False: 45.8k]
  |  |  |  |  ------------------
  |  |  |  |  501|  46.1k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3683|  46.1k|  if (orig_pktlen)
  ------------------
  |  Branch (3683:7): [True: 261, False: 45.9k]
  ------------------
 3684|    261|    pktlen--;
 3685|       |
 3686|       |  /* Store the remaining length of the encrypted data.  We read the
 3687|       |   * rest during decryption.  */
 3688|  46.1k|  ed->len = pktlen;
 3689|       |
 3690|  46.1k|  if (list_mode)
  ------------------
  |  Branch (3690:7): [True: 46.1k, False: 0]
  ------------------
 3691|  46.1k|    {
 3692|  46.1k|      es_fprintf (listfp, ":aead encrypted packet: cipher=%u aead=%u cb=%u\n",
 3693|  46.1k|                  ed->cipher_algo, ed->aead_algo, ed->chunkbyte);
 3694|  46.1k|      if (orig_pktlen)
  ------------------
  |  Branch (3694:11): [True: 261, False: 45.9k]
  ------------------
 3695|    261|	es_fprintf (listfp, "\tlength: %lu\n", orig_pktlen);
 3696|  45.9k|      else
 3697|  45.9k|	es_fprintf (listfp, "\tlength: unknown\n");
 3698|  46.1k|    }
 3699|       |
 3700|  46.1k|  ed->buf = inp;
 3701|       |
 3702|  66.5k| leave:
 3703|  66.5k|  return rc;
 3704|  46.1k|}
parse-packet.c:parse_gpg_control:
 3721|  24.1k|{
 3722|  24.1k|  byte *p;
 3723|  24.1k|  const byte *sesmark;
 3724|  24.1k|  size_t sesmarklen;
 3725|  24.1k|  int i;
 3726|       |
 3727|  24.1k|  (void) pkttype;
 3728|       |
 3729|  24.1k|  if (list_mode)
  ------------------
  |  Branch (3729:7): [True: 24.1k, False: 0]
  ------------------
 3730|  24.1k|    es_fprintf (listfp, ":packet 63: length %lu ", pktlen);
 3731|       |
 3732|  24.1k|  sesmark = get_session_marker (&sesmarklen);
 3733|  24.1k|  if (pktlen < sesmarklen + 1)	/* 1 is for the control bytes */
  ------------------
  |  Branch (3733:7): [True: 17.1k, False: 6.98k]
  ------------------
 3734|  17.1k|    goto skipit;
 3735|  69.2k|  for (i = 0; i < sesmarklen; i++, pktlen--)
  ------------------
  |  Branch (3735:15): [True: 65.3k, False: 3.89k]
  ------------------
 3736|  65.3k|    {
 3737|  65.3k|      if (sesmark[i] != iobuf_get_noeof (inp))
  ------------------
  |  |  502|  65.3k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  65.3k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 65.3k]
  |  |  |  |  |  Branch (500:24): [True: 303, False: 65.0k]
  |  |  |  |  ------------------
  |  |  |  |  501|  65.3k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
  |  Branch (3737:11): [True: 3.09k, False: 62.2k]
  ------------------
 3738|  3.09k|	goto skipit;
 3739|  65.3k|    }
 3740|  3.89k|  if (pktlen > 4096)
  ------------------
  |  Branch (3740:7): [True: 258, False: 3.63k]
  ------------------
 3741|    258|    goto skipit;  /* Definitely too large.  We skip it to avoid an
 3742|       |                     overflow in the malloc.  */
 3743|  3.63k|  if (list_mode)
  ------------------
  |  Branch (3743:7): [True: 3.63k, False: 0]
  ------------------
 3744|  3.63k|    es_fputs ("- gpg control packet", listfp);
 3745|       |
 3746|  3.63k|  packet->pkt.gpg_control = xmalloc (sizeof *packet->pkt.gpg_control
  ------------------
  |  |  107|  3.63k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 3747|  3.63k|				     + pktlen - 1);
 3748|  3.63k|  packet->pkt.gpg_control->control = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  3.63k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  3.63k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 3.63k]
  |  |  |  |  |  Branch (500:24): [True: 144, False: 3.48k]
  |  |  |  |  ------------------
  |  |  |  |  501|  3.63k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3749|  3.63k|  pktlen--;
 3750|  3.63k|  packet->pkt.gpg_control->datalen = pktlen;
 3751|  3.63k|  p = packet->pkt.gpg_control->data;
 3752|  41.4k|  for (; pktlen; pktlen--, p++)
  ------------------
  |  Branch (3752:10): [True: 37.7k, False: 3.63k]
  ------------------
 3753|  37.7k|    *p = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  41.4k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  37.7k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 37.7k]
  |  |  |  |  |  Branch (500:24): [True: 24.8k, False: 12.9k]
  |  |  |  |  ------------------
  |  |  |  |  501|  37.7k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3754|       |
 3755|  3.63k|  return 0;
 3756|       |
 3757|  20.5k| skipit:
 3758|  20.5k|  if (list_mode)
  ------------------
  |  Branch (3758:7): [True: 20.5k, False: 0]
  ------------------
 3759|  20.5k|    {
 3760|  20.5k|      int c;
 3761|       |
 3762|  20.5k|      i = 0;
 3763|  20.5k|      es_fprintf (listfp, "- private (rest length %lu)\n", pktlen);
 3764|  20.5k|      if (partial)
  ------------------
  |  Branch (3764:11): [True: 0, False: 20.5k]
  ------------------
 3765|      0|	{
 3766|      0|	  while ((c = iobuf_get (inp)) != -1)
  ------------------
  |  |  500|      0|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 0]
  |  |  |  Branch (500:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  501|      0|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (3766:11): [True: 0, False: 0]
  ------------------
 3767|      0|	    dump_hex_line (c, &i);
 3768|      0|	}
 3769|  20.5k|      else
 3770|  20.5k|	{
 3771|   968k|	  for (; pktlen; pktlen--)
  ------------------
  |  Branch (3771:11): [True: 948k, False: 19.7k]
  ------------------
 3772|   948k|	    {
 3773|   948k|	      dump_hex_line ((c = iobuf_get (inp)), &i);
  ------------------
  |  |  500|   948k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 948k]
  |  |  |  Branch (500:24): [True: 1.11k, False: 947k]
  |  |  ------------------
  |  |  501|   948k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 3774|   948k|	      if (c == -1)
  ------------------
  |  Branch (3774:12): [True: 740, False: 948k]
  ------------------
 3775|    740|		break;
 3776|   948k|	    }
 3777|  20.5k|	}
 3778|  20.5k|      es_putc ('\n', listfp);
 3779|  20.5k|    }
 3780|  20.5k|  iobuf_skip_rest (inp, pktlen, 0);
 3781|  20.5k|  return gpg_error (GPG_ERR_INV_PACKET);
 3782|  3.89k|}
parse-packet.c:dump_hex_line:
  972|  1.69M|{
  973|  1.69M|  if (*i && !(*i % 8))
  ------------------
  |  Branch (973:7): [True: 1.67M, False: 16.1k]
  |  Branch (973:13): [True: 205k, False: 1.47M]
  ------------------
  974|   205k|    {
  975|   205k|      if (*i && !(*i % 24))
  ------------------
  |  Branch (975:11): [True: 205k, False: 0]
  |  Branch (975:17): [True: 64.7k, False: 140k]
  ------------------
  976|  64.7k|	es_fprintf (listfp, "\n%4d:", *i);
  977|   140k|      else
  978|   140k|	es_putc (' ', listfp);
  979|   205k|    }
  980|  1.69M|  if (c == -1)
  ------------------
  |  Branch (980:7): [True: 1.43k, False: 1.69M]
  ------------------
  981|  1.43k|    es_fprintf (listfp, " EOF");
  982|  1.69M|  else
  983|  1.69M|    es_fprintf (listfp, " %02x", c);
  984|  1.69M|  ++*i;
  985|  1.69M|}
parse-packet.c:parse_marker:
 1166|  14.9k|{
 1167|  14.9k|  (void) pkttype;
 1168|       |
 1169|  14.9k|  if (pktlen != 3)
  ------------------
  |  Branch (1169:7): [True: 1.39k, False: 13.5k]
  ------------------
 1170|  1.39k|    goto fail;
 1171|       |
 1172|  13.5k|  if (iobuf_get (inp) != 'P')
  ------------------
  |  |  500|  13.5k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 13.5k]
  |  |  |  Branch (500:24): [True: 201, False: 13.3k]
  |  |  ------------------
  |  |  501|  13.5k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (1172:7): [True: 993, False: 12.5k]
  ------------------
 1173|    993|    {
 1174|    993|      pktlen--;
 1175|    993|      goto fail;
 1176|    993|    }
 1177|       |
 1178|  12.5k|  if (iobuf_get (inp) != 'G')
  ------------------
  |  |  500|  12.5k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 12.5k]
  |  |  |  Branch (500:24): [True: 219, False: 12.3k]
  |  |  ------------------
  |  |  501|  12.5k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (1178:7): [True: 5.63k, False: 6.94k]
  ------------------
 1179|  5.63k|    {
 1180|  5.63k|      pktlen--;
 1181|  5.63k|      goto fail;
 1182|  5.63k|    }
 1183|       |
 1184|  6.94k|  if (iobuf_get (inp) != 'P')
  ------------------
  |  |  500|  6.94k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 6.94k]
  |  |  |  Branch (500:24): [True: 85, False: 6.85k]
  |  |  ------------------
  |  |  501|  6.94k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (1184:7): [True: 1.51k, False: 5.42k]
  ------------------
 1185|  1.51k|    {
 1186|  1.51k|      pktlen--;
 1187|  1.51k|      goto fail;
 1188|  1.51k|    }
 1189|       |
 1190|  5.42k|  if (list_mode)
  ------------------
  |  Branch (1190:7): [True: 5.42k, False: 0]
  ------------------
 1191|  5.42k|    es_fputs (":marker packet: PGP\n", listfp);
 1192|       |
 1193|  5.42k|  return 0;
 1194|       |
 1195|  9.54k| fail:
 1196|  9.54k|  log_error ("invalid marker packet\n");
 1197|  9.54k|  if (list_mode)
  ------------------
  |  Branch (1197:7): [True: 9.54k, False: 0]
  ------------------
 1198|  9.54k|    es_fputs (":marker packet: [invalid]\n", listfp);
 1199|  9.54k|  iobuf_skip_rest (inp, pktlen, 0);
 1200|  9.54k|  return GPG_ERR_INV_PACKET;
 1201|  6.94k|}
parse-packet.c:skip_packet:
 1045|  18.0k|{
 1046|  18.0k|  if (list_mode)
  ------------------
  |  Branch (1046:7): [True: 18.0k, False: 0]
  ------------------
 1047|  18.0k|    {
 1048|  18.0k|      es_fprintf (listfp, ":unknown packet: type %2d, length %lu\n",
 1049|  18.0k|                  pkttype, pktlen);
 1050|  18.0k|      if (pkttype)
  ------------------
  |  Branch (1050:11): [True: 18.0k, False: 0]
  ------------------
 1051|  18.0k|	{
 1052|  18.0k|	  int c, i = 0;
 1053|  18.0k|	  es_fputs ("dump:", listfp);
 1054|  18.0k|	  if (partial)
  ------------------
  |  Branch (1054:8): [True: 0, False: 18.0k]
  ------------------
 1055|      0|	    {
 1056|      0|	      while ((c = iobuf_get (inp)) != -1)
  ------------------
  |  |  500|      0|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 0]
  |  |  |  Branch (500:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  501|      0|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (1056:15): [True: 0, False: 0]
  ------------------
 1057|      0|		dump_hex_line (c, &i);
 1058|      0|	    }
 1059|  18.0k|	  else
 1060|  18.0k|	    {
 1061|   762k|	      for (; pktlen; pktlen--)
  ------------------
  |  Branch (1061:15): [True: 744k, False: 17.4k]
  ------------------
 1062|   744k|		{
 1063|   744k|		  dump_hex_line ((c = iobuf_get (inp)), &i);
  ------------------
  |  |  500|   744k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 744k]
  |  |  |  Branch (500:24): [True: 1.02k, False: 743k]
  |  |  ------------------
  |  |  501|   744k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 1064|   744k|		  if (c == -1)
  ------------------
  |  Branch (1064:9): [True: 697, False: 743k]
  ------------------
 1065|    697|		    break;
 1066|   744k|		}
 1067|  18.0k|	    }
 1068|  18.0k|	  es_putc ('\n', listfp);
 1069|  18.0k|	  return;
 1070|  18.0k|	}
 1071|  18.0k|    }
 1072|      0|  iobuf_skip_rest (inp, pktlen, partial);
 1073|      0|}
parse-packet.c:can_handle_critical:
 1834|  23.3k|{
 1835|  23.3k|  switch (type)
 1836|  23.3k|    {
 1837|  1.87k|    case SIGSUBPKT_NOTATION:
  ------------------
  |  Branch (1837:5): [True: 1.87k, False: 21.4k]
  ------------------
 1838|  1.87k|      if (n >= 8)
  ------------------
  |  Branch (1838:11): [True: 1.25k, False: 621]
  ------------------
 1839|  1.25k|	{
 1840|  1.25k|	  size_t notation_len = ((buffer[4] << 8) | buffer[5]);
 1841|  1.25k|	  if (n - 8 >= notation_len)
  ------------------
  |  Branch (1841:8): [True: 1.02k, False: 225]
  ------------------
 1842|  1.02k|	    return can_handle_critical_notation (buffer + 8, notation_len);
 1843|  1.25k|	}
 1844|    846|      return 0;
 1845|    433|    case SIGSUBPKT_SIGNATURE:
  ------------------
  |  Branch (1845:5): [True: 433, False: 22.9k]
  ------------------
 1846|    630|    case SIGSUBPKT_SIG_CREATED:
  ------------------
  |  Branch (1846:5): [True: 197, False: 23.1k]
  ------------------
 1847|    888|    case SIGSUBPKT_SIG_EXPIRE:
  ------------------
  |  Branch (1847:5): [True: 258, False: 23.0k]
  ------------------
 1848|  1.12k|    case SIGSUBPKT_KEY_EXPIRE:
  ------------------
  |  Branch (1848:5): [True: 235, False: 23.1k]
  ------------------
 1849|  1.58k|    case SIGSUBPKT_EXPORTABLE:
  ------------------
  |  Branch (1849:5): [True: 464, False: 22.8k]
  ------------------
 1850|  2.62k|    case SIGSUBPKT_REVOCABLE:
  ------------------
  |  Branch (1850:5): [True: 1.03k, False: 22.3k]
  ------------------
 1851|  4.02k|    case SIGSUBPKT_REV_KEY:
  ------------------
  |  Branch (1851:5): [True: 1.40k, False: 21.9k]
  ------------------
 1852|  4.23k|    case SIGSUBPKT_ISSUER:	/* issuer key ID */
  ------------------
  |  Branch (1852:5): [True: 203, False: 23.1k]
  ------------------
 1853|  4.71k|    case SIGSUBPKT_ISSUER_FPR:	/* issuer fingerprint */
  ------------------
  |  Branch (1853:5): [True: 489, False: 22.8k]
  ------------------
 1854|  5.70k|    case SIGSUBPKT_PREF_SYM:
  ------------------
  |  Branch (1854:5): [True: 984, False: 22.3k]
  ------------------
 1855|  5.92k|    case SIGSUBPKT_PREF_AEAD:
  ------------------
  |  Branch (1855:5): [True: 225, False: 23.1k]
  ------------------
 1856|  6.50k|    case SIGSUBPKT_PREF_HASH:
  ------------------
  |  Branch (1856:5): [True: 577, False: 22.7k]
  ------------------
 1857|  6.90k|    case SIGSUBPKT_PREF_COMPR:
  ------------------
  |  Branch (1857:5): [True: 398, False: 22.9k]
  ------------------
 1858|  7.13k|    case SIGSUBPKT_KEY_FLAGS:
  ------------------
  |  Branch (1858:5): [True: 231, False: 23.1k]
  ------------------
 1859|  7.38k|    case SIGSUBPKT_PRIMARY_UID:
  ------------------
  |  Branch (1859:5): [True: 249, False: 23.0k]
  ------------------
 1860|  8.53k|    case SIGSUBPKT_FEATURES:
  ------------------
  |  Branch (1860:5): [True: 1.15k, False: 22.1k]
  ------------------
 1861|  8.83k|    case SIGSUBPKT_TRUST:
  ------------------
  |  Branch (1861:5): [True: 297, False: 23.0k]
  ------------------
 1862|  10.1k|    case SIGSUBPKT_REGEXP:
  ------------------
  |  Branch (1862:5): [True: 1.30k, False: 22.0k]
  ------------------
 1863|  11.6k|    case SIGSUBPKT_ATTST_SIGS:
  ------------------
  |  Branch (1863:5): [True: 1.51k, False: 21.8k]
  ------------------
 1864|       |      /* Is it enough to show the policy or keyserver? */
 1865|  12.2k|    case SIGSUBPKT_POLICY:
  ------------------
  |  Branch (1865:5): [True: 613, False: 22.7k]
  ------------------
 1866|  13.2k|    case SIGSUBPKT_PREF_KS:
  ------------------
  |  Branch (1866:5): [True: 1.03k, False: 22.3k]
  ------------------
 1867|  14.0k|    case SIGSUBPKT_REVOC_REASON: /* At least we know about it.  */
  ------------------
  |  Branch (1867:5): [True: 735, False: 22.6k]
  ------------------
 1868|  14.0k|      return 1;
 1869|       |
 1870|  2.44k|    case SIGSUBPKT_KEY_BLOCK:
  ------------------
  |  Branch (1870:5): [True: 2.44k, False: 20.8k]
  ------------------
 1871|  2.44k|      if (n && !buffer[0])
  ------------------
  |  Branch (1871:11): [True: 937, False: 1.51k]
  |  Branch (1871:16): [True: 299, False: 638]
  ------------------
 1872|    299|        return 1;
 1873|  2.14k|      else
 1874|  2.14k|        return 0;
 1875|       |
 1876|  4.98k|    default:
  ------------------
  |  Branch (1876:5): [True: 4.98k, False: 18.3k]
  ------------------
 1877|  4.98k|      return 0;
 1878|  23.3k|    }
 1879|  23.3k|}
parse-packet.c:can_handle_critical_notation:
 1812|  1.02k|{
 1813|  1.02k|  strlist_t sl;
 1814|       |
 1815|  1.02k|  register_known_notation (NULL); /* Make sure it is initialized.  */
 1816|       |
 1817|  1.99k|  for (sl = known_notations_list; sl; sl = sl->next)
  ------------------
  |  Branch (1817:35): [True: 1.02k, False: 962]
  ------------------
 1818|  1.02k|    if (sl->flags == len && !memcmp (sl->d, name, len))
  ------------------
  |  Branch (1818:9): [True: 329, False: 699]
  |  Branch (1818:29): [True: 66, False: 263]
  ------------------
 1819|     66|      return 1; /* Known */
 1820|       |
 1821|    962|  if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (1821:7): [True: 0, False: 962]
  |  Branch (1821:22): [True: 0, False: 0]
  ------------------
 1822|      0|    {
 1823|      0|      log_info(_("Unknown critical signature notation: ") );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1824|      0|      print_utf8_buffer (log_get_stream(), name, len);
 1825|      0|      log_printf ("\n");
 1826|      0|    }
 1827|       |
 1828|    962|  return 0; /* Unknown.  */
 1829|  1.02k|}
parse-packet.c:dump_sig_subpkt:
 1457|  71.2k|{
 1458|  71.2k|  const char *p = NULL;
 1459|  71.2k|  int i;
 1460|  71.2k|  int nprinted;
 1461|       |
 1462|       |  /* The CERT has warning out with explains how to use GNUPG to detect
 1463|       |   * the ARRs - we print our old message here when it is a faked ARR
 1464|       |   * and add an additional notice.  */
 1465|  71.2k|  if (type == SIGSUBPKT_ARR && !hashed)
  ------------------
  |  Branch (1465:7): [True: 677, False: 70.5k]
  |  Branch (1465:32): [True: 409, False: 268]
  ------------------
 1466|    409|    {
 1467|    409|      es_fprintf (listfp,
 1468|    409|                  "\tsubpkt %d len %u (additional recipient request)\n"
 1469|    409|                  "WARNING: PGP versions > 5.0 and < 6.5.8 will automagically "
 1470|    409|                  "encrypt to this key and thereby reveal the plaintext to "
 1471|    409|                  "the owner of this ARR key. Detailed info follows:\n",
 1472|    409|                  type, (unsigned) length);
 1473|    409|    }
 1474|       |
 1475|  71.2k|  buffer++;
 1476|  71.2k|  length--;
 1477|       |
 1478|  71.2k|  nprinted = es_fprintf (listfp, "\t%s%ssubpkt %d len %u (",	/*) */
 1479|  71.2k|                         critical ? "critical " : "",
  ------------------
  |  Branch (1479:26): [True: 27.7k, False: 43.5k]
  ------------------
 1480|  71.2k|                         hashed ? "hashed " : "", type, (unsigned) length);
  ------------------
  |  Branch (1480:26): [True: 57.9k, False: 13.2k]
  ------------------
 1481|  71.2k|  if (nprinted < 1)
  ------------------
  |  Branch (1481:7): [True: 0, False: 71.2k]
  ------------------
 1482|      0|    nprinted = 1; /*(we use (nprinted-1) later.)*/
 1483|  71.2k|  if (length > buflen)
  ------------------
  |  Branch (1483:7): [True: 22.0k, False: 49.2k]
  ------------------
 1484|  22.0k|    {
 1485|  22.0k|      es_fprintf (listfp, "too short: buffer is only %u)\n", (unsigned) buflen);
 1486|  22.0k|      return;
 1487|  22.0k|    }
 1488|  49.2k|  switch (type)
 1489|  49.2k|    {
 1490|    981|    case SIGSUBPKT_SIG_CREATED:
  ------------------
  |  Branch (1490:5): [True: 981, False: 48.2k]
  ------------------
 1491|    981|      if (length >= 4)
  ------------------
  |  Branch (1491:11): [True: 474, False: 507]
  ------------------
 1492|    474|	es_fprintf (listfp, "sig created %s",
 1493|    474|                    strtimestamp (buf32_to_u32 (buffer)));
 1494|    981|      break;
 1495|  2.08k|    case SIGSUBPKT_SIG_EXPIRE:
  ------------------
  |  Branch (1495:5): [True: 2.08k, False: 47.1k]
  ------------------
 1496|  2.08k|      if (length >= 4)
  ------------------
  |  Branch (1496:11): [True: 1.44k, False: 643]
  ------------------
 1497|  1.44k|	{
 1498|  1.44k|	  if (buf32_to_u32 (buffer))
  ------------------
  |  Branch (1498:8): [True: 772, False: 673]
  ------------------
 1499|    772|	    es_fprintf (listfp, "sig expires after %s",
 1500|    772|                        strtimevalue (buf32_to_u32 (buffer)));
 1501|    673|	  else
 1502|    673|	    es_fprintf (listfp, "sig does not expire");
 1503|  1.44k|	}
 1504|  2.08k|      break;
 1505|  1.53k|    case SIGSUBPKT_EXPORTABLE:
  ------------------
  |  Branch (1505:5): [True: 1.53k, False: 47.6k]
  ------------------
 1506|  1.53k|      if (length)
  ------------------
  |  Branch (1506:11): [True: 839, False: 700]
  ------------------
 1507|    839|	es_fprintf (listfp, "%sexportable", *buffer ? "" : "not ");
  ------------------
  |  Branch (1507:38): [True: 570, False: 269]
  ------------------
 1508|  1.53k|      break;
 1509|  3.57k|    case SIGSUBPKT_TRUST:
  ------------------
  |  Branch (1509:5): [True: 3.57k, False: 45.6k]
  ------------------
 1510|  3.57k|      if (length != 2)
  ------------------
  |  Branch (1510:11): [True: 1.00k, False: 2.56k]
  ------------------
 1511|  1.00k|	p = "[invalid trust subpacket]";
 1512|  2.56k|      else
 1513|  2.56k|	es_fprintf (listfp, "trust signature of depth %d, value %d", buffer[0],
 1514|  2.56k|                    buffer[1]);
 1515|  3.57k|      break;
 1516|  1.88k|    case SIGSUBPKT_REGEXP:
  ------------------
  |  Branch (1516:5): [True: 1.88k, False: 47.3k]
  ------------------
 1517|  1.88k|      if (!length)
  ------------------
  |  Branch (1517:11): [True: 1.56k, False: 311]
  ------------------
 1518|  1.56k|	p = "[invalid regexp subpacket]";
 1519|    311|      else
 1520|    311|        {
 1521|    311|          es_fprintf (listfp, "regular expression: \"");
 1522|    311|          es_write_sanitized (listfp, buffer, length, "\"", NULL);
 1523|    311|          p = "\"";
 1524|    311|        }
 1525|  1.88k|      break;
 1526|  2.75k|    case SIGSUBPKT_REVOCABLE:
  ------------------
  |  Branch (1526:5): [True: 2.75k, False: 46.4k]
  ------------------
 1527|  2.75k|      if (length)
  ------------------
  |  Branch (1527:11): [True: 1.85k, False: 904]
  ------------------
 1528|  1.85k|	es_fprintf (listfp, "%srevocable", *buffer ? "" : "not ");
  ------------------
  |  Branch (1528:37): [True: 738, False: 1.11k]
  ------------------
 1529|  2.75k|      break;
 1530|    932|    case SIGSUBPKT_KEY_EXPIRE:
  ------------------
  |  Branch (1530:5): [True: 932, False: 48.2k]
  ------------------
 1531|    932|      if (length >= 4)
  ------------------
  |  Branch (1531:11): [True: 691, False: 241]
  ------------------
 1532|    691|	{
 1533|    691|	  if (buf32_to_u32 (buffer))
  ------------------
  |  Branch (1533:8): [True: 424, False: 267]
  ------------------
 1534|    424|	    es_fprintf (listfp, "key expires after %s",
 1535|    424|                        strtimevalue (buf32_to_u32 (buffer)));
 1536|    267|	  else
 1537|    267|	    es_fprintf (listfp, "key does not expire");
 1538|    691|	}
 1539|    932|      break;
 1540|  1.25k|    case SIGSUBPKT_PREF_SYM:
  ------------------
  |  Branch (1540:5): [True: 1.25k, False: 47.9k]
  ------------------
 1541|  1.25k|      es_fputs ("pref-sym-algos:", listfp);
 1542|  5.57k|      for (i = 0; i < length; i++)
  ------------------
  |  Branch (1542:19): [True: 4.32k, False: 1.25k]
  ------------------
 1543|  4.32k|	es_fprintf (listfp, " %d", buffer[i]);
 1544|  1.25k|      break;
 1545|    837|    case SIGSUBPKT_PREF_AEAD:
  ------------------
  |  Branch (1545:5): [True: 837, False: 48.3k]
  ------------------
 1546|    837|      es_fputs ("pref-aead-algos:", listfp);
 1547|  3.37k|      for (i = 0; i < length; i++)
  ------------------
  |  Branch (1547:19): [True: 2.54k, False: 837]
  ------------------
 1548|  2.54k|        es_fprintf (listfp, " %d", buffer[i]);
 1549|    837|      break;
 1550|  1.88k|    case SIGSUBPKT_REV_KEY:
  ------------------
  |  Branch (1550:5): [True: 1.88k, False: 47.3k]
  ------------------
 1551|  1.88k|      es_fputs ("revocation key: ", listfp);
 1552|  1.88k|      if (length < 22)
  ------------------
  |  Branch (1552:11): [True: 494, False: 1.39k]
  ------------------
 1553|    494|	p = "[too short]";
 1554|  1.39k|      else
 1555|  1.39k|	{
 1556|  1.39k|	  es_fprintf (listfp, "c=%02x a=%d f=", buffer[0], buffer[1]);
 1557|  36.1k|	  for (i = 2; i < length; i++)
  ------------------
  |  Branch (1557:16): [True: 34.7k, False: 1.39k]
  ------------------
 1558|  34.7k|	    es_fprintf (listfp, "%02X", buffer[i]);
 1559|  1.39k|	}
 1560|  1.88k|      break;
 1561|    925|    case SIGSUBPKT_ISSUER:
  ------------------
  |  Branch (1561:5): [True: 925, False: 48.2k]
  ------------------
 1562|    925|      if (length >= 8)
  ------------------
  |  Branch (1562:11): [True: 267, False: 658]
  ------------------
 1563|    267|	es_fprintf (listfp, "issuer key ID %08lX%08lX",
 1564|    267|                    (ulong) buf32_to_u32 (buffer),
 1565|    267|                    (ulong) buf32_to_u32 (buffer + 4));
 1566|    925|      break;
 1567|  1.47k|    case SIGSUBPKT_ISSUER_FPR:
  ------------------
  |  Branch (1567:5): [True: 1.47k, False: 47.7k]
  ------------------
 1568|  1.47k|      if (length >= 21)
  ------------------
  |  Branch (1568:11): [True: 1.05k, False: 429]
  ------------------
 1569|  1.05k|        {
 1570|  1.05k|          char *tmp;
 1571|  1.05k|          es_fprintf (listfp, "issuer fpr v%d ", buffer[0]);
 1572|  1.05k|          tmp = bin2hex (buffer+1, length-1, NULL);
 1573|  1.05k|          if (tmp)
  ------------------
  |  Branch (1573:15): [True: 1.05k, False: 0]
  ------------------
 1574|  1.05k|            {
 1575|  1.05k|              es_fputs (tmp, listfp);
 1576|  1.05k|              xfree (tmp);
  ------------------
  |  |  104|  1.05k|#define xfree(a)         gcry_free ((a))
  ------------------
 1577|  1.05k|            }
 1578|  1.05k|        }
 1579|  1.47k|      break;
 1580|  3.00k|    case SIGSUBPKT_NOTATION:
  ------------------
  |  Branch (1580:5): [True: 3.00k, False: 46.2k]
  ------------------
 1581|  3.00k|      {
 1582|  3.00k|	es_fputs ("notation: ", listfp);
 1583|  3.00k|	if (length < 8)
  ------------------
  |  Branch (1583:6): [True: 1.73k, False: 1.27k]
  ------------------
 1584|  1.73k|	  p = "[too short]";
 1585|  1.27k|	else
 1586|  1.27k|	  {
 1587|  1.27k|	    const byte *s = buffer;
 1588|  1.27k|	    size_t n1, n2;
 1589|       |
 1590|  1.27k|	    n1 = (s[4] << 8) | s[5];
 1591|  1.27k|	    n2 = (s[6] << 8) | s[7];
 1592|  1.27k|	    s += 8;
 1593|  1.27k|	    if (8 + n1 + n2 != length)
  ------------------
  |  Branch (1593:10): [True: 709, False: 562]
  ------------------
 1594|    709|	      p = "[error]";
 1595|    562|	    else
 1596|    562|	      {
 1597|    562|		es_write_sanitized (listfp, s, n1, ")", NULL);
 1598|    562|		es_putc ('=', listfp);
 1599|       |
 1600|    562|		if (*buffer & 0x80)
  ------------------
  |  Branch (1600:7): [True: 266, False: 296]
  ------------------
 1601|    266|		  es_write_sanitized (listfp, s + n1, n2, ")", NULL);
 1602|    296|		else
 1603|    296|		  p = "[not human readable]";
 1604|    562|	      }
 1605|  1.27k|	  }
 1606|  3.00k|      }
 1607|  3.00k|      break;
 1608|    671|    case SIGSUBPKT_PREF_HASH:
  ------------------
  |  Branch (1608:5): [True: 671, False: 48.5k]
  ------------------
 1609|    671|      es_fputs ("pref-hash-algos:", listfp);
 1610|  1.98k|      for (i = 0; i < length; i++)
  ------------------
  |  Branch (1610:19): [True: 1.31k, False: 671]
  ------------------
 1611|  1.31k|	es_fprintf (listfp, " %d", buffer[i]);
 1612|    671|      break;
 1613|    407|    case SIGSUBPKT_PREF_COMPR:
  ------------------
  |  Branch (1613:5): [True: 407, False: 48.7k]
  ------------------
 1614|    407|      es_fputs ("pref-zip-algos:", listfp);
 1615|  3.54k|      for (i = 0; i < length; i++)
  ------------------
  |  Branch (1615:19): [True: 3.13k, False: 407]
  ------------------
 1616|  3.13k|	es_fprintf (listfp, " %d", buffer[i]);
 1617|    407|      break;
 1618|    544|    case SIGSUBPKT_KS_FLAGS:
  ------------------
  |  Branch (1618:5): [True: 544, False: 48.6k]
  ------------------
 1619|    544|      es_fputs ("keyserver preferences:", listfp);
 1620|  1.48k|      for (i = 0; i < length; i++)
  ------------------
  |  Branch (1620:19): [True: 940, False: 544]
  ------------------
 1621|    940|	es_fprintf (listfp, " %02X", buffer[i]);
 1622|    544|      break;
 1623|  1.06k|    case SIGSUBPKT_PREF_KS:
  ------------------
  |  Branch (1623:5): [True: 1.06k, False: 48.1k]
  ------------------
 1624|  1.06k|      es_fputs ("preferred keyserver: ", listfp);
 1625|  1.06k|      es_write_sanitized (listfp, buffer, length, ")", NULL);
 1626|  1.06k|      break;
 1627|    253|    case SIGSUBPKT_PRIMARY_UID:
  ------------------
  |  Branch (1627:5): [True: 253, False: 48.9k]
  ------------------
 1628|    253|      p = "primary user ID";
 1629|    253|      break;
 1630|    724|    case SIGSUBPKT_POLICY:
  ------------------
  |  Branch (1630:5): [True: 724, False: 48.4k]
  ------------------
 1631|    724|      es_fputs ("policy: ", listfp);
 1632|    724|      es_write_sanitized (listfp, buffer, length, ")", NULL);
 1633|    724|      break;
 1634|    476|    case SIGSUBPKT_KEY_FLAGS:
  ------------------
  |  Branch (1634:5): [True: 476, False: 48.7k]
  ------------------
 1635|    476|      es_fputs ("key flags:", listfp);
 1636|  1.18k|      for (i = 0; i < length; i++)
  ------------------
  |  Branch (1636:19): [True: 704, False: 476]
  ------------------
 1637|    704|	es_fprintf (listfp, " %02X", buffer[i]);
 1638|    476|      break;
 1639|  6.64k|    case SIGSUBPKT_SIGNERS_UID:
  ------------------
  |  Branch (1639:5): [True: 6.64k, False: 42.5k]
  ------------------
 1640|  6.64k|      p = "signer's user ID";
 1641|  6.64k|      break;
 1642|    814|    case SIGSUBPKT_REVOC_REASON:
  ------------------
  |  Branch (1642:5): [True: 814, False: 48.3k]
  ------------------
 1643|    814|      if (length)
  ------------------
  |  Branch (1643:11): [True: 290, False: 524]
  ------------------
 1644|    290|	{
 1645|    290|	  es_fprintf (listfp, "revocation reason 0x%02x (", *buffer);
 1646|    290|	  es_write_sanitized (listfp, buffer + 1, length - 1, ")", NULL);
 1647|    290|	  p = ")";
 1648|    290|	}
 1649|    814|      break;
 1650|    580|    case SIGSUBPKT_ARR:
  ------------------
  |  Branch (1650:5): [True: 580, False: 48.6k]
  ------------------
 1651|    580|      es_fputs ("Big Brother's key (ignored): ", listfp);
 1652|    580|      if (length < 22)
  ------------------
  |  Branch (1652:11): [True: 467, False: 113]
  ------------------
 1653|    467|	p = "[too short]";
 1654|    113|      else
 1655|    113|	{
 1656|    113|	  es_fprintf (listfp, "c=%02x a=%d f=", buffer[0], buffer[1]);
 1657|    113|          if (length > 2)
  ------------------
  |  Branch (1657:15): [True: 113, False: 0]
  ------------------
 1658|    113|            es_write_hexstring (listfp, buffer+2, length-2, 0, NULL);
 1659|    113|	}
 1660|    580|      break;
 1661|  1.16k|    case SIGSUBPKT_FEATURES:
  ------------------
  |  Branch (1661:5): [True: 1.16k, False: 48.0k]
  ------------------
 1662|  1.16k|      es_fputs ("features:", listfp);
 1663|  1.59k|      for (i = 0; i < length; i++)
  ------------------
  |  Branch (1663:19): [True: 426, False: 1.16k]
  ------------------
 1664|    426|	es_fprintf (listfp, " %02x", buffer[i]);
 1665|  1.16k|      break;
 1666|  1.07k|    case SIGSUBPKT_SIGNATURE:
  ------------------
  |  Branch (1666:5): [True: 1.07k, False: 48.1k]
  ------------------
 1667|  1.07k|      es_fputs ("signature: ", listfp);
 1668|  1.07k|      if (length < 17)
  ------------------
  |  Branch (1668:11): [True: 593, False: 482]
  ------------------
 1669|    593|	p = "[too short]";
 1670|    482|      else
 1671|    482|	es_fprintf (listfp, "v%d, class 0x%02X, algo %d, digest algo %d",
 1672|    482|                    buffer[0],
 1673|    482|                    buffer[0] == 3 ? buffer[2] : buffer[1],
  ------------------
  |  Branch (1673:21): [True: 194, False: 288]
  ------------------
 1674|    482|                    buffer[0] == 3 ? buffer[15] : buffer[2],
  ------------------
  |  Branch (1674:21): [True: 194, False: 288]
  ------------------
 1675|    482|                    buffer[0] == 3 ? buffer[16] : buffer[3]);
  ------------------
  |  Branch (1675:21): [True: 194, False: 288]
  ------------------
 1676|  1.07k|      break;
 1677|       |
 1678|  3.07k|    case SIGSUBPKT_ATTST_SIGS:
  ------------------
  |  Branch (1678:5): [True: 3.07k, False: 46.1k]
  ------------------
 1679|  3.07k|      {
 1680|  3.07k|        unsigned int hlen;
 1681|       |
 1682|  3.07k|	es_fputs ("attst-sigs: ", listfp);
 1683|  3.07k|        hlen = gcry_md_get_algo_dlen (map_md_openpgp_to_gcry (digest_algo));
 1684|  3.07k|	if (!hlen)
  ------------------
  |  Branch (1684:6): [True: 223, False: 2.85k]
  ------------------
 1685|    223|	  p = "[unknown digest algo]";
 1686|  2.85k|        else if ((length % hlen))
  ------------------
  |  Branch (1686:18): [True: 1.70k, False: 1.14k]
  ------------------
 1687|  1.70k|	  p = "[invalid length]";
 1688|  1.14k|	else
 1689|  1.14k|	  {
 1690|  1.14k|            es_fprintf (listfp, "%u", (unsigned int)length/hlen);
 1691|  2.53k|            while (length)
  ------------------
  |  Branch (1691:20): [True: 1.38k, False: 1.14k]
  ------------------
 1692|  1.38k|              {
 1693|  1.38k|                es_fprintf (listfp, "\n\t%*s", nprinted-1, "");
 1694|  1.38k|                es_write_hexstring (listfp, buffer, hlen, 0, NULL);
 1695|  1.38k|                buffer += hlen;
 1696|  1.38k|                length -= hlen;
 1697|  1.38k|              }
 1698|  1.14k|	  }
 1699|  3.07k|      }
 1700|  3.07k|      break;
 1701|       |
 1702|  3.78k|    case SIGSUBPKT_KEY_BLOCK:
  ------------------
  |  Branch (1702:5): [True: 3.78k, False: 45.4k]
  ------------------
 1703|  3.78k|      es_fputs ("key-block: ", listfp);
 1704|  3.78k|      if (length && buffer[0])
  ------------------
  |  Branch (1704:11): [True: 1.42k, False: 2.35k]
  |  Branch (1704:21): [True: 1.04k, False: 384]
  ------------------
 1705|  1.04k|        p = "[unknown reserved octet]";
 1706|  2.74k|      else if (length < 50)  /* 50 is an arbitrary min. length.  */
  ------------------
  |  Branch (1706:16): [True: 2.65k, False: 82]
  ------------------
 1707|  2.65k|        p = "[invalid subpacket]";
 1708|     82|      else
 1709|     82|        {
 1710|       |          /* estream_t fp; */
 1711|       |          /* fp = es_fopen ("a.key-block", "wb"); */
 1712|       |          /* log_assert (fp); */
 1713|       |          /* es_fwrite ( buffer+1, length-1, 1, fp); */
 1714|       |          /* es_fclose (fp); */
 1715|     82|          es_fprintf (listfp, "[%u octets]", (unsigned int)length-1);
 1716|     82|        }
 1717|  3.78k|      break;
 1718|       |
 1719|       |
 1720|  4.79k|    default:
  ------------------
  |  Branch (1720:5): [True: 4.79k, False: 44.4k]
  ------------------
 1721|  4.79k|      if (type >= 100 && type <= 110)
  ------------------
  |  Branch (1721:11): [True: 1.41k, False: 3.37k]
  |  Branch (1721:26): [True: 395, False: 1.01k]
  ------------------
 1722|    395|	p = "experimental / private subpacket";
 1723|  4.39k|      else
 1724|  4.39k|	p = "?";
 1725|  4.79k|      break;
 1726|  49.2k|    }
 1727|       |
 1728|  49.2k|  es_fprintf (listfp, "%s)\n", p ? p : "");
  ------------------
  |  Branch (1728:32): [True: 24.7k, False: 24.4k]
  ------------------
 1729|  49.2k|}
parse-packet.c:read_32:
  106|   115k|{
  107|   115k|  unsigned long a;
  108|   115k|  a = (unsigned long)iobuf_get_noeof (inp) << 24;
  ------------------
  |  |  502|   115k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|   115k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 115k]
  |  |  |  |  |  Branch (500:24): [True: 1.29k, False: 114k]
  |  |  |  |  ------------------
  |  |  |  |  501|   115k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
  109|   115k|  a |= iobuf_get_noeof (inp) << 16;
  ------------------
  |  |  502|   115k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|   115k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 115k]
  |  |  |  |  |  Branch (500:24): [True: 1.38k, False: 114k]
  |  |  |  |  ------------------
  |  |  |  |  501|   115k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
  110|   115k|  a |= iobuf_get_noeof (inp) << 8;
  ------------------
  |  |  502|   115k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|   115k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 115k]
  |  |  |  |  |  Branch (500:24): [True: 1.41k, False: 114k]
  |  |  |  |  ------------------
  |  |  |  |  501|   115k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
  111|   115k|  a |= iobuf_get_noeof (inp);
  ------------------
  |  |  502|   115k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|   115k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 115k]
  |  |  |  |  |  Branch (500:24): [True: 1.45k, False: 114k]
  |  |  |  |  ------------------
  |  |  |  |  501|   115k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
  112|   115k|  return a;
  113|   115k|}
parse-packet.c:read_16:
   95|  81.1k|{
   96|  81.1k|  unsigned short a;
   97|  81.1k|  a = (unsigned short)iobuf_get_noeof (inp) << 8;
  ------------------
  |  |  502|  81.1k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  81.1k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 81.1k]
  |  |  |  |  |  Branch (500:24): [True: 701, False: 80.4k]
  |  |  |  |  ------------------
  |  |  |  |  501|  81.1k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
   98|  81.1k|  a |= iobuf_get_noeof (inp);
  ------------------
  |  |  502|  81.1k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  81.1k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 81.1k]
  |  |  |  |  |  Branch (500:24): [True: 872, False: 80.3k]
  |  |  |  |  ------------------
  |  |  |  |  501|  81.1k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
   99|  81.1k|  return a;
  100|  81.1k|}
parse-packet.c:unknown_pubkey_warning:
  334|  47.6k|{
  335|  47.6k|  static byte unknown_pubkey_algos[256];
  336|       |
  337|       |  /* First check whether the algorithm is usable but not suitable for
  338|       |     encryption/signing.  */
  339|  47.6k|  if (pubkey_get_npkey (algo))
  ------------------
  |  Branch (339:7): [True: 825, False: 46.8k]
  ------------------
  340|    825|    {
  341|    825|      if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (341:11): [True: 0, False: 825]
  |  Branch (341:26): [True: 0, False: 0]
  ------------------
  342|      0|        {
  343|      0|          if (!pubkey_get_nsig (algo))
  ------------------
  |  Branch (343:15): [True: 0, False: 0]
  ------------------
  344|      0|            log_info ("public key algorithm %s not suitable for %s\n",
  345|      0|                      openpgp_pk_algo_name (algo), "signing");
  346|      0|          if (!pubkey_get_nenc (algo))
  ------------------
  |  Branch (346:15): [True: 0, False: 0]
  ------------------
  347|      0|            log_info ("public key algorithm %s not suitable for %s\n",
  348|      0|                      openpgp_pk_algo_name (algo), "encryption");
  349|      0|        }
  350|    825|    }
  351|  46.8k|  else
  352|  46.8k|    {
  353|  46.8k|      algo &= 0xff;
  354|  46.8k|      if (!unknown_pubkey_algos[algo])
  ------------------
  |  Branch (354:11): [True: 226, False: 46.6k]
  ------------------
  355|    226|        {
  356|    226|          if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (356:15): [True: 0, False: 226]
  |  Branch (356:30): [True: 0, False: 0]
  ------------------
  357|      0|            log_info (_("can't handle public key algorithm %d\n"), algo);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  358|    226|          unknown_pubkey_algos[algo] = 1;
  359|    226|        }
  360|  46.8k|    }
  361|  47.6k|}
parse-packet.c:read_rest:
 1082|  48.0k|{
 1083|  48.0k|  int c;
 1084|  48.0k|  byte *buf, *p;
 1085|       |
 1086|  48.0k|  buf = xtrymalloc (pktlen);
  ------------------
  |  |   97|  48.0k|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 1087|  48.0k|  if (!buf)
  ------------------
  |  Branch (1087:7): [True: 10.3k, False: 37.7k]
  ------------------
 1088|  10.3k|    {
 1089|  10.3k|      gpg_error_t err = gpg_error_from_syserror ();
 1090|  10.3k|      log_error ("error reading rest of packet: %s\n", gpg_strerror (err));
 1091|  10.3k|      return NULL;
 1092|  10.3k|    }
 1093|   337k|  for (p = buf; pktlen; pktlen--)
  ------------------
  |  Branch (1093:17): [True: 301k, False: 35.6k]
  ------------------
 1094|   301k|    {
 1095|   301k|      c = iobuf_get (inp);
  ------------------
  |  |  500|   301k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 301k]
  |  |  |  Branch (500:24): [True: 2.13k, False: 299k]
  |  |  ------------------
  |  |  501|   301k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 1096|   301k|      if (c == -1)
  ------------------
  |  Branch (1096:11): [True: 2.12k, False: 299k]
  ------------------
 1097|  2.12k|        {
 1098|  2.12k|          log_error ("premature eof while reading rest of packet\n");
 1099|  2.12k|          xfree (buf);
  ------------------
  |  |  104|  2.12k|#define xfree(a)         gcry_free ((a))
  ------------------
 1100|  2.12k|          return NULL;
 1101|  2.12k|        }
 1102|   299k|      *p++ = c;
 1103|   299k|    }
 1104|       |
 1105|  35.6k|  return buf;
 1106|  37.7k|}
parse-packet.c:sos_read:
  204|  21.3k|{
  205|  21.3k|  int c, c1, c2, i;
  206|  21.3k|  unsigned int nmax = *ret_nread;
  207|  21.3k|  unsigned int nbits, nbytes;
  208|  21.3k|  size_t nread = 0;
  209|  21.3k|  gcry_mpi_t a = NULL;
  210|  21.3k|  byte *buf = NULL;
  211|  21.3k|  byte *p;
  212|       |
  213|  21.3k|  if (!nmax)
  ------------------
  |  Branch (213:7): [True: 1.38k, False: 19.9k]
  ------------------
  214|  1.38k|    goto overflow;
  215|       |
  216|  19.9k|  if ((c = c1 = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|  19.9k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 19.9k]
  |  |  |  Branch (500:24): [True: 528, False: 19.4k]
  |  |  ------------------
  |  |  501|  19.9k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (216:7): [True: 528, False: 19.4k]
  ------------------
  217|    528|    goto leave;
  218|  19.4k|  if (++nread == nmax)
  ------------------
  |  Branch (218:7): [True: 299, False: 19.1k]
  ------------------
  219|    299|    goto overflow;
  220|  19.1k|  nbits = c << 8;
  221|  19.1k|  if ((c = c2 = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|  19.1k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 19.1k]
  |  |  |  Branch (500:24): [True: 259, False: 18.8k]
  |  |  ------------------
  |  |  501|  19.1k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (221:7): [True: 259, False: 18.8k]
  ------------------
  222|    259|    goto leave;
  223|  18.8k|  ++nread;
  224|  18.8k|  nbits |= c;
  225|  18.8k|  if (nbits > MAX_EXTERN_MPI_BITS)
  ------------------
  |  |   42|  18.8k|#define MAX_EXTERN_MPI_BITS 16384
  ------------------
  |  Branch (225:7): [True: 1.66k, False: 17.1k]
  ------------------
  226|  1.66k|    {
  227|  1.66k|      log_error ("mpi too large (%u bits)\n", nbits);
  228|  1.66k|      goto leave;
  229|  1.66k|    }
  230|       |
  231|  17.1k|  nbytes = (nbits + 7) / 8;
  232|  17.1k|  buf = secure ? gcry_xmalloc_secure (nbytes) : gcry_xmalloc (nbytes);
  ------------------
  |  Branch (232:9): [True: 0, False: 17.1k]
  ------------------
  233|  17.1k|  p = buf;
  234|  92.6k|  for (i = 0; i < nbytes; i++)
  ------------------
  |  Branch (234:15): [True: 79.3k, False: 13.2k]
  ------------------
  235|  79.3k|    {
  236|  79.3k|      if (nread == nmax)
  ------------------
  |  Branch (236:11): [True: 3.66k, False: 75.7k]
  ------------------
  237|  3.66k|        goto overflow;
  238|       |
  239|  75.7k|      c = iobuf_get (inp);
  ------------------
  |  |  500|  75.7k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 75.7k]
  |  |  |  Branch (500:24): [True: 285, False: 75.4k]
  |  |  ------------------
  |  |  501|  75.7k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  240|  75.7k|      if (c == -1)
  ------------------
  |  Branch (240:11): [True: 283, False: 75.4k]
  ------------------
  241|    283|        goto leave;
  242|       |
  243|  75.4k|      p[i] = c;
  244|  75.4k|      nread ++;
  245|  75.4k|    }
  246|       |
  247|  13.2k|  a = gcry_mpi_set_opaque (NULL, buf, nbits);
  248|  13.2k|  gcry_mpi_set_flag (a, GCRYMPI_FLAG_USER2);
  249|  13.2k|  *ret_nread = nread;
  250|  13.2k|  return a;
  251|       |
  252|  5.35k| overflow:
  253|  5.35k|  log_error ("mpi larger than indicated length (%u bits)\n", 8*nmax);
  254|  8.08k| leave:
  255|  8.08k|  *ret_nread = nread;
  256|  8.08k|  gcry_free(buf);
  257|  8.08k|  return a;
  258|  5.35k|}
parse-packet.c:mpi_read:
  130|  90.4k|{
  131|  90.4k|  int c, c1, c2, i;
  132|  90.4k|  unsigned int nmax = *ret_nread;
  133|  90.4k|  unsigned int nbits, nbytes;
  134|  90.4k|  size_t nread = 0;
  135|  90.4k|  gcry_mpi_t a = NULL;
  136|  90.4k|  byte *buf = NULL;
  137|  90.4k|  byte *p;
  138|       |
  139|  90.4k|  if (!nmax)
  ------------------
  |  Branch (139:7): [True: 2.36k, False: 88.1k]
  ------------------
  140|  2.36k|    goto overflow;
  141|       |
  142|  88.1k|  if ((c = c1 = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|  88.1k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 88.1k]
  |  |  |  Branch (500:24): [True: 746, False: 87.3k]
  |  |  ------------------
  |  |  501|  88.1k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (142:7): [True: 742, False: 87.3k]
  ------------------
  143|    742|    goto leave;
  144|  87.3k|  if (++nread == nmax)
  ------------------
  |  Branch (144:7): [True: 605, False: 86.7k]
  ------------------
  145|    605|    goto overflow;
  146|  86.7k|  nbits = c << 8;
  147|  86.7k|  if ((c = c2 = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|  86.7k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 86.7k]
  |  |  |  Branch (500:24): [True: 297, False: 86.4k]
  |  |  ------------------
  |  |  501|  86.7k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (147:7): [True: 296, False: 86.4k]
  ------------------
  148|    296|    goto leave;
  149|  86.4k|  ++nread;
  150|  86.4k|  nbits |= c;
  151|  86.4k|  if (nbits > MAX_EXTERN_MPI_BITS)
  ------------------
  |  |   42|  86.4k|#define MAX_EXTERN_MPI_BITS 16384
  ------------------
  |  Branch (151:7): [True: 2.60k, False: 83.8k]
  ------------------
  152|  2.60k|    {
  153|  2.60k|      log_error ("mpi too large (%u bits)\n", nbits);
  154|  2.60k|      goto leave;
  155|  2.60k|    }
  156|       |
  157|  83.8k|  nbytes = (nbits + 7) / 8;
  158|  83.8k|  buf = secure ? gcry_xmalloc_secure (nbytes + 2) : gcry_xmalloc (nbytes + 2);
  ------------------
  |  Branch (158:9): [True: 0, False: 83.8k]
  ------------------
  159|  83.8k|  p = buf;
  160|  83.8k|  p[0] = c1;
  161|  83.8k|  p[1] = c2;
  162|   261k|  for (i = 0; i < nbytes; i++)
  ------------------
  |  Branch (162:15): [True: 181k, False: 79.8k]
  ------------------
  163|   181k|    {
  164|   181k|      if (nread == nmax)
  ------------------
  |  Branch (164:11): [True: 3.65k, False: 178k]
  ------------------
  165|  3.65k|	goto overflow;
  166|       |
  167|   178k|      c = iobuf_get (inp);
  ------------------
  |  |  500|   178k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 178k]
  |  |  |  Branch (500:24): [True: 366, False: 177k]
  |  |  ------------------
  |  |  501|   178k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  168|   178k|      if (c == -1)
  ------------------
  |  Branch (168:11): [True: 366, False: 177k]
  ------------------
  169|    366|	goto leave;
  170|       |
  171|   177k|      p[i + 2] = c;
  172|   177k|      nread ++;
  173|   177k|    }
  174|       |
  175|  79.8k|  if (gcry_mpi_scan (&a, GCRYMPI_FMT_PGP, buf, nread, &nread))
  ------------------
  |  Branch (175:7): [True: 0, False: 79.8k]
  ------------------
  176|      0|    a = NULL;
  177|       |
  178|  79.8k|  *ret_nread = nread;
  179|  79.8k|  gcry_free(buf);
  180|  79.8k|  return a;
  181|       |
  182|  6.62k| overflow:
  183|  6.62k|  log_error ("mpi larger than indicated length (%u bits)\n", 8*nmax);
  184|  10.6k| leave:
  185|  10.6k|  *ret_nread = nread;
  186|  10.6k|  gcry_free(buf);
  187|  10.6k|  return a;
  188|  6.62k|}

have_static_passphrase:
   53|   118k|{
   54|   118k|  return (!!fd_passwd
  ------------------
  |  Branch (54:11): [True: 0, False: 118k]
  ------------------
   55|   118k|          && (opt.batch || opt.pinentry_mode == PINENTRY_MODE_LOOPBACK));
  ------------------
  |  Branch (55:15): [True: 0, False: 0]
  |  Branch (55:28): [True: 0, False: 0]
  ------------------
   56|   118k|}
passphrase_to_dek:
  284|   118k|{
  285|   118k|  char *pw = NULL;
  286|   118k|  DEK *dek;
  287|   118k|  STRING2KEY help_s2k;
  288|   118k|  int dummy_canceled;
  289|   118k|  char s2k_cacheidbuf[1+16+1];
  290|   118k|  char *s2k_cacheid = NULL;
  291|       |
  292|   118k|  if (!canceled)
  ------------------
  |  Branch (292:7): [True: 7.85k, False: 110k]
  ------------------
  293|  7.85k|    canceled = &dummy_canceled;
  294|   118k|  *canceled = 0;
  295|       |
  296|   118k|  if (opt.no_symkey_cache)
  ------------------
  |  Branch (296:7): [True: 0, False: 118k]
  ------------------
  297|      0|    nocache = 1;  /* Force no symmetric key caching.  */
  298|       |
  299|   118k|  if ( !s2k )
  ------------------
  |  Branch (299:8): [True: 0, False: 118k]
  ------------------
  300|      0|    {
  301|      0|      log_assert (create && !nocache);
  302|       |      /* This is used for the old rfc1991 mode
  303|       |       * Note: This must match the code in encode.c with opt.rfc1991 set */
  304|      0|      memset (&help_s2k, 0, sizeof (help_s2k));
  305|      0|      s2k = &help_s2k;
  306|      0|      s2k->hash_algo = S2K_DIGEST_ALGO;
  ------------------
  |  |   53|      0|#define S2K_DIGEST_ALGO (opt.s2k_digest_algo?opt.s2k_digest_algo:DEFAULT_S2K_DIGEST_ALGO)
  |  |  ------------------
  |  |  |  |   45|      0|#define DEFAULT_S2K_DIGEST_ALGO DIGEST_ALGO_SHA1
  |  |  ------------------
  |  |  |  Branch (53:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  307|      0|    }
  308|       |
  309|       |  /* Create a new salt or what else to be filled into the s2k for a
  310|       |     new key.  */
  311|   118k|  if (create && (s2k->mode == 1 || s2k->mode == 3))
  ------------------
  |  Branch (311:7): [True: 0, False: 118k]
  |  Branch (311:18): [True: 0, False: 0]
  |  Branch (311:36): [True: 0, False: 0]
  ------------------
  312|      0|    {
  313|      0|      gcry_randomize (s2k->salt, 8, GCRY_STRONG_RANDOM);
  314|      0|      if ( s2k->mode == 3 )
  ------------------
  |  Branch (314:12): [True: 0, False: 0]
  ------------------
  315|      0|        {
  316|       |          /* We delay the encoding until it is really needed.  This is
  317|       |             if we are going to dynamically calibrate it, we need to
  318|       |             call out to gpg-agent and that should not be done during
  319|       |             option processing in main().  */
  320|      0|          if (!opt.s2k_count)
  ------------------
  |  Branch (320:15): [True: 0, False: 0]
  ------------------
  321|      0|            opt.s2k_count = encode_s2k_iterations (agent_get_s2k_count ());
  322|      0|          s2k->count = opt.s2k_count;
  323|      0|        }
  324|      0|    }
  325|       |
  326|       |  /* If we do not have a passphrase available in NEXT_PW and status
  327|       |     information are request, we print them now. */
  328|   118k|  if ( !next_pw && is_status_enabled() )
  ------------------
  |  Branch (328:8): [True: 118k, False: 0]
  |  Branch (328:20): [True: 0, False: 118k]
  ------------------
  329|      0|    {
  330|      0|      char buf[50];
  331|       |
  332|      0|      snprintf (buf, sizeof buf, "%d %d %d",
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  333|      0|                cipher_algo, s2k->mode, s2k->hash_algo );
  334|      0|      write_status_text ( STATUS_NEED_PASSPHRASE_SYM, buf );
  335|      0|    }
  336|       |
  337|   118k|  if ( next_pw )
  ------------------
  |  Branch (337:8): [True: 0, False: 118k]
  ------------------
  338|      0|    {
  339|       |      /* Simply return the passphrase we already have in NEXT_PW. */
  340|      0|      pw = next_pw;
  341|      0|      next_pw = NULL;
  342|      0|    }
  343|   118k|  else if ( have_static_passphrase () )
  ------------------
  |  Branch (343:13): [True: 0, False: 118k]
  ------------------
  344|      0|    {
  345|       |      /* Return the passphrase we have stored in FD_PASSWD. */
  346|      0|      pw = xmalloc_secure ( strlen(fd_passwd)+1 );
  ------------------
  |  |  108|      0|#define xmalloc_secure(a)  gcry_xmalloc_secure ((a))
  ------------------
  347|      0|      strcpy ( pw, fd_passwd );
  348|      0|    }
  349|   118k|  else
  350|   118k|    {
  351|   118k|      if (!nocache && (s2k->mode == 1 || s2k->mode == 3))
  ------------------
  |  Branch (351:11): [True: 118k, False: 0]
  |  Branch (351:24): [True: 4.85k, False: 113k]
  |  Branch (351:42): [True: 1.01k, False: 112k]
  ------------------
  352|  5.87k|	{
  353|  5.87k|	  memset (s2k_cacheidbuf, 0, sizeof s2k_cacheidbuf);
  354|  5.87k|	  *s2k_cacheidbuf = 'S';
  355|  5.87k|	  bin2hex (s2k->salt, 8, s2k_cacheidbuf + 1);
  356|  5.87k|	  s2k_cacheid = s2k_cacheidbuf;
  357|  5.87k|	}
  358|       |
  359|   118k|      if (opt.pinentry_mode == PINENTRY_MODE_LOOPBACK)
  ------------------
  |  Branch (359:11): [True: 0, False: 118k]
  ------------------
  360|      0|        {
  361|      0|          char buf[32];
  362|       |
  363|      0|          snprintf (buf, sizeof (buf), "%u", 100);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  364|      0|          write_status_text (STATUS_INQUIRE_MAXLEN, buf);
  365|      0|        }
  366|       |
  367|       |      /* Divert to the gpg-agent. */
  368|   118k|      pw = passphrase_get (create, create && nocache, s2k_cacheid,
  ------------------
  |  Branch (368:36): [True: 0, False: 118k]
  |  Branch (368:46): [True: 0, False: 0]
  ------------------
  369|   118k|                           create? opt.passphrase_repeat : 0,
  ------------------
  |  Branch (369:28): [True: 0, False: 118k]
  ------------------
  370|   118k|                           tryagain_text, flags, canceled);
  371|   118k|      if (*canceled)
  ------------------
  |  Branch (371:11): [True: 118k, False: 0]
  ------------------
  372|   118k|        {
  373|   118k|          xfree (pw);
  ------------------
  |  |  104|   118k|#define xfree(a)         gcry_free ((a))
  ------------------
  374|   118k|	  write_status( STATUS_CANCELED_BY_USER );
  375|   118k|          return NULL;
  376|   118k|        }
  377|   118k|    }
  378|       |
  379|      0|  if ( !pw || !*pw )
  ------------------
  |  Branch (379:8): [True: 0, False: 0]
  |  Branch (379:15): [True: 0, False: 0]
  ------------------
  380|      0|    write_status( STATUS_MISSING_PASSPHRASE );
  381|       |
  382|       |  /* Hash the passphrase and store it in a newly allocated DEK object.
  383|       |     Keep a copy of the passphrase in LAST_PW for use by
  384|       |     get_last_passphrase(). */
  385|      0|  dek = xmalloc_secure_clear ( sizeof *dek );
  ------------------
  |  |  117|      0|#define xmalloc_secure_clear(a) gcry_xcalloc_secure (1, (a))
  ------------------
  386|      0|  dek->algo = cipher_algo;
  387|      0|  if ( (!pw || !*pw) && create)
  ------------------
  |  Branch (387:9): [True: 0, False: 0]
  |  Branch (387:16): [True: 0, False: 0]
  |  Branch (387:25): [True: 0, False: 0]
  ------------------
  388|      0|    dek->keylen = 0;
  389|      0|  else
  390|      0|    {
  391|      0|      gpg_error_t err;
  392|       |
  393|      0|      dek->keylen = openpgp_cipher_get_algo_keylen (dek->algo);
  ------------------
  |  |  121|      0|  gcry_cipher_get_algo_keylen(map_cipher_openpgp_to_gcry((_a)))
  ------------------
  394|      0|      if (!(dek->keylen > 0 && dek->keylen <= DIM(dek->key)))
  ------------------
  |  |   47|      0|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (394:13): [True: 0, False: 0]
  |  Branch (394:32): [True: 0, False: 0]
  ------------------
  395|      0|        BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  396|      0|      err = gcry_kdf_derive (pw, strlen (pw),
  397|      0|                             s2k->mode == 3? GCRY_KDF_ITERSALTED_S2K :
  ------------------
  |  Branch (397:30): [True: 0, False: 0]
  ------------------
  398|      0|                             s2k->mode == 1? GCRY_KDF_SALTED_S2K :
  ------------------
  |  Branch (398:30): [True: 0, False: 0]
  ------------------
  399|      0|                             /* */           GCRY_KDF_SIMPLE_S2K,
  400|      0|                             s2k->hash_algo, s2k->salt, 8,
  401|      0|                             S2K_DECODE_COUNT(s2k->count),
  ------------------
  |  |  210|      0|#define S2K_DECODE_COUNT(_val) ((16ul + ((_val) & 15)) << (((_val) >> 4) + 6))
  ------------------
  402|      0|                             dek->keylen, dek->key);
  403|      0|      if (err)
  ------------------
  |  Branch (403:11): [True: 0, False: 0]
  ------------------
  404|      0|        {
  405|      0|          log_error ("gcry_kdf_derive failed: %s", gpg_strerror (err));
  406|      0|          xfree (pw);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  407|      0|          xfree (dek);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  408|      0|	  write_status( STATUS_MISSING_PASSPHRASE );
  409|      0|          return NULL;
  410|      0|        }
  411|      0|    }
  412|      0|  if (s2k_cacheid)
  ------------------
  |  Branch (412:7): [True: 0, False: 0]
  ------------------
  413|      0|    memcpy (dek->s2k_cacheid, s2k_cacheid, sizeof dek->s2k_cacheid);
  414|      0|  xfree(last_pw);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  415|      0|  last_pw = pw;
  416|      0|  return dek;
  417|      0|}
passphrase.c:passphrase_get:
  180|   118k|{
  181|   118k|  int rc;
  182|   118k|  char *pw = NULL;
  183|   118k|  char *orig_codeset;
  184|   118k|  const char *my_cacheid;
  185|   118k|  const char *desc;
  186|       |
  187|   118k|  if (canceled)
  ------------------
  |  Branch (187:7): [True: 118k, False: 0]
  ------------------
  188|   118k|    *canceled = 0;
  189|       |
  190|   118k|  orig_codeset = i18n_switchto_utf8 ();
  191|       |
  192|   118k|  if (!nocache && cacheid)
  ------------------
  |  Branch (192:7): [True: 118k, False: 0]
  |  Branch (192:19): [True: 5.87k, False: 112k]
  ------------------
  193|  5.87k|    my_cacheid = cacheid;
  194|   112k|  else
  195|   112k|    my_cacheid = NULL;
  196|       |
  197|   118k|  if (tryagain_text)
  ------------------
  |  Branch (197:7): [True: 0, False: 118k]
  ------------------
  198|      0|    tryagain_text = _(tryagain_text);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  199|       |
  200|   118k|  if ((flags & GETPASSWORD_FLAG_SYMDECRYPT))
  ------------------
  |  |  297|   118k|#define GETPASSWORD_FLAG_SYMDECRYPT  1
  ------------------
  |  Branch (200:7): [True: 118k, False: 0]
  ------------------
  201|   118k|    desc = _("Please enter the passphrase for decryption.");
  ------------------
  |  |   28|   118k|#  define _(a) gettext (a)
  ------------------
  202|      0|  else
  203|      0|    desc = _("Enter passphrase\n");
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  204|       |
  205|       |  /* Here we have:
  206|       |   * REPEAT is set in create mode and if opt.passphrase_repeat is set.
  207|       |   * (Thus it is not a clean indication that we want a new passphrase).
  208|       |   * NOCACHE is set in create mode or if --no-symkey-cache is used.
  209|       |   * CACHEID is only set if caching shall be used.
  210|       |   * NEWSYMKEY has been added latter to make it clear that a new key
  211|       |   * is requested.  The whole chain of API is a bit too complex since
  212|       |   * we we stripped things out over time; however, there is no time
  213|       |   * for a full state analysis and thus this new parameter.
  214|       |   */
  215|   118k|  rc = agent_get_passphrase (my_cacheid, tryagain_text, NULL,
  216|   118k|                             desc,
  217|   118k|                             newsymkey, repeat, nocache, &pw);
  218|       |
  219|   118k|  i18n_switchback (orig_codeset);
  220|       |
  221|       |
  222|   118k|  if (!rc)
  ------------------
  |  Branch (222:7): [True: 0, False: 118k]
  ------------------
  223|      0|    ;
  224|   118k|  else if (gpg_err_code (rc) == GPG_ERR_CANCELED
  ------------------
  |  Branch (224:12): [True: 0, False: 118k]
  ------------------
  225|   118k|            || gpg_err_code (rc) == GPG_ERR_FULLY_CANCELED)
  ------------------
  |  Branch (225:16): [True: 0, False: 118k]
  ------------------
  226|      0|    {
  227|      0|      log_info (_("cancelled by user\n") );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  228|      0|      if (canceled)
  ------------------
  |  Branch (228:11): [True: 0, False: 0]
  ------------------
  229|      0|        *canceled = 1;
  230|      0|    }
  231|   118k|  else
  232|   118k|    {
  233|   118k|      log_error (_("problem with the agent: %s\n"), gpg_strerror (rc));
  ------------------
  |  |   28|   118k|#  define _(a) gettext (a)
  ------------------
  234|       |      /* Due to limitations in the API of the upper layers they
  235|       |         consider an error as no passphrase entered.  This works in
  236|       |         most cases but not during key creation where this should
  237|       |         definitely not happen and let it continue without requiring a
  238|       |         passphrase.  Given that now all the upper layers handle a
  239|       |         cancel correctly, we simply set the cancel flag now for all
  240|       |         errors from the agent.  */
  241|   118k|      if (canceled)
  ------------------
  |  Branch (241:11): [True: 118k, False: 0]
  ------------------
  242|   118k|        *canceled = 1;
  243|       |
  244|   118k|      write_status_errcode ("get_passphrase", rc);
  245|   118k|    }
  246|       |
  247|   118k|  if (rc)
  ------------------
  |  Branch (247:7): [True: 118k, False: 0]
  ------------------
  248|   118k|    {
  249|   118k|      xfree (pw);
  ------------------
  |  |  104|   118k|#define xfree(a)         gcry_free ((a))
  ------------------
  250|   118k|      pw = NULL;
  251|   118k|    }
  252|   118k|  return pw;
  253|   118k|}

parse_image_header:
  310|  2.13k|{
  311|  2.13k|  u16 headerlen;
  312|       |
  313|  2.13k|  if(attr->len<3)
  ------------------
  |  Branch (313:6): [True: 870, False: 1.26k]
  ------------------
  314|    870|    return 0;
  315|       |
  316|       |  /* For historical reasons (i.e. "oops!"), the header length is
  317|       |     little endian. */
  318|  1.26k|  headerlen=(attr->data[1]<<8) | attr->data[0];
  319|       |
  320|  1.26k|  if(headerlen>attr->len)
  ------------------
  |  Branch (320:6): [True: 252, False: 1.00k]
  ------------------
  321|    252|    return 0;
  322|       |
  323|  1.00k|  if(type && attr->len>=4)
  ------------------
  |  Branch (323:6): [True: 1.00k, False: 0]
  |  Branch (323:14): [True: 786, False: 223]
  ------------------
  324|    786|    {
  325|    786|      if(attr->data[2]==1) /* header version 1 */
  ------------------
  |  Branch (325:10): [True: 539, False: 247]
  ------------------
  326|    539|	*type=attr->data[3];
  327|    247|      else
  328|    247|	*type=0;
  329|    786|    }
  330|       |
  331|  1.00k|  *len=attr->len-headerlen;
  332|       |
  333|  1.00k|  if(*len==0)
  ------------------
  |  Branch (333:6): [True: 219, False: 790]
  ------------------
  334|    219|    return 0;
  335|       |
  336|    790|  return 1;
  337|  1.00k|}
image_type_to_string:
  346|    790|{
  347|    790|  const char *string;
  348|       |
  349|    790|  switch(type)
  350|    790|    {
  351|    485|    case 1: /* jpeg */
  ------------------
  |  Branch (351:5): [True: 485, False: 305]
  ------------------
  352|    485|      if(style==0)
  ------------------
  |  Branch (352:10): [True: 0, False: 485]
  ------------------
  353|      0|	string="jpg";
  354|    485|      else if(style==1)
  ------------------
  |  Branch (354:15): [True: 485, False: 0]
  ------------------
  355|    485|	string="jpeg";
  356|      0|      else
  357|      0|	string="image/jpeg";
  358|    485|      break;
  359|       |
  360|    305|    default:
  ------------------
  |  Branch (360:5): [True: 305, False: 485]
  ------------------
  361|    305|      if(style==0)
  ------------------
  |  Branch (361:10): [True: 0, False: 305]
  ------------------
  362|      0|	string="bin";
  363|    305|      else if(style==1)
  ------------------
  |  Branch (363:15): [True: 305, False: 0]
  ------------------
  364|    305|	string="unknown";
  365|      0|      else
  366|      0|	string="image/x-unknown";
  367|    305|      break;
  368|    790|    }
  369|       |
  370|    790|  return string;
  371|    790|}

get_session_key:
   76|  58.5k|{
   77|  58.5k|  PKT_public_key *sk = NULL;
   78|  58.5k|  gpg_error_t err;
   79|  58.5k|  void *enum_context = NULL;
   80|  58.5k|  u32 keyid[2];
   81|  58.5k|  int search_for_secret_keys = 1;
   82|  58.5k|  struct pubkey_enc_list *k;
   83|       |
   84|  58.5k|  if (DBG_CLOCK)
  ------------------
  |  |  356|  58.5k|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  58.5k|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 58.5k]
  |  |  ------------------
  ------------------
   85|      0|    log_clock ("get_session_key enter");
   86|       |
   87|  58.5k|  while (search_for_secret_keys)
  ------------------
  |  Branch (87:10): [True: 58.5k, False: 0]
  ------------------
   88|  58.5k|    {
   89|  58.5k|      sk = xmalloc_clear (sizeof *sk);
  ------------------
  |  |  116|  58.5k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
   90|  58.5k|      err = enum_secret_keys (ctrl, &enum_context, sk);
   91|  58.5k|      if (err)
  ------------------
  |  Branch (91:11): [True: 58.5k, False: 0]
  ------------------
   92|  58.5k|        break;
   93|       |
   94|       |      /* Check compliance.  */
   95|      0|      if (! gnupg_pk_is_allowed (opt.compliance, PK_USE_DECRYPTION,
  ------------------
  |  Branch (95:11): [True: 0, False: 0]
  ------------------
   96|      0|                                 sk->pubkey_algo, 0,
   97|      0|                                 sk->pkey, nbits_from_pk (sk), NULL))
   98|      0|        {
   99|      0|          log_info (_("key %s is not suitable for decryption"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  100|      0|                      " in %s mode\n"),
  101|      0|                    keystr_from_pk (sk),
  102|      0|                    gnupg_compliance_option_string (opt.compliance));
  103|      0|          continue;
  104|      0|        }
  105|       |
  106|       |      /* FIXME: The list needs to be sorted so that we try the keys in
  107|       |       * an appropriate order.  For example:
  108|       |       * - On-disk keys w/o protection
  109|       |       * - On-disk keys with a cached passphrase
  110|       |       * - On-card keys of an active card
  111|       |       * - On-disk keys with protection
  112|       |       * - On-card keys from cards which are not plugged it.  Here a
  113|       |       *   cancel-all button should stop asking for other cards.
  114|       |       * Without any anonymous keys the sorting can be skipped.
  115|       |       */
  116|      0|      for (k = list; k; k = k->next)
  ------------------
  |  Branch (116:22): [True: 0, False: 0]
  ------------------
  117|      0|        {
  118|      0|          if (!(k->pubkey_algo == PUBKEY_ALGO_ELGAMAL_E
  ------------------
  |  Branch (118:17): [True: 0, False: 0]
  ------------------
  119|      0|                || k->pubkey_algo == PUBKEY_ALGO_ECDH
  ------------------
  |  Branch (119:20): [True: 0, False: 0]
  ------------------
  120|      0|                || k->pubkey_algo == PUBKEY_ALGO_RSA
  ------------------
  |  Branch (120:20): [True: 0, False: 0]
  ------------------
  121|      0|                || k->pubkey_algo == PUBKEY_ALGO_RSA_E
  ------------------
  |  Branch (121:20): [True: 0, False: 0]
  ------------------
  122|      0|                || k->pubkey_algo == PUBKEY_ALGO_ELGAMAL))
  ------------------
  |  Branch (122:20): [True: 0, False: 0]
  ------------------
  123|      0|            continue;
  124|       |
  125|      0|          if (openpgp_pk_test_algo2 (k->pubkey_algo, PUBKEY_USAGE_ENC))
  ------------------
  |  |   50|      0|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  ------------------
  |  Branch (125:15): [True: 0, False: 0]
  ------------------
  126|      0|            continue;
  127|       |
  128|      0|          if (sk->pubkey_algo != k->pubkey_algo)
  ------------------
  |  Branch (128:15): [True: 0, False: 0]
  ------------------
  129|      0|            continue;
  130|       |
  131|      0|          keyid_from_pk (sk, keyid);
  132|       |
  133|      0|          if (!k->keyid[0] && !k->keyid[1])
  ------------------
  |  Branch (133:15): [True: 0, False: 0]
  |  Branch (133:31): [True: 0, False: 0]
  ------------------
  134|      0|            {
  135|      0|              if (opt.skip_hidden_recipients)
  ------------------
  |  Branch (135:19): [True: 0, False: 0]
  ------------------
  136|      0|                continue;
  137|       |
  138|      0|              if (!opt.quiet)
  ------------------
  |  Branch (138:19): [True: 0, False: 0]
  ------------------
  139|      0|                log_info (_("anonymous recipient; trying secret key %s ...\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  140|      0|                          keystr (keyid));
  141|      0|            }
  142|      0|          else if (opt.try_all_secrets
  ------------------
  |  Branch (142:20): [True: 0, False: 0]
  ------------------
  143|      0|                   || (k->keyid[0] == keyid[0] && k->keyid[1] == keyid[1]))
  ------------------
  |  Branch (143:24): [True: 0, False: 0]
  |  Branch (143:51): [True: 0, False: 0]
  ------------------
  144|      0|            {
  145|      0|              if (!opt.quiet && !(sk->pubkey_usage & PUBKEY_USAGE_ENC))
  ------------------
  |  |   50|      0|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  ------------------
  |  Branch (145:19): [True: 0, False: 0]
  |  Branch (145:33): [True: 0, False: 0]
  ------------------
  146|      0|                log_info (_("used key is not marked for encryption use.\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  147|      0|            }
  148|      0|          else
  149|      0|            continue;
  150|       |
  151|      0|          err = get_it (ctrl, k, dek, sk, keyid);
  152|      0|          k->result = err;
  153|      0|          if (!err)
  ------------------
  |  Branch (153:15): [True: 0, False: 0]
  ------------------
  154|      0|            {
  155|      0|              if (!opt.quiet && !k->keyid[0] && !k->keyid[1])
  ------------------
  |  Branch (155:19): [True: 0, False: 0]
  |  Branch (155:33): [True: 0, False: 0]
  |  Branch (155:49): [True: 0, False: 0]
  ------------------
  156|      0|                {
  157|      0|                  log_info (_("okay, we are the anonymous recipient.\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  158|      0|                  if (!(sk->pubkey_usage & PUBKEY_USAGE_ENC))
  ------------------
  |  |   50|      0|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  ------------------
  |  Branch (158:23): [True: 0, False: 0]
  ------------------
  159|      0|                    log_info (_("used key is not marked for encryption use.\n")
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  160|      0|                              );
  161|      0|                }
  162|      0|              search_for_secret_keys = 0;
  163|      0|              break;
  164|      0|            }
  165|      0|          else if (gpg_err_code (err) == GPG_ERR_FULLY_CANCELED)
  ------------------
  |  Branch (165:20): [True: 0, False: 0]
  ------------------
  166|      0|            {
  167|      0|              search_for_secret_keys = 0;
  168|      0|              break; /* Don't try any more secret keys.  */
  169|      0|            }
  170|      0|        }
  171|      0|    }
  172|  58.5k|  enum_secret_keys (ctrl, &enum_context, NULL);  /* free context */
  173|       |
  174|  58.5k|  if (gpg_err_code (err) == GPG_ERR_EOF)
  ------------------
  |  Branch (174:7): [True: 58.5k, False: 0]
  ------------------
  175|  58.5k|    {
  176|  58.5k|      err = gpg_error (GPG_ERR_NO_SECKEY);
  177|       |
  178|       |      /* Return the last specific error, if any.  */
  179|  6.98M|      for (k = list; k; k = k->next)
  ------------------
  |  Branch (179:22): [True: 6.92M, False: 58.5k]
  ------------------
  180|  6.92M|        if (k->result != -1)
  ------------------
  |  Branch (180:13): [True: 0, False: 6.92M]
  ------------------
  181|      0|          err = k->result;
  182|  58.5k|    }
  183|       |
  184|  58.5k|  if (DBG_CLOCK)
  ------------------
  |  |  356|  58.5k|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  58.5k|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 58.5k]
  |  |  ------------------
  ------------------
  185|      0|    log_clock ("get_session_key leave");
  186|  58.5k|  return err;
  187|  58.5k|}

release_sk_list:
   48|  58.5k|{
   49|  58.5k|  SK_LIST sk_rover;
   50|       |
   51|  58.5k|  for (; sk_list; sk_list = sk_rover)
  ------------------
  |  Branch (51:10): [True: 0, False: 58.5k]
  ------------------
   52|      0|    {
   53|      0|      sk_rover = sk_list->next;
   54|      0|      free_public_key (sk_list->pk);
   55|      0|      xfree (sk_list);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
   56|      0|    }
   57|  58.5k|}
enum_secret_keys:
  323|   117k|{
  324|   117k|  gpg_error_t err = 0;
  325|   117k|  const char *name;
  326|   117k|  int cardkey;
  327|   117k|  kbnode_t keyblock;
  328|   117k|  struct
  329|   117k|  {
  330|   117k|    int eof;
  331|   117k|    int state;
  332|   117k|    int cardkey_done;
  333|   117k|    strlist_t sl;
  334|   117k|    keypair_info_t card_keyinfo;
  335|   117k|    keypair_info_t card_keyinfo_list;
  336|   117k|    char fpr2[2 * MAX_FINGERPRINT_LEN + 2 ];
  337|   117k|    kbnode_t keyblock;
  338|   117k|    kbnode_t node;
  339|   117k|    getkey_ctx_t ctx;
  340|   117k|    SK_LIST results;
  341|   117k|  } *c = *context;
  342|       |
  343|       |#if MAX_FINGERPRINT_LEN < KEYGRIP_LEN
  344|       |# error buffer too short for this configuration
  345|       |#endif
  346|       |
  347|   117k|  if (!c)
  ------------------
  |  Branch (347:7): [True: 58.5k, False: 58.5k]
  ------------------
  348|  58.5k|    {
  349|       |      /* Make a new context.  */
  350|  58.5k|      c = xtrycalloc (1, sizeof *c);
  ------------------
  |  |   99|  58.5k|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  351|  58.5k|      if (!c)
  ------------------
  |  Branch (351:11): [True: 0, False: 58.5k]
  ------------------
  352|      0|        {
  353|      0|          err = gpg_error_from_syserror ();
  354|      0|          free_public_key (sk);
  355|      0|          return err;
  356|      0|        }
  357|  58.5k|      *context = c;
  358|  58.5k|    }
  359|       |
  360|   117k|  if (!sk)
  ------------------
  |  Branch (360:7): [True: 58.5k, False: 58.5k]
  ------------------
  361|  58.5k|    {
  362|       |      /* Free the context.  */
  363|  58.5k|      free_keypair_info (c->card_keyinfo_list);
  364|  58.5k|      release_sk_list (c->results);
  365|  58.5k|      release_kbnode (c->keyblock);
  366|  58.5k|      getkey_end (ctrl, c->ctx);
  367|  58.5k|      xfree (c);
  ------------------
  |  |  104|  58.5k|#define xfree(a)         gcry_free ((a))
  ------------------
  368|  58.5k|      *context = NULL;
  369|  58.5k|      return 0;
  370|  58.5k|    }
  371|       |
  372|  58.5k|  if (c->eof)
  ------------------
  |  Branch (372:7): [True: 0, False: 58.5k]
  ------------------
  373|      0|    {
  374|      0|      free_public_key (sk);
  375|      0|      return gpg_error (GPG_ERR_EOF);
  376|      0|    }
  377|       |
  378|  58.5k|  for (;;)
  379|  58.5k|    {
  380|       |      /* Loop until we have a keyblock.  */
  381|  58.5k|      while (!c->keyblock)
  ------------------
  |  Branch (381:14): [True: 58.5k, False: 0]
  ------------------
  382|  58.5k|        {
  383|       |          /* Loop over the list of secret keys.  */
  384|  58.5k|          do
  385|   468k|            {
  386|   468k|              name = NULL;
  387|   468k|              cardkey = 0;
  388|   468k|              keyblock = NULL;
  389|   468k|              switch (c->state)
  390|   468k|                {
  391|  58.5k|                case 0: /* First try to use the --default-key.  */
  ------------------
  |  Branch (391:17): [True: 58.5k, False: 409k]
  ------------------
  392|  58.5k|                  name = parse_def_secret_key (ctrl);
  393|  58.5k|                  c->state = 1;
  394|  58.5k|                  break;
  395|       |
  396|  58.5k|                case 1: /* Init list of keys to try.  */
  ------------------
  |  Branch (396:17): [True: 58.5k, False: 409k]
  ------------------
  397|  58.5k|                  c->sl = opt.secret_keys_to_try;
  398|  58.5k|                  c->state++;
  399|  58.5k|                  break;
  400|       |
  401|  58.5k|                case 2: /* Get next item from list.  */
  ------------------
  |  Branch (401:17): [True: 58.5k, False: 409k]
  ------------------
  402|  58.5k|                  if (c->sl)
  ------------------
  |  Branch (402:23): [True: 0, False: 58.5k]
  ------------------
  403|      0|                    {
  404|      0|                      name = c->sl->d;
  405|      0|                      c->sl = c->sl->next;
  406|      0|                    }
  407|  58.5k|                  else
  408|  58.5k|                    c->state++;
  409|  58.5k|                  break;
  410|       |
  411|  58.5k|                case 3: /* Init list of card keys to try.  */
  ------------------
  |  Branch (411:17): [True: 58.5k, False: 409k]
  ------------------
  412|  58.5k|                  c->card_keyinfo_list = NULL;
  413|  58.5k|                  err = agent_scd_serialno (NULL, NULL);
  414|  58.5k|                  if (!err)
  ------------------
  |  Branch (414:23): [True: 0, False: 58.5k]
  ------------------
  415|      0|                    {
  416|      0|                      err = agent_scd_keyinfo (NULL, GCRY_PK_USAGE_ENCR,
  417|      0|                                               &c->card_keyinfo_list);
  418|      0|                    }
  419|  58.5k|                  c->card_keyinfo = c->card_keyinfo_list;
  420|  58.5k|                  c->state++;
  421|  58.5k|                  break;
  422|       |
  423|  58.5k|                case 4: /* Get next item from card keyinfo.  */
  ------------------
  |  Branch (423:17): [True: 58.5k, False: 409k]
  ------------------
  424|  58.5k|                  if (c->card_keyinfo)
  ------------------
  |  Branch (424:23): [True: 0, False: 58.5k]
  ------------------
  425|      0|                    {
  426|      0|                      const char *s;
  427|      0|                      int i;
  428|       |
  429|       |                      /* Get the key using the keygrip.  */
  430|      0|                      c->fpr2[0] = '&';
  431|      0|                      for (i=1, s = c->card_keyinfo->keygrip;
  432|      0|                           (*s && *s != ' '
  ------------------
  |  Branch (432:29): [True: 0, False: 0]
  |  Branch (432:35): [True: 0, False: 0]
  ------------------
  433|      0|                            && i < sizeof c->fpr2 - 2);
  ------------------
  |  Branch (433:32): [True: 0, False: 0]
  ------------------
  434|      0|                           s++, i++)
  435|      0|                        c->fpr2[i] = *s;
  436|      0|                      c->fpr2[i] = 0;
  437|      0|                      name = c->fpr2;
  438|      0|                      cardkey = 1;
  439|       |
  440|      0|                      c->card_keyinfo = c->card_keyinfo->next;
  441|      0|                    }
  442|  58.5k|                  else
  443|  58.5k|                    c->state++;
  444|  58.5k|                  break;
  445|       |
  446|  58.5k|                case 5: /* Init search context to enum all secret keys.  */
  ------------------
  |  Branch (446:17): [True: 58.5k, False: 409k]
  ------------------
  447|  58.5k|                  err = getkey_bynames (ctrl, &c->ctx, NULL, NULL, 1,
  448|  58.5k|                                        &keyblock);
  449|  58.5k|                  if (err)
  ------------------
  |  Branch (449:23): [True: 58.5k, False: 0]
  ------------------
  450|  58.5k|                    {
  451|  58.5k|                      release_kbnode (keyblock);
  452|  58.5k|                      keyblock = NULL;
  453|  58.5k|                      getkey_end (ctrl, c->ctx);
  454|  58.5k|                      c->ctx = NULL;
  455|  58.5k|                    }
  456|  58.5k|                  c->state++;
  457|  58.5k|                  break;
  458|       |
  459|  58.5k|                case 6: /* Get next item from the context.  */
  ------------------
  |  Branch (459:17): [True: 58.5k, False: 409k]
  ------------------
  460|  58.5k|                  if (c->ctx)
  ------------------
  |  Branch (460:23): [True: 0, False: 58.5k]
  ------------------
  461|      0|                    {
  462|      0|                      err = getkey_next (ctrl, c->ctx, NULL, &keyblock);
  463|      0|                      if (err)
  ------------------
  |  Branch (463:27): [True: 0, False: 0]
  ------------------
  464|      0|                        {
  465|      0|                          release_kbnode (keyblock);
  466|      0|                          keyblock = NULL;
  467|      0|                          getkey_end (ctrl, c->ctx);
  468|      0|                          c->ctx = NULL;
  469|      0|                        }
  470|      0|                    }
  471|  58.5k|                  else
  472|  58.5k|                    c->state++;
  473|  58.5k|                  break;
  474|       |
  475|  58.5k|                default: /* No more names to check - stop.  */
  ------------------
  |  Branch (475:17): [True: 58.5k, False: 409k]
  ------------------
  476|  58.5k|                  c->eof = 1;
  477|  58.5k|                  free_public_key (sk);
  478|  58.5k|                  return gpg_error (GPG_ERR_EOF);
  479|   468k|                }
  480|   468k|            }
  481|   409k|          while ((!name || !*name) && !keyblock);
  ------------------
  |  Branch (481:19): [True: 409k, False: 0]
  |  Branch (481:28): [True: 0, False: 0]
  |  Branch (481:39): [True: 409k, False: 0]
  ------------------
  482|       |
  483|      0|          if (keyblock)
  ------------------
  |  Branch (483:15): [True: 0, False: 0]
  ------------------
  484|      0|            c->node = c->keyblock = keyblock;
  485|      0|          else
  486|      0|            {
  487|      0|              err = getkey_byname (ctrl, NULL, NULL, name, 1, &c->keyblock);
  488|      0|              if (err)
  ------------------
  |  Branch (488:19): [True: 0, False: 0]
  ------------------
  489|      0|                {
  490|      0|                  struct agent_card_info_s cinfo = { 0 };
  491|       |
  492|       |                  /* getkey_byname might return a keyblock even in the
  493|       |                     error case - I have not checked.  Thus better release
  494|       |                     it.  */
  495|      0|                  release_kbnode (c->keyblock);
  496|      0|                  c->keyblock = NULL;
  497|       |                  /* If this was a card key we might not yet have the
  498|       |                   * public key for it.  Thus check whether the card
  499|       |                   * can return the fingerprint of the encryption key
  500|       |                   * and we can then find the public key via LDAP.  */
  501|      0|                  if (cardkey && !c->cardkey_done
  ------------------
  |  Branch (501:23): [True: 0, False: 0]
  |  Branch (501:34): [True: 0, False: 0]
  ------------------
  502|      0|                      && gpg_err_code (err) == GPG_ERR_NO_SECKEY
  ------------------
  |  Branch (502:26): [True: 0, False: 0]
  ------------------
  503|      0|                      && !agent_scd_getattr ("KEY-FPR", &cinfo)
  ------------------
  |  Branch (503:26): [True: 0, False: 0]
  ------------------
  504|      0|                      && cinfo.fpr2len)
  ------------------
  |  Branch (504:26): [True: 0, False: 0]
  ------------------
  505|      0|                    {
  506|       |                      /* Note that this code does not handle the case
  507|       |                       * for two readers having both openpgp
  508|       |                       * encryption keys. only one will be tried.  */
  509|      0|                      c->cardkey_done = 1;
  510|      0|                      if (opt.debug)
  ------------------
  |  Branch (510:27): [True: 0, False: 0]
  ------------------
  511|      0|                        log_debug ("using LDAP to find public key"
  512|      0|                                   " for current card\n");
  513|      0|                      if (!keyserver_import_fprint
  ------------------
  |  Branch (513:27): [True: 0, False: 0]
  ------------------
  514|      0|                          (ctrl, cinfo.fpr2, cinfo.fpr2len, opt.keyserver,
  515|      0|                           KEYSERVER_IMPORT_FLAG_LDAP))
  ------------------
  |  |   29|      0|#define KEYSERVER_IMPORT_FLAG_LDAP  2
  ------------------
  516|      0|                        {
  517|      0|                          char fpr_string[MAX_FINGERPRINT_LEN * 2 + 1];
  518|       |
  519|      0|                          bin2hex (cinfo.fpr2, cinfo.fpr2len, fpr_string);
  520|      0|                          err = getkey_byname (ctrl, NULL, NULL, fpr_string, 1,
  521|      0|                                               &c->keyblock);
  522|      0|                          if (err)
  ------------------
  |  Branch (522:31): [True: 0, False: 0]
  ------------------
  523|      0|                            {
  524|      0|                              release_kbnode (c->keyblock);
  525|      0|                              c->keyblock = NULL;
  526|      0|                            }
  527|      0|                          else
  528|      0|                            c->node = c->keyblock;
  529|      0|                        }
  530|      0|                    }
  531|      0|                }
  532|      0|              else
  533|      0|                c->node = c->keyblock;
  534|      0|            }
  535|      0|        }
  536|       |
  537|       |      /* Get the next key from the current keyblock.  */
  538|      0|      for (; c->node; c->node = c->node->next)
  ------------------
  |  Branch (538:14): [True: 0, False: 0]
  ------------------
  539|      0|        {
  540|      0|          if (c->node->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (540:15): [True: 0, False: 0]
  ------------------
  541|      0|              || c->node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (541:18): [True: 0, False: 0]
  ------------------
  542|      0|            {
  543|      0|              SK_LIST r;
  544|       |
  545|       |              /* Skip this candidate if it's already enumerated.  */
  546|      0|              for (r = c->results; r; r = r->next)
  ------------------
  |  Branch (546:36): [True: 0, False: 0]
  ------------------
  547|      0|                if (!cmp_public_keys (r->pk, c->node->pkt->pkt.public_key))
  ------------------
  |  Branch (547:21): [True: 0, False: 0]
  ------------------
  548|      0|                  break;
  549|      0|              if (r)
  ------------------
  |  Branch (549:19): [True: 0, False: 0]
  ------------------
  550|      0|                continue;
  551|       |
  552|      0|              copy_public_key (sk, c->node->pkt->pkt.public_key);
  553|      0|              c->node = c->node->next;
  554|       |
  555|      0|              r = xtrycalloc (1, sizeof (*r));
  ------------------
  |  |   99|      0|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  556|      0|              if (!r)
  ------------------
  |  Branch (556:19): [True: 0, False: 0]
  ------------------
  557|      0|                {
  558|      0|                  err = gpg_error_from_syserror ();
  559|      0|                  free_public_key (sk);
  560|      0|                  return err;
  561|      0|                }
  562|       |
  563|      0|              r->pk = sk;
  564|      0|              r->next = c->results;
  565|      0|              c->results = r;
  566|       |
  567|      0|              return 0; /* Found.  */
  568|      0|            }
  569|      0|        }
  570|       |
  571|       |      /* Dispose the keyblock and continue.  */
  572|      0|      release_kbnode (c->keyblock);
  573|      0|      c->keyblock = NULL;
  574|      0|    }
  575|  58.5k|}

tdbio_sync:
  429|      2|{
  430|      2|    CACHE_CTRL r;
  431|      2|    int did_lock = 0;
  432|       |
  433|      2|    if( db_fd == -1 )
  ------------------
  |  Branch (433:9): [True: 0, False: 2]
  ------------------
  434|      0|	open_db();
  435|       |#if 0 /* Transactions are not yet used.  */
  436|       |    if( in_transaction )
  437|       |	log_bug("tdbio: syncing while in transaction\n");
  438|       |#endif
  439|       |
  440|      2|    if( !cache_is_dirty )
  ------------------
  |  Branch (440:9): [True: 0, False: 2]
  ------------------
  441|      0|	return 0;
  442|       |
  443|      2|    if (!take_write_lock ())
  ------------------
  |  Branch (443:9): [True: 0, False: 2]
  ------------------
  444|      0|        did_lock = 1;
  445|       |
  446|     33|    for( r = cache_list; r; r = r->next ) {
  ------------------
  |  Branch (446:26): [True: 31, False: 2]
  ------------------
  447|     31|	if( r->flags.used && r->flags.dirty ) {
  ------------------
  |  Branch (447:6): [True: 31, False: 0]
  |  Branch (447:23): [True: 31, False: 0]
  ------------------
  448|     31|	    int rc = write_cache_item( r );
  449|     31|	    if( rc )
  ------------------
  |  Branch (449:10): [True: 0, False: 31]
  ------------------
  450|      0|		return rc;
  451|     31|	}
  452|     31|    }
  453|      2|    cache_is_dirty = 0;
  454|      2|    if (did_lock)
  ------------------
  |  Branch (454:9): [True: 0, False: 2]
  ------------------
  455|      0|        release_write_lock ();
  456|       |
  457|      2|    return 0;
  458|      2|}
tdbio_set_dbname:
  639|      1|{
  640|      1|  char *fname, *p;
  641|      1|  struct stat statbuf;
  642|      1|  static int initialized = 0;
  643|      1|  int save_slash;
  644|       |
  645|      1|  if (!initialized)
  ------------------
  |  Branch (645:7): [True: 1, False: 0]
  ------------------
  646|      1|    {
  647|      1|      atexit (cleanup);
  648|      1|      initialized = 1;
  649|      1|    }
  650|       |
  651|      1|  *r_nofile = 0;
  652|       |
  653|      1|  if (!new_dbname)
  ------------------
  |  Branch (653:7): [True: 1, False: 0]
  ------------------
  654|      1|    {
  655|      1|      fname = make_filename (gnupg_homedir (),
  656|      1|                             "trustdb" EXTSEP_S GPGEXT_GPG, NULL);
  ------------------
  |  |  122|      1|#define GPGEXT_GPG "gpg"
  ------------------
  657|      1|    }
  658|      0|  else if (*new_dbname != DIRSEP_C )
  ------------------
  |  |  886|      0|#define DIRSEP_C '/'
  ------------------
  |  Branch (658:12): [True: 0, False: 0]
  ------------------
  659|      0|    {
  660|      0|      if (strchr (new_dbname, DIRSEP_C))
  ------------------
  |  |  886|      0|#define DIRSEP_C '/'
  ------------------
  |  Branch (660:11): [True: 0, False: 0]
  ------------------
  661|      0|        fname = make_filename (new_dbname, NULL);
  662|      0|      else
  663|      0|        fname = make_filename (gnupg_homedir (), new_dbname, NULL);
  664|      0|    }
  665|      0|  else
  666|      0|    {
  667|      0|      fname = xstrdup (new_dbname);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  668|      0|    }
  669|       |
  670|      1|  xfree (db_name);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  671|      1|  db_name = fname;
  672|       |
  673|       |  /* Quick check for (likely) case where there already is a
  674|       |   * trustdb.gpg.  This check is not required in theory, but it helps
  675|       |   * in practice avoiding costly operations of preparing and taking
  676|       |   * the lock.  */
  677|      1|  if (!gnupg_stat (fname, &statbuf) && statbuf.st_size > 0)
  ------------------
  |  Branch (677:7): [True: 0, False: 1]
  |  Branch (677:40): [True: 0, False: 0]
  ------------------
  678|      0|    {
  679|       |      /* OK, we have the valid trustdb.gpg already.  */
  680|      0|      return 0;
  681|      0|    }
  682|      1|  else if (!create)
  ------------------
  |  Branch (682:12): [True: 0, False: 1]
  ------------------
  683|      0|    {
  684|      0|      *r_nofile = 1;
  685|      0|      return 0;
  686|      0|    }
  687|       |
  688|       |  /* Here comes: No valid trustdb.gpg AND CREATE==1 */
  689|       |
  690|       |  /*
  691|       |   * Make sure the directory exists.  This should be done before
  692|       |   * acquiring the lock, which assumes the existence of the directory.
  693|       |   */
  694|      1|  p = strrchr (fname, DIRSEP_C);
  ------------------
  |  |  886|      1|#define DIRSEP_C '/'
  ------------------
  695|       |#if HAVE_W32_SYSTEM
  696|       |  {
  697|       |    /* Windows may either have a slash or a backslash.  Take
  698|       |       care of it.  */
  699|       |    char *pp = strrchr (fname, '/');
  700|       |    if (!p || pp > p)
  701|       |      p = pp;
  702|       |  }
  703|       |#endif /*HAVE_W32_SYSTEM*/
  704|      1|  log_assert (p);
  705|      0|  save_slash = *p;
  706|      1|  *p = 0;
  707|      1|  if (gnupg_access (fname, F_OK))
  ------------------
  |  Branch (707:7): [True: 0, False: 1]
  ------------------
  708|      0|    {
  709|      0|      try_make_homedir (fname);
  710|      0|      if (gnupg_access (fname, F_OK))
  ------------------
  |  Branch (710:11): [True: 0, False: 0]
  ------------------
  711|      0|        log_fatal (_("%s: directory does not exist!\n"), fname);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  712|      0|    }
  713|      1|  *p = save_slash;
  714|       |
  715|      1|  take_write_lock ();
  716|       |
  717|      1|  if (gnupg_access (fname, R_OK)
  ------------------
  |  Branch (717:7): [True: 1, False: 0]
  ------------------
  718|      1|      || gnupg_stat (fname, &statbuf)
  ------------------
  |  Branch (718:10): [True: 0, False: 0]
  ------------------
  719|      1|      || statbuf.st_size == 0)
  ------------------
  |  Branch (719:10): [True: 0, False: 0]
  ------------------
  720|      1|    {
  721|      1|      estream_t fp;
  722|      1|      TRUSTREC rec;
  723|      1|      int rc;
  724|      1|      mode_t oldmask;
  725|       |
  726|      1|      if (errno && errno != ENOENT)
  ------------------
  |  Branch (726:20): [True: 0, False: 1]
  ------------------
  727|      0|        log_fatal ( _("can't access '%s': %s\n"), fname, strerror (errno));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  728|       |
  729|      1|      oldmask = umask (077);
  730|      1|      if (is_secured_filename (fname))
  ------------------
  |  Branch (730:11): [True: 0, False: 1]
  ------------------
  731|      0|        {
  732|      0|          fp = NULL;
  733|      0|          gpg_err_set_errno (EPERM);
  734|      0|        }
  735|      1|      else
  736|      1|        fp = es_fopen (fname, "wb");
  737|      1|      umask(oldmask);
  738|      1|      if (!fp)
  ------------------
  |  Branch (738:11): [True: 0, False: 1]
  ------------------
  739|      0|        log_fatal (_("can't create '%s': %s\n"), fname, strerror (errno));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  740|      1|      es_fclose (fp);
  741|       |
  742|      1|      db_fd = gnupg_open (db_name, O_RDWR | MY_O_BINARY, 0);
  ------------------
  |  |   48|      1|#define MY_O_BINARY  0
  ------------------
  743|      1|      if (db_fd == -1)
  ------------------
  |  Branch (743:11): [True: 0, False: 1]
  ------------------
  744|      0|        log_fatal (_("can't open '%s': %s\n"), db_name, strerror (errno));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  745|       |
  746|      1|      rc = create_version_record (ctrl);
  747|      1|      if (rc)
  ------------------
  |  Branch (747:11): [True: 0, False: 1]
  ------------------
  748|      0|        log_fatal (_("%s: failed to create version record: %s"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  749|      0|                   fname, gpg_strerror (rc));
  750|       |
  751|       |      /* Read again to check that we are okay. */
  752|      1|      if (tdbio_read_record (0, &rec, RECTYPE_VER))
  ------------------
  |  |   36|      1|#define RECTYPE_VER  1
  ------------------
  |  Branch (752:11): [True: 0, False: 1]
  ------------------
  753|      0|        log_fatal (_("%s: invalid trustdb created\n"), db_name);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  754|       |
  755|      1|      if (!opt.quiet)
  ------------------
  |  Branch (755:11): [True: 1, False: 0]
  ------------------
  756|      1|        log_info (_("%s: trustdb created\n"), db_name);
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
  757|      1|    }
  758|       |
  759|      1|  release_write_lock ();
  760|      1|  return 0;
  761|      1|}
tdbio_db_matches_options:
  863|      1|{
  864|      1|  static int yes_no = -1;
  865|       |
  866|      1|  if (yes_no == -1)
  ------------------
  |  Branch (866:7): [True: 1, False: 0]
  ------------------
  867|      1|    {
  868|      1|      TRUSTREC vr;
  869|      1|      int rc;
  870|      1|      int opt_tm, tm;
  871|       |
  872|      1|      rc = tdbio_read_record (0, &vr, RECTYPE_VER);
  ------------------
  |  |   36|      1|#define RECTYPE_VER  1
  ------------------
  873|      1|      if( rc )
  ------------------
  |  Branch (873:11): [True: 0, False: 1]
  ------------------
  874|      0|	log_fatal( _("%s: error reading version record: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  875|      0|		   db_name, gpg_strerror (rc) );
  876|       |
  877|       |      /* Consider tofu and pgp the same.  */
  878|      1|      tm = vr.r.ver.trust_model;
  879|      1|      if (tm == TM_TOFU || tm == TM_TOFU_PGP)
  ------------------
  |  Branch (879:11): [True: 0, False: 1]
  |  Branch (879:28): [True: 0, False: 1]
  ------------------
  880|      0|        tm = TM_PGP;
  881|      1|      opt_tm  = opt.trust_model;
  882|      1|      if (opt_tm == TM_TOFU || opt_tm == TM_TOFU_PGP)
  ------------------
  |  Branch (882:11): [True: 0, False: 1]
  |  Branch (882:32): [True: 0, False: 1]
  ------------------
  883|      0|        opt_tm = TM_PGP;
  884|       |
  885|      1|      yes_no = vr.r.ver.marginals == opt.marginals_needed
  ------------------
  |  Branch (885:16): [True: 1, False: 0]
  ------------------
  886|      1|	&& vr.r.ver.completes == opt.completes_needed
  ------------------
  |  Branch (886:5): [True: 1, False: 0]
  ------------------
  887|      1|	&& vr.r.ver.cert_depth == opt.max_cert_depth
  ------------------
  |  Branch (887:5): [True: 1, False: 0]
  ------------------
  888|      1|	&& tm == opt_tm
  ------------------
  |  Branch (888:5): [True: 1, False: 0]
  ------------------
  889|      1|	&& vr.r.ver.min_cert_level == opt.min_cert_level;
  ------------------
  |  Branch (889:5): [True: 1, False: 0]
  ------------------
  890|      1|    }
  891|       |
  892|      1|  return yes_no;
  893|      1|}
tdbio_read_nextcheck:
  920|      1|{
  921|      1|  TRUSTREC vr;
  922|      1|  int rc;
  923|       |
  924|      1|  rc = tdbio_read_record (0, &vr, RECTYPE_VER);
  ------------------
  |  |   36|      1|#define RECTYPE_VER  1
  ------------------
  925|      1|  if (rc)
  ------------------
  |  Branch (925:7): [True: 0, False: 1]
  ------------------
  926|      0|    log_fatal (_("%s: error reading version record: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  927|      0|               db_name, gpg_strerror (rc));
  928|      1|  return vr.r.ver.nextcheck;
  929|      1|}
tdbio_read_record:
 1490|     33|{
 1491|     33|  byte readbuf[TRUST_RECORD_LEN];
 1492|     33|  const byte *buf, *p;
 1493|     33|  gpg_error_t err = 0;
 1494|     33|  int n, i;
 1495|       |
 1496|     33|  if (db_fd == -1)
  ------------------
  |  Branch (1496:7): [True: 0, False: 33]
  ------------------
 1497|      0|    open_db ();
 1498|       |
 1499|     33|  buf = get_record_from_cache( recnum );
 1500|     33|  if (!buf)
  ------------------
  |  Branch (1500:7): [True: 1, False: 32]
  ------------------
 1501|      1|    {
 1502|      1|      if (lseek (db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET) == -1)
  ------------------
  |  |   25|      1|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (1502:11): [True: 0, False: 1]
  ------------------
 1503|      0|        {
 1504|      0|          err = gpg_error_from_syserror ();
 1505|      0|          log_error (_("trustdb: lseek failed: %s\n"), strerror (errno));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1506|      0|          return err;
 1507|      0|	}
 1508|      1|      n = read (db_fd, readbuf, TRUST_RECORD_LEN);
  ------------------
  |  |   25|      1|#define TRUST_RECORD_LEN 40
  ------------------
 1509|      1|      if (!n)
  ------------------
  |  Branch (1509:11): [True: 1, False: 0]
  ------------------
 1510|      1|        {
 1511|      1|          return gpg_error (GPG_ERR_EOF);
 1512|      1|	}
 1513|      0|      else if (n != TRUST_RECORD_LEN)
  ------------------
  |  |   25|      0|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (1513:16): [True: 0, False: 0]
  ------------------
 1514|      0|        {
 1515|      0|          err = gpg_error_from_syserror ();
 1516|      0|          log_error (_("trustdb: read failed (n=%d): %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1517|      0|                     n, strerror(errno));
 1518|      0|          return err;
 1519|      0|	}
 1520|      0|      buf = readbuf;
 1521|      0|    }
 1522|     32|  rec->recnum = recnum;
 1523|     32|  rec->dirty = 0;
 1524|     32|  p = buf;
 1525|     32|  rec->rectype = *p++;
 1526|     32|  if (expected && rec->rectype != expected)
  ------------------
  |  Branch (1526:7): [True: 3, False: 29]
  |  Branch (1526:19): [True: 0, False: 3]
  ------------------
 1527|      0|    {
 1528|      0|      log_error ("%lu: read expected rec type %d, got %d\n",
 1529|      0|                 recnum, expected, rec->rectype);
 1530|      0|      return gpg_error (GPG_ERR_TRUSTDB);
 1531|      0|    }
 1532|     32|  p++;    /* Skip reserved byte.  */
 1533|     32|  switch (rec->rectype)
 1534|     32|    {
 1535|      0|    case 0:  /* unused (free) record */
  ------------------
  |  Branch (1535:5): [True: 0, False: 32]
  ------------------
 1536|      0|      break;
 1537|       |
 1538|      3|    case RECTYPE_VER: /* version record */
  ------------------
  |  |   36|      3|#define RECTYPE_VER  1
  ------------------
  |  Branch (1538:5): [True: 3, False: 29]
  ------------------
 1539|      3|      if (memcmp(buf+1, GPGEXT_GPG, 3))
  ------------------
  |  |  122|      3|#define GPGEXT_GPG "gpg"
  ------------------
  |  Branch (1539:11): [True: 0, False: 3]
  ------------------
 1540|      0|        {
 1541|      0|          log_error (_("%s: not a trustdb file\n"), db_name );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1542|      0|          err = gpg_error (GPG_ERR_TRUSTDB);
 1543|      0|        }
 1544|      3|      else
 1545|      3|        {
 1546|      3|          p += 2; /* skip "gpg" */
 1547|      3|          rec->r.ver.version  = *p++;
 1548|      3|          rec->r.ver.marginals = *p++;
 1549|      3|          rec->r.ver.completes = *p++;
 1550|      3|          rec->r.ver.cert_depth = *p++;
 1551|      3|          rec->r.ver.trust_model = *p++;
 1552|      3|          rec->r.ver.min_cert_level = *p++;
 1553|      3|          p += 2;
 1554|      3|          rec->r.ver.created  = buf32_to_ulong(p);
 1555|      3|          p += 4;
 1556|      3|          rec->r.ver.nextcheck = buf32_to_ulong(p);
 1557|      3|          p += 4;
 1558|      3|          p += 4;
 1559|      3|          p += 4;
 1560|      3|          rec->r.ver.firstfree = buf32_to_ulong(p);
 1561|      3|          p += 4;
 1562|      3|          p += 4;
 1563|      3|          rec->r.ver.trusthashtbl = buf32_to_ulong(p);
 1564|      3|          if (recnum)
  ------------------
  |  Branch (1564:15): [True: 0, False: 3]
  ------------------
 1565|      0|            {
 1566|      0|              log_error( _("%s: version record with recnum %lu\n"), db_name,
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1567|      0|                         (ulong)recnum );
 1568|      0|              err = gpg_error (GPG_ERR_TRUSTDB);
 1569|      0|            }
 1570|      3|          else if (rec->r.ver.version != 3)
  ------------------
  |  Branch (1570:20): [True: 0, False: 3]
  ------------------
 1571|      0|            {
 1572|      0|              log_error( _("%s: invalid file version %d\n"), db_name,
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1573|      0|                         rec->r.ver.version );
 1574|      0|              err = gpg_error (GPG_ERR_TRUSTDB);
 1575|      0|            }
 1576|      3|        }
 1577|      3|      break;
 1578|       |
 1579|      0|    case RECTYPE_FREE:
  ------------------
  |  |   41|      0|#define RECTYPE_FREE 254
  ------------------
  |  Branch (1579:5): [True: 0, False: 32]
  ------------------
 1580|      0|      rec->r.free.next  = buf32_to_ulong(p);
 1581|      0|      break;
 1582|       |
 1583|     29|    case RECTYPE_HTBL:
  ------------------
  |  |   37|     29|#define RECTYPE_HTBL 10
  ------------------
  |  Branch (1583:5): [True: 29, False: 3]
  ------------------
 1584|    290|      for (i=0; i < ITEMS_PER_HTBL_RECORD; i++)
  ------------------
  |  |   27|    290|#define ITEMS_PER_HTBL_RECORD	((TRUST_RECORD_LEN-2)/4)
  |  |  ------------------
  |  |  |  |   25|    290|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  |  Branch (1584:17): [True: 261, False: 29]
  ------------------
 1585|    261|        {
 1586|    261|          rec->r.htbl.item[i] = buf32_to_ulong(p);
 1587|    261|          p += 4;
 1588|    261|	}
 1589|     29|      break;
 1590|       |
 1591|      0|    case RECTYPE_HLST:
  ------------------
  |  |   38|      0|#define RECTYPE_HLST 11
  ------------------
  |  Branch (1591:5): [True: 0, False: 32]
  ------------------
 1592|      0|      rec->r.hlst.next = buf32_to_ulong(p);
 1593|      0|      p += 4;
 1594|      0|      for (i=0; i < ITEMS_PER_HLST_RECORD; i++)
  ------------------
  |  |   28|      0|#define ITEMS_PER_HLST_RECORD	((TRUST_RECORD_LEN-6)/5)
  |  |  ------------------
  |  |  |  |   25|      0|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  |  Branch (1594:17): [True: 0, False: 0]
  ------------------
 1595|      0|        {
 1596|      0|          rec->r.hlst.rnum[i] = buf32_to_ulong(p);
 1597|      0|          p += 4;
 1598|      0|	}
 1599|      0|      break;
 1600|       |
 1601|      0|    case RECTYPE_TRUST:
  ------------------
  |  |   39|      0|#define RECTYPE_TRUST 12
  ------------------
  |  Branch (1601:5): [True: 0, False: 32]
  ------------------
 1602|      0|      memcpy (rec->r.trust.fingerprint, p, 20);
 1603|      0|      p+=20;
 1604|      0|      rec->r.trust.ownertrust = *p++;
 1605|      0|      rec->r.trust.depth = *p++;
 1606|      0|      rec->r.trust.min_ownertrust = *p++;
 1607|      0|      rec->r.trust.flags = *p++;
 1608|      0|      rec->r.trust.validlist = buf32_to_ulong(p);
 1609|      0|      break;
 1610|       |
 1611|      0|    case RECTYPE_VALID:
  ------------------
  |  |   40|      0|#define RECTYPE_VALID 13
  ------------------
  |  Branch (1611:5): [True: 0, False: 32]
  ------------------
 1612|      0|      memcpy (rec->r.valid.namehash, p, 20);
 1613|      0|      p+=20;
 1614|      0|      rec->r.valid.validity = *p++;
 1615|      0|      rec->r.valid.next = buf32_to_ulong(p);
 1616|      0|      p += 4;
 1617|      0|      rec->r.valid.full_count = *p++;
 1618|      0|      rec->r.valid.marginal_count = *p++;
 1619|      0|      break;
 1620|       |
 1621|      0|    default:
  ------------------
  |  Branch (1621:5): [True: 0, False: 32]
  ------------------
 1622|      0|      log_error ("%s: invalid record type %d at recnum %lu\n",
 1623|      0|                 db_name, rec->rectype, (ulong)recnum);
 1624|      0|      err = gpg_error (GPG_ERR_TRUSTDB);
 1625|      0|      break;
 1626|     32|    }
 1627|       |
 1628|     32|  return err;
 1629|     32|}
tdbio_write_record:
 1639|     31|{
 1640|     31|  byte buf[TRUST_RECORD_LEN];
 1641|     31|  byte *p;
 1642|     31|  int rc = 0;
 1643|     31|  int i;
 1644|     31|  ulong recnum = rec->recnum;
 1645|       |
 1646|     31|  if (db_fd == -1)
  ------------------
  |  Branch (1646:7): [True: 0, False: 31]
  ------------------
 1647|      0|    open_db ();
 1648|       |
 1649|     31|  memset (buf, 0, TRUST_RECORD_LEN);
  ------------------
  |  |   25|     31|#define TRUST_RECORD_LEN 40
  ------------------
 1650|     31|  p = buf;
 1651|     31|  *p++ = rec->rectype; p++;
 1652|       |
 1653|     31|  switch (rec->rectype)
 1654|     31|    {
 1655|      0|    case 0:  /* unused record */
  ------------------
  |  Branch (1655:5): [True: 0, False: 31]
  ------------------
 1656|      0|      break;
 1657|       |
 1658|      2|    case RECTYPE_VER: /* version record */
  ------------------
  |  |   36|      2|#define RECTYPE_VER  1
  ------------------
  |  Branch (1658:5): [True: 2, False: 29]
  ------------------
 1659|      2|      if (recnum)
  ------------------
  |  Branch (1659:11): [True: 0, False: 2]
  ------------------
 1660|      0|        BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1661|      2|      memcpy(p-1, GPGEXT_GPG, 3 ); p += 2;
  ------------------
  |  |  122|      2|#define GPGEXT_GPG "gpg"
  ------------------
 1662|      2|      *p++ = rec->r.ver.version;
 1663|      2|      *p++ = rec->r.ver.marginals;
 1664|      2|      *p++ = rec->r.ver.completes;
 1665|      2|      *p++ = rec->r.ver.cert_depth;
 1666|      2|      *p++ = rec->r.ver.trust_model;
 1667|      2|      *p++ = rec->r.ver.min_cert_level;
 1668|      2|      p += 2;
 1669|      2|      ulongtobuf(p, rec->r.ver.created); p += 4;
  ------------------
  |  |   35|      2|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      2|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      2|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      2|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      2|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      2|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1670|      2|      ulongtobuf(p, rec->r.ver.nextcheck); p += 4;
  ------------------
  |  |   35|      2|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      2|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      2|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      2|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      2|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      2|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1671|      2|      p += 4;
 1672|      2|      p += 4;
 1673|      2|      ulongtobuf(p, rec->r.ver.firstfree ); p += 4;
  ------------------
  |  |   35|      2|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      2|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      2|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      2|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      2|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      2|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1674|      2|      p += 4;
 1675|      2|      ulongtobuf(p, rec->r.ver.trusthashtbl ); p += 4;
  ------------------
  |  |   35|      2|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      2|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      2|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      2|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      2|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      2|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1676|      2|      break;
 1677|       |
 1678|      0|    case RECTYPE_FREE:
  ------------------
  |  |   41|      0|#define RECTYPE_FREE 254
  ------------------
  |  Branch (1678:5): [True: 0, False: 31]
  ------------------
 1679|      0|      ulongtobuf(p, rec->r.free.next); p += 4;
  ------------------
  |  |   35|      0|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      0|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      0|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      0|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      0|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      0|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1680|      0|      break;
 1681|       |
 1682|     29|    case RECTYPE_HTBL:
  ------------------
  |  |   37|     29|#define RECTYPE_HTBL 10
  ------------------
  |  Branch (1682:5): [True: 29, False: 2]
  ------------------
 1683|    290|      for (i=0; i < ITEMS_PER_HTBL_RECORD; i++)
  ------------------
  |  |   27|    290|#define ITEMS_PER_HTBL_RECORD	((TRUST_RECORD_LEN-2)/4)
  |  |  ------------------
  |  |  |  |   25|    290|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  |  Branch (1683:17): [True: 261, False: 29]
  ------------------
 1684|    261|        {
 1685|    261|          ulongtobuf( p, rec->r.htbl.item[i]); p += 4;
  ------------------
  |  |   35|    261|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|    261|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|    261|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|    261|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|    261|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|    261|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1686|    261|        }
 1687|     29|      break;
 1688|       |
 1689|      0|    case RECTYPE_HLST:
  ------------------
  |  |   38|      0|#define RECTYPE_HLST 11
  ------------------
  |  Branch (1689:5): [True: 0, False: 31]
  ------------------
 1690|      0|      ulongtobuf( p, rec->r.hlst.next); p += 4;
  ------------------
  |  |   35|      0|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      0|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      0|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      0|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      0|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      0|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1691|      0|      for (i=0; i < ITEMS_PER_HLST_RECORD; i++ )
  ------------------
  |  |   28|      0|#define ITEMS_PER_HLST_RECORD	((TRUST_RECORD_LEN-6)/5)
  |  |  ------------------
  |  |  |  |   25|      0|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  |  Branch (1691:17): [True: 0, False: 0]
  ------------------
 1692|      0|        {
 1693|      0|          ulongtobuf( p, rec->r.hlst.rnum[i]); p += 4;
  ------------------
  |  |   35|      0|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      0|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      0|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      0|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      0|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      0|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1694|      0|	}
 1695|      0|      break;
 1696|       |
 1697|      0|    case RECTYPE_TRUST:
  ------------------
  |  |   39|      0|#define RECTYPE_TRUST 12
  ------------------
  |  Branch (1697:5): [True: 0, False: 31]
  ------------------
 1698|      0|      memcpy (p, rec->r.trust.fingerprint, 20); p += 20;
 1699|      0|      *p++ = rec->r.trust.ownertrust;
 1700|      0|      *p++ = rec->r.trust.depth;
 1701|      0|      *p++ = rec->r.trust.min_ownertrust;
 1702|      0|      *p++ = rec->r.trust.flags;
 1703|      0|      ulongtobuf( p, rec->r.trust.validlist); p += 4;
  ------------------
  |  |   35|      0|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      0|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      0|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      0|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      0|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      0|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1704|      0|      break;
 1705|       |
 1706|      0|    case RECTYPE_VALID:
  ------------------
  |  |   40|      0|#define RECTYPE_VALID 13
  ------------------
  |  Branch (1706:5): [True: 0, False: 31]
  ------------------
 1707|      0|      memcpy (p, rec->r.valid.namehash, 20); p += 20;
 1708|      0|      *p++ = rec->r.valid.validity;
 1709|      0|      ulongtobuf( p, rec->r.valid.next); p += 4;
  ------------------
  |  |   35|      0|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      0|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      0|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      0|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      0|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      0|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1710|      0|      *p++ = rec->r.valid.full_count;
 1711|      0|      *p++ = rec->r.valid.marginal_count;
 1712|      0|      break;
 1713|       |
 1714|      0|    default:
  ------------------
  |  Branch (1714:5): [True: 0, False: 31]
  ------------------
 1715|      0|      BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1716|     31|    }
 1717|       |
 1718|     31|  rc = put_record_into_cache (recnum, buf);
 1719|     31|  if (rc)
  ------------------
  |  Branch (1719:7): [True: 0, False: 31]
  ------------------
 1720|      0|    ;
 1721|     31|  else if (rec->rectype == RECTYPE_TRUST)
  ------------------
  |  |   39|     31|#define RECTYPE_TRUST 12
  ------------------
  |  Branch (1721:12): [True: 0, False: 31]
  ------------------
 1722|      0|    rc = update_trusthashtbl (ctrl, rec);
 1723|       |
 1724|     31|  return rc;
 1725|     31|}
tdbio.c:take_write_lock:
  131|      3|{
  132|      3|  int rc;
  133|       |
  134|      3|  if (!lockhandle)
  ------------------
  |  Branch (134:7): [True: 1, False: 2]
  ------------------
  135|      1|    lockhandle = dotlock_create (db_name, 0);
  136|      3|  if (!lockhandle)
  ------------------
  |  Branch (136:7): [True: 0, False: 3]
  ------------------
  137|      0|    log_fatal ( _("can't create lock for '%s'\n"), db_name );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  138|       |
  139|      3|  if (!is_locked)
  ------------------
  |  Branch (139:7): [True: 1, False: 2]
  ------------------
  140|      1|    {
  141|      1|      if (dotlock_take (lockhandle, -1) )
  ------------------
  |  Branch (141:11): [True: 0, False: 1]
  ------------------
  142|      0|        log_fatal ( _("can't lock '%s'\n"), db_name );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  143|      1|      rc = 0;
  144|      1|    }
  145|      2|  else
  146|      2|    rc = 1;
  147|       |
  148|      3|  if (opt.lock_once)
  ------------------
  |  Branch (148:7): [True: 0, False: 3]
  ------------------
  149|      0|    is_locked = 1;
  150|      3|  else
  151|      3|    is_locked++;
  152|      3|  return rc;
  153|      3|}
tdbio.c:write_cache_item:
  210|     31|{
  211|     31|  gpg_error_t err;
  212|     31|  int n;
  213|       |
  214|     31|  if (lseek (db_fd, r->recno * TRUST_RECORD_LEN, SEEK_SET) == -1)
  ------------------
  |  |   25|     31|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (214:7): [True: 0, False: 31]
  ------------------
  215|      0|    {
  216|      0|      err = gpg_error_from_syserror ();
  217|      0|      log_error (_("trustdb rec %lu: lseek failed: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  218|      0|                 r->recno, strerror (errno));
  219|      0|      return err;
  220|      0|    }
  221|     31|  n = write (db_fd, r->data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|     31|#define TRUST_RECORD_LEN 40
  ------------------
  222|     31|  if (n != TRUST_RECORD_LEN)
  ------------------
  |  |   25|     31|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (222:7): [True: 0, False: 31]
  ------------------
  223|      0|    {
  224|      0|      err = gpg_error_from_syserror ();
  225|      0|      log_error (_("trustdb rec %lu: write failed (n=%d): %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  226|      0|                 r->recno, n, strerror (errno) );
  227|      0|      return err;
  228|      0|    }
  229|     31|  r->flags.dirty = 0;
  230|     31|  return 0;
  231|     31|}
tdbio.c:release_write_lock:
  162|      1|{
  163|      1|  if (opt.lock_once)
  ------------------
  |  Branch (163:7): [True: 0, False: 1]
  ------------------
  164|      0|    return;  /* Don't care; here IS_LOCKED is fixed to 1.  */
  165|       |
  166|      1|  if (!is_locked)
  ------------------
  |  Branch (166:7): [True: 0, False: 1]
  ------------------
  167|      0|    {
  168|      0|      log_error ("Ooops, tdbio:release_write_lock with no lock held\n");
  169|      0|      return;
  170|      0|    }
  171|      1|  if (--is_locked)
  ------------------
  |  Branch (171:7): [True: 1, False: 0]
  ------------------
  172|      1|    return;
  173|       |
  174|      0|  if (dotlock_release (lockhandle))
  ------------------
  |  Branch (174:7): [True: 0, False: 0]
  ------------------
  175|      0|    log_error ("Oops, tdbio:release_write_locked failed\n");
  176|      0|}
tdbio.c:cleanup:
  538|      1|{
  539|      1|  if (is_locked)
  ------------------
  |  Branch (539:7): [True: 1, False: 0]
  ------------------
  540|      1|    {
  541|      1|      if (!dotlock_release (lockhandle))
  ------------------
  |  Branch (541:11): [True: 1, False: 0]
  ------------------
  542|      1|        is_locked = 0;
  543|      1|    }
  544|      1|}
tdbio.c:create_version_record:
  590|      1|{
  591|      1|  TRUSTREC rec;
  592|      1|  int rc;
  593|      1|  int opt_tm;
  594|       |
  595|       |  /* Never store a TOFU trust model in the trustdb.  Use PGP instead.  */
  596|      1|  opt_tm = opt.trust_model;
  597|      1|  if (opt_tm == TM_TOFU || opt_tm == TM_TOFU_PGP)
  ------------------
  |  Branch (597:7): [True: 0, False: 1]
  |  Branch (597:28): [True: 0, False: 1]
  ------------------
  598|      0|    opt_tm = TM_PGP;
  599|       |
  600|      1|  memset (&rec, 0, sizeof rec);
  601|      1|  rec.r.ver.version     = 3;
  602|      1|  rec.r.ver.created     = make_timestamp ();
  603|      1|  rec.r.ver.marginals   = opt.marginals_needed;
  604|      1|  rec.r.ver.completes   = opt.completes_needed;
  605|      1|  rec.r.ver.cert_depth  = opt.max_cert_depth;
  606|      1|  if (opt_tm == TM_PGP || opt_tm == TM_CLASSIC)
  ------------------
  |  Branch (606:7): [True: 0, False: 1]
  |  Branch (606:27): [True: 1, False: 0]
  ------------------
  607|      1|    rec.r.ver.trust_model = opt_tm;
  608|      0|  else
  609|      0|    rec.r.ver.trust_model = TM_PGP;
  610|      1|  rec.r.ver.min_cert_level = opt.min_cert_level;
  611|      1|  rec.rectype = RECTYPE_VER;
  ------------------
  |  |   36|      1|#define RECTYPE_VER  1
  ------------------
  612|      1|  rec.recnum = 0;
  613|      1|  rc = tdbio_write_record (ctrl, &rec);
  614|       |
  615|      1|  if (!rc)
  ------------------
  |  Branch (615:7): [True: 1, False: 0]
  ------------------
  616|      1|    tdbio_sync ();
  617|       |
  618|      1|  if (!rc)
  ------------------
  |  Branch (618:7): [True: 1, False: 0]
  ------------------
  619|      1|    create_hashtable (ctrl, &rec, 0);
  620|       |
  621|      1|  return rc;
  622|      1|}
tdbio.c:create_hashtable:
  818|      1|{
  819|      1|  TRUSTREC rec;
  820|      1|  off_t offset;
  821|      1|  ulong recnum;
  822|      1|  int i, n, rc;
  823|       |
  824|      1|  offset = lseek (db_fd, 0, SEEK_END);
  825|      1|  if (offset == -1)
  ------------------
  |  Branch (825:7): [True: 0, False: 1]
  ------------------
  826|      0|    log_fatal ("trustdb: lseek to end failed: %s\n", strerror(errno));
  827|      1|  recnum = offset / TRUST_RECORD_LEN;
  ------------------
  |  |   25|      1|#define TRUST_RECORD_LEN 40
  ------------------
  828|      1|  log_assert (recnum); /* This is will never be the first record. */
  829|       |
  830|      1|  if (!type)
  ------------------
  |  Branch (830:7): [True: 1, False: 0]
  ------------------
  831|      1|    vr->r.ver.trusthashtbl = recnum;
  832|       |
  833|       |  /* Now write the records making up the hash table. */
  834|      1|  n = (256+ITEMS_PER_HTBL_RECORD-1) / ITEMS_PER_HTBL_RECORD;
  ------------------
  |  |   27|      1|#define ITEMS_PER_HTBL_RECORD	((TRUST_RECORD_LEN-2)/4)
  |  |  ------------------
  |  |  |  |   25|      1|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
                n = (256+ITEMS_PER_HTBL_RECORD-1) / ITEMS_PER_HTBL_RECORD;
  ------------------
  |  |   27|      1|#define ITEMS_PER_HTBL_RECORD	((TRUST_RECORD_LEN-2)/4)
  |  |  ------------------
  |  |  |  |   25|      1|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  835|     30|  for (i=0; i < n; i++, recnum++)
  ------------------
  |  Branch (835:13): [True: 29, False: 1]
  ------------------
  836|     29|    {
  837|     29|      memset (&rec, 0, sizeof rec);
  838|     29|      rec.rectype = RECTYPE_HTBL;
  ------------------
  |  |   37|     29|#define RECTYPE_HTBL 10
  ------------------
  839|     29|      rec.recnum = recnum;
  840|     29|      rc = tdbio_write_record (ctrl, &rec);
  841|     29|      if (rc)
  ------------------
  |  Branch (841:11): [True: 0, False: 29]
  ------------------
  842|      0|        log_fatal (_("%s: failed to create hashtable: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  843|      0|                   db_name, gpg_strerror (rc));
  844|     29|    }
  845|       |  /* Update the version record and flush. */
  846|      1|  rc = tdbio_write_record (ctrl, vr);
  847|      1|  if (!rc)
  ------------------
  |  Branch (847:7): [True: 1, False: 0]
  ------------------
  848|      1|    rc = tdbio_sync ();
  849|      1|  if (rc)
  ------------------
  |  Branch (849:7): [True: 0, False: 1]
  ------------------
  850|      0|    log_fatal (_("%s: error updating version record: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  851|      0|               db_name, gpg_strerror (rc));
  852|      1|}
tdbio.c:get_record_from_cache:
  191|     33|{
  192|     33|  CACHE_CTRL r;
  193|       |
  194|    556|  for (r = cache_list; r; r = r->next)
  ------------------
  |  Branch (194:24): [True: 555, False: 1]
  ------------------
  195|    555|    {
  196|    555|      if (r->flags.used && r->recno == recno)
  ------------------
  |  Branch (196:11): [True: 555, False: 0]
  |  Branch (196:28): [True: 32, False: 523]
  ------------------
  197|     32|        return r->data;
  198|    555|    }
  199|      1|  return NULL;
  200|     33|}
tdbio.c:put_record_into_cache:
  242|     31|{
  243|     31|  CACHE_CTRL r, unused;
  244|     31|  int dirty_count = 0;
  245|     31|  int clean_count = 0;
  246|       |
  247|       |  /* See whether we already cached this one.  */
  248|    495|  for (unused = NULL, r = cache_list; r; r = r->next)
  ------------------
  |  Branch (248:39): [True: 465, False: 30]
  ------------------
  249|    465|    {
  250|    465|      if (!r->flags.used)
  ------------------
  |  Branch (250:11): [True: 0, False: 465]
  ------------------
  251|      0|        {
  252|      0|          if (!unused)
  ------------------
  |  Branch (252:15): [True: 0, False: 0]
  ------------------
  253|      0|            unused = r;
  254|      0|	}
  255|    465|      else if (r->recno == recno)
  ------------------
  |  Branch (255:16): [True: 1, False: 464]
  ------------------
  256|      1|        {
  257|      1|          if (!r->flags.dirty)
  ------------------
  |  Branch (257:15): [True: 1, False: 0]
  ------------------
  258|      1|            {
  259|       |              /* Hmmm: should we use a copy and compare? */
  260|      1|              if (memcmp (r->data, data, TRUST_RECORD_LEN))
  ------------------
  |  |   25|      1|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (260:19): [True: 1, False: 0]
  ------------------
  261|      1|                {
  262|      1|                  r->flags.dirty = 1;
  263|      1|                  cache_is_dirty = 1;
  264|      1|		}
  265|      1|	    }
  266|      1|          memcpy (r->data, data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|      1|#define TRUST_RECORD_LEN 40
  ------------------
  267|      1|          return 0;
  268|      1|	}
  269|    464|      if (r->flags.used)
  ------------------
  |  Branch (269:11): [True: 464, False: 0]
  ------------------
  270|    464|        {
  271|    464|          if (r->flags.dirty)
  ------------------
  |  Branch (271:15): [True: 435, False: 29]
  ------------------
  272|    435|            dirty_count++;
  273|     29|          else
  274|     29|            clean_count++;
  275|    464|	}
  276|    464|    }
  277|       |
  278|       |  /* Not in the cache: add a new entry. */
  279|     30|  if (unused)
  ------------------
  |  Branch (279:7): [True: 0, False: 30]
  ------------------
  280|      0|    {
  281|       |      /* Reuse this entry. */
  282|      0|      r = unused;
  283|      0|      r->flags.used = 1;
  284|      0|      r->recno = recno;
  285|      0|      memcpy (r->data, data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|      0|#define TRUST_RECORD_LEN 40
  ------------------
  286|      0|      r->flags.dirty = 1;
  287|      0|      cache_is_dirty = 1;
  288|      0|      cache_entries++;
  289|      0|      return 0;
  290|      0|    }
  291|       |
  292|       |  /* See whether we reached the limit. */
  293|     30|  if (cache_entries < MAX_CACHE_ENTRIES_SOFT)
  ------------------
  |  |   72|     30|#define MAX_CACHE_ENTRIES_SOFT	200
  ------------------
  |  Branch (293:7): [True: 30, False: 0]
  ------------------
  294|     30|    {
  295|       |      /* No: Put into cache.  */
  296|     30|      r = xmalloc (sizeof *r);
  ------------------
  |  |  107|     30|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  297|     30|      r->flags.used = 1;
  298|     30|      r->recno = recno;
  299|     30|      memcpy (r->data, data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|     30|#define TRUST_RECORD_LEN 40
  ------------------
  300|     30|      r->flags.dirty = 1;
  301|     30|      r->next = cache_list;
  302|     30|      cache_list = r;
  303|     30|      cache_is_dirty = 1;
  304|     30|      cache_entries++;
  305|     30|      return 0;
  306|     30|    }
  307|       |
  308|       |  /* Cache is full: discard some clean entries.  */
  309|      0|  if (clean_count)
  ------------------
  |  Branch (309:7): [True: 0, False: 0]
  ------------------
  310|      0|    {
  311|      0|      int n;
  312|       |
  313|       |      /* We discard a third of the clean entries.  */
  314|      0|      n = clean_count / 3;
  315|      0|      if (!n)
  ------------------
  |  Branch (315:11): [True: 0, False: 0]
  ------------------
  316|      0|        n = 1;
  317|       |
  318|      0|      for (unused = NULL, r = cache_list; r; r = r->next)
  ------------------
  |  Branch (318:43): [True: 0, False: 0]
  ------------------
  319|      0|        {
  320|      0|          if (r->flags.used && !r->flags.dirty)
  ------------------
  |  Branch (320:15): [True: 0, False: 0]
  |  Branch (320:32): [True: 0, False: 0]
  ------------------
  321|      0|            {
  322|      0|              if (!unused)
  ------------------
  |  Branch (322:19): [True: 0, False: 0]
  ------------------
  323|      0|                unused = r;
  324|      0|              r->flags.used = 0;
  325|      0|              cache_entries--;
  326|      0|              if (!--n)
  ------------------
  |  Branch (326:19): [True: 0, False: 0]
  ------------------
  327|      0|                break;
  328|      0|	    }
  329|      0|	}
  330|       |
  331|       |      /* Now put into the cache.  */
  332|      0|      log_assert (unused);
  333|      0|      r = unused;
  334|      0|      r->flags.used = 1;
  335|      0|      r->recno = recno;
  336|      0|      memcpy (r->data, data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|      0|#define TRUST_RECORD_LEN 40
  ------------------
  337|      0|      r->flags.dirty = 1;
  338|      0|      cache_is_dirty = 1;
  339|      0|      cache_entries++;
  340|      0|      return 0;
  341|      0|    }
  342|       |
  343|       |  /* No clean entries: We have to flush some dirty entries.  */
  344|       |#if 0 /* Transactions are not yet used.  */
  345|       |  if (in_transaction)
  346|       |    {
  347|       |      /* But we can't do this while in a transaction.  Thus we
  348|       |       * increase the cache size instead.  */
  349|       |      if (cache_entries < MAX_CACHE_ENTRIES_HARD)
  350|       |        {
  351|       |          if (opt.debug && !(cache_entries % 100))
  352|       |            log_debug ("increasing tdbio cache size\n");
  353|       |          r = xmalloc (sizeof *r);
  354|       |          r->flags.used = 1;
  355|       |          r->recno = recno;
  356|       |          memcpy (r->data, data, TRUST_RECORD_LEN);
  357|       |          r->flags.dirty = 1;
  358|       |          r->next = cache_list;
  359|       |          cache_list = r;
  360|       |          cache_is_dirty = 1;
  361|       |          cache_entries++;
  362|       |          return 0;
  363|       |	}
  364|       |      /* Hard limit for the cache size reached.  */
  365|       |      log_info (_("trustdb transaction too large\n"));
  366|       |      return GPG_ERR_RESOURCE_LIMIT;
  367|       |    }
  368|       |#endif
  369|       |
  370|      0|  if (dirty_count)
  ------------------
  |  Branch (370:7): [True: 0, False: 0]
  ------------------
  371|      0|    {
  372|      0|      int n;
  373|       |
  374|       |      /* Discard some dirty entries. */
  375|      0|      n = dirty_count / 5;
  376|      0|      if (!n)
  ------------------
  |  Branch (376:11): [True: 0, False: 0]
  ------------------
  377|      0|        n = 1;
  378|       |
  379|      0|      take_write_lock ();
  380|      0|      for (unused = NULL, r = cache_list; r; r = r->next)
  ------------------
  |  Branch (380:43): [True: 0, False: 0]
  ------------------
  381|      0|        {
  382|      0|          if (r->flags.used && r->flags.dirty)
  ------------------
  |  Branch (382:15): [True: 0, False: 0]
  |  Branch (382:32): [True: 0, False: 0]
  ------------------
  383|      0|            {
  384|      0|              int rc;
  385|       |
  386|      0|              rc = write_cache_item (r);
  387|      0|              if (rc)
  ------------------
  |  Branch (387:19): [True: 0, False: 0]
  ------------------
  388|      0|                return rc;
  389|      0|              if (!unused)
  ------------------
  |  Branch (389:19): [True: 0, False: 0]
  ------------------
  390|      0|                unused = r;
  391|      0|              r->flags.used = 0;
  392|      0|              cache_entries--;
  393|      0|              if (!--n)
  ------------------
  |  Branch (393:19): [True: 0, False: 0]
  ------------------
  394|      0|                break;
  395|      0|	    }
  396|      0|	}
  397|      0|      release_write_lock ();
  398|       |
  399|       |      /* Now put into the cache.  */
  400|      0|      log_assert (unused);
  401|      0|      r = unused;
  402|      0|      r->flags.used = 1;
  403|      0|      r->recno = recno;
  404|      0|      memcpy (r->data, data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|      0|#define TRUST_RECORD_LEN 40
  ------------------
  405|      0|      r->flags.dirty = 1;
  406|      0|      cache_is_dirty = 1;
  407|      0|      cache_entries++;
  408|      0|      return 0;
  409|      0|    }
  410|       |
  411|       |  /* We should never reach this.  */
  412|      0|  BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  413|      0|}

check_trustdb_stale:
  302|      1|{
  303|      1|#ifndef NO_TRUST_MODELS
  304|      1|  tdb_check_trustdb_stale (ctrl);
  305|       |#else
  306|       |  (void)ctrl;
  307|       |#endif
  308|      1|}

setup_trustdb:
  537|      1|{
  538|       |    /* just store the args */
  539|      1|    if( trustdb_args.init )
  ------------------
  |  Branch (539:9): [True: 0, False: 1]
  ------------------
  540|      0|	return 0;
  541|      1|    trustdb_args.level = level;
  542|      1|    trustdb_args.dbname = dbname? xstrdup(dbname): NULL;
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  |  Branch (542:27): [True: 0, False: 1]
  ------------------
  543|      1|    return 0;
  544|      1|}
init_trustdb:
  573|      1|{
  574|      1|  int level = trustdb_args.level;
  575|      1|  const char* dbname = trustdb_args.dbname;
  576|       |
  577|      1|  if( trustdb_args.init )
  ------------------
  |  Branch (577:7): [True: 0, False: 1]
  ------------------
  578|      0|    return 0;
  579|       |
  580|      1|  trustdb_args.init = 1;
  581|       |
  582|      1|  if(level==0 || level==1)
  ------------------
  |  Branch (582:6): [True: 0, False: 1]
  |  Branch (582:18): [True: 1, False: 0]
  ------------------
  583|      1|    {
  584|      1|      int rc = tdbio_set_dbname (ctrl, dbname, (!no_create && level),
  ------------------
  |  Branch (584:49): [True: 1, False: 0]
  |  Branch (584:63): [True: 1, False: 0]
  ------------------
  585|      1|                                 &trustdb_args.no_trustdb);
  586|      1|      if (no_create && trustdb_args.no_trustdb)
  ------------------
  |  Branch (586:11): [True: 0, False: 1]
  |  Branch (586:24): [True: 0, False: 0]
  ------------------
  587|      0|        {
  588|       |          /* No trustdb found and the caller asked us not to create
  589|       |           * it.  Return an error and set the initialization state
  590|       |           * back so that we always test for an existing trustdb.  */
  591|      0|          trustdb_args.init = 0;
  592|      0|          return gpg_error (GPG_ERR_ENOENT);
  593|      0|        }
  594|      1|      if (rc)
  ------------------
  |  Branch (594:11): [True: 0, False: 1]
  ------------------
  595|      0|	log_fatal("can't init trustdb: %s\n", gpg_strerror (rc) );
  596|      1|    }
  597|      0|  else
  598|      0|    BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  599|       |
  600|      1|  if(opt.trust_model==TM_AUTO)
  ------------------
  |  Branch (600:6): [True: 0, False: 1]
  ------------------
  601|      0|    {
  602|       |      /* Try and set the trust model off of whatever the trustdb says
  603|       |	 it is. */
  604|      0|      opt.trust_model=tdbio_read_model();
  605|       |
  606|       |      /* Sanity check this ;) */
  607|      0|      if(opt.trust_model != TM_CLASSIC
  ------------------
  |  Branch (607:10): [True: 0, False: 0]
  ------------------
  608|      0|	 && opt.trust_model != TM_PGP
  ------------------
  |  Branch (608:6): [True: 0, False: 0]
  ------------------
  609|      0|	 && opt.trust_model != TM_TOFU_PGP
  ------------------
  |  Branch (609:6): [True: 0, False: 0]
  ------------------
  610|      0|	 && opt.trust_model != TM_TOFU
  ------------------
  |  Branch (610:6): [True: 0, False: 0]
  ------------------
  611|      0|	 && opt.trust_model != TM_EXTERNAL)
  ------------------
  |  Branch (611:6): [True: 0, False: 0]
  ------------------
  612|      0|	{
  613|      0|	  log_info(_("unable to use unknown trust model (%d) - "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  614|      0|		     "assuming %s trust model\n"),opt.trust_model,"pgp");
  615|      0|	  opt.trust_model = TM_PGP;
  616|      0|	}
  617|       |
  618|      0|      if(opt.verbose)
  ------------------
  |  Branch (618:10): [True: 0, False: 0]
  ------------------
  619|      0|	log_info(_("using %s trust model\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  620|      0|                 trust_model_string (opt.trust_model));
  621|      0|    }
  622|       |
  623|      1|  if (opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC
  ------------------
  |  Branch (623:7): [True: 0, False: 1]
  |  Branch (623:34): [True: 1, False: 0]
  ------------------
  624|      1|      || opt.trust_model == TM_TOFU || opt.trust_model == TM_TOFU_PGP)
  ------------------
  |  Branch (624:10): [True: 0, False: 0]
  |  Branch (624:40): [True: 0, False: 0]
  ------------------
  625|      1|    {
  626|       |      /* Verify the list of ultimately trusted keys and move the
  627|       |	 --trusted-keys list there as well. */
  628|      1|      if(level==1)
  ------------------
  |  Branch (628:10): [True: 1, False: 0]
  ------------------
  629|      1|	verify_own_keys (ctrl);
  630|       |
  631|      1|      if(!tdbio_db_matches_options())
  ------------------
  |  Branch (631:10): [True: 0, False: 1]
  ------------------
  632|      0|	pending_check_trustdb=1;
  633|      1|    }
  634|       |
  635|      1|  return 0;
  636|      1|}
tdb_check_trustdb_stale:
 1132|      1|{
 1133|      1|  static int did_nextcheck=0;
 1134|       |
 1135|      1|  init_trustdb (ctrl, 0);
 1136|       |
 1137|      1|  if (trustdb_args.no_trustdb)
  ------------------
  |  Branch (1137:7): [True: 0, False: 1]
  ------------------
 1138|      0|    return;  /* No trustdb => can't be stale.  */
 1139|       |
 1140|      1|  if (!did_nextcheck
  ------------------
  |  Branch (1140:7): [True: 1, False: 0]
  ------------------
 1141|      1|      && (opt.trust_model == TM_PGP || opt.trust_model == TM_CLASSIC
  ------------------
  |  Branch (1141:11): [True: 0, False: 1]
  |  Branch (1141:40): [True: 1, False: 0]
  ------------------
 1142|      1|          || opt.trust_model == TM_TOFU_PGP || opt.trust_model == TM_TOFU))
  ------------------
  |  Branch (1142:14): [True: 0, False: 0]
  |  Branch (1142:48): [True: 0, False: 0]
  ------------------
 1143|      1|    {
 1144|      1|      ulong scheduled;
 1145|       |
 1146|      1|      did_nextcheck = 1;
 1147|      1|      scheduled = tdbio_read_nextcheck ();
 1148|      1|      if ((scheduled && scheduled <= make_timestamp ())
  ------------------
  |  Branch (1148:12): [True: 0, False: 1]
  |  Branch (1148:25): [True: 0, False: 0]
  ------------------
 1149|      1|	  || pending_check_trustdb)
  ------------------
  |  Branch (1149:7): [True: 0, False: 1]
  ------------------
 1150|      0|        {
 1151|      0|          if (opt.no_auto_check_trustdb)
  ------------------
  |  Branch (1151:15): [True: 0, False: 0]
  ------------------
 1152|      0|            {
 1153|      0|              pending_check_trustdb = 1;
 1154|      0|              if (!opt.quiet)
  ------------------
  |  Branch (1154:19): [True: 0, False: 0]
  ------------------
 1155|      0|                log_info (_("please do a --check-trustdb\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1156|      0|            }
 1157|      0|          else
 1158|      0|            {
 1159|      0|              if (!opt.quiet)
  ------------------
  |  Branch (1159:19): [True: 0, False: 0]
  ------------------
 1160|      0|                log_info (_("checking the trustdb\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1161|      0|              validate_keys (ctrl, 0);
 1162|      0|            }
 1163|      0|        }
 1164|      1|    }
 1165|      1|}
trustdb.c:verify_own_keys:
  359|      1|{
  360|      1|  TRUSTREC rec;
  361|      1|  ulong recnum;
  362|      1|  int rc;
  363|      1|  struct key_item *k, *k2;
  364|      1|  int need_revalidation = 0;
  365|       |
  366|      1|  if (utk_list)
  ------------------
  |  Branch (366:7): [True: 0, False: 1]
  ------------------
  367|      0|    return; /* Has already been run.  */
  368|       |
  369|       |  /* scan the trustdb to find all ultimately trusted keys */
  370|     30|  for (recnum=1; !tdbio_read_record (recnum, &rec, 0); recnum++ )
  ------------------
  |  Branch (370:18): [True: 29, False: 1]
  ------------------
  371|     29|    {
  372|     29|      if (rec.rectype == RECTYPE_TRUST
  ------------------
  |  |   39|     58|#define RECTYPE_TRUST 12
  ------------------
  |  Branch (372:11): [True: 0, False: 29]
  ------------------
  373|     29|          && (rec.r.trust.ownertrust & TRUST_MASK) == TRUST_ULTIMATE)
  ------------------
  |  |   25|      0|#define TRUST_MASK	 15
  ------------------
                        && (rec.r.trust.ownertrust & TRUST_MASK) == TRUST_ULTIMATE)
  ------------------
  |  |   32|      0|#define TRUST_ULTIMATE	  6  /* u: ultimately trusted */
  ------------------
  |  Branch (373:14): [True: 0, False: 0]
  ------------------
  374|      0|        {
  375|      0|          u32 kid[2];
  376|       |
  377|      0|          keyid_from_fpr20 (ctrl, rec.r.trust.fingerprint, kid);
  378|      0|          if (!add_utk (kid))
  ------------------
  |  Branch (378:15): [True: 0, False: 0]
  ------------------
  379|      0|            log_info (_("key %s occurs more than once in the trustdb\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  380|      0|                      keystr(kid));
  381|      0|          else if ((rec.r.trust.flags & 1))
  ------------------
  |  Branch (381:20): [True: 0, False: 0]
  ------------------
  382|      0|            {
  383|       |              /* Record marked as inserted via --trusted-key.  Is this
  384|       |               * still the case?  */
  385|      0|              for (k2 = user_utk_list; k2; k2 = k2->next)
  ------------------
  |  Branch (385:40): [True: 0, False: 0]
  ------------------
  386|      0|                if (k2->kid[0] == kid[0] && k2->kid[1] == kid[1])
  ------------------
  |  Branch (386:21): [True: 0, False: 0]
  |  Branch (386:45): [True: 0, False: 0]
  ------------------
  387|      0|                  break;
  388|      0|              if (!k2) /* No - clear the flag.  */
  ------------------
  |  Branch (388:19): [True: 0, False: 0]
  ------------------
  389|      0|                {
  390|      0|                  if (DBG_TRUST)
  ------------------
  |  |  353|      0|#define DBG_TRUST  (opt.debug & DBG_TRUST_VALUE)
  |  |  ------------------
  |  |  |  |  340|      0|#define DBG_TRUST_VALUE   256	/* debug the trustdb */
  |  |  ------------------
  |  |  |  Branch (353:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  391|      0|                    log_debug ("clearing former --trusted-key %s\n",
  392|      0|                               keystr (kid));
  393|      0|                  rec.r.trust.ownertrust = TRUST_UNKNOWN;
  ------------------
  |  |   26|      0|#define TRUST_UNKNOWN	  0  /* o: not yet calculated/assigned */
  ------------------
  394|      0|                  rec.r.trust.flags &= ~(rec.r.trust.flags & 1);
  395|      0|                  write_record (ctrl, &rec);
  396|      0|                  need_revalidation = 1;
  397|      0|                }
  398|      0|            }
  399|      0|        }
  400|     29|    }
  401|       |
  402|      1|  if (need_revalidation)
  ------------------
  |  Branch (402:7): [True: 0, False: 1]
  ------------------
  403|      0|    {
  404|      0|      tdb_revalidation_mark (ctrl);
  405|      0|      do_sync ();
  406|      0|    }
  407|       |
  408|       |  /* Put any --trusted-key keys into the trustdb */
  409|      1|  for (k = user_utk_list; k; k = k->next)
  ------------------
  |  Branch (409:27): [True: 0, False: 1]
  ------------------
  410|      0|    {
  411|      0|      if ( add_utk (k->kid) )
  ------------------
  |  Branch (411:12): [True: 0, False: 0]
  ------------------
  412|      0|        { /* not yet in trustDB as ultimately trusted */
  413|      0|          PKT_public_key pk;
  414|       |
  415|      0|          memset (&pk, 0, sizeof pk);
  416|      0|          rc = get_pubkey_with_ldap_fallback (ctrl, &pk, k->kid);
  417|      0|          if (rc)
  ------------------
  |  Branch (417:15): [True: 0, False: 0]
  ------------------
  418|      0|	    log_info(_("key %s: no public key for trusted key - skipped\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  419|      0|		     keystr(k->kid));
  420|      0|          else
  421|      0|	    {
  422|      0|	      tdb_update_ownertrust
  423|      0|                (ctrl, &pk, ((tdb_get_ownertrust (ctrl, &pk, 0) & ~TRUST_MASK)
  ------------------
  |  |   25|      0|#define TRUST_MASK	 15
  ------------------
  424|      0|                             | TRUST_ULTIMATE ),  1);
  ------------------
  |  |   32|      0|#define TRUST_ULTIMATE	  6  /* u: ultimately trusted */
  ------------------
  425|      0|	      release_public_key_parts (&pk);
  426|      0|	    }
  427|       |
  428|      0|          if (!opt.quiet)
  ------------------
  |  Branch (428:15): [True: 0, False: 0]
  ------------------
  429|      0|            log_info (_("key %s marked as ultimately trusted\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  430|      0|                      keystr(k->kid));
  431|      0|        }
  432|      0|    }
  433|       |
  434|       |  /* release the helper table table */
  435|      1|  release_key_items (user_utk_list);
  436|      1|  user_utk_list = NULL;
  437|      1|  return;
  438|      1|}
trustdb.c:release_key_items:
  137|      1|{
  138|      1|  struct key_item *k2;
  139|       |
  140|      1|  for (; k; k = k2)
  ------------------
  |  Branch (140:10): [True: 0, False: 1]
  ------------------
  141|      0|    {
  142|      0|      k2 = k->next;
  143|      0|      xfree (k->trust_regexp);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  144|      0|      xfree (k);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  145|      0|    }
  146|      1|}

keybox-update.c:buf32_to_u32:
  105|      1|{
  106|      1|  const unsigned char *p = buffer;
  107|       |
  108|      1|  return (((u32)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
  109|      1|}

_keybox_new_blob:
 1050|  58.9k|{
 1051|  58.9k|  KEYBOXBLOB blob;
 1052|       |
 1053|  58.9k|  *r_blob = NULL;
 1054|  58.9k|  blob = xtrycalloc (1, sizeof *blob);
  ------------------
  |  |   99|  58.9k|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
 1055|  58.9k|  if (!blob)
  ------------------
  |  Branch (1055:7): [True: 0, False: 58.9k]
  ------------------
 1056|      0|    return gpg_error_from_syserror ();
 1057|       |
 1058|  58.9k|  blob->blob = image;
 1059|  58.9k|  blob->bloblen = imagelen;
 1060|  58.9k|  blob->fileoffset = off;
 1061|  58.9k|  *r_blob = blob;
 1062|  58.9k|  return 0;
 1063|  58.9k|}
_keybox_release_blob:
 1068|   294k|{
 1069|   294k|  int i;
 1070|   294k|  if (!blob)
  ------------------
  |  Branch (1070:7): [True: 235k, False: 58.9k]
  ------------------
 1071|   235k|    return;
 1072|  58.9k|  if (blob->buf)
  ------------------
  |  Branch (1072:7): [True: 0, False: 58.9k]
  ------------------
 1073|      0|    {
 1074|      0|      size_t len;
 1075|      0|      xfree (get_membuf (blob->buf, &len));
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1076|      0|    }
 1077|  58.9k|  xfree (blob->keys );
  ------------------
  |  |  104|  58.9k|#define xfree(a)         gcry_free ((a))
  ------------------
 1078|  58.9k|  xfree (blob->serialbuf);
  ------------------
  |  |  104|  58.9k|#define xfree(a)         gcry_free ((a))
  ------------------
 1079|  58.9k|  for (i=0; i < blob->nuids; i++)
  ------------------
  |  Branch (1079:13): [True: 0, False: 58.9k]
  ------------------
 1080|      0|    xfree (blob->uids[i].name);
  ------------------
  |  |  104|  58.9k|#define xfree(a)         gcry_free ((a))
  ------------------
 1081|  58.9k|  xfree (blob->uids );
  ------------------
  |  |  104|  58.9k|#define xfree(a)         gcry_free ((a))
  ------------------
 1082|  58.9k|  xfree (blob->sigs );
  ------------------
  |  |  104|  58.9k|#define xfree(a)         gcry_free ((a))
  ------------------
 1083|  58.9k|  xfree (blob->blob );
  ------------------
  |  |  104|  58.9k|#define xfree(a)         gcry_free ((a))
  ------------------
 1084|  58.9k|  xfree (blob );
  ------------------
  |  |  104|  58.9k|#define xfree(a)         gcry_free ((a))
  ------------------
 1085|  58.9k|}
_keybox_get_blob_image:
 1091|  58.9k|{
 1092|  58.9k|  *n = blob->bloblen;
 1093|  58.9k|  return blob->blob;
 1094|  58.9k|}

keybox-search.c:blob_get_type:
  182|  58.9k|{
  183|  58.9k|  const unsigned char *buffer;
  184|  58.9k|  size_t length;
  185|       |
  186|  58.9k|  buffer = _keybox_get_blob_image (blob, &length);
  187|  58.9k|  if (length < 32)
  ------------------
  |  Branch (187:7): [True: 0, False: 58.9k]
  ------------------
  188|      0|    return -1; /* blob too short */
  189|       |
  190|  58.9k|  return buffer[4];
  191|  58.9k|}

_keybox_read_blob:
   52|   117k|{
   53|   117k|  unsigned char *image;
   54|   117k|  size_t imagelen = 0;
   55|   117k|  int c1, c2, c3, c4, type;
   56|   117k|  int rc;
   57|   117k|  off_t off;
   58|       |
   59|   117k|  if (skipped_deleted)
  ------------------
  |  Branch (59:7): [True: 0, False: 117k]
  ------------------
   60|      0|    *skipped_deleted = 0;
   61|   117k| again:
   62|   117k|  if (r_blob)
  ------------------
  |  Branch (62:7): [True: 117k, False: 0]
  ------------------
   63|   117k|    *r_blob = NULL;
   64|   117k|  off = es_ftello (fp);
   65|   117k|  if (off == (off_t)-1)
  ------------------
  |  Branch (65:7): [True: 0, False: 117k]
  ------------------
   66|      0|    return gpg_error_from_syserror ();
   67|       |
   68|   117k|  if ((c1 = es_getc (fp)) == EOF
  ------------------
  |  Branch (68:7): [True: 58.9k, False: 58.9k]
  ------------------
   69|   117k|      || (c2 = es_getc (fp)) == EOF
  ------------------
  |  Branch (69:10): [True: 0, False: 58.9k]
  ------------------
   70|   117k|      || (c3 = es_getc (fp)) == EOF
  ------------------
  |  Branch (70:10): [True: 0, False: 58.9k]
  ------------------
   71|   117k|      || (c4 = es_getc (fp)) == EOF
  ------------------
  |  Branch (71:10): [True: 0, False: 58.9k]
  ------------------
   72|   117k|      || (type = es_getc (fp)) == EOF)
  ------------------
  |  Branch (72:10): [True: 0, False: 58.9k]
  ------------------
   73|  58.9k|    {
   74|  58.9k|      if ( c1 == EOF && !es_ferror (fp) )
  ------------------
  |  Branch (74:12): [True: 58.9k, False: 0]
  |  Branch (74:25): [True: 58.9k, False: 0]
  ------------------
   75|  58.9k|        return -1; /* eof */
   76|      0|      if (!es_ferror (fp))
  ------------------
  |  Branch (76:11): [True: 0, False: 0]
  ------------------
   77|      0|        return gpg_error (GPG_ERR_TOO_SHORT);
   78|      0|      return gpg_error_from_syserror ();
   79|      0|    }
   80|       |
   81|  58.9k|  imagelen = ((unsigned int) c1 << 24) | (c2 << 16) | (c3 << 8 ) | c4;
   82|  58.9k|  if (imagelen < 5)
  ------------------
  |  Branch (82:7): [True: 0, False: 58.9k]
  ------------------
   83|      0|    return gpg_error (GPG_ERR_TOO_SHORT);
   84|       |
   85|  58.9k|  if (!type)
  ------------------
  |  Branch (85:7): [True: 0, False: 58.9k]
  ------------------
   86|      0|    {
   87|       |      /* Special treatment for empty blobs. */
   88|      0|      if (es_fseek (fp, imagelen-5, SEEK_CUR))
  ------------------
  |  Branch (88:11): [True: 0, False: 0]
  ------------------
   89|      0|        return gpg_error_from_syserror ();
   90|      0|      if (skipped_deleted)
  ------------------
  |  Branch (90:11): [True: 0, False: 0]
  ------------------
   91|      0|        *skipped_deleted = 1;
   92|      0|      goto again;
   93|      0|    }
   94|       |
   95|  58.9k|  if (imagelen > IMAGELEN_LIMIT) /* Sanity check. */
  ------------------
  |  |   30|  58.9k|#define IMAGELEN_LIMIT (5*1024*1024)
  ------------------
  |  Branch (95:7): [True: 0, False: 58.9k]
  ------------------
   96|      0|    {
   97|       |      /* Seek forward so that the caller may choose to ignore this
   98|       |         record.  */
   99|      0|      if (es_fseek (fp, imagelen-5, SEEK_CUR))
  ------------------
  |  Branch (99:11): [True: 0, False: 0]
  ------------------
  100|      0|        return gpg_error_from_syserror ();
  101|      0|      return gpg_error (GPG_ERR_TOO_LARGE);
  102|      0|    }
  103|       |
  104|  58.9k|  if (!r_blob)
  ------------------
  |  Branch (104:7): [True: 0, False: 58.9k]
  ------------------
  105|      0|    {
  106|       |      /* This blob shall be skipped.  */
  107|      0|      if (es_fseek (fp, imagelen-5, SEEK_CUR))
  ------------------
  |  Branch (107:11): [True: 0, False: 0]
  ------------------
  108|      0|        return gpg_error_from_syserror ();
  109|      0|      return 0;
  110|      0|    }
  111|       |
  112|  58.9k|  image = xtrymalloc (imagelen);
  ------------------
  |  |   97|  58.9k|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  113|  58.9k|  if (!image)
  ------------------
  |  Branch (113:7): [True: 0, False: 58.9k]
  ------------------
  114|      0|    return gpg_error_from_syserror ();
  115|       |
  116|  58.9k|  image[0] = c1; image[1] = c2; image[2] = c3; image[3] = c4; image[4] = type;
  117|  58.9k|  if (es_fread (image+5, imagelen-5, 1, fp) != 1)
  ------------------
  |  Branch (117:7): [True: 0, False: 58.9k]
  ------------------
  118|      0|    {
  119|      0|      gpg_error_t tmperr = gpg_error_from_syserror ();
  120|      0|      xfree (image);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  121|      0|      return tmperr;
  122|      0|    }
  123|       |
  124|  58.9k|  rc = _keybox_new_blob (r_blob, image, imagelen, off);
  125|  58.9k|  if (rc)
  ------------------
  |  Branch (125:7): [True: 0, False: 58.9k]
  ------------------
  126|      0|    xfree (image);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  127|  58.9k|  return rc;
  128|  58.9k|}
_keybox_write_header_blob:
  161|      1|{
  162|      1|  unsigned char image[32];
  163|      1|  u32 val;
  164|       |
  165|      1|  memset (image, 0, sizeof image);
  166|       |  /* Length of this blob. */
  167|      1|  image[3] = 32;
  168|       |
  169|      1|  image[4] = KEYBOX_BLOBTYPE_HEADER;
  170|      1|  image[5] = 1; /* Version */
  171|      1|  if (for_openpgp)
  ------------------
  |  Branch (171:7): [True: 1, False: 0]
  ------------------
  172|      1|    image[7] = 0x02; /* OpenPGP data may be available.  */
  173|       |
  174|      1|  memcpy (image+8, "KBXf", 4);
  175|      1|  val = time (NULL);
  176|       |  /* created_at and last maintenance run. */
  177|      1|  image[16]   = (val >> 24);
  178|      1|  image[16+1] = (val >> 16);
  179|      1|  image[16+2] = (val >>  8);
  180|      1|  image[16+3] = (val      );
  181|      1|  image[20]   = (val >> 24);
  182|      1|  image[20+1] = (val >> 16);
  183|      1|  image[20+2] = (val >>  8);
  184|      1|  image[20+3] = (val      );
  185|       |
  186|      1|  if (es_fwrite (image, 32, 1, fp) != 1)
  ------------------
  |  Branch (186:7): [True: 0, False: 1]
  ------------------
  187|      0|    return gpg_error_from_syserror ();
  188|       |
  189|      1|  return 0;
  190|      1|}

keybox_register_file:
   41|      1|{
   42|      1|  KB_NAME kr;
   43|       |
   44|      1|  *r_token = NULL;
   45|       |
   46|      1|  for (kr=kb_names; kr; kr = kr->next)
  ------------------
  |  Branch (46:21): [True: 0, False: 1]
  ------------------
   47|      0|    {
   48|      0|      if (same_file_p (kr->fname, fname) )
  ------------------
  |  Branch (48:11): [True: 0, False: 0]
  ------------------
   49|      0|        {
   50|      0|          *r_token = kr;
   51|      0|          return gpg_error (GPG_ERR_EEXIST); /* Already registered. */
   52|      0|        }
   53|      0|    }
   54|       |
   55|      1|  kr = xtrymalloc (sizeof *kr + strlen (fname));
  ------------------
  |  |   97|      1|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
   56|      1|  if (!kr)
  ------------------
  |  Branch (56:7): [True: 0, False: 1]
  ------------------
   57|      0|    return gpg_error_from_syserror ();
   58|      1|  strcpy (kr->fname, fname);
   59|      1|  kr->secret = !!secret;
   60|       |
   61|      1|  kr->handle_table = NULL;
   62|      1|  kr->handle_table_size = 0;
   63|       |
   64|      1|  kr->lockhd = NULL;
   65|      1|  kr->is_locked = 0;
   66|      1|  kr->did_full_scan = 0;
   67|       |  /* keep a list of all issued pointers */
   68|      1|  kr->next = kb_names;
   69|      1|  kb_names = kr;
   70|       |
   71|       |  /* create the offset table the first time a function here is used */
   72|       |/*      if (!kb_offtbl) */
   73|       |/*        kb_offtbl = new_offset_hash_table (); */
   74|       |
   75|      1|  *r_token = kr;
   76|      1|  return 0;
   77|      1|}
keybox_is_writable:
   81|      2|{
   82|      2|  KB_NAME r = token;
   83|       |
   84|      2|  return r? !gnupg_access (r->fname, W_OK) : 0;
  ------------------
  |  Branch (84:10): [True: 2, False: 0]
  ------------------
   85|      2|}
keybox_new_openpgp:
  149|  58.8k|{
  150|  58.8k|  KB_NAME resource = token;
  151|       |
  152|  58.8k|  return do_keybox_new (resource, secret, 1);
  153|  58.8k|}
keybox_release:
  169|  58.8k|{
  170|  58.8k|  if (!hd)
  ------------------
  |  Branch (170:7): [True: 0, False: 58.8k]
  ------------------
  171|      0|    return;
  172|  58.8k|  if (hd->kb->handle_table)
  ------------------
  |  Branch (172:7): [True: 58.8k, False: 0]
  ------------------
  173|  58.8k|    {
  174|  58.8k|      int idx;
  175|   235k|      for (idx=0; idx < hd->kb->handle_table_size; idx++)
  ------------------
  |  Branch (175:19): [True: 176k, False: 58.8k]
  ------------------
  176|   176k|        if (hd->kb->handle_table[idx] == hd)
  ------------------
  |  Branch (176:13): [True: 58.8k, False: 117k]
  ------------------
  177|  58.8k|          hd->kb->handle_table[idx] = NULL;
  178|  58.8k|    }
  179|  58.8k|  _keybox_release_blob (hd->found.blob);
  180|  58.8k|  _keybox_release_blob (hd->saved_found.blob);
  181|  58.8k|  if (hd->fp)
  ------------------
  |  Branch (181:7): [True: 58.7k, False: 57]
  ------------------
  182|  58.7k|    {
  183|  58.7k|      es_fclose (hd->fp);
  184|  58.7k|      hd->fp = NULL;
  185|  58.7k|    }
  186|  58.8k|  xfree (hd->word_match.name);
  ------------------
  |  |  104|  58.8k|#define xfree(a)         gcry_free ((a))
  ------------------
  187|  58.8k|  xfree (hd->word_match.pattern);
  ------------------
  |  |  104|  58.8k|#define xfree(a)         gcry_free ((a))
  ------------------
  188|  58.8k|  xfree (hd);
  ------------------
  |  |  104|  58.8k|#define xfree(a)         gcry_free ((a))
  ------------------
  189|  58.8k|}
_keybox_close_file:
  244|      1|{
  245|      1|  int idx;
  246|      1|  KEYBOX_HANDLE roverhd;
  247|       |
  248|      1|  if (!hd || !hd->kb || !hd->kb->handle_table)
  ------------------
  |  Branch (248:7): [True: 0, False: 1]
  |  Branch (248:14): [True: 0, False: 1]
  |  Branch (248:25): [True: 0, False: 1]
  ------------------
  249|      0|    return;
  250|       |
  251|      4|  for (idx=0; idx < hd->kb->handle_table_size; idx++)
  ------------------
  |  Branch (251:15): [True: 3, False: 1]
  ------------------
  252|      3|    if ((roverhd = hd->kb->handle_table[idx]))
  ------------------
  |  Branch (252:9): [True: 1, False: 2]
  ------------------
  253|      1|      {
  254|      1|        if (roverhd->fp)
  ------------------
  |  Branch (254:13): [True: 0, False: 1]
  ------------------
  255|      0|          {
  256|      0|            es_fclose (roverhd->fp);
  257|      0|            roverhd->fp = NULL;
  258|      0|          }
  259|      1|      }
  260|      1|  log_assert (!hd->fp);
  261|      1|}
keybox_lock:
  271|      2|{
  272|      2|  gpg_error_t err = 0;
  273|      2|  KB_NAME kb = hd->kb;
  274|       |
  275|      2|  if (!keybox_is_writable (kb))
  ------------------
  |  Branch (275:7): [True: 0, False: 2]
  ------------------
  276|      0|    return 0;
  277|       |
  278|       |  /* Make sure the lock handle has been created.  */
  279|      2|  if (!kb->lockhd)
  ------------------
  |  Branch (279:7): [True: 1, False: 1]
  ------------------
  280|      1|    {
  281|      1|      kb->lockhd = dotlock_create (kb->fname, 0);
  282|      1|      if (!kb->lockhd)
  ------------------
  |  Branch (282:11): [True: 0, False: 1]
  ------------------
  283|      0|        {
  284|      0|          err = gpg_error_from_syserror ();
  285|      0|          log_info ("can't allocate lock for '%s'\n", kb->fname );
  286|      0|          return err;
  287|      0|        }
  288|      1|    }
  289|       |
  290|      2|  if (yes) /* Take the lock.  */
  ------------------
  |  Branch (290:7): [True: 1, False: 1]
  ------------------
  291|      1|    {
  292|      1|      if (!kb->is_locked)
  ------------------
  |  Branch (292:11): [True: 1, False: 0]
  ------------------
  293|      1|        {
  294|       |#ifdef HAVE_W32_SYSTEM
  295|       |          /* Under Windows we need to close the file before we try
  296|       |           * to lock it.  This is because another process might have
  297|       |           * taken the lock and is using keybox_file_rename to
  298|       |           * rename the base file.  Now if our dotlock_take below is
  299|       |           * waiting for the lock but we have the base file still
  300|       |           * open, keybox_file_rename will never succeed as we are
  301|       |           * in a deadlock.  */
  302|       |          _keybox_close_file (hd);
  303|       |#endif /*HAVE_W32_SYSTEM*/
  304|      1|          if (dotlock_take (kb->lockhd, timeout))
  ------------------
  |  Branch (304:15): [True: 0, False: 1]
  ------------------
  305|      0|            {
  306|      0|              err = gpg_error_from_syserror ();
  307|      0|              if (!timeout && gpg_err_code (err) == GPG_ERR_EACCES)
  ------------------
  |  Branch (307:19): [True: 0, False: 0]
  |  Branch (307:31): [True: 0, False: 0]
  ------------------
  308|      0|                ; /* No diagnostic if we only tried to lock.  */
  309|      0|              else
  310|      0|                log_info ("can't lock '%s'\n", kb->fname );
  311|      0|            }
  312|      1|          else
  313|      1|            kb->is_locked = 1;
  314|      1|        }
  315|      1|    }
  316|      1|  else /* Release the lock.  */
  317|      1|    {
  318|      1|      if (kb->is_locked)
  ------------------
  |  Branch (318:11): [True: 1, False: 0]
  ------------------
  319|      1|        {
  320|      1|          if (dotlock_release (kb->lockhd))
  ------------------
  |  Branch (320:15): [True: 0, False: 1]
  ------------------
  321|      0|            {
  322|      0|              err = gpg_error_from_syserror ();
  323|      0|              log_info ("can't unlock '%s'\n", kb->fname );
  324|      0|            }
  325|      1|          else
  326|      1|            kb->is_locked = 0;
  327|      1|        }
  328|      1|   }
  329|       |
  330|      2|  return err;
  331|      2|}
keybox-init.c:do_keybox_new:
   91|  58.8k|{
   92|  58.8k|  KEYBOX_HANDLE hd;
   93|  58.8k|  int idx;
   94|       |
   95|  58.8k|  assert (resource && !resource->secret == !secret);
   96|  58.8k|  hd = xtrycalloc (1, sizeof *hd);
  ------------------
  |  |   99|  58.8k|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
   97|  58.8k|  if (hd)
  ------------------
  |  Branch (97:7): [True: 58.8k, False: 0]
  ------------------
   98|  58.8k|    {
   99|  58.8k|      hd->kb = resource;
  100|  58.8k|      hd->secret = !!secret;
  101|  58.8k|      hd->for_openpgp = for_openpgp;
  102|  58.8k|      if (!resource->handle_table)
  ------------------
  |  Branch (102:11): [True: 1, False: 58.8k]
  ------------------
  103|      1|        {
  104|      1|          resource->handle_table_size = 3;
  105|      1|          resource->handle_table = xtrycalloc (resource->handle_table_size,
  ------------------
  |  |   99|      1|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  106|      1|                                               sizeof *resource->handle_table);
  107|      1|          if (!resource->handle_table)
  ------------------
  |  Branch (107:15): [True: 0, False: 1]
  ------------------
  108|      0|            {
  109|      0|              resource->handle_table_size = 0;
  110|      0|              xfree (hd);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  111|      0|              return NULL;
  112|      0|            }
  113|      1|        }
  114|   117k|      for (idx=0; idx < resource->handle_table_size; idx++)
  ------------------
  |  Branch (114:19): [True: 117k, False: 0]
  ------------------
  115|   117k|        if (!resource->handle_table[idx])
  ------------------
  |  Branch (115:13): [True: 58.8k, False: 58.5k]
  ------------------
  116|  58.8k|          {
  117|  58.8k|            resource->handle_table[idx] = hd;
  118|  58.8k|            break;
  119|  58.8k|          }
  120|  58.8k|      if (!(idx < resource->handle_table_size))
  ------------------
  |  Branch (120:11): [True: 0, False: 58.8k]
  ------------------
  121|      0|        {
  122|      0|          KEYBOX_HANDLE *tmptbl;
  123|      0|          size_t newsize;
  124|       |
  125|      0|          newsize = resource->handle_table_size + 5;
  126|      0|          tmptbl = xtryrealloc (resource->handle_table,
  ------------------
  |  |  101|      0|#define xtryrealloc(a,b) gcry_realloc ((a),(b))
  ------------------
  127|      0|                                newsize * sizeof (*tmptbl));
  128|      0|          if (!tmptbl)
  ------------------
  |  Branch (128:15): [True: 0, False: 0]
  ------------------
  129|      0|            {
  130|      0|              xfree (hd);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  131|      0|              return NULL;
  132|      0|            }
  133|      0|          resource->handle_table = tmptbl;
  134|      0|          resource->handle_table_size = newsize;
  135|      0|          resource->handle_table[idx] = hd;
  136|      0|          for (idx++; idx < resource->handle_table_size; idx++)
  ------------------
  |  Branch (136:23): [True: 0, False: 0]
  ------------------
  137|      0|            resource->handle_table[idx] = NULL;
  138|      0|        }
  139|  58.8k|    }
  140|  58.8k|  return hd;
  141|  58.8k|}

keybox_search_reset:
  901|  6.98M|{
  902|  6.98M|  if (!hd)
  ------------------
  |  Branch (902:7): [True: 0, False: 6.98M]
  ------------------
  903|      0|    return gpg_error (GPG_ERR_INV_VALUE);
  904|       |
  905|  6.98M|  if (hd->found.blob)
  ------------------
  |  Branch (905:7): [True: 0, False: 6.98M]
  ------------------
  906|      0|    {
  907|      0|      _keybox_release_blob (hd->found.blob);
  908|      0|      hd->found.blob = NULL;
  909|      0|    }
  910|       |
  911|  6.98M|  if (hd->fp)
  ------------------
  |  Branch (911:7): [True: 6.86M, False: 118k]
  ------------------
  912|  6.86M|    {
  913|  6.86M|      if (es_fseeko (hd->fp, 0, SEEK_SET))
  ------------------
  |  Branch (913:11): [True: 0, False: 6.86M]
  ------------------
  914|      0|        {
  915|       |          /* Ooops.  Seek did not work.  Close so that the search will
  916|       |           * open the file again.  */
  917|      0|          es_fclose (hd->fp);
  918|      0|          hd->fp = NULL;
  919|      0|        }
  920|  6.86M|    }
  921|  6.98M|  hd->error = 0;
  922|  6.98M|  hd->eof = 0;
  923|  6.98M|  return 0;
  924|  6.98M|}
keybox_search:
  936|  58.9k|{
  937|  58.9k|  gpg_error_t rc;
  938|  58.9k|  size_t n;
  939|  58.9k|  int need_words, any_skip;
  940|  58.9k|  KEYBOXBLOB blob = NULL;
  941|  58.9k|  struct sn_array_s *sn_array = NULL;
  942|  58.9k|  int pk_no, uid_no;
  943|  58.9k|  off_t lastfoundoff;
  944|       |
  945|  58.9k|  if (!hd)
  ------------------
  |  Branch (945:7): [True: 0, False: 58.9k]
  ------------------
  946|      0|    return gpg_error (GPG_ERR_INV_VALUE);
  947|       |
  948|       |  /* Clear last found result but record the offset of the last found
  949|       |   * blob which we may need later. */
  950|  58.9k|  if (hd->found.blob)
  ------------------
  |  Branch (950:7): [True: 0, False: 58.9k]
  ------------------
  951|      0|    {
  952|      0|      lastfoundoff = _keybox_get_blob_fileoffset (hd->found.blob);
  953|      0|      _keybox_release_blob (hd->found.blob);
  954|      0|      hd->found.blob = NULL;
  955|      0|    }
  956|  58.9k|  else
  957|  58.9k|    lastfoundoff = 0;
  958|       |
  959|  58.9k|  if (hd->error)
  ------------------
  |  Branch (959:7): [True: 0, False: 58.9k]
  ------------------
  960|      0|    return hd->error; /* still in error state */
  961|  58.9k|  if (hd->eof)
  ------------------
  |  Branch (961:7): [True: 0, False: 58.9k]
  ------------------
  962|      0|    return -1; /* still EOF */
  963|       |
  964|       |  /* figure out what information we need */
  965|  58.9k|  need_words = any_skip = 0;
  966|   117k|  for (n=0; n < ndesc; n++)
  ------------------
  |  Branch (966:13): [True: 58.9k, False: 58.9k]
  ------------------
  967|  58.9k|    {
  968|  58.9k|      switch (desc[n].mode)
  969|  58.9k|        {
  970|      0|        case KEYDB_SEARCH_MODE_WORDS:
  ------------------
  |  Branch (970:9): [True: 0, False: 58.9k]
  ------------------
  971|      0|          need_words = 1;
  972|      0|          break;
  973|  58.5k|        case KEYDB_SEARCH_MODE_FIRST:
  ------------------
  |  Branch (973:9): [True: 58.5k, False: 389]
  ------------------
  974|       |          /* always restart the search in this mode */
  975|  58.5k|          keybox_search_reset (hd);
  976|  58.5k|          lastfoundoff = 0;
  977|  58.5k|          break;
  978|    389|        default:
  ------------------
  |  Branch (978:9): [True: 389, False: 58.5k]
  ------------------
  979|    389|          break;
  980|  58.9k|	}
  981|  58.9k|      if (desc[n].skipfnc)
  ------------------
  |  Branch (981:11): [True: 0, False: 58.9k]
  ------------------
  982|      0|        any_skip = 1;
  983|  58.9k|      if (desc[n].snhex && !sn_array)
  ------------------
  |  Branch (983:11): [True: 0, False: 58.9k]
  |  Branch (983:28): [True: 0, False: 0]
  ------------------
  984|      0|        {
  985|      0|          sn_array = xtrycalloc (ndesc, sizeof *sn_array);
  ------------------
  |  |   99|      0|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  986|      0|          if (!sn_array)
  ------------------
  |  Branch (986:15): [True: 0, False: 0]
  ------------------
  987|      0|            return (hd->error = gpg_error_from_syserror ());
  988|      0|        }
  989|  58.9k|    }
  990|       |
  991|  58.9k|  (void)need_words;  /* Not yet implemented.  */
  992|       |
  993|  58.9k|  if (!hd->fp)
  ------------------
  |  Branch (993:7): [True: 58.7k, False: 157]
  ------------------
  994|  58.7k|    {
  995|  58.7k|      rc = open_file (hd);
  996|  58.7k|      if (rc)
  ------------------
  |  Branch (996:11): [True: 0, False: 58.7k]
  ------------------
  997|      0|        {
  998|      0|          xfree (sn_array);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  999|      0|          return rc;
 1000|      0|        }
 1001|       |      /* log_debug ("%s: re-opened file\n", __func__); */
 1002|  58.7k|      if (ndesc && desc[0].mode != KEYDB_SEARCH_MODE_FIRST && lastfoundoff)
  ------------------
  |  Branch (1002:11): [True: 58.7k, False: 0]
  |  Branch (1002:20): [True: 232, False: 58.5k]
  |  Branch (1002:63): [True: 0, False: 232]
  ------------------
 1003|      0|        {
 1004|       |          /* Search mode is not first and the last search operation
 1005|       |           * returned a blob which also was not the first one.  We now
 1006|       |           * need to skip over that blob and hope that the file has
 1007|       |           * not changed.  */
 1008|      0|          if (es_fseeko (hd->fp, lastfoundoff, SEEK_SET))
  ------------------
  |  Branch (1008:15): [True: 0, False: 0]
  ------------------
 1009|      0|            {
 1010|      0|              rc = gpg_error_from_syserror ();
 1011|      0|              log_debug ("%s: seeking to last found offset failed: %s\n",
 1012|      0|                         __func__, gpg_strerror (rc));
 1013|      0|              xfree (sn_array);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1014|      0|              return gpg_error (GPG_ERR_NOTHING_FOUND);
 1015|      0|            }
 1016|       |          /* log_debug ("%s: re-opened file and sought to last offset\n", */
 1017|       |          /*            __func__); */
 1018|      0|          rc = _keybox_read_blob (NULL, hd->fp, NULL);
 1019|      0|          if (rc)
  ------------------
  |  Branch (1019:15): [True: 0, False: 0]
  ------------------
 1020|      0|            {
 1021|      0|              log_debug ("%s: skipping last found blob failed: %s\n",
 1022|      0|                         __func__, gpg_strerror (rc));
 1023|      0|              xfree (sn_array);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1024|      0|              return gpg_error (GPG_ERR_NOTHING_FOUND);
 1025|      0|            }
 1026|      0|        }
 1027|  58.7k|    }
 1028|       |
 1029|       |  /* Kludge: We need to convert an SN given as hexstring to its binary
 1030|       |     representation - in some cases we are not able to store it in the
 1031|       |     search descriptor, because due to the way we use it, it is not
 1032|       |     possible to free allocated memory. */
 1033|  58.9k|  if (sn_array)
  ------------------
  |  Branch (1033:7): [True: 0, False: 58.9k]
  ------------------
 1034|      0|    {
 1035|      0|      const unsigned char *s;
 1036|      0|      int i, odd;
 1037|      0|      size_t snlen;
 1038|       |
 1039|      0|      for (n=0; n < ndesc; n++)
  ------------------
  |  Branch (1039:17): [True: 0, False: 0]
  ------------------
 1040|      0|        {
 1041|      0|          if (!desc[n].sn)
  ------------------
  |  Branch (1041:15): [True: 0, False: 0]
  ------------------
 1042|      0|            ;
 1043|      0|          else if (desc[n].snhex)
  ------------------
  |  Branch (1043:20): [True: 0, False: 0]
  ------------------
 1044|      0|            {
 1045|      0|              unsigned char *sn;
 1046|       |
 1047|      0|              s = desc[n].sn;
 1048|      0|              for (i=0; *s && *s != '/' && i < desc[n].snlen; s++, i++)
  ------------------
  |  Branch (1048:25): [True: 0, False: 0]
  |  Branch (1048:31): [True: 0, False: 0]
  |  Branch (1048:44): [True: 0, False: 0]
  ------------------
 1049|      0|                ;
 1050|      0|              odd = (i & 1);
 1051|      0|              snlen = (i+1)/2;
 1052|      0|              sn_array[n].sn = xtrymalloc (snlen);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 1053|      0|              if (!sn_array[n].sn)
  ------------------
  |  Branch (1053:19): [True: 0, False: 0]
  ------------------
 1054|      0|                {
 1055|      0|                  hd->error = gpg_error_from_syserror ();
 1056|      0|                  release_sn_array (sn_array, n);
 1057|      0|                  return hd->error;
 1058|      0|                }
 1059|      0|              sn_array[n].snlen = snlen;
 1060|      0|              sn = sn_array[n].sn;
 1061|      0|              s = desc[n].sn;
 1062|      0|              if (odd)
  ------------------
  |  Branch (1062:19): [True: 0, False: 0]
  ------------------
 1063|      0|                {
 1064|      0|                  *sn++ = xtoi_1 (s);
  ------------------
  |  |   33|      0|#define xtoi_1(p)   (*(p) <= '9'? (*(p)- '0'): \
  |  |  ------------------
  |  |  |  Branch (33:22): [True: 0, False: 0]
  |  |  ------------------
  |  |   34|      0|                     *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
  |  |  ------------------
  |  |  |  Branch (34:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1065|      0|                  s++;
 1066|      0|                }
 1067|      0|              for (; *s && *s != '/';  s += 2)
  ------------------
  |  Branch (1067:22): [True: 0, False: 0]
  |  Branch (1067:28): [True: 0, False: 0]
  ------------------
 1068|      0|                *sn++ = xtoi_2 (s);
  ------------------
  |  |   35|      0|#define xtoi_2(p)   ((xtoi_1(p) * 16) + xtoi_1((p)+1))
  |  |  ------------------
  |  |  |  |   33|      0|#define xtoi_1(p)   (*(p) <= '9'? (*(p)- '0'): \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (33:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   34|      0|                     *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (34:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define xtoi_2(p)   ((xtoi_1(p) * 16) + xtoi_1((p)+1))
  |  |  ------------------
  |  |  |  |   33|      0|#define xtoi_1(p)   (*(p) <= '9'? (*(p)- '0'): \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (33:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   34|      0|                     *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (34:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1069|      0|            }
 1070|      0|          else
 1071|      0|            {
 1072|      0|              const unsigned char *sn;
 1073|       |
 1074|      0|              sn = desc[n].sn;
 1075|      0|              snlen = desc[n].snlen;
 1076|      0|              sn_array[n].sn = xtrymalloc (snlen);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 1077|      0|              if (!sn_array[n].sn)
  ------------------
  |  Branch (1077:19): [True: 0, False: 0]
  ------------------
 1078|      0|                {
 1079|      0|                  hd->error = gpg_error_from_syserror ();
 1080|      0|                  release_sn_array (sn_array, n);
 1081|      0|                  return hd->error;
 1082|      0|                }
 1083|      0|              sn_array[n].snlen = snlen;
 1084|      0|              memcpy (sn_array[n].sn, sn, snlen);
 1085|      0|            }
 1086|      0|        }
 1087|      0|    }
 1088|       |
 1089|       |
 1090|  58.9k|  pk_no = uid_no = 0;
 1091|  58.9k|  for (;;)
 1092|   117k|    {
 1093|   117k|      unsigned int blobflags;
 1094|   117k|      int blobtype;
 1095|       |
 1096|   117k|      _keybox_release_blob (blob); blob = NULL;
 1097|   117k|      rc = _keybox_read_blob (&blob, hd->fp, NULL);
 1098|   117k|      if (gpg_err_code (rc) == GPG_ERR_TOO_LARGE
  ------------------
  |  Branch (1098:11): [True: 0, False: 117k]
  ------------------
 1099|   117k|          && gpg_err_source (rc) == GPG_ERR_SOURCE_KEYBOX)
  ------------------
  |  Branch (1099:14): [True: 0, False: 0]
  ------------------
 1100|      0|        {
 1101|      0|          ++*r_skipped;
 1102|      0|          continue; /* Skip too large records.  */
 1103|      0|        }
 1104|       |
 1105|   117k|      if (rc)
  ------------------
  |  Branch (1105:11): [True: 58.9k, False: 58.9k]
  ------------------
 1106|  58.9k|        break;
 1107|       |
 1108|  58.9k|      blobtype = blob_get_type (blob);
 1109|  58.9k|      if (blobtype == KEYBOX_BLOBTYPE_HEADER)
  ------------------
  |  Branch (1109:11): [True: 58.9k, False: 0]
  ------------------
 1110|  58.9k|        continue;
 1111|      0|      if (want_blobtype && blobtype != want_blobtype)
  ------------------
  |  Branch (1111:11): [True: 0, False: 0]
  |  Branch (1111:28): [True: 0, False: 0]
  ------------------
 1112|      0|        continue;
 1113|       |
 1114|      0|      blobflags = blob_get_blob_flags (blob);
 1115|      0|      if (!hd->ephemeral && (blobflags & 2))
  ------------------
  |  Branch (1115:11): [True: 0, False: 0]
  |  Branch (1115:29): [True: 0, False: 0]
  ------------------
 1116|      0|        continue; /* Not in ephemeral mode but blob is flagged ephemeral.  */
 1117|       |
 1118|      0|      for (n=0; n < ndesc; n++)
  ------------------
  |  Branch (1118:17): [True: 0, False: 0]
  ------------------
 1119|      0|        {
 1120|      0|          switch (desc[n].mode)
 1121|      0|            {
 1122|      0|            case KEYDB_SEARCH_MODE_NONE:
  ------------------
  |  Branch (1122:13): [True: 0, False: 0]
  ------------------
 1123|      0|              never_reached ();
  ------------------
  |  |   88|      0|#define never_reached() do {                             \
  |  |   89|      0|    log_debug ("%s:%d: oops - should never get here\n",  \
  |  |   90|      0|               __FILE__, __LINE__ );                     \
  |  |   91|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1124|      0|              break;
 1125|      0|            case KEYDB_SEARCH_MODE_EXACT:
  ------------------
  |  Branch (1125:13): [True: 0, False: 0]
  ------------------
 1126|      0|              uid_no = has_username (blob, desc[n].u.name, 0);
 1127|      0|              if (uid_no)
  ------------------
  |  Branch (1127:19): [True: 0, False: 0]
  ------------------
 1128|      0|                goto found;
 1129|      0|              break;
 1130|      0|            case KEYDB_SEARCH_MODE_MAIL:
  ------------------
  |  Branch (1130:13): [True: 0, False: 0]
  ------------------
 1131|      0|              uid_no = has_mail (blob, desc[n].u.name, 0);
 1132|      0|              if (uid_no)
  ------------------
  |  Branch (1132:19): [True: 0, False: 0]
  ------------------
 1133|      0|                goto found;
 1134|      0|              break;
 1135|      0|            case KEYDB_SEARCH_MODE_MAILSUB:
  ------------------
  |  Branch (1135:13): [True: 0, False: 0]
  ------------------
 1136|      0|              uid_no = has_mail (blob, desc[n].u.name, 1);
 1137|      0|              if (uid_no)
  ------------------
  |  Branch (1137:19): [True: 0, False: 0]
  ------------------
 1138|      0|                goto found;
 1139|      0|              break;
 1140|      0|            case KEYDB_SEARCH_MODE_SUBSTR:
  ------------------
  |  Branch (1140:13): [True: 0, False: 0]
  ------------------
 1141|      0|              uid_no =  has_username (blob, desc[n].u.name, 1);
 1142|      0|              if (uid_no)
  ------------------
  |  Branch (1142:19): [True: 0, False: 0]
  ------------------
 1143|      0|                goto found;
 1144|      0|              break;
 1145|      0|            case KEYDB_SEARCH_MODE_MAILEND:
  ------------------
  |  Branch (1145:13): [True: 0, False: 0]
  ------------------
 1146|      0|            case KEYDB_SEARCH_MODE_WORDS:
  ------------------
  |  Branch (1146:13): [True: 0, False: 0]
  ------------------
 1147|       |              /* not yet implemented */
 1148|      0|              break;
 1149|      0|            case KEYDB_SEARCH_MODE_ISSUER:
  ------------------
  |  Branch (1149:13): [True: 0, False: 0]
  ------------------
 1150|      0|              if (has_issuer (blob, desc[n].u.name))
  ------------------
  |  Branch (1150:19): [True: 0, False: 0]
  ------------------
 1151|      0|                goto found;
 1152|      0|              break;
 1153|      0|            case KEYDB_SEARCH_MODE_ISSUER_SN:
  ------------------
  |  Branch (1153:13): [True: 0, False: 0]
  ------------------
 1154|      0|              if (has_issuer_sn (blob, desc[n].u.name,
  ------------------
  |  Branch (1154:19): [True: 0, False: 0]
  ------------------
 1155|      0|                                 sn_array? sn_array[n].sn : desc[n].sn,
  ------------------
  |  Branch (1155:34): [True: 0, False: 0]
  ------------------
 1156|      0|                                 sn_array? sn_array[n].snlen : desc[n].snlen))
  ------------------
  |  Branch (1156:34): [True: 0, False: 0]
  ------------------
 1157|      0|                goto found;
 1158|      0|              break;
 1159|      0|            case KEYDB_SEARCH_MODE_SN:
  ------------------
  |  Branch (1159:13): [True: 0, False: 0]
  ------------------
 1160|      0|              if (has_sn (blob, sn_array? sn_array[n].sn : desc[n].sn,
  ------------------
  |  Branch (1160:19): [True: 0, False: 0]
  |  Branch (1160:33): [True: 0, False: 0]
  ------------------
 1161|      0|                                sn_array? sn_array[n].snlen : desc[n].snlen))
  ------------------
  |  Branch (1161:33): [True: 0, False: 0]
  ------------------
 1162|      0|                goto found;
 1163|      0|              break;
 1164|      0|            case KEYDB_SEARCH_MODE_SUBJECT:
  ------------------
  |  Branch (1164:13): [True: 0, False: 0]
  ------------------
 1165|      0|              if (has_subject (blob, desc[n].u.name))
  ------------------
  |  Branch (1165:19): [True: 0, False: 0]
  ------------------
 1166|      0|                goto found;
 1167|      0|              break;
 1168|      0|            case KEYDB_SEARCH_MODE_SHORT_KID:
  ------------------
  |  Branch (1168:13): [True: 0, False: 0]
  ------------------
 1169|      0|              pk_no = has_short_kid (blob, desc[n].u.kid[1]);
 1170|      0|              if (pk_no)
  ------------------
  |  Branch (1170:19): [True: 0, False: 0]
  ------------------
 1171|      0|                goto found;
 1172|      0|              break;
 1173|      0|            case KEYDB_SEARCH_MODE_LONG_KID:
  ------------------
  |  Branch (1173:13): [True: 0, False: 0]
  ------------------
 1174|      0|              pk_no = has_long_kid (blob, desc[n].u.kid[0], desc[n].u.kid[1]);
 1175|      0|              if (pk_no)
  ------------------
  |  Branch (1175:19): [True: 0, False: 0]
  ------------------
 1176|      0|                goto found;
 1177|      0|              break;
 1178|       |
 1179|      0|            case KEYDB_SEARCH_MODE_FPR:
  ------------------
  |  Branch (1179:13): [True: 0, False: 0]
  ------------------
 1180|      0|              pk_no = has_fingerprint (blob, desc[n].u.fpr, desc[n].fprlen);
 1181|      0|              if (pk_no)
  ------------------
  |  Branch (1181:19): [True: 0, False: 0]
  ------------------
 1182|      0|                goto found;
 1183|      0|              break;
 1184|       |
 1185|      0|            case KEYDB_SEARCH_MODE_KEYGRIP:
  ------------------
  |  Branch (1185:13): [True: 0, False: 0]
  ------------------
 1186|      0|              if (has_keygrip (blob, desc[n].u.grip))
  ------------------
  |  Branch (1186:19): [True: 0, False: 0]
  ------------------
 1187|      0|                goto found;
 1188|      0|              break;
 1189|      0|            case KEYDB_SEARCH_MODE_UBID:
  ------------------
  |  Branch (1189:13): [True: 0, False: 0]
  ------------------
 1190|      0|              if (has_ubid (blob, desc[n].u.ubid))
  ------------------
  |  Branch (1190:19): [True: 0, False: 0]
  ------------------
 1191|      0|                goto found;
 1192|      0|              break;
 1193|      0|            case KEYDB_SEARCH_MODE_FIRST:
  ------------------
  |  Branch (1193:13): [True: 0, False: 0]
  ------------------
 1194|      0|              goto found;
 1195|      0|              break;
 1196|      0|            case KEYDB_SEARCH_MODE_NEXT:
  ------------------
  |  Branch (1196:13): [True: 0, False: 0]
  ------------------
 1197|      0|              goto found;
 1198|      0|              break;
 1199|      0|            default:
  ------------------
  |  Branch (1199:13): [True: 0, False: 0]
  ------------------
 1200|      0|              rc = gpg_error (GPG_ERR_INV_VALUE);
 1201|      0|              goto found;
 1202|      0|            }
 1203|      0|	}
 1204|      0|      continue;
 1205|      0|    found:
 1206|       |      /* Record which DESC we matched on.  Note this value is only
 1207|       |	 meaningful if this function returns with no errors. */
 1208|      0|      if(r_descindex)
  ------------------
  |  Branch (1208:10): [True: 0, False: 0]
  ------------------
 1209|      0|	*r_descindex = n;
 1210|      0|      for (n=any_skip?0:ndesc; n < ndesc; n++)
  ------------------
  |  Branch (1210:14): [True: 0, False: 0]
  |  Branch (1210:32): [True: 0, False: 0]
  ------------------
 1211|      0|        {
 1212|      0|          u32 kid[2];
 1213|       |
 1214|      0|          if (desc[n].skipfnc
  ------------------
  |  Branch (1214:15): [True: 0, False: 0]
  ------------------
 1215|      0|              && blob_get_first_keyid (blob, kid)
  ------------------
  |  Branch (1215:18): [True: 0, False: 0]
  ------------------
 1216|      0|	      && desc[n].skipfnc (desc[n].skipfncvalue, kid, uid_no))
  ------------------
  |  Branch (1216:11): [True: 0, False: 0]
  ------------------
 1217|      0|		break;
 1218|      0|        }
 1219|      0|      if (n == ndesc)
  ------------------
  |  Branch (1219:11): [True: 0, False: 0]
  ------------------
 1220|      0|        break; /* got it */
 1221|      0|    }
 1222|       |
 1223|  58.9k|  if (!rc)
  ------------------
  |  Branch (1223:7): [True: 0, False: 58.9k]
  ------------------
 1224|      0|    {
 1225|      0|      hd->found.blob = blob;
 1226|      0|      hd->found.pk_no = pk_no;
 1227|      0|      hd->found.uid_no = uid_no;
 1228|      0|    }
 1229|  58.9k|  else if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
  ------------------
  |  Branch (1229:12): [True: 58.9k, False: 0]
  |  Branch (1229:24): [True: 0, False: 0]
  ------------------
 1230|  58.9k|    {
 1231|  58.9k|      _keybox_release_blob (blob);
 1232|  58.9k|      hd->eof = 1;
 1233|  58.9k|    }
 1234|      0|  else
 1235|      0|    {
 1236|      0|      _keybox_release_blob (blob);
 1237|      0|      hd->error = rc;
 1238|      0|    }
 1239|       |
 1240|  58.9k|  if (sn_array)
  ------------------
  |  Branch (1240:7): [True: 0, False: 58.9k]
  ------------------
 1241|      0|    release_sn_array (sn_array, ndesc);
 1242|       |
 1243|  58.9k|  return rc;
 1244|  58.9k|}
keybox-search.c:open_file:
  879|  58.7k|{
  880|       |
  881|  58.7k|  hd->fp = es_fopen (hd->kb->fname, "rb");
  882|  58.7k|  if (!hd->fp)
  ------------------
  |  Branch (882:7): [True: 0, False: 58.7k]
  ------------------
  883|      0|    {
  884|      0|      hd->error = gpg_error_from_syserror ();
  885|      0|      return hd->error;
  886|      0|    }
  887|       |
  888|  58.7k|  return 0;
  889|  58.7k|}

keybox_compress:
  629|      1|{
  630|      1|  gpg_err_code_t ec;
  631|      1|  int read_rc, rc;
  632|      1|  const char *fname;
  633|      1|  estream_t fp, newfp;
  634|      1|  char *bakfname = NULL;
  635|      1|  char *tmpfname = NULL;
  636|      1|  int first_blob;
  637|      1|  KEYBOXBLOB blob = NULL;
  638|      1|  u32 cut_time;
  639|      1|  int any_changes = 0;
  640|      1|  int skipped_deleted;
  641|       |
  642|      1|  if (!hd)
  ------------------
  |  Branch (642:7): [True: 0, False: 1]
  ------------------
  643|      0|    return gpg_error (GPG_ERR_INV_HANDLE);
  644|      1|  if (!hd->kb)
  ------------------
  |  Branch (644:7): [True: 0, False: 1]
  ------------------
  645|      0|    return gpg_error (GPG_ERR_INV_HANDLE);
  646|      1|  if (hd->secret)
  ------------------
  |  Branch (646:7): [True: 0, False: 1]
  ------------------
  647|      0|    return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
  648|      1|  fname = hd->kb->fname;
  649|      1|  if (!fname)
  ------------------
  |  Branch (649:7): [True: 0, False: 1]
  ------------------
  650|      0|    return gpg_error (GPG_ERR_INV_HANDLE);
  651|       |
  652|      1|  _keybox_close_file (hd);
  653|       |
  654|       |  /* Open the source file. Because we do a rename, we have to check the
  655|       |     permissions of the file */
  656|      1|  if ((ec = gnupg_access (fname, W_OK)))
  ------------------
  |  Branch (656:7): [True: 0, False: 1]
  ------------------
  657|      0|    return gpg_error (ec);
  658|       |
  659|      1|  fp = es_fopen (fname, "rb");
  660|      1|  if (!fp && errno == ENOENT)
  ------------------
  |  Branch (660:7): [True: 0, False: 1]
  |  Branch (660:14): [True: 0, False: 0]
  ------------------
  661|      0|    return 0; /* Ready. File has been deleted right after the access above. */
  662|      1|  if (!fp)
  ------------------
  |  Branch (662:7): [True: 0, False: 1]
  ------------------
  663|      0|    {
  664|      0|      rc = gpg_error_from_syserror ();
  665|      0|      return rc;
  666|      0|    }
  667|       |
  668|       |  /* A quick test to see if we need to compress the file at all.  We
  669|       |     schedule a compress run after 3 hours. */
  670|      1|  if ( !_keybox_read_blob (&blob, fp, NULL) )
  ------------------
  |  Branch (670:8): [True: 1, False: 0]
  ------------------
  671|      1|    {
  672|      1|      const unsigned char *buffer;
  673|      1|      size_t length;
  674|       |
  675|      1|      buffer = _keybox_get_blob_image (blob, &length);
  676|      1|      if (length > 4 && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
  ------------------
  |  Branch (676:11): [True: 1, False: 0]
  |  Branch (676:25): [True: 1, False: 0]
  ------------------
  677|      1|        {
  678|      1|          u32 last_maint = buf32_to_u32 (buffer+20);
  679|       |
  680|      1|          if ( (last_maint + 3*3600) > make_timestamp () )
  ------------------
  |  Branch (680:16): [True: 1, False: 0]
  ------------------
  681|      1|            {
  682|      1|              es_fclose (fp);
  683|      1|              _keybox_release_blob (blob);
  684|      1|              return 0; /* Compress run not yet needed. */
  685|      1|            }
  686|      1|        }
  687|      0|      _keybox_release_blob (blob);
  688|      0|      es_fseek (fp, 0, SEEK_SET);
  689|      0|      es_clearerr (fp);
  690|      0|    }
  691|       |
  692|       |  /* Create the new file. */
  693|      0|  rc = create_tmp_file (fname, &bakfname, &tmpfname, &newfp);
  694|      0|  if (rc)
  ------------------
  |  Branch (694:7): [True: 0, False: 0]
  ------------------
  695|      0|    {
  696|      0|      es_fclose (fp);
  697|      0|      return rc;;
  698|      0|    }
  699|       |
  700|       |
  701|       |  /* Processing loop.  By reading using _keybox_read_blob we
  702|       |     automagically skip any blobs flagged as deleted.  Thus what we
  703|       |     only have to do is to check all ephemeral flagged blocks whether
  704|       |     their time has come and write out all other blobs. */
  705|      0|  cut_time = make_timestamp () - 86400;
  706|      0|  first_blob = 1;
  707|      0|  skipped_deleted = 0;
  708|      0|  for (rc=0; !(read_rc = _keybox_read_blob (&blob, fp, &skipped_deleted));
  ------------------
  |  Branch (708:14): [True: 0, False: 0]
  ------------------
  709|      0|       _keybox_release_blob (blob), blob = NULL )
  710|      0|    {
  711|      0|      unsigned int blobflags;
  712|      0|      const unsigned char *buffer;
  713|      0|      size_t length, pos, size;
  714|      0|      u32 created_at;
  715|       |
  716|      0|      if (skipped_deleted)
  ------------------
  |  Branch (716:11): [True: 0, False: 0]
  ------------------
  717|      0|        any_changes = 1;
  718|      0|      buffer = _keybox_get_blob_image (blob, &length);
  719|      0|      if (first_blob)
  ------------------
  |  Branch (719:11): [True: 0, False: 0]
  ------------------
  720|      0|        {
  721|      0|          first_blob = 0;
  722|      0|          if (length > 4 && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
  ------------------
  |  Branch (722:15): [True: 0, False: 0]
  |  Branch (722:29): [True: 0, False: 0]
  ------------------
  723|      0|            {
  724|       |              /* Write out the blob with an updated maintenance time
  725|       |                 stamp and if needed (ie. used by gpg) set the openpgp
  726|       |                 flag.  */
  727|      0|              _keybox_update_header_blob (blob, hd->for_openpgp);
  728|      0|              rc = _keybox_write_blob (blob, newfp, NULL);
  729|      0|              if (rc)
  ------------------
  |  Branch (729:19): [True: 0, False: 0]
  ------------------
  730|      0|                break;
  731|      0|              continue;
  732|      0|            }
  733|       |
  734|       |          /* The header blob is missing.  Insert it.  */
  735|      0|          rc = _keybox_write_header_blob (newfp, hd->for_openpgp);
  736|      0|          if (rc)
  ------------------
  |  Branch (736:15): [True: 0, False: 0]
  ------------------
  737|      0|            break;
  738|      0|          any_changes = 1;
  739|      0|        }
  740|      0|      else if (length > 4 && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
  ------------------
  |  Branch (740:16): [True: 0, False: 0]
  |  Branch (740:30): [True: 0, False: 0]
  ------------------
  741|      0|        {
  742|       |          /* Oops: There is another header record - remove it. */
  743|      0|          any_changes = 1;
  744|      0|          continue;
  745|      0|        }
  746|       |
  747|      0|      if (_keybox_get_flag_location (buffer, length,
  ------------------
  |  Branch (747:11): [True: 0, False: 0]
  ------------------
  748|      0|                                     KEYBOX_FLAG_BLOB, &pos, &size)
  749|      0|          || size != 2)
  ------------------
  |  Branch (749:14): [True: 0, False: 0]
  ------------------
  750|      0|        {
  751|      0|          rc = gpg_error (GPG_ERR_BUG);
  752|      0|          break;
  753|      0|        }
  754|      0|      blobflags = buf16_to_uint (buffer+pos);
  755|      0|      if ((blobflags & KEYBOX_FLAG_BLOB_EPHEMERAL))
  ------------------
  |  |   54|      0|#define KEYBOX_FLAG_BLOB_EPHEMERAL  2
  ------------------
  |  Branch (755:11): [True: 0, False: 0]
  ------------------
  756|      0|        {
  757|       |          /* This is an ephemeral blob. */
  758|      0|          if (_keybox_get_flag_location (buffer, length,
  ------------------
  |  Branch (758:15): [True: 0, False: 0]
  ------------------
  759|      0|                                         KEYBOX_FLAG_CREATED_AT, &pos, &size)
  760|      0|              || size != 4)
  ------------------
  |  Branch (760:18): [True: 0, False: 0]
  ------------------
  761|      0|            created_at = 0; /* oops. */
  762|      0|          else
  763|      0|            created_at = buf32_to_u32 (buffer+pos);
  764|       |
  765|      0|          if (created_at && created_at < cut_time)
  ------------------
  |  Branch (765:15): [True: 0, False: 0]
  |  Branch (765:29): [True: 0, False: 0]
  ------------------
  766|      0|            {
  767|      0|              any_changes = 1;
  768|      0|              continue; /* Skip this blob. */
  769|      0|            }
  770|      0|        }
  771|       |
  772|      0|      rc = _keybox_write_blob (blob, newfp, NULL);
  773|      0|      if (rc)
  ------------------
  |  Branch (773:11): [True: 0, False: 0]
  ------------------
  774|      0|        break;
  775|      0|    }
  776|      0|  if (skipped_deleted)
  ------------------
  |  Branch (776:7): [True: 0, False: 0]
  ------------------
  777|      0|    any_changes = 1;
  778|      0|  _keybox_release_blob (blob); blob = NULL;
  779|      0|  if (!rc && read_rc == -1)
  ------------------
  |  Branch (779:7): [True: 0, False: 0]
  |  Branch (779:14): [True: 0, False: 0]
  ------------------
  780|      0|    rc = 0;
  781|      0|  else if (!rc)
  ------------------
  |  Branch (781:12): [True: 0, False: 0]
  ------------------
  782|      0|    rc = read_rc;
  783|       |
  784|       |  /* Close both files. */
  785|      0|  if (es_fclose(fp) && !rc)
  ------------------
  |  Branch (785:7): [True: 0, False: 0]
  |  Branch (785:24): [True: 0, False: 0]
  ------------------
  786|      0|    rc = gpg_error_from_syserror ();
  787|      0|  if (es_fclose(newfp) && !rc)
  ------------------
  |  Branch (787:7): [True: 0, False: 0]
  |  Branch (787:27): [True: 0, False: 0]
  ------------------
  788|      0|    rc = gpg_error_from_syserror ();
  789|       |
  790|       |  /* Rename or remove the temporary file. */
  791|      0|  if (rc || !any_changes)
  ------------------
  |  Branch (791:7): [True: 0, False: 0]
  |  Branch (791:13): [True: 0, False: 0]
  ------------------
  792|      0|    gnupg_remove (tmpfname);
  793|      0|  else
  794|      0|    rc = rename_tmp_file (bakfname, tmpfname, fname, hd->secret);
  795|       |
  796|      0|  xfree(bakfname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  797|      0|  xfree(tmpfname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  798|      0|  return rc;
  799|      0|}

keybox_tmp_names:
   40|      1|{
   41|      1|  gpg_error_t err;
   42|      1|  char *bak_name, *tmp_name;
   43|       |
   44|      1|  *r_bakname = NULL;
   45|      1|  *r_tmpname = NULL;
   46|       |
   47|       |# ifdef USE_ONLY_8DOT3
   48|       |  /* Here is another Windoze bug?:
   49|       |   * you can't rename("pubring.kbx.tmp", "pubring.kbx");
   50|       |   * but	rename("pubring.kbx.tmp", "pubring.aaa");
   51|       |   * works.  So we replace ".kbx" by ".kb_" or ".k__".  Note that we
   52|       |   * can't use ".bak" and ".tmp", because these suffixes are used by
   53|       |   * gpg's keyrings and would lead to a sharing violation or data
   54|       |   * corruption.  If the name does not end in ".kbx" we assume working
   55|       |   * on a modern file system and append the suffix.  */
   56|       |  {
   57|       |    const char *ext   = for_keyring? EXTSEP_S GPGEXT_GPG : EXTSEP_S "kbx";
   58|       |    const char *b_ext = for_keyring? EXTSEP_S "bak"      : EXTSEP_S "kb_";
   59|       |    const char *t_ext = for_keyring? EXTSEP_S "tmp"      : EXTSEP_S "k__";
   60|       |    int repl;
   61|       |
   62|       |    if (strlen (ext) != 4 || strlen (b_ext) != 4)
   63|       |      BUG ();
   64|       |    repl = (strlen (filename) > 4
   65|       |            && !strcmp (filename + strlen (filename) - 4, ext));
   66|       |    bak_name = xtrymalloc (strlen (filename) + (repl?0:4) + 1);
   67|       |    if (!bak_name)
   68|       |      return gpg_error_from_syserror ();
   69|       |    strcpy (bak_name, filename);
   70|       |    strcpy (bak_name + strlen (filename) - (repl?4:0), b_ext);
   71|       |
   72|       |    tmp_name = xtrymalloc (strlen (filename) + (repl?0:4) + 1);
   73|       |    if (!tmp_name)
   74|       |      {
   75|       |        err = gpg_error_from_syserror ();
   76|       |        xfree (bak_name);
   77|       |        return err;
   78|       |      }
   79|       |    strcpy (tmp_name, filename);
   80|       |    strcpy (tmp_name + strlen (filename) - (repl?4:0), t_ext);
   81|       |  }
   82|       |# else /* Posix file names */
   83|      1|  (void)for_keyring;
   84|      1|  bak_name = xtrymalloc (strlen (filename) + 2);
  ------------------
  |  |   97|      1|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
   85|      1|  if (!bak_name)
  ------------------
  |  Branch (85:7): [True: 0, False: 1]
  ------------------
   86|      0|    return gpg_error_from_syserror ();
   87|      1|  strcpy (stpcpy (bak_name, filename), "~");
   88|       |
   89|      1|  tmp_name = xtrymalloc (strlen (filename) + 5);
  ------------------
  |  |   97|      1|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
   90|      1|  if (!tmp_name)
  ------------------
  |  Branch (90:7): [True: 0, False: 1]
  ------------------
   91|      0|    {
   92|      0|      err = gpg_error_from_syserror ();
   93|      0|      xfree (bak_name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
   94|      0|      return err;
   95|      0|    }
   96|      1|  strcpy (stpcpy (tmp_name,filename), EXTSEP_S "tmp");
  ------------------
  |  |  889|      1|#define EXTSEP_S "."
  ------------------
   97|      1|# endif /* Posix filename */
   98|       |
   99|      1|  *r_bakname = bak_name;
  100|      1|  *r_tmpname = tmp_name;
  101|      1|  return 0;
  102|      1|}

LLVMFuzzerTestOneInput:
   93|  11.9k|int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   94|  11.9k|    IOBUF a;
   95|  11.9k|    armor_filter_context_t *afx = NULL;
   96|       |
   97|  11.9k|    if (! initialized) {
  ------------------
  |  Branch (97:9): [True: 1, False: 11.9k]
  ------------------
   98|      1|        ctrlGlobal = (ctrl_t) malloc(sizeof(*ctrlGlobal));
   99|      1|        if (!ctrlGlobal) {
  ------------------
  |  Branch (99:13): [True: 0, False: 1]
  ------------------
  100|      0|            exit(1);
  101|      0|        }
  102|       |        //deletes previous tmp dir and (re)create it as a ramfs
  103|       |        //system("umount /tmp/fuzzdirlist");
  104|      1|        rmrfdir("/tmp/fuzzdirlist");
  105|      1|        if (mkdir("/tmp/fuzzdirlist", 0700) < 0) {
  ------------------
  |  Branch (105:13): [True: 0, False: 1]
  ------------------
  106|      0|            printf("failed mkdir, errno=%d\n", errno);
  107|      0|            if (errno != EEXIST) {
  ------------------
  |  Branch (107:17): [True: 0, False: 0]
  ------------------
  108|      0|                return 0;
  109|      0|            }
  110|      0|        }
  111|       |        //system("mount -t tmpfs -o size=64M tmpfs /tmp/fuzzdirlist");
  112|      1|        filename=strdup("/tmp/fuzzdirlist/fuzz.gpg");
  113|      1|        if (!filename) {
  ------------------
  |  Branch (113:13): [True: 0, False: 1]
  ------------------
  114|      0|            free(ctrlGlobal);
  115|      0|            return 0;
  116|      0|        }
  117|      1|        fd = open(filename, O_RDWR | O_CREAT, 0666);
  118|      1|        if (fd == -1) {
  ------------------
  |  Branch (118:13): [True: 0, False: 1]
  ------------------
  119|      0|            free(filename);
  120|      0|            free(ctrlGlobal);
  121|      0|            printf("failed open, errno=%d\n", errno);
  122|      0|            return 0;
  123|      0|        }
  124|      1|        gnupg_set_homedir("/tmp/fuzzdirlist/");
  125|      1|        gpg_error_t gpgerr = keydb_add_resource ("pubring" EXTSEP_S GPGEXT_GPG, KEYDB_RESOURCE_FLAG_DEFAULT);
  ------------------
  |  |  122|      1|#define GPGEXT_GPG "gpg"
  ------------------
                      gpg_error_t gpgerr = keydb_add_resource ("pubring" EXTSEP_S GPGEXT_GPG, KEYDB_RESOURCE_FLAG_DEFAULT);
  ------------------
  |  |  212|      1|#define KEYDB_RESOURCE_FLAG_DEFAULT  4  /* The default one.  */
  ------------------
  126|      1|        if (gpgerr != GPG_ERR_NO_ERROR) {
  ------------------
  |  Branch (126:13): [True: 0, False: 1]
  ------------------
  127|      0|            free(filename);
  128|      0|            free(ctrlGlobal);
  129|      0|            close(fd);
  130|      0|            printf("failed keydb_add_resource, errno=%d\n", gpgerr);
  131|      0|            return 0;
  132|      0|        }
  133|      1|        gpgerr = setup_trustdb (1, NULL);
  134|      1|        if (gpgerr != GPG_ERR_NO_ERROR) {
  ------------------
  |  Branch (134:13): [True: 0, False: 1]
  ------------------
  135|      0|            free(filename);
  136|      0|            free(ctrlGlobal);
  137|      0|            close(fd);
  138|      0|            printf("failed setup_trustdb, errno=%d\n", gpgerr);
  139|      0|            return 0;
  140|      0|        }
  141|       |        //populate /tmp/fuzzdirlist/ as homedir ~/.gnupg
  142|      1|        strlist_t sl = NULL;
  143|      1|        public_key_list (ctrlGlobal, sl, 0, 0);
  144|      1|        free_strlist(sl);
  145|       |        //no output for stderr
  146|      1|        log_set_file("/dev/null");
  147|      1|        gcry_set_log_handler (my_gcry_logger, NULL);
  148|      1|        gnupg_initialize_compliance (GNUPG_MODULE_NAME_GPG);
  ------------------
  |  |  293|      1|#define GNUPG_MODULE_NAME_GPG           8
  ------------------
  149|      1|        opt.list_packets=1;
  150|      1|        set_packet_list_mode(1);
  151|      1|        initialized = true;
  152|      1|    }
  153|       |
  154|  11.9k|    if (Size > MAX_LEN) {
  ------------------
  |  |   91|  11.9k|#define MAX_LEN 0x10000
  ------------------
  |  Branch (154:9): [True: 1, False: 11.9k]
  ------------------
  155|       |        // limit maximum size to avoid long computing times
  156|      1|        return 0;
  157|      1|    }
  158|       |
  159|  11.9k|    memset(ctrlGlobal, 0, sizeof(*ctrlGlobal));
  160|  11.9k|    ctrlGlobal->magic = SERVER_CONTROL_MAGIC;
  ------------------
  |  |   83|  11.9k|# define SERVER_CONTROL_MAGIC 0x53616c696e676572
  ------------------
  161|       |
  162|  11.9k|    if (ftruncate(fd, Size) == -1) {
  ------------------
  |  Branch (162:9): [True: 0, False: 11.9k]
  ------------------
  163|      0|        return 0;
  164|      0|    }
  165|  11.9k|    if (lseek (fd, 0, SEEK_SET) < 0) {
  ------------------
  |  Branch (165:9): [True: 0, False: 11.9k]
  ------------------
  166|      0|        return 0;
  167|      0|    }
  168|  11.9k|    if (write (fd, Data, Size) != Size) {
  ------------------
  |  Branch (168:9): [True: 0, False: 11.9k]
  ------------------
  169|      0|        return 0;
  170|      0|    }
  171|       |
  172|  11.9k|    a = iobuf_open(filename);
  173|  11.9k|    if( !a ) {
  ------------------
  |  Branch (173:9): [True: 0, False: 11.9k]
  ------------------
  174|      0|        printf("failed iobuf_open\n");
  175|      0|        return 0;
  176|      0|    }
  177|  11.9k|    if( use_armor_filter( a ) ) {
  ------------------
  |  Branch (177:9): [True: 2.68k, False: 9.26k]
  ------------------
  178|  2.68k|        afx = new_armor_context ();
  179|  2.68k|        push_armor_filter (afx, a);
  180|  2.68k|    }
  181|  11.9k|    proc_packets (ctrlGlobal, NULL, a );
  182|  11.9k|    iobuf_close(a);
  183|  11.9k|    release_armor_context (afx);
  184|  11.9k|    gpg_deinit_default_ctrl (ctrlGlobal);
  185|       |
  186|  11.9k|    return 0;
  187|  11.9k|}
fuzz_list.c:rmrfdir:
   83|      1|{
   84|      1|    ftw(path, unlink_cb, 16);
   85|      1|    if (rmdir(path) != 0) {
  ------------------
  |  Branch (85:9): [True: 1, False: 0]
  ------------------
   86|      1|        printf("failed rmdir, errno=%d\n", errno);
   87|      1|    }
   88|      1|}
fuzz_list.c:gpg_deinit_default_ctrl:
   59|  11.9k|{
   60|       |#ifdef USE_TOFU
   61|       |    tofu_closedbs (ctrl);
   62|       |#endif
   63|  11.9k|    gpg_dirmngr_deinit_session_data (ctrl);
   64|       |
   65|  11.9k|    keydb_release (ctrl->cached_getkey_kdb);
   66|  11.9k|}

assuan-socket-connect.c:_assuan_error:
  237|   176k|{
  238|   176k|  return gpg_err_make (ctx?ctx->err_source: GPG_ERR_SOURCE_ASSUAN, errcode);
  ------------------
  |  Branch (238:24): [True: 176k, False: 0]
  ------------------
  239|   176k|}

_assuan_log_handler:
  128|  1.76M|{
  129|  1.76M|  FILE *fp;
  130|  1.76M|  const char *prf;
  131|  1.76M|  int saved_errno = errno;
  132|       |
  133|       |  /* For now.  */
  134|  1.76M|  if (msg == NULL)
  ------------------
  |  Branch (134:7): [True: 1.76M, False: 0]
  ------------------
  135|  1.76M|    return TEST_LOG_CAT (cat);
  ------------------
  |  |   55|  1.76M|#define TEST_LOG_CAT(x) (!! (log_cats & (1 << (x - 1))))
  ------------------
  136|       |
  137|      0|  if (! TEST_LOG_CAT (cat))
  ------------------
  |  |   55|      0|#define TEST_LOG_CAT(x) (!! (log_cats & (1 << (x - 1))))
  ------------------
  |  Branch (137:7): [True: 0, False: 0]
  ------------------
  138|      0|    return 0;
  139|       |
  140|      0|  fp = ctx->log_fp ? ctx->log_fp : _assuan_log;
  ------------------
  |  Branch (140:8): [True: 0, False: 0]
  ------------------
  141|      0|  if (!fp)
  ------------------
  |  Branch (141:7): [True: 0, False: 0]
  ------------------
  142|      0|    return 0;
  143|       |
  144|      0|  prf = assuan_get_assuan_log_prefix ();
  145|      0|  if (*prf)
  ------------------
  |  Branch (145:7): [True: 0, False: 0]
  ------------------
  146|      0|    fprintf (fp, "%s[%u]: ", prf, (unsigned int)getpid ());
  147|       |
  148|      0|  fprintf (fp, "%s", msg);
  149|       |  /* If the log stream is a file, the output would be buffered.  This
  150|       |     is bad for debugging, thus we flush the stream if FORMAT ends
  151|       |     with a LF.  */
  152|      0|  if (msg && *msg && msg[strlen (msg) - 1] == '\n')
  ------------------
  |  Branch (152:7): [True: 0, False: 0]
  |  Branch (152:14): [True: 0, False: 0]
  |  Branch (152:22): [True: 0, False: 0]
  ------------------
  153|      0|    fflush (fp);
  154|      0|  gpg_err_set_errno (saved_errno);
  155|       |
  156|      0|  return 0;
  157|      0|}

assuan_socket_connect:
  221|   176k|{
  222|   176k|  gpg_error_t err = 0;
  223|   176k|  assuan_fd_t fd;
  224|   176k|#ifdef WITH_IPV6
  225|   176k|  struct sockaddr_in6 srvr_addr_in6;
  226|   176k|#endif
  227|   176k|  struct sockaddr_un srvr_addr_un;
  228|   176k|  struct sockaddr_in srvr_addr_in;
  229|   176k|  struct sockaddr *srvr_addr = NULL;
  230|   176k|  uint16_t port = 0;
  231|   176k|  size_t len = 0;
  232|   176k|  const char *s;
  233|   176k|  int af = AF_LOCAL;
  234|   176k|  int pf = PF_LOCAL;
  235|       |
  236|   176k|  TRACE2 (ctx, ASSUAN_LOG_CTX, "assuan_socket_connect", ctx,
  ------------------
  |  |  152|   176k|  _assuan_debug (ctx, lvl, "%s (%s=%p): call: " fmt "\n",		\
  |  |  153|   353k|		 name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1, \
  |  |  ------------------
  |  |  |  |   35|   176k|#define STRINGIFY(v) #v
  |  |  ------------------
  |  |  |  Branch (153:53): [True: 176k, False: 0]
  |  |  ------------------
  |  |  154|   176k|		 arg2)
  ------------------
  237|   176k|	  "name=%s, flags=0x%x", name ? name : "(null)", flags);
  238|       |
  239|   176k|  if (!ctx || !name)
  ------------------
  |  Branch (239:7): [True: 0, False: 176k]
  |  Branch (239:15): [True: 0, False: 176k]
  ------------------
  240|      0|    return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
  241|       |
  242|   176k|  if (!strncmp (name, "file://", 7) && name[7])
  ------------------
  |  Branch (242:7): [True: 0, False: 176k]
  |  Branch (242:40): [True: 0, False: 0]
  ------------------
  243|      0|    name += 7;
  244|   176k|  else if (!strncmp (name, "assuan://", 9) && name[9])
  ------------------
  |  Branch (244:12): [True: 0, False: 176k]
  |  Branch (244:47): [True: 0, False: 0]
  ------------------
  245|      0|    {
  246|      0|      name += 9;
  247|      0|      af = AF_INET;
  248|      0|      pf = PF_INET;
  249|      0|    }
  250|   176k|  else /* Default.  */
  251|   176k|    {
  252|       |      /* We require that the name starts with a slash if no URL
  253|       |         schemata is used.  To make things easier we allow an optional
  254|       |         drive prefix.  */
  255|   176k|      s = name;
  256|   176k|      if (*s && s[1] == ':')
  ------------------
  |  Branch (256:11): [True: 176k, False: 0]
  |  Branch (256:17): [True: 0, False: 176k]
  ------------------
  257|      0|        s += 2;
  258|   176k|      if (*s != DIRSEP_C && *s != '/')
  ------------------
  |  |   51|   353k|#define DIRSEP_C '/'
  ------------------
  |  Branch (258:11): [True: 0, False: 176k]
  |  Branch (258:29): [True: 0, False: 0]
  ------------------
  259|      0|        return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
  260|   176k|    }
  261|       |
  262|   176k|  if (af == AF_LOCAL)
  ------------------
  |  Branch (262:7): [True: 176k, False: 0]
  ------------------
  263|   176k|    {
  264|   176k|      int redirected;
  265|       |
  266|   176k|      if (_assuan_sock_set_sockaddr_un (name, (struct sockaddr *)&srvr_addr_un,
  ------------------
  |  Branch (266:11): [True: 0, False: 176k]
  ------------------
  267|   176k|                                        &redirected))
  268|      0|        return _assuan_error (ctx, gpg_err_code_from_syserror ());
  269|       |
  270|   176k|      len = SUN_LEN (&srvr_addr_un);
  271|   176k|      srvr_addr = (struct sockaddr *)&srvr_addr_un;
  272|   176k|    }
  273|      0|  else
  274|      0|    {
  275|      0|      char *addrstr, *p;
  276|      0|#ifdef HAVE_INET_PTON
  277|      0|      void *addrbuf = NULL;
  278|      0|#endif
  279|       |
  280|      0|      addrstr = _assuan_malloc (ctx, strlen (name) + 1);
  281|      0|      if (!addrstr)
  ------------------
  |  Branch (281:11): [True: 0, False: 0]
  ------------------
  282|      0|        return _assuan_error (ctx, gpg_err_code_from_syserror ());
  283|       |
  284|      0|      if (*name == '[')
  ------------------
  |  Branch (284:11): [True: 0, False: 0]
  ------------------
  285|      0|        {
  286|      0|          strcpy (addrstr, name+1);
  287|      0|          p = strchr (addrstr, ']');
  288|      0|          if (!p || p[1] != ':' || !parse_portno (p+2, &port))
  ------------------
  |  Branch (288:15): [True: 0, False: 0]
  |  Branch (288:21): [True: 0, False: 0]
  |  Branch (288:36): [True: 0, False: 0]
  ------------------
  289|      0|            err = _assuan_error (ctx, GPG_ERR_BAD_URI);
  290|      0|          else
  291|      0|            {
  292|      0|              *p = 0;
  293|      0|#ifdef WITH_IPV6
  294|      0|              af = AF_INET6;
  295|      0|              pf = PF_INET6;
  296|      0|              memset (&srvr_addr_in6, 0, sizeof srvr_addr_in6);
  297|      0|              srvr_addr_in6.sin6_family = af;
  298|      0|              srvr_addr_in6.sin6_port = htons (port);
  299|      0|#ifdef HAVE_INET_PTON
  300|      0|              addrbuf = &srvr_addr_in6.sin6_addr;
  301|      0|#endif
  302|      0|              srvr_addr = (struct sockaddr *)&srvr_addr_in6;
  303|      0|              len = sizeof srvr_addr_in6;
  304|       |#else
  305|       |              err =  _assuan_error (ctx, GPG_ERR_EAFNOSUPPORT);
  306|       |#endif
  307|      0|            }
  308|      0|        }
  309|      0|      else
  310|      0|        {
  311|      0|          strcpy (addrstr, name);
  312|      0|          p = strchr (addrstr, ':');
  313|      0|          if (!p || !parse_portno (p+1, &port))
  ------------------
  |  Branch (313:15): [True: 0, False: 0]
  |  Branch (313:21): [True: 0, False: 0]
  ------------------
  314|      0|            err = _assuan_error (ctx, GPG_ERR_BAD_URI);
  315|      0|          else
  316|      0|            {
  317|      0|              *p = 0;
  318|      0|              memset (&srvr_addr_in, 0, sizeof srvr_addr_in);
  319|      0|              srvr_addr_in.sin_family = af;
  320|      0|              srvr_addr_in.sin_port = htons (port);
  321|      0|#ifdef HAVE_INET_PTON
  322|      0|              addrbuf = &srvr_addr_in.sin_addr;
  323|      0|#endif
  324|      0|              srvr_addr = (struct sockaddr *)&srvr_addr_in;
  325|      0|              len = sizeof srvr_addr_in;
  326|      0|            }
  327|      0|        }
  328|       |
  329|      0|      if (!err)
  ------------------
  |  Branch (329:11): [True: 0, False: 0]
  ------------------
  330|      0|        {
  331|      0|#ifdef HAVE_INET_PTON
  332|      0|          switch (inet_pton (af, addrstr, addrbuf))
  333|      0|            {
  334|      0|            case 1:  break;
  ------------------
  |  Branch (334:13): [True: 0, False: 0]
  ------------------
  335|      0|            case 0:  err = _assuan_error (ctx, GPG_ERR_BAD_URI); break;
  ------------------
  |  Branch (335:13): [True: 0, False: 0]
  ------------------
  336|      0|            default: err = _assuan_error (ctx, gpg_err_code_from_syserror ());
  ------------------
  |  Branch (336:13): [True: 0, False: 0]
  ------------------
  337|      0|            }
  338|       |#else /*!HAVE_INET_PTON*/
  339|       |          /* We need to use the old function.  If we are here v6
  340|       |             support isn't enabled anyway and thus we can do fine
  341|       |             without.  Note that Windows as a compatible inet_pton
  342|       |             function named inetPton, but only since Vista.  */
  343|       |          srvr_addr_in.sin_addr.s_addr = inet_addr (addrstr);
  344|       |          if (srvr_addr_in.sin_addr.s_addr == INADDR_NONE)
  345|       |            err = _assuan_error (ctx, GPG_ERR_BAD_URI);
  346|       |#endif /*!HAVE_INET_PTON*/
  347|      0|        }
  348|       |
  349|      0|      _assuan_free (ctx, addrstr);
  350|      0|      if (err)
  ------------------
  |  Branch (350:11): [True: 0, False: 0]
  ------------------
  351|      0|        return err;
  352|      0|    }
  353|       |
  354|   176k|  fd = _assuan_sock_new (ctx, pf, SOCK_STREAM, 0);
  355|   176k|  if (fd == ASSUAN_INVALID_FD)
  ------------------
  |  |   86|   176k|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  |  Branch (355:7): [True: 0, False: 176k]
  ------------------
  356|      0|    {
  357|      0|      err = _assuan_error (ctx, gpg_err_code_from_syserror ());
  358|      0|      TRACE1 (ctx, ASSUAN_LOG_SYSIO, "assuan_socket_connect", ctx,
  ------------------
  |  |  149|      0|  _assuan_debug (ctx, lvl, "%s (%s=%p): call: " fmt "\n",		\
  |  |  150|      0|		 name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1)
  |  |  ------------------
  |  |  |  |   35|      0|#define STRINGIFY(v) #v
  |  |  ------------------
  ------------------
  359|      0|              "can't create socket: %s", strerror (errno));
  360|      0|      return err;
  361|      0|    }
  362|       |
  363|   176k|  if (_assuan_sock_connect (ctx, fd, srvr_addr, len) == -1)
  ------------------
  |  Branch (363:7): [True: 176k, False: 0]
  ------------------
  364|   176k|    {
  365|   176k|      TRACE2 (ctx, ASSUAN_LOG_SYSIO, "assuan_socket_connect", ctx,
  ------------------
  |  |  152|   176k|  _assuan_debug (ctx, lvl, "%s (%s=%p): call: " fmt "\n",		\
  |  |  153|   176k|		 name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1, \
  |  |  ------------------
  |  |  |  |   35|   176k|#define STRINGIFY(v) #v
  |  |  ------------------
  |  |  154|   176k|		 arg2)
  ------------------
  366|   176k|	      "can't connect to `%s': %s\n", name, strerror (errno));
  367|   176k|      _assuan_close (ctx, fd);
  368|   176k|      return _assuan_error (ctx, GPG_ERR_ASS_CONNECT_FAILED);
  369|   176k|    }
  370|       |
  371|      0|  err = _assuan_connect_finalize (ctx, fd, flags);
  372|       |
  373|      0|  if (err)
  ------------------
  |  Branch (373:7): [True: 0, False: 0]
  ------------------
  374|      0|    _assuan_reset (ctx);
  375|       |
  376|      0|  return err;
  377|   176k|}

_assuan_sock_new:
  527|   176k|{
  528|       |#ifdef HAVE_W32_SYSTEM
  529|       |  assuan_fd_t res;
  530|       |  if (domain == AF_UNIX || domain == AF_LOCAL)
  531|       |    domain = AF_INET;
  532|       |  res = _assuan_socket (ctx, domain, type, proto);
  533|       |  return res;
  534|       |#else
  535|   176k|  return _assuan_socket (ctx, domain, type, proto);
  536|   176k|#endif
  537|   176k|}
_assuan_sock_connect:
 1011|   176k|{
 1012|       |#ifdef HAVE_W32_SYSTEM
 1013|       |  if (addr->sa_family == AF_LOCAL || addr->sa_family == AF_UNIX)
 1014|       |    {
 1015|       |      struct sockaddr_in myaddr;
 1016|       |      struct sockaddr_un *unaddr;
 1017|       |      unsigned short port;
 1018|       |      char nonce[16];
 1019|       |      int cygwin;
 1020|       |      int ret;
 1021|       |
 1022|       |      unaddr = (struct sockaddr_un *)addr;
 1023|       |      if (read_port_and_nonce (unaddr->sun_path, &port, nonce, &cygwin))
 1024|       |        return -1;
 1025|       |
 1026|       |      myaddr.sin_family = AF_INET;
 1027|       |      myaddr.sin_port = htons (port);
 1028|       |      myaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
 1029|       |
 1030|       |      /* Set return values.  */
 1031|       |      unaddr->sun_family = myaddr.sin_family;
 1032|       |      unaddr->sun_port = myaddr.sin_port;
 1033|       |      unaddr->sun_addr.s_addr = myaddr.sin_addr.s_addr;
 1034|       |
 1035|       |      ret = _assuan_connect (ctx, sockfd,
 1036|       |			    (struct sockaddr *)&myaddr, sizeof myaddr);
 1037|       |      if (!ret)
 1038|       |        {
 1039|       |          /* Send the nonce. */
 1040|       |          ret = do_writen (ctx, sockfd, nonce, 16);
 1041|       |          if (!ret && cygwin)
 1042|       |            {
 1043|       |              char buffer[16];
 1044|       |
 1045|       |              /* The client sends the nonce back - not useful.  We do
 1046|       |                 a dummy read.  */
 1047|       |              ret = do_readn (ctx, sockfd, buffer, 16);
 1048|       |              if (!ret)
 1049|       |                {
 1050|       |                  /* Send our credentials.  */
 1051|       |                  int n = getpid ();
 1052|       |                  memcpy (buffer, &n, 4);
 1053|       |                  memset (buffer+4, 0, 4); /* uid = gid = 0 */
 1054|       |                  ret = do_writen (ctx, sockfd, buffer, 8);
 1055|       |                  if (!ret)
 1056|       |                    {
 1057|       |                      /* Receive credentials.  We don't need them.  */
 1058|       |                      ret = do_readn (ctx, sockfd, buffer, 8);
 1059|       |                    }
 1060|       |                }
 1061|       |            }
 1062|       |        }
 1063|       |      return ret;
 1064|       |    }
 1065|       |  else if (use_socks (addr))
 1066|       |    {
 1067|       |      return socks5_connect (ctx, sockfd, tor_mode,
 1068|       |                             NULL, NULL, 0, addr, addrlen);
 1069|       |    }
 1070|       |  else
 1071|       |    {
 1072|       |      return _assuan_connect (ctx, sockfd, addr, addrlen);
 1073|       |    }
 1074|       |#else
 1075|   176k|# if HAVE_STAT
 1076|   176k|  if (addr->sa_family == AF_LOCAL || addr->sa_family == AF_UNIX)
  ------------------
  |  Branch (1076:7): [True: 176k, False: 0]
  |  Branch (1076:38): [True: 0, False: 0]
  ------------------
 1077|   176k|    {
 1078|   176k|      struct sockaddr_un *unaddr;
 1079|   176k|      struct stat statbuf;
 1080|   176k|      int redirect, res;
 1081|       |
 1082|   176k|      unaddr = (struct sockaddr_un *)addr;
 1083|   176k|      if (!stat (unaddr->sun_path, &statbuf)
  ------------------
  |  Branch (1083:11): [True: 0, False: 176k]
  ------------------
 1084|   176k|          && !S_ISSOCK (statbuf.st_mode)
  ------------------
  |  Branch (1084:14): [True: 0, False: 0]
  ------------------
 1085|   176k|          && S_ISREG (statbuf.st_mode))
 1086|      0|        {
 1087|       |          /* The given socket file is not a socket but a regular file.
 1088|       |             We use the content of that file to redirect to another
 1089|       |             socket file.  This can be used to use sockets on file
 1090|       |             systems which do not support sockets or if for example a
 1091|       |             home directory is shared by several machines.  */
 1092|      0|          unaddr = eval_redirection (unaddr->sun_path, &redirect);
 1093|      0|          if (unaddr)
  ------------------
  |  Branch (1093:15): [True: 0, False: 0]
  ------------------
 1094|      0|            {
 1095|      0|              res = _assuan_connect (ctx, sockfd, (struct sockaddr *)unaddr,
 1096|      0|                                     SUN_LEN (unaddr));
 1097|      0|              free (unaddr);
 1098|      0|              return res;
 1099|      0|            }
 1100|      0|          if (redirect)
  ------------------
  |  Branch (1100:15): [True: 0, False: 0]
  ------------------
 1101|      0|            return -1;
 1102|       |          /* Continue using the standard connect.  */
 1103|      0|        }
 1104|       |
 1105|   176k|    }
 1106|   176k|# endif /*HAVE_STAT*/
 1107|       |
 1108|   176k|  if (use_socks (addr))
  ------------------
  |  Branch (1108:7): [True: 0, False: 176k]
  ------------------
 1109|      0|    {
 1110|      0|      return socks5_connect (ctx, sockfd, tor_mode,
 1111|      0|                             NULL, NULL, 0, addr, addrlen);
 1112|      0|    }
 1113|   176k|  else
 1114|   176k|    {
 1115|   176k|      return _assuan_connect (ctx, sockfd, addr, addrlen);
 1116|   176k|    }
 1117|   176k|#endif
 1118|   176k|}
_assuan_sock_set_sockaddr_un:
 1278|   176k|{
 1279|   176k|  struct sockaddr_un *unaddr = (struct sockaddr_un *)addr;
 1280|   176k|#if !defined(HAVE_W32_SYSTEM) && defined(HAVE_STAT)
 1281|   176k|  struct stat statbuf;
 1282|   176k|#endif
 1283|       |
 1284|   176k|  if (r_redirected)
  ------------------
  |  Branch (1284:7): [True: 176k, False: 0]
  ------------------
 1285|   176k|    *r_redirected = 0;
 1286|       |
 1287|   176k|#if !defined(HAVE_W32_SYSTEM) && defined(HAVE_STAT)
 1288|   176k|  if (r_redirected
  ------------------
  |  Branch (1288:7): [True: 176k, False: 0]
  ------------------
 1289|   176k|      && !stat (fname, &statbuf)
  ------------------
  |  Branch (1289:10): [True: 0, False: 176k]
  ------------------
 1290|   176k|      && !S_ISSOCK (statbuf.st_mode)
  ------------------
  |  Branch (1290:10): [True: 0, False: 0]
  ------------------
 1291|   176k|      && S_ISREG (statbuf.st_mode))
 1292|      0|    {
 1293|       |      /* The given socket file is not a socket but a regular file.  We
 1294|       |         use the content of that file to redirect to another socket
 1295|       |         file.  This can be used to use sockets on file systems which
 1296|       |         do not support sockets or if for example a home directory is
 1297|       |         shared by several machines.  */
 1298|      0|      struct sockaddr_un *unaddr_new;
 1299|      0|      int redirect;
 1300|       |
 1301|      0|      unaddr_new = eval_redirection (fname, &redirect);
 1302|      0|      if (unaddr_new)
  ------------------
  |  Branch (1302:11): [True: 0, False: 0]
  ------------------
 1303|      0|        {
 1304|      0|          memcpy (unaddr, unaddr_new, sizeof *unaddr);
 1305|      0|          free (unaddr_new);
 1306|      0|          *r_redirected = 1;
 1307|      0|          return 0;
 1308|      0|        }
 1309|      0|      if (redirect)
  ------------------
  |  Branch (1309:11): [True: 0, False: 0]
  ------------------
 1310|      0|        {
 1311|      0|          *r_redirected = 1;
 1312|      0|          return -1;  /* Error.  */
 1313|      0|        }
 1314|       |      /* Fallback to standard setup.  */
 1315|      0|    }
 1316|   176k|#endif /*!HAVE_W32_SYSTEM && HAVE_STAT*/
 1317|       |
 1318|   176k|  if (strlen (fname)+1 >= sizeof unaddr->sun_path)
  ------------------
  |  Branch (1318:7): [True: 0, False: 176k]
  ------------------
 1319|      0|    {
 1320|      0|      gpg_err_set_errno (ENAMETOOLONG);
 1321|      0|      return -1;
 1322|      0|    }
 1323|       |
 1324|   176k|  memset (unaddr, 0, sizeof *unaddr);
 1325|   176k|  unaddr->sun_family = AF_LOCAL;
 1326|   176k|  strncpy (unaddr->sun_path, fname, sizeof unaddr->sun_path - 1);
 1327|   176k|  unaddr->sun_path[sizeof unaddr->sun_path - 1] = 0;
 1328|       |
 1329|   176k|  return 0;
 1330|   176k|}
assuan-socket.c:use_socks:
  953|   176k|{
  954|   176k|  union {
  955|   176k|    struct sockaddr *addr;
  956|   176k|    struct sockaddr_in *addr_in;
  957|   176k|    struct sockaddr_in6 *addr_in6;
  958|   176k|  } addru;
  959|       |
  960|   176k|  addru.addr = addr;
  961|       |
  962|   176k|  if (!tor_mode)
  ------------------
  |  Branch (962:7): [True: 176k, False: 0]
  ------------------
  963|   176k|    return 0;
  964|      0|  else if (addr->sa_family == AF_INET6)
  ------------------
  |  Branch (964:12): [True: 0, False: 0]
  ------------------
  965|      0|    {
  966|      0|      const unsigned char *s;
  967|      0|      int i;
  968|       |
  969|      0|      s = (unsigned char *)&addru.addr_in6->sin6_addr.s6_addr;
  970|      0|      if (s[15] != 1)
  ------------------
  |  Branch (970:11): [True: 0, False: 0]
  ------------------
  971|      0|        return 1;   /* Last octet is not 1 - not the loopback address.  */
  972|      0|      for (i=0; i < 15; i++, s++)
  ------------------
  |  Branch (972:17): [True: 0, False: 0]
  ------------------
  973|      0|        if (*s)
  ------------------
  |  Branch (973:13): [True: 0, False: 0]
  ------------------
  974|      0|          return 1; /* Non-zero octet found - not the loopback address.  */
  975|       |
  976|      0|      return 0; /* This is the loopback address.  */
  977|      0|    }
  978|      0|  else if (addr->sa_family == AF_INET)
  ------------------
  |  Branch (978:12): [True: 0, False: 0]
  ------------------
  979|      0|    {
  980|      0|      if (*(unsigned char*)&addru.addr_in->sin_addr.s_addr == 127)
  ------------------
  |  Branch (980:11): [True: 0, False: 0]
  ------------------
  981|      0|        return 0; /* Loopback (127.0.0.0/8) */
  982|       |
  983|      0|      return 1;
  984|      0|    }
  985|      0|  else
  986|      0|    return 0;
  987|   176k|}

_assuan_pre_syscall:
  120|   353k|{
  121|   353k|  if (pre_syscall_func)
  ------------------
  |  Branch (121:7): [True: 0, False: 353k]
  ------------------
  122|      0|    pre_syscall_func ();
  123|   353k|}
_assuan_post_syscall:
  129|   353k|{
  130|   353k|  if (post_syscall_func)
  ------------------
  |  Branch (130:7): [True: 0, False: 353k]
  ------------------
  131|      0|    post_syscall_func ();
  132|   353k|}
assuan_new_ext:
  140|   176k|{
  141|   176k|  struct assuan_context_s wctx;
  142|   176k|  assuan_context_t ctx;
  143|       |
  144|   176k|  if (!_assuan_syscall_func_initialized)
  ------------------
  |  Branch (144:7): [True: 1, False: 176k]
  ------------------
  145|      1|    {
  146|      1|      gpgrt_get_syscall_clamp (&pre_syscall_func, &post_syscall_func);
  147|      1|      _assuan_syscall_func_initialized = 1;
  148|      1|    }
  149|       |
  150|       |  /* Set up a working context so we can use standard functions.  */
  151|   176k|  memset (&wctx, 0, sizeof (wctx));
  152|   176k|  wctx.err_source = err_source;
  153|   176k|  wctx.malloc_hooks = *malloc_hooks;
  154|   176k|  wctx.log_cb = log_cb;
  155|   176k|  wctx.log_cb_data = log_cb_data;
  156|       |
  157|       |  /* Need a new block for the trace macros to work.  */
  158|   176k|  {
  159|   176k|    TRACE_BEG8 (&wctx, ASSUAN_LOG_CTX, "assuan_new_ext", r_ctx,
  ------------------
  |  |  135|   176k|  _TRACE (ctx, lvl, name, tag);						\
  |  |  ------------------
  |  |  |  |   84|   176k|  assuan_context_t _assuan_trace_context = ctx;				\
  |  |  |  |   85|   176k|  int _assuan_trace_level = lvl;					\
  |  |  |  |   86|   176k|  const char *const _assuan_trace_func = name;				\
  |  |  |  |   87|   176k|  const char *const _assuan_trace_tagname = STRINGIFY (tag);		\
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|   176k|#define STRINGIFY(v) #v
  |  |  |  |  ------------------
  |  |  |  |   88|   176k|  void *_assuan_trace_tag = (void *) (uintptr_t) tag
  |  |  ------------------
  |  |  136|   176k|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,            \
  |  |  137|   176k|                 "%s (%s=%p): enter: " fmt "\n",                        \
  |  |  138|   176k|		 _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  139|   176k|		 _assuan_trace_tag, arg1, arg2, arg3, arg4,		\
  |  |  140|   176k|		 arg5, arg6, arg7, arg8)
  ------------------
  160|   176k|		"err_source = %i (%s), malloc_hooks = %p (%p, %p, %p), "
  161|   176k|		"log_cb = %p, log_cb_data = %p", err_source,
  162|   176k|		gpg_strsource (err_source), malloc_hooks, malloc_hooks->malloc,
  163|   176k|		malloc_hooks->realloc, malloc_hooks->free, log_cb, log_cb_data);
  164|       |
  165|   176k|    *r_ctx = NULL;
  166|   176k|    ctx = _assuan_malloc (&wctx, sizeof (*ctx));
  167|   176k|    if (!ctx)
  ------------------
  |  Branch (167:9): [True: 0, False: 176k]
  ------------------
  168|      0|      return TRACE_ERR (gpg_err_code_from_syserror ());
  ------------------
  |  |  169|      0|  err == 0 ? (TRACE_SUC ()) :						\
  |  |  ------------------
  |  |  |  |  190|      0|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,	 \
  |  |  |  |  191|      0|		 "%s (%s=%p): leave\n",				 \
  |  |  |  |  192|      0|		_assuan_trace_func, _assuan_trace_tagname,	 \
  |  |  |  |  193|      0|		_assuan_trace_tag), 0
  |  |  ------------------
  |  |  |  Branch (169:3): [True: 0, False: 0]
  |  |  ------------------
  |  |  170|      0|    (_assuan_debug (_assuan_trace_context, _assuan_trace_level,		\
  |  |  171|      0|		    "%s (%s=%p): error: %s <%s>\n",			\
  |  |  172|      0|		    _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  173|      0|		    _assuan_trace_tag, gpg_strerror (err),		\
  |  |  174|      0|		    ctx?gpg_strsource (ctx->err_source):""),            \
  |  |  ------------------
  |  |  |  Branch (174:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  175|      0|     _assuan_error (ctx, err))
  ------------------
  169|       |
  170|   176k|    memcpy (ctx, &wctx, sizeof (*ctx));
  171|   176k|    ctx->system = _assuan_system_hooks;
  172|       |
  173|       |    /* FIXME: Delegate to subsystems/engines, as the FDs are not our
  174|       |       responsibility (we don't deallocate them, for example).  */
  175|   176k|    ctx->input_fd = ASSUAN_INVALID_FD;
  ------------------
  |  |   86|   176k|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  176|   176k|    ctx->output_fd = ASSUAN_INVALID_FD;
  ------------------
  |  |   86|   176k|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  177|   176k|    ctx->inbound.fd = ASSUAN_INVALID_FD;
  ------------------
  |  |   86|   176k|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  178|   176k|    ctx->outbound.fd = ASSUAN_INVALID_FD;
  ------------------
  |  |   86|   176k|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  179|   176k|    ctx->listen_fd = ASSUAN_INVALID_FD;
  ------------------
  |  |   86|   176k|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  180|       |
  181|   176k|    *r_ctx = ctx;
  182|       |
  183|   176k|    return TRACE_SUC1 ("ctx=%p", ctx);
  ------------------
  |  |  200|   176k|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,		\
  |  |  201|   176k|		 "%s (%s=%p): leave: " fmt "\n",			\
  |  |  202|   176k|		 _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  203|   176k|		 _assuan_trace_tag, arg1), 0
  ------------------
  184|   176k|  }
  185|   176k|}
assuan_new:
  191|   176k|{
  192|   176k|  return assuan_new_ext (r_ctx, _assuan_default_err_source,
  193|   176k|			 &_assuan_default_malloc_hooks,
  194|   176k|			 _assuan_default_log_cb,
  195|   176k|			 _assuan_default_log_cb_data);
  196|   176k|}
_assuan_reset:
  202|   176k|{
  203|   176k|  if (ctx->engine.release)
  ------------------
  |  Branch (203:7): [True: 0, False: 176k]
  ------------------
  204|      0|    {
  205|      0|      (*ctx->engine.release) (ctx);
  206|      0|      ctx->engine.release = NULL;
  207|      0|    }
  208|       |
  209|       |  /* FIXME: Clean standard commands */
  210|   176k|}
assuan_release:
  216|   176k|{
  217|   176k|  if (! ctx)
  ------------------
  |  Branch (217:7): [True: 0, False: 176k]
  ------------------
  218|      0|    return;
  219|       |
  220|   176k|  TRACE (ctx, ASSUAN_LOG_CTX, "assuan_release", ctx);
  ------------------
  |  |  143|   176k|  _assuan_debug (ctx, lvl, "%s (%s=%p): call\n",			\
  |  |  144|   176k|		 name, STRINGIFY (tag), (void *) (uintptr_t) tag)
  |  |  ------------------
  |  |  |  |   35|   176k|#define STRINGIFY(v) #v
  |  |  ------------------
  ------------------
  221|       |
  222|   176k|  _assuan_reset (ctx);
  223|       |  /* None of the members that are our responsibility requires
  224|       |     deallocation.  To avoid sensitive data in the line buffers we
  225|       |     wipe them out, though.  Note that we can't wipe the entire
  226|       |     context because it also has a pointer to the actual free().  */
  227|   176k|  wipememory (&ctx->inbound, sizeof ctx->inbound);
  ------------------
  |  |  410|   176k|#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
  |  |  ------------------
  |  |  |  |  405|   176k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  406|   176k|              volatile char *_vptr=(volatile char *)(_ptr); \
  |  |  |  |  407|   176k|              size_t _vlen=(_len); \
  |  |  |  |  408|   358M|              while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (408:21): [True: 358M, False: 176k]
  |  |  |  |  ------------------
  |  |  |  |  409|   176k|                  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (409:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  228|   176k|  wipememory (&ctx->outbound, sizeof ctx->outbound);
  ------------------
  |  |  410|   176k|#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
  |  |  ------------------
  |  |  |  |  405|   176k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  406|   176k|              volatile char *_vptr=(volatile char *)(_ptr); \
  |  |  |  |  407|   176k|              size_t _vlen=(_len); \
  |  |  |  |  408|   182M|              while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (408:21): [True: 182M, False: 176k]
  |  |  |  |  ------------------
  |  |  |  |  409|   176k|                  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (409:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  229|   176k|  _assuan_free (ctx, ctx);
  230|   176k|}

_assuan_debug:
   48|  1.76M|{
   49|  1.76M|  va_list arg_ptr;
   50|  1.76M|  int saved_errno;
   51|  1.76M|  char *msg;
   52|  1.76M|  int res;
   53|       |
   54|       |  /* vasprintf is an expensive operation thus we first check whether
   55|       |     the callback has enabled CAT for logging.  */
   56|  1.76M|  if (!ctx
  ------------------
  |  Branch (56:7): [True: 0, False: 1.76M]
  ------------------
   57|  1.76M|      || !ctx->log_cb
  ------------------
  |  Branch (57:10): [True: 0, False: 1.76M]
  ------------------
   58|  1.76M|      || !(*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL))
  ------------------
  |  Branch (58:10): [True: 1.76M, False: 0]
  ------------------
   59|  1.76M|    return;
   60|       |
   61|      0|  saved_errno = errno;
   62|      0|  va_start (arg_ptr, format);
   63|      0|  res = gpgrt_vasprintf (&msg, format, arg_ptr);
   64|      0|  va_end (arg_ptr);
   65|      0|  if (res < 0)
  ------------------
  |  Branch (65:7): [True: 0, False: 0]
  ------------------
   66|      0|    return;
   67|      0|  ctx->log_cb (ctx, ctx->log_cb_data, cat, msg);
   68|      0|  gpgrt_free (msg);
   69|      0|  gpg_err_set_errno (saved_errno);
   70|      0|}

__assuan_close:
  103|   176k|{
  104|   176k|  return close (fd);
  105|   176k|}
__assuan_socket:
  421|   176k|{
  422|   176k|  return socket (namespace, style, protocol);
  423|   176k|}
__assuan_connect:
  429|   176k|{
  430|   176k|  return connect (sock, addr, length);
  431|   176k|}

_assuan_malloc:
   49|   176k|{
   50|   176k|  return ctx->malloc_hooks.malloc (cnt);
   51|   176k|}
_assuan_free:
   82|   176k|{
   83|   176k|  if (ptr)
  ------------------
  |  Branch (83:7): [True: 176k, False: 0]
  ------------------
   84|   176k|    ctx->malloc_hooks.free (ptr);
   85|   176k|}
_assuan_close:
  181|   176k|{
  182|   176k|  TRACE1 (ctx, ASSUAN_LOG_SYSIO, "_assuan_close", ctx,
  ------------------
  |  |  149|   176k|  _assuan_debug (ctx, lvl, "%s (%s=%p): call: " fmt "\n",		\
  |  |  150|   176k|		 name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1)
  |  |  ------------------
  |  |  |  |   35|   176k|#define STRINGIFY(v) #v
  |  |  ------------------
  ------------------
  183|   176k|	  "fd=0x%x", fd);
  184|       |
  185|   176k|  if (ctx->system.version)
  ------------------
  |  Branch (185:7): [True: 0, False: 176k]
  ------------------
  186|      0|    return (ctx->system.close) (ctx, fd);
  187|   176k|  else
  188|   176k|    {
  189|   176k|      int res;
  190|   176k|      _assuan_pre_syscall ();
  191|   176k|      res = __assuan_close (ctx, fd);
  192|   176k|      _assuan_post_syscall ();
  193|   176k|      return res;
  194|   176k|    }
  195|   176k|}
_assuan_socket:
  505|   176k|{
  506|   176k|  assuan_fd_t res;
  507|   176k|  TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_socket", ctx,
  ------------------
  |  |  115|   176k|  _TRACE (ctx, lvl, name, tag);					      \
  |  |  ------------------
  |  |  |  |   84|   176k|  assuan_context_t _assuan_trace_context = ctx;				\
  |  |  |  |   85|   176k|  int _assuan_trace_level = lvl;					\
  |  |  |  |   86|   176k|  const char *const _assuan_trace_func = name;				\
  |  |  |  |   87|   176k|  const char *const _assuan_trace_tagname = STRINGIFY (tag);		\
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|   176k|#define STRINGIFY(v) #v
  |  |  |  |  ------------------
  |  |  |  |   88|   176k|  void *_assuan_trace_tag = (void *) (uintptr_t) tag
  |  |  ------------------
  |  |  116|   176k|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,	      \
  |  |  117|   176k|		 "%s (%s=%p): enter: " fmt "\n",		      \
  |  |  118|   176k|		 _assuan_trace_func, _assuan_trace_tagname,	      \
  |  |  119|   176k|		 _assuan_trace_tag, arg1, arg2, arg3)
  ------------------
  508|   176k|	      "namespace=%i,style=%i,protocol=%i",
  509|   176k|	      namespace, style, protocol);
  510|       |
  511|   176k|  if (ctx->system.version)
  ------------------
  |  Branch (511:7): [True: 0, False: 176k]
  ------------------
  512|      0|    res = (ctx->system.socket) (ctx, namespace, style, protocol);
  513|   176k|  else
  514|   176k|    res = __assuan_socket (ctx, namespace, style, protocol);
  515|   176k|  return TRACE_SYSRES (res);
  ------------------
  |  |  179|   176k|  res >= 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) :		\
  |  |  ------------------
  |  |  |  |  200|   176k|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,		\
  |  |  |  |  201|   176k|		 "%s (%s=%p): leave: " fmt "\n",			\
  |  |  |  |  202|   176k|		 _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  |  |  203|   176k|		 _assuan_trace_tag, arg1), 0
  |  |  ------------------
  |  |  |  Branch (179:3): [True: 176k, False: 0]
  |  |  ------------------
  |  |  180|   176k|    (_assuan_debug (_assuan_trace_context, _assuan_trace_level, "%s (%s=%p): error: %s\n", \
  |  |  181|      0|		    _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  182|      0|		   _assuan_trace_tag, strerror (errno)), (res))
  ------------------
  516|   176k|}
_assuan_connect:
  522|   176k|{
  523|   176k|  int res;
  524|   176k|  TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_connect", ctx,
  ------------------
  |  |  115|   176k|  _TRACE (ctx, lvl, name, tag);					      \
  |  |  ------------------
  |  |  |  |   84|   176k|  assuan_context_t _assuan_trace_context = ctx;				\
  |  |  |  |   85|   176k|  int _assuan_trace_level = lvl;					\
  |  |  |  |   86|   176k|  const char *const _assuan_trace_func = name;				\
  |  |  |  |   87|   176k|  const char *const _assuan_trace_tagname = STRINGIFY (tag);		\
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|   176k|#define STRINGIFY(v) #v
  |  |  |  |  ------------------
  |  |  |  |   88|   176k|  void *_assuan_trace_tag = (void *) (uintptr_t) tag
  |  |  ------------------
  |  |  116|   176k|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,	      \
  |  |  117|   176k|		 "%s (%s=%p): enter: " fmt "\n",		      \
  |  |  118|   176k|		 _assuan_trace_func, _assuan_trace_tagname,	      \
  |  |  119|   176k|		 _assuan_trace_tag, arg1, arg2, arg3)
  ------------------
  525|   176k|	      "socket=%i,addr=%p,length=%i", sock, addr, length);
  526|       |
  527|   176k|  if (ctx->system.version)
  ------------------
  |  Branch (527:7): [True: 0, False: 176k]
  ------------------
  528|      0|    res = (ctx->system.connect) (ctx, sock, addr, length);
  529|   176k|  else
  530|   176k|    {
  531|   176k|      _assuan_pre_syscall ();
  532|   176k|      res = __assuan_connect (ctx, sock, addr, length);
  533|   176k|      _assuan_post_syscall ();
  534|   176k|    }
  535|   176k|  return TRACE_SYSRES (res);
  ------------------
  |  |  179|   176k|  res >= 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) :		\
  |  |  ------------------
  |  |  |  |  200|      0|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,		\
  |  |  |  |  201|      0|		 "%s (%s=%p): leave: " fmt "\n",			\
  |  |  |  |  202|      0|		 _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  |  |  203|      0|		 _assuan_trace_tag, arg1), 0
  |  |  ------------------
  |  |  |  Branch (179:3): [True: 0, False: 176k]
  |  |  ------------------
  |  |  180|   176k|    (_assuan_debug (_assuan_trace_context, _assuan_trace_level, "%s (%s=%p): error: %s\n", \
  |  |  181|   176k|		    _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  182|   176k|		   _assuan_trace_tag, strerror (errno)), (res))
  ------------------
  536|   176k|}

sha1.c:_gcry_ctz:
   84|  83.0k|{
   85|  83.0k|#if defined (HAVE_BUILTIN_CTZ)
   86|  83.0k|  return x ? __builtin_ctz (x) : 8 * sizeof (x);
  ------------------
  |  Branch (86:10): [True: 83.0k, False: 0]
  ------------------
   87|       |#else
   88|       |  /* See
   89|       |   * http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightModLookup
   90|       |   */
   91|       |  static const unsigned char mod37[] =
   92|       |    {
   93|       |      sizeof (unsigned int)*8,
   94|       |          0,  1, 26,  2, 23, 27,  0,  3, 16, 24, 30, 28, 11,  0, 13,
   95|       |      4,  7, 17,  0, 25, 22, 31, 15, 29, 10, 12,  6,  0, 21, 14,  9,
   96|       |      5, 20,  8, 19, 18
   97|       |    };
   98|       |  return (int)mod37[(-x & x) % 37];
   99|       |#endif
  100|  83.0k|}
sha256.c:_gcry_ctz:
   84|  2.45k|{
   85|  2.45k|#if defined (HAVE_BUILTIN_CTZ)
   86|  2.45k|  return x ? __builtin_ctz (x) : 8 * sizeof (x);
  ------------------
  |  Branch (86:10): [True: 2.45k, False: 0]
  ------------------
   87|       |#else
   88|       |  /* See
   89|       |   * http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightModLookup
   90|       |   */
   91|       |  static const unsigned char mod37[] =
   92|       |    {
   93|       |      sizeof (unsigned int)*8,
   94|       |          0,  1, 26,  2, 23, 27,  0,  3, 16, 24, 30, 28, 11,  0, 13,
   95|       |      4,  7, 17,  0, 25, 22, 31, 15, 29, 10, 12,  6,  0, 21, 14,  9,
   96|       |      5, 20,  8, 19, 18
   97|       |    };
   98|       |  return (int)mod37[(-x & x) % 37];
   99|       |#endif
  100|  2.45k|}

sha1.c:buf_put_be32:
  141|   443k|{
  142|   443k|  bufhelp_u32_t *out = _buf;
  143|   443k|  out->a = be_bswap32(val);
  ------------------
  |  |   73|   443k|# define be_bswap32(x) _gcry_bswap32(x)
  |  |  ------------------
  |  |  |  |   46|   443k|# define _gcry_bswap32 __builtin_bswap32
  |  |  ------------------
  ------------------
  144|   443k|}
sha256.c:buf_put_be32:
  141|  24.5k|{
  142|  24.5k|  bufhelp_u32_t *out = _buf;
  143|  24.5k|  out->a = be_bswap32(val);
  ------------------
  |  |   73|  24.5k|# define be_bswap32(x) _gcry_bswap32(x)
  |  |  ------------------
  |  |  |  |   46|  24.5k|# define _gcry_bswap32 __builtin_bswap32
  |  |  ------------------
  ------------------
  144|  24.5k|}
crc.c:buf_put_le32:
  147|  11.5k|{
  148|  11.5k|  bufhelp_u32_t *out = _buf;
  149|  11.5k|  out->a = le_bswap32(val);
  ------------------
  |  |   72|  11.5k|# define le_bswap32(x) ((u32)(x))
  ------------------
  150|  11.5k|}
hash-common.c:buf_cpy:
  203|   158k|{
  204|   158k|  byte *dst = _dst;
  205|   158k|  const byte *src = _src;
  206|       |
  207|   158k|#if __GNUC__ >= 4
  208|   158k|  if (!__builtin_constant_p (len))
  ------------------
  |  Branch (208:7): [True: 158k, False: 0]
  ------------------
  209|   158k|    {
  210|   158k|      if (UNLIKELY(len == 0))
  ------------------
  |  |   86|   158k|#define UNLIKELY(expr)    __builtin_expect( !!(expr), 0 )
  |  |  ------------------
  |  |  |  Branch (86:27): [True: 0, False: 158k]
  |  |  ------------------
  ------------------
  211|      0|	return;
  212|   158k|      memcpy(_dst, _src, len);
  213|   158k|      return;
  214|   158k|    }
  215|      0|#endif
  216|       |
  217|      0|  while (len >= sizeof(u64))
  ------------------
  |  Branch (217:10): [True: 0, False: 0]
  ------------------
  218|      0|    {
  219|      0|      buf_put_he64(dst, buf_get_he64(src));
  ------------------
  |  |  195|      0|# define buf_put_he64 buf_put_le64
  ------------------
                    buf_put_he64(dst, buf_get_he64(src));
  ------------------
  |  |  194|      0|# define buf_get_he64 buf_get_le64
  ------------------
  220|      0|      dst += sizeof(u64);
  221|      0|      src += sizeof(u64);
  222|      0|      len -= sizeof(u64);
  223|      0|    }
  224|       |
  225|      0|  if (len >= sizeof(u32))
  ------------------
  |  Branch (225:7): [True: 0, False: 0]
  ------------------
  226|      0|    {
  227|      0|      buf_put_he32(dst, buf_get_he32(src));
  ------------------
  |  |  193|      0|# define buf_put_he32 buf_put_le32
  ------------------
                    buf_put_he32(dst, buf_get_he32(src));
  ------------------
  |  |  192|      0|# define buf_get_he32 buf_get_le32
  ------------------
  228|      0|      dst += sizeof(u32);
  229|      0|      src += sizeof(u32);
  230|      0|      len -= sizeof(u32);
  231|      0|    }
  232|       |
  233|       |  /* Handle tail.  */
  234|      0|  for (; len; len--)
  ------------------
  |  Branch (234:10): [True: 0, False: 0]
  ------------------
  235|      0|    *dst++ = *src++;
  236|      0|}

_gcry_cipher_algo_info:
 1893|   142k|{
 1894|   142k|  gcry_err_code_t rc = 0;
 1895|   142k|  unsigned int ui;
 1896|       |
 1897|   142k|  switch (what)
 1898|   142k|    {
 1899|      0|    case GCRYCTL_GET_KEYLEN:
  ------------------
  |  Branch (1899:5): [True: 0, False: 142k]
  ------------------
 1900|      0|      if (buffer || (! nbytes))
  ------------------
  |  Branch (1900:11): [True: 0, False: 0]
  |  Branch (1900:21): [True: 0, False: 0]
  ------------------
 1901|      0|	rc = GPG_ERR_CIPHER_ALGO;
 1902|      0|      else
 1903|      0|	{
 1904|      0|	  ui = cipher_get_keylen (algo);
 1905|      0|	  if ((ui > 0) && (ui <= 512))
  ------------------
  |  Branch (1905:8): [True: 0, False: 0]
  |  Branch (1905:20): [True: 0, False: 0]
  ------------------
 1906|      0|	    *nbytes = (size_t) ui / 8;
 1907|      0|	  else
 1908|       |	    /* The only reason for an error is an invalid algo.  */
 1909|      0|	    rc = GPG_ERR_CIPHER_ALGO;
 1910|      0|	}
 1911|      0|      break;
 1912|       |
 1913|      0|    case GCRYCTL_GET_BLKLEN:
  ------------------
  |  Branch (1913:5): [True: 0, False: 142k]
  ------------------
 1914|      0|      if (buffer || (! nbytes))
  ------------------
  |  Branch (1914:11): [True: 0, False: 0]
  |  Branch (1914:21): [True: 0, False: 0]
  ------------------
 1915|      0|	rc = GPG_ERR_CIPHER_ALGO;
 1916|      0|      else
 1917|      0|	{
 1918|      0|	  ui = cipher_get_blocksize (algo);
 1919|      0|	  if ((ui > 0) && (ui < 10000))
  ------------------
  |  Branch (1919:8): [True: 0, False: 0]
  |  Branch (1919:20): [True: 0, False: 0]
  ------------------
 1920|      0|	    *nbytes = ui;
 1921|      0|	  else
 1922|      0|            {
 1923|       |              /* The only reason is an invalid algo or a strange
 1924|       |                 blocksize.  */
 1925|      0|              rc = GPG_ERR_CIPHER_ALGO;
 1926|      0|            }
 1927|      0|	}
 1928|      0|      break;
 1929|       |
 1930|   142k|    case GCRYCTL_TEST_ALGO:
  ------------------
  |  Branch (1930:5): [True: 142k, False: 0]
  ------------------
 1931|   142k|      if (buffer || nbytes)
  ------------------
  |  Branch (1931:11): [True: 0, False: 142k]
  |  Branch (1931:21): [True: 0, False: 142k]
  ------------------
 1932|      0|	rc = GPG_ERR_INV_ARG;
 1933|   142k|      else
 1934|   142k|	rc = check_cipher_algo (algo);
 1935|   142k|      break;
 1936|       |
 1937|      0|      default:
  ------------------
  |  Branch (1937:7): [True: 0, False: 142k]
  ------------------
 1938|      0|	rc = GPG_ERR_INV_OP;
 1939|   142k|    }
 1940|       |
 1941|   142k|  return rc;
 1942|   142k|}
_gcry_cipher_init:
 1984|      1|{
 1985|      1|  return 0;
 1986|      1|}
cipher.c:spec_from_algo:
  231|   142k|{
  232|   142k|  gcry_cipher_spec_t *spec = NULL;
  233|       |
  234|   142k|  algo = map_algo (algo);
  235|       |
  236|   142k|  if (algo >= 0 && algo < DIM(cipher_list_algo0))
  ------------------
  |  |  104|   142k|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (236:7): [True: 142k, False: 0]
  |  Branch (236:20): [True: 136k, False: 5.87k]
  ------------------
  237|   136k|    spec = cipher_list_algo0[algo];
  238|  5.87k|  else if (algo >= 301 && algo < 301 + DIM(cipher_list_algo301))
  ------------------
  |  |  104|  5.87k|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (238:12): [True: 5.87k, False: 0]
  |  Branch (238:27): [True: 5.87k, False: 0]
  ------------------
  239|  5.87k|    spec = cipher_list_algo301[algo - 301];
  240|       |
  241|   142k|  if (spec)
  ------------------
  |  Branch (241:7): [True: 142k, False: 0]
  ------------------
  242|   142k|    gcry_assert (spec->algo == algo);
  ------------------
  |  |  188|   142k|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|   142k|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 142k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|   142k|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  243|       |
  244|      0|  return spec;
  245|   142k|}
cipher.c:map_algo:
  222|   142k|{
  223|   142k|  return algo;
  224|   142k|}
cipher.c:check_cipher_algo:
  411|   142k|{
  412|   142k|  gcry_cipher_spec_t *spec;
  413|       |
  414|   142k|  spec = spec_from_algo (algorithm);
  415|   142k|  if (spec && !spec->flags.disabled && (spec->flags.fips || !fips_mode ()))
  ------------------
  |  |  449|   120k|#define fips_mode() (!_gcry_no_fips_mode_required)
  ------------------
  |  Branch (415:7): [True: 142k, False: 0]
  |  Branch (415:15): [True: 142k, False: 0]
  |  Branch (415:41): [True: 21.2k, False: 120k]
  |  Branch (415:61): [True: 120k, False: 0]
  ------------------
  416|   142k|    return 0;
  417|       |
  418|      0|  return GPG_ERR_CIPHER_ALGO;
  419|   142k|}

crc.c:crc32_read:
  485|    626|{
  486|    626|  CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
  487|    626|  return ctx->buf;
  488|    626|}
crc.c:crc24rfc2440_init:
  840|  15.4k|{
  841|  15.4k|  CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
  842|  15.4k|  u32 hwf = _gcry_get_hw_features ();
  843|       |
  844|  15.4k|#ifdef USE_INTEL_PCLMUL
  845|  15.4k|  ctx->use_pclmul = (hwf & HWF_INTEL_SSE4_1) && (hwf & HWF_INTEL_PCLMUL);
  ------------------
  |  |  230|  15.4k|#define HWF_INTEL_SSE4_1        (1 << 8)
  ------------------
                ctx->use_pclmul = (hwf & HWF_INTEL_SSE4_1) && (hwf & HWF_INTEL_PCLMUL);
  ------------------
  |  |  231|  15.4k|#define HWF_INTEL_PCLMUL        (1 << 9)
  ------------------
  |  Branch (845:21): [True: 15.4k, False: 0]
  |  Branch (845:49): [True: 15.4k, False: 0]
  ------------------
  846|  15.4k|#endif
  847|       |#ifdef USE_ARM_PMULL
  848|       |  ctx->use_pmull = (hwf & HWF_ARM_NEON) && (hwf & HWF_ARM_PMULL);
  849|       |#endif
  850|       |#ifdef USE_PPC_VPMSUM
  851|       |  ctx->use_vpmsum = !!(hwf & HWF_PPC_ARCH_2_07);
  852|       |#endif
  853|       |
  854|  15.4k|  (void)hwf;
  855|  15.4k|  (void)flags;
  856|       |
  857|  15.4k|  ctx->CRC = crc24_init();
  858|  15.4k|}
crc.c:crc24_init:
  807|  15.4k|{
  808|       |  /* Transformed to 32-bit CRC by multiplied by x⁸ and then byte swapped. */
  809|  15.4k|  return 0xce04b7; /* _gcry_bswap(0xb704ce << 8) */
  810|  15.4k|}
crc.c:crc24rfc2440_write:
  862|  7.08k|{
  863|  7.08k|  const unsigned char *inbuf = inbuf_arg;
  864|  7.08k|  CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
  865|  7.08k|  u32 crc;
  866|       |
  867|  7.08k|#ifdef USE_INTEL_PCLMUL
  868|  7.08k|  if (ctx->use_pclmul)
  ------------------
  |  Branch (868:7): [True: 7.08k, False: 0]
  ------------------
  869|  7.08k|    {
  870|  7.08k|      _gcry_crc24rfc2440_intel_pclmul(&ctx->CRC, inbuf, inlen);
  871|  7.08k|      return;
  872|  7.08k|    }
  873|      0|#endif
  874|       |#ifdef USE_ARM_PMULL
  875|       |  if (ctx->use_pmull)
  876|       |    {
  877|       |      _gcry_crc24rfc2440_armv8_ce_pmull(&ctx->CRC, inbuf, inlen);
  878|       |      return;
  879|       |    }
  880|       |#endif
  881|       |#ifdef USE_PPC_VPMSUM
  882|       |  if (ctx->use_vpmsum)
  883|       |    {
  884|       |      _gcry_crc24rfc2440_ppc8_vpmsum(&ctx->CRC, inbuf, inlen);
  885|       |      return;
  886|       |    }
  887|       |#endif
  888|       |
  889|      0|  if (!inbuf || !inlen)
  ------------------
  |  Branch (889:7): [True: 0, False: 0]
  |  Branch (889:17): [True: 0, False: 0]
  ------------------
  890|      0|    return;
  891|       |
  892|      0|  crc = ctx->CRC;
  893|       |
  894|      0|  while (inlen >= 16)
  ------------------
  |  Branch (894:10): [True: 0, False: 0]
  ------------------
  895|      0|    {
  896|      0|      inlen -= 16;
  897|      0|      crc = crc24_next4(crc, buf_get_le32(&inbuf[0]));
  898|      0|      crc = crc24_next4(crc, buf_get_le32(&inbuf[4]));
  899|      0|      crc = crc24_next4(crc, buf_get_le32(&inbuf[8]));
  900|      0|      crc = crc24_next4(crc, buf_get_le32(&inbuf[12]));
  901|      0|      inbuf += 16;
  902|      0|    }
  903|       |
  904|      0|  while (inlen >= 4)
  ------------------
  |  Branch (904:10): [True: 0, False: 0]
  ------------------
  905|      0|    {
  906|      0|      inlen -= 4;
  907|      0|      crc = crc24_next4(crc, buf_get_le32(inbuf));
  908|      0|      inbuf += 4;
  909|      0|    }
  910|       |
  911|      0|  while (inlen--)
  ------------------
  |  Branch (911:10): [True: 0, False: 0]
  ------------------
  912|      0|    {
  913|      0|      crc = crc24_next(crc, *inbuf++);
  914|      0|    }
  915|       |
  916|      0|  ctx->CRC = crc;
  917|      0|}
crc.c:crc24rfc2440_final:
  921|  11.5k|{
  922|  11.5k|  CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
  923|  11.5k|  ctx->CRC = crc24_final(ctx->CRC);
  924|  11.5k|  buf_put_le32 (ctx->buf, ctx->CRC);
  925|  11.5k|}
crc.c:crc24_final:
  834|  11.5k|{
  835|  11.5k|  return crc & 0xffffff;
  836|  11.5k|}

_gcry_md_block_write:
  121|   158k|{
  122|   158k|  const unsigned char *inbuf = inbuf_arg;
  123|   158k|  gcry_md_block_ctx_t *hd = context;
  124|   158k|  unsigned int stack_burn = 0;
  125|   158k|  unsigned int nburn;
  126|   158k|  const unsigned int blocksize_shift = hd->blocksize_shift;
  127|   158k|  const unsigned int blocksize = 1 << blocksize_shift;
  128|   158k|  size_t inblocks;
  129|   158k|  size_t copylen;
  130|       |
  131|   158k|  if (sizeof(hd->buf) < blocksize)
  ------------------
  |  Branch (131:7): [True: 0, False: 158k]
  ------------------
  132|      0|    BUG();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  133|       |
  134|   158k|  if (!hd->bwrite)
  ------------------
  |  Branch (134:7): [True: 0, False: 158k]
  ------------------
  135|      0|    return;
  136|       |
  137|   158k|  if (hd->count > blocksize)
  ------------------
  |  Branch (137:7): [True: 0, False: 158k]
  ------------------
  138|      0|    {
  139|       |      /* This happens only when gcry_md_write is called after final.
  140|       |       * Writing after final is used for mitigating timing attacks. */
  141|      0|      hd->count = 0;
  142|      0|    }
  143|       |
  144|   252k|  while (hd->count)
  ------------------
  |  Branch (144:10): [True: 185k, False: 66.7k]
  ------------------
  145|   185k|    {
  146|   185k|      if (hd->count == blocksize)  /* Flush the buffer. */
  ------------------
  |  Branch (146:11): [True: 832, False: 184k]
  ------------------
  147|    832|	{
  148|    832|	  nburn = hd->bwrite (hd, hd->buf, 1);
  149|    832|	  stack_burn = nburn > stack_burn ? nburn : stack_burn;
  ------------------
  |  Branch (149:17): [True: 0, False: 832]
  ------------------
  150|    832|	  hd->count = 0;
  151|    832|	  if (!++hd->nblocks)
  ------------------
  |  Branch (151:8): [True: 0, False: 832]
  ------------------
  152|      0|	    hd->nblocks_high++;
  153|    832|	}
  154|   184k|      else
  155|   184k|	{
  156|   184k|	  copylen = inlen;
  157|   184k|	  if (copylen > blocksize - hd->count)
  ------------------
  |  Branch (157:8): [True: 783, False: 183k]
  ------------------
  158|    783|	    copylen = blocksize - hd->count;
  159|       |
  160|   184k|	  if (copylen == 0)
  ------------------
  |  Branch (160:8): [True: 91.8k, False: 92.6k]
  ------------------
  161|  91.8k|	    break;
  162|       |
  163|  92.6k|	  buf_cpy (&hd->buf[hd->count], inbuf, copylen);
  164|  92.6k|	  hd->count += copylen;
  165|  92.6k|	  inbuf += copylen;
  166|  92.6k|	  inlen -= copylen;
  167|  92.6k|	}
  168|   185k|    }
  169|       |
  170|   158k|  if (inlen == 0)
  ------------------
  |  Branch (170:7): [True: 91.8k, False: 66.6k]
  ------------------
  171|  91.8k|    return;
  172|       |
  173|  66.6k|  if (inlen >= blocksize)
  ------------------
  |  Branch (173:7): [True: 20.1k, False: 46.5k]
  ------------------
  174|  20.1k|    {
  175|  20.1k|      inblocks = inlen >> blocksize_shift;
  176|  20.1k|      nburn = hd->bwrite (hd, inbuf, inblocks);
  177|  20.1k|      stack_burn = nburn > stack_burn ? nburn : stack_burn;
  ------------------
  |  Branch (177:20): [True: 0, False: 20.1k]
  ------------------
  178|  20.1k|      hd->count = 0;
  179|  20.1k|      hd->nblocks_high += (hd->nblocks + inblocks < inblocks);
  180|  20.1k|      hd->nblocks += inblocks;
  181|  20.1k|      inlen -= inblocks << blocksize_shift;
  182|  20.1k|      inbuf += inblocks << blocksize_shift;
  183|  20.1k|    }
  184|       |
  185|  66.6k|  if (inlen)
  ------------------
  |  Branch (185:7): [True: 66.3k, False: 398]
  ------------------
  186|  66.3k|    {
  187|  66.3k|      buf_cpy (hd->buf, inbuf, inlen);
  188|  66.3k|      hd->count = inlen;
  189|  66.3k|    }
  190|       |
  191|  66.6k|  if (stack_burn > 0)
  ------------------
  |  Branch (191:7): [True: 0, False: 66.6k]
  ------------------
  192|      0|    _gcry_burn_stack (stack_burn);
  ------------------
  |  |  371|      0|	do { __gcry_burn_stack (bytes); \
  |  |  372|      0|	     __gcry_burn_stack_dummy (); } while(0)
  |  |  ------------------
  |  |  |  |  364|      0|#define  __gcry_burn_stack_dummy() asm volatile ("":::"memory")
  |  |  ------------------
  |  |  |  Branch (372:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  193|  66.6k|}

_gcry_mac_init:
  384|      1|{
  385|      1|  return 0;
  386|      1|}

_gcry_md_open:
  530|  48.9k|{
  531|  48.9k|  gcry_err_code_t rc;
  532|  48.9k|  gcry_md_hd_t hd;
  533|       |
  534|  48.9k|  if ((flags & ~(GCRY_MD_FLAG_SECURE
  ------------------
  |  Branch (534:7): [True: 0, False: 48.9k]
  ------------------
  535|  48.9k|                 | GCRY_MD_FLAG_HMAC
  536|  48.9k|                 | GCRY_MD_FLAG_BUGEMU1)))
  537|      0|    rc = GPG_ERR_INV_ARG;
  538|  48.9k|  else
  539|  48.9k|    rc = md_open (&hd, algo, flags);
  540|       |
  541|  48.9k|  *h = rc? NULL : hd;
  ------------------
  |  Branch (541:8): [True: 0, False: 48.9k]
  ------------------
  542|  48.9k|  return rc;
  543|  48.9k|}
_gcry_md_reset:
  700|  12.8k|{
  701|  12.8k|  GcryDigestEntry *r;
  702|       |
  703|       |  /* Note: We allow this even in fips non operational mode.  */
  704|       |
  705|  12.8k|  a->bufpos = a->ctx->flags.finalized = 0;
  706|       |
  707|  12.8k|  if (a->ctx->flags.hmac)
  ------------------
  |  Branch (707:7): [True: 0, False: 12.8k]
  ------------------
  708|      0|    for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (708:28): [True: 0, False: 0]
  ------------------
  709|      0|      {
  710|      0|        memcpy (r->context, (char *)r->context + r->spec->contextsize,
  711|      0|                r->spec->contextsize);
  712|      0|      }
  713|  12.8k|  else
  714|  25.6k|    for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (714:28): [True: 12.8k, False: 12.8k]
  ------------------
  715|  12.8k|      {
  716|  12.8k|        memset (r->context, 0, r->spec->contextsize);
  717|  12.8k|        (*r->spec->init) (r->context,
  718|  12.8k|                          a->ctx->flags.bugemu1? GCRY_MD_FLAG_BUGEMU1:0);
  ------------------
  |  Branch (718:27): [True: 0, False: 12.8k]
  ------------------
  719|  12.8k|      }
  720|  12.8k|}
_gcry_md_close:
  746|  79.7k|{
  747|       |  /* Note: We allow this even in fips non operational mode.  */
  748|  79.7k|  md_close (hd);
  749|  79.7k|}
_gcry_md_write:
  780|  99.8k|{
  781|  99.8k|  md_write (hd, inbuf, inlen);
  782|  99.8k|}
_gcry_md_ctl:
 1001|   104k|{
 1002|   104k|  gcry_err_code_t rc = 0;
 1003|       |
 1004|   104k|  (void)buflen; /* Currently not used.  */
 1005|       |
 1006|   104k|  switch (cmd)
 1007|   104k|    {
 1008|   104k|    case GCRYCTL_FINALIZE:
  ------------------
  |  Branch (1008:5): [True: 104k, False: 0]
  ------------------
 1009|   104k|      md_final (hd);
 1010|   104k|      break;
 1011|      0|    case GCRYCTL_START_DUMP:
  ------------------
  |  Branch (1011:5): [True: 0, False: 104k]
  ------------------
 1012|      0|      md_start_debug (hd, buffer);
 1013|      0|      break;
 1014|      0|    case GCRYCTL_STOP_DUMP:
  ------------------
  |  Branch (1014:5): [True: 0, False: 104k]
  ------------------
 1015|      0|      md_stop_debug ( hd );
 1016|      0|      break;
 1017|      0|    default:
  ------------------
  |  Branch (1017:5): [True: 0, False: 104k]
  ------------------
 1018|      0|      rc = GPG_ERR_INV_OP;
 1019|   104k|    }
 1020|   104k|  return rc;
 1021|   104k|}
_gcry_md_read:
 1103|  46.9k|{
 1104|       |  /* This function is expected to always return a digest, thus we
 1105|       |     can't return an error which we actually should do in
 1106|       |     non-operational state.  */
 1107|  46.9k|  _gcry_md_ctl (hd, GCRYCTL_FINALIZE, NULL, 0);
 1108|  46.9k|  return md_read (hd, algo);
 1109|  46.9k|}
_gcry_md_get_algo:
 1356|  46.2k|{
 1357|  46.2k|  return md_get_algo (hd);
 1358|  46.2k|}
_gcry_md_get_algo_dlen:
 1380|  49.3k|{
 1381|  49.3k|  return md_digest_length (algorithm);
 1382|  49.3k|}
_gcry_md_algo_info:
 1429|  10.1k|{
 1430|  10.1k|  gcry_err_code_t rc;
 1431|       |
 1432|  10.1k|  switch (what)
 1433|  10.1k|    {
 1434|  10.1k|    case GCRYCTL_TEST_ALGO:
  ------------------
  |  Branch (1434:5): [True: 10.1k, False: 0]
  ------------------
 1435|  10.1k|      if (buffer || nbytes)
  ------------------
  |  Branch (1435:11): [True: 0, False: 10.1k]
  |  Branch (1435:21): [True: 0, False: 10.1k]
  ------------------
 1436|      0|	rc = GPG_ERR_INV_ARG;
 1437|  10.1k|      else
 1438|  10.1k|	rc = check_digest_algo (algo);
 1439|  10.1k|      break;
 1440|       |
 1441|      0|    case GCRYCTL_GET_ASNOID:
  ------------------
  |  Branch (1441:5): [True: 0, False: 10.1k]
  ------------------
 1442|       |      /* We need to check that the algo is available because
 1443|       |         md_asn_oid would otherwise raise an assertion. */
 1444|      0|      rc = check_digest_algo (algo);
 1445|      0|      if (!rc)
  ------------------
  |  Branch (1445:11): [True: 0, False: 0]
  ------------------
 1446|      0|        {
 1447|      0|          const char unsigned *asn;
 1448|      0|          size_t asnlen;
 1449|       |
 1450|      0|          asn = md_asn_oid (algo, &asnlen, NULL);
 1451|      0|          if (buffer && (*nbytes >= asnlen))
  ------------------
  |  Branch (1451:15): [True: 0, False: 0]
  |  Branch (1451:25): [True: 0, False: 0]
  ------------------
 1452|      0|            {
 1453|      0|              memcpy (buffer, asn, asnlen);
 1454|      0|              *nbytes = asnlen;
 1455|      0|            }
 1456|      0|          else if (!buffer && nbytes)
  ------------------
  |  Branch (1456:20): [True: 0, False: 0]
  |  Branch (1456:31): [True: 0, False: 0]
  ------------------
 1457|      0|            *nbytes = asnlen;
 1458|      0|          else
 1459|      0|            {
 1460|      0|              if (buffer)
  ------------------
  |  Branch (1460:19): [True: 0, False: 0]
  ------------------
 1461|      0|                rc = GPG_ERR_TOO_SHORT;
 1462|      0|              else
 1463|      0|                rc = GPG_ERR_INV_ARG;
 1464|      0|            }
 1465|      0|        }
 1466|      0|      break;
 1467|       |
 1468|      0|    case GCRYCTL_SELFTEST:
  ------------------
  |  Branch (1468:5): [True: 0, False: 10.1k]
  ------------------
 1469|       |      /* Helper function for the regression tests.  */
 1470|      0|      rc = gpg_err_code (_gcry_md_selftest (algo, nbytes? (int)*nbytes : 0,
  ------------------
  |  Branch (1470:51): [True: 0, False: 0]
  ------------------
 1471|      0|                                             NULL));
 1472|      0|      break;
 1473|       |
 1474|      0|    default:
  ------------------
  |  Branch (1474:5): [True: 0, False: 10.1k]
  ------------------
 1475|      0|      rc = GPG_ERR_INV_OP;
 1476|      0|      break;
 1477|  10.1k|  }
 1478|       |
 1479|  10.1k|  return rc;
 1480|  10.1k|}
_gcry_md_init:
 1581|      1|{
 1582|      1|  return 0;
 1583|      1|}
md.c:spec_from_algo:
  301|   108k|{
  302|   108k|  const gcry_md_spec_t *spec = NULL;
  303|       |
  304|   108k|  algo = map_algo (algo);
  305|       |
  306|   108k|  if (algo >= 0 && algo < DIM(digest_list_algo0))
  ------------------
  |  |  104|   108k|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (306:7): [True: 108k, False: 0]
  |  Branch (306:20): [True: 105k, False: 2.68k]
  ------------------
  307|   105k|    spec = digest_list_algo0[algo];
  308|  2.68k|  else if (algo >= 301 && algo < 301 + DIM(digest_list_algo301))
  ------------------
  |  |  104|  2.68k|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (308:12): [True: 2.68k, False: 0]
  |  Branch (308:27): [True: 2.68k, False: 0]
  ------------------
  309|  2.68k|    spec = digest_list_algo301[algo - 301];
  310|       |
  311|   108k|  if (spec)
  ------------------
  |  Branch (311:7): [True: 108k, False: 223]
  ------------------
  312|   108k|    gcry_assert (spec->algo == algo);
  ------------------
  |  |  188|   108k|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|   108k|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 108k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|   108k|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  313|       |
  314|      0|  return spec;
  315|   108k|}
md.c:map_algo:
  292|   108k|{
  293|   108k|  return algo;
  294|   108k|}
md.c:md_open:
  450|  48.9k|{
  451|  48.9k|  gcry_err_code_t err = 0;
  452|  48.9k|  int secure = !!(flags & GCRY_MD_FLAG_SECURE);
  453|  48.9k|  int hmac =   !!(flags & GCRY_MD_FLAG_HMAC);
  454|  48.9k|  int bufsize = secure ? 512 : 1024;
  ------------------
  |  Branch (454:17): [True: 0, False: 48.9k]
  ------------------
  455|  48.9k|  gcry_md_hd_t hd;
  456|  48.9k|  size_t n;
  457|       |
  458|       |  /* Allocate a memory area to hold the caller visible buffer with it's
  459|       |   * control information and the data required by this module. Set the
  460|       |   * context pointer at the beginning to this area.
  461|       |   * We have to use this strange scheme because we want to hide the
  462|       |   * internal data but have a variable sized buffer.
  463|       |   *
  464|       |   *	+---+------+---........------+-------------+
  465|       |   *	!ctx! bctl !  buffer	     ! private	   !
  466|       |   *	+---+------+---........------+-------------+
  467|       |   *	  !			      ^
  468|       |   *	  !---------------------------!
  469|       |   *
  470|       |   * We have to make sure that private is well aligned.
  471|       |   */
  472|  48.9k|  n = offsetof (struct gcry_md_handle, buf) + bufsize;
  473|  48.9k|  n = ((n + sizeof (PROPERLY_ALIGNED_TYPE) - 1)
  474|  48.9k|       / sizeof (PROPERLY_ALIGNED_TYPE)) * sizeof (PROPERLY_ALIGNED_TYPE);
  475|       |
  476|       |  /* Allocate and set the Context pointer to the private data */
  477|  48.9k|  if (secure)
  ------------------
  |  Branch (477:7): [True: 0, False: 48.9k]
  ------------------
  478|      0|    hd = xtrymalloc_secure (n + sizeof (struct gcry_md_context));
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
  479|  48.9k|  else
  480|  48.9k|    hd = xtrymalloc (n + sizeof (struct gcry_md_context));
  ------------------
  |  |  138|  48.9k|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  481|       |
  482|  48.9k|  if (! hd)
  ------------------
  |  Branch (482:7): [True: 0, False: 48.9k]
  ------------------
  483|      0|    err = gpg_err_code_from_errno (errno);
  484|       |
  485|  48.9k|  if (! err)
  ------------------
  |  Branch (485:7): [True: 48.9k, False: 0]
  ------------------
  486|  48.9k|    {
  487|  48.9k|      struct gcry_md_context *ctx;
  488|       |
  489|  48.9k|      ctx = (void *) (hd->buf - offsetof (struct gcry_md_handle, buf) + n);
  490|       |      /* Setup the globally visible data (bctl in the diagram).*/
  491|  48.9k|      hd->ctx = ctx;
  492|  48.9k|      hd->bufsize = n - offsetof (struct gcry_md_handle, buf);
  493|  48.9k|      hd->bufpos = 0;
  494|       |
  495|       |      /* Initialize the private data. */
  496|  48.9k|      wipememory2 (ctx, 0, sizeof *ctx);
  ------------------
  |  |  388|  48.9k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  389|  48.9k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  ------------------
  |  |  |  |   87|  97.9k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  ------------------
  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  ------------------
  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  ------------------
  |  |  |  Branch (389:12): [Folded - Ignored]
  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  ------------------
  |  |  390|      0|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  ------------------
  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  ------------------
  |  |  391|      0|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  392|      0|		else \
  |  |  393|      0|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  394|  48.9k|	      } else { \
  |  |  395|  48.9k|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  ------------------
  |  |  |  |  380|  48.9k|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  381|  48.9k|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  382|  48.9k|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  383|  48.9k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  396|  48.9k|	      } \
  |  |  397|  48.9k|	    } while(0)
  |  |  ------------------
  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  497|  48.9k|      ctx->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL;
  ------------------
  |  |  277|      0|#define CTX_MAGIC_SECURE 0x16917011
  ------------------
                    ctx->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL;
  ------------------
  |  |  276|  97.9k|#define CTX_MAGIC_NORMAL 0x11071961
  ------------------
  |  Branch (497:20): [True: 0, False: 48.9k]
  ------------------
  498|  48.9k|      ctx->actual_handle_size = n + sizeof (struct gcry_md_context);
  499|  48.9k|      ctx->flags.secure = secure;
  500|  48.9k|      ctx->flags.hmac = hmac;
  501|  48.9k|      ctx->flags.bugemu1 = !!(flags & GCRY_MD_FLAG_BUGEMU1);
  502|  48.9k|    }
  503|       |
  504|  48.9k|  if (! err)
  ------------------
  |  Branch (504:7): [True: 48.9k, False: 0]
  ------------------
  505|  48.9k|    {
  506|       |      /* Hmmm, should we really do that? - yes [-wk] */
  507|  48.9k|      _gcry_fast_random_poll ();
  508|       |
  509|  48.9k|      if (algo)
  ------------------
  |  Branch (509:11): [True: 48.9k, False: 0]
  ------------------
  510|  48.9k|	{
  511|  48.9k|	  err = md_enable (hd, algo);
  512|  48.9k|	  if (err)
  ------------------
  |  Branch (512:8): [True: 0, False: 48.9k]
  ------------------
  513|      0|	    md_close (hd);
  514|  48.9k|	}
  515|  48.9k|    }
  516|       |
  517|  48.9k|  if (! err)
  ------------------
  |  Branch (517:7): [True: 48.9k, False: 0]
  ------------------
  518|  48.9k|    *h = hd;
  519|       |
  520|  48.9k|  return err;
  521|  48.9k|}
md.c:md_enable:
  549|  48.9k|{
  550|  48.9k|  struct gcry_md_context *h = hd->ctx;
  551|  48.9k|  const gcry_md_spec_t *spec;
  552|  48.9k|  GcryDigestEntry *entry;
  553|  48.9k|  gcry_err_code_t err = 0;
  554|       |
  555|  48.9k|  for (entry = h->list; entry; entry = entry->next)
  ------------------
  |  Branch (555:25): [True: 0, False: 48.9k]
  ------------------
  556|      0|    if (entry->spec->algo == algorithm)
  ------------------
  |  Branch (556:9): [True: 0, False: 0]
  ------------------
  557|      0|      return 0; /* Already enabled */
  558|       |
  559|  48.9k|  spec = spec_from_algo (algorithm);
  560|  48.9k|  if (!spec)
  ------------------
  |  Branch (560:7): [True: 0, False: 48.9k]
  ------------------
  561|      0|    {
  562|      0|      log_debug ("md_enable: algorithm %d not available\n", algorithm);
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
  563|      0|      err = GPG_ERR_DIGEST_ALGO;
  564|      0|    }
  565|       |
  566|  48.9k|  if (!err && spec->flags.disabled)
  ------------------
  |  Branch (566:7): [True: 48.9k, False: 0]
  |  Branch (566:15): [True: 0, False: 48.9k]
  ------------------
  567|      0|    err = GPG_ERR_DIGEST_ALGO;
  568|       |
  569|       |  /* Any non-FIPS algorithm should go this way */
  570|  48.9k|  if (!err && !spec->flags.fips && fips_mode ())
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (570:7): [True: 48.9k, False: 0]
  |  Branch (570:15): [True: 0, False: 48.9k]
  ------------------
  571|      0|    err = GPG_ERR_DIGEST_ALGO;
  572|       |
  573|  48.9k|  if (!err && h->flags.hmac && spec->read == NULL)
  ------------------
  |  Branch (573:7): [True: 48.9k, False: 0]
  |  Branch (573:15): [True: 0, False: 48.9k]
  |  Branch (573:32): [True: 0, False: 0]
  ------------------
  574|      0|    {
  575|       |      /* Expandable output function cannot act as part of HMAC. */
  576|      0|      err = GPG_ERR_DIGEST_ALGO;
  577|      0|    }
  578|       |
  579|  48.9k|  if (!err)
  ------------------
  |  Branch (579:7): [True: 48.9k, False: 0]
  ------------------
  580|  48.9k|    {
  581|  48.9k|      size_t size = (sizeof (*entry)
  582|  48.9k|                     + spec->contextsize * (h->flags.hmac? 3 : 1)
  ------------------
  |  Branch (582:45): [True: 0, False: 48.9k]
  ------------------
  583|  48.9k|                     - sizeof (entry->context));
  584|       |
  585|       |      /* And allocate a new list entry. */
  586|  48.9k|      if (h->flags.secure)
  ------------------
  |  Branch (586:11): [True: 0, False: 48.9k]
  ------------------
  587|      0|	entry = xtrymalloc_secure (size);
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
  588|  48.9k|      else
  589|  48.9k|	entry = xtrymalloc (size);
  ------------------
  |  |  138|  48.9k|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  590|       |
  591|  48.9k|      if (! entry)
  ------------------
  |  Branch (591:11): [True: 0, False: 48.9k]
  ------------------
  592|      0|	err = gpg_err_code_from_errno (errno);
  593|  48.9k|      else
  594|  48.9k|	{
  595|  48.9k|	  entry->spec = spec;
  596|  48.9k|	  entry->next = h->list;
  597|  48.9k|          entry->actual_struct_size = size;
  598|  48.9k|	  h->list = entry;
  599|       |
  600|       |	  /* And init this instance. */
  601|  48.9k|	  entry->spec->init (entry->context,
  602|  48.9k|                             h->flags.bugemu1? GCRY_MD_FLAG_BUGEMU1:0);
  ------------------
  |  Branch (602:30): [True: 0, False: 48.9k]
  ------------------
  603|  48.9k|	}
  604|  48.9k|    }
  605|       |
  606|  48.9k|  return err;
  607|  48.9k|}
md.c:md_close:
  725|  79.7k|{
  726|  79.7k|  GcryDigestEntry *r, *r2;
  727|       |
  728|  79.7k|  if (! a)
  ------------------
  |  Branch (728:7): [True: 30.8k, False: 48.9k]
  ------------------
  729|  30.8k|    return;
  730|  48.9k|  if (a->ctx->debug)
  ------------------
  |  Branch (730:7): [True: 0, False: 48.9k]
  ------------------
  731|      0|    md_stop_debug (a);
  732|  97.9k|  for (r = a->ctx->list; r; r = r2)
  ------------------
  |  Branch (732:26): [True: 48.9k, False: 48.9k]
  ------------------
  733|  48.9k|    {
  734|  48.9k|      r2 = r->next;
  735|  48.9k|      wipememory (r, r->actual_struct_size);
  ------------------
  |  |  398|  48.9k|#define wipememory(_ptr,_len) wipememory2((_ptr),0,(_len))
  |  |  ------------------
  |  |  |  |  388|  48.9k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|  48.9k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|  97.9k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 48.9k, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|  48.9k|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|  97.9k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|  48.9k|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|  48.9k|		else \
  |  |  |  |  393|  48.9k|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|  48.9k|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|  48.9k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  736|  48.9k|      xfree (r);
  ------------------
  |  |  150|  48.9k|#define xfree(a)         _gcry_free ((a))
  ------------------
  737|  48.9k|    }
  738|       |
  739|  48.9k|  wipememory (a, a->ctx->actual_handle_size);
  ------------------
  |  |  398|  48.9k|#define wipememory(_ptr,_len) wipememory2((_ptr),0,(_len))
  |  |  ------------------
  |  |  |  |  388|  48.9k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|  48.9k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|  97.9k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 48.9k, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|  48.9k|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|  97.9k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|  48.9k|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|  48.9k|		else \
  |  |  |  |  393|  48.9k|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|  48.9k|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|  48.9k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|  48.9k|  xfree(a);
  ------------------
  |  |  150|  48.9k|#define xfree(a)         _gcry_free ((a))
  ------------------
  741|  48.9k|}
md.c:md_write:
  754|  99.8k|{
  755|  99.8k|  GcryDigestEntry *r;
  756|       |
  757|  99.8k|  if (a->ctx->debug)
  ------------------
  |  Branch (757:7): [True: 0, False: 99.8k]
  ------------------
  758|      0|    {
  759|      0|      if (a->bufpos && fwrite (a->buf, a->bufpos, 1, a->ctx->debug) != 1)
  ------------------
  |  Branch (759:11): [True: 0, False: 0]
  |  Branch (759:24): [True: 0, False: 0]
  ------------------
  760|      0|	BUG();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  761|      0|      if (inlen && fwrite (inbuf, inlen, 1, a->ctx->debug) != 1)
  ------------------
  |  Branch (761:11): [True: 0, False: 0]
  |  Branch (761:20): [True: 0, False: 0]
  ------------------
  762|      0|	BUG();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  763|      0|    }
  764|       |
  765|   199k|  for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (765:26): [True: 99.8k, False: 99.8k]
  ------------------
  766|  99.8k|    {
  767|  99.8k|      if (a->bufpos)
  ------------------
  |  Branch (767:11): [True: 46.2k, False: 53.5k]
  ------------------
  768|  46.2k|	(*r->spec->write) (r->context, a->buf, a->bufpos);
  769|  99.8k|      (*r->spec->write) (r->context, inbuf, inlen);
  770|  99.8k|    }
  771|  99.8k|  a->bufpos = 0;
  772|  99.8k|}
md.c:md_final:
  787|   104k|{
  788|   104k|  GcryDigestEntry *r;
  789|       |
  790|   104k|  if (a->ctx->flags.finalized)
  ------------------
  |  Branch (790:7): [True: 46.9k, False: 57.8k]
  ------------------
  791|  46.9k|    return;
  792|       |
  793|  57.8k|  if (a->bufpos)
  ------------------
  |  Branch (793:7): [True: 0, False: 57.8k]
  ------------------
  794|      0|    md_write (a, NULL, 0);
  795|       |
  796|   115k|  for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (796:26): [True: 57.8k, False: 57.8k]
  ------------------
  797|  57.8k|    (*r->spec->final) (r->context);
  798|       |
  799|  57.8k|  a->ctx->flags.finalized = 1;
  800|       |
  801|  57.8k|  if (!a->ctx->flags.hmac)
  ------------------
  |  Branch (801:7): [True: 57.8k, False: 0]
  ------------------
  802|  57.8k|    return;
  803|       |
  804|      0|  for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (804:26): [True: 0, False: 0]
  ------------------
  805|      0|    {
  806|      0|      byte *p;
  807|      0|      size_t dlen = r->spec->mdlen;
  808|      0|      byte *hash;
  809|      0|      gcry_err_code_t err;
  810|       |
  811|      0|      if (r->spec->read == NULL)
  ------------------
  |  Branch (811:11): [True: 0, False: 0]
  ------------------
  812|      0|        continue;
  813|       |
  814|      0|      p = r->spec->read (r->context);
  815|       |
  816|      0|      if (a->ctx->flags.secure)
  ------------------
  |  Branch (816:11): [True: 0, False: 0]
  ------------------
  817|      0|        hash = xtrymalloc_secure (dlen);
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
  818|      0|      else
  819|      0|        hash = xtrymalloc (dlen);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  820|      0|      if (!hash)
  ------------------
  |  Branch (820:11): [True: 0, False: 0]
  ------------------
  821|      0|        {
  822|      0|          err = gpg_err_code_from_errno (errno);
  823|      0|          _gcry_fatal_error (err, NULL);
  824|      0|        }
  825|       |
  826|      0|      memcpy (hash, p, dlen);
  827|      0|      memcpy (r->context, (char *)r->context + r->spec->contextsize * 2,
  828|      0|              r->spec->contextsize);
  829|      0|      (*r->spec->write) (r->context, hash, dlen);
  830|      0|      (*r->spec->final) (r->context);
  831|      0|      xfree (hash);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  832|      0|    }
  833|      0|}
md.c:md_read:
 1063|  46.9k|{
 1064|  46.9k|  GcryDigestEntry *r = a->ctx->list;
 1065|       |
 1066|  46.9k|  if (! algo)
  ------------------
  |  Branch (1066:7): [True: 46.2k, False: 626]
  ------------------
 1067|  46.2k|    {
 1068|       |      /* Return the first algorithm */
 1069|  46.2k|      if (r)
  ------------------
  |  Branch (1069:11): [True: 46.2k, False: 0]
  ------------------
 1070|  46.2k|        {
 1071|  46.2k|          if (r->next)
  ------------------
  |  Branch (1071:15): [True: 0, False: 46.2k]
  ------------------
 1072|      0|            log_debug ("more than one algorithm in md_read(0)\n");
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
 1073|  46.2k|          if (r->spec->read)
  ------------------
  |  Branch (1073:15): [True: 46.2k, False: 0]
  ------------------
 1074|  46.2k|            return r->spec->read (r->context);
 1075|  46.2k|        }
 1076|  46.2k|    }
 1077|    626|  else
 1078|    626|    {
 1079|    626|      for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (1079:30): [True: 626, False: 0]
  ------------------
 1080|    626|	if (r->spec->algo == algo)
  ------------------
  |  Branch (1080:6): [True: 626, False: 0]
  ------------------
 1081|    626|	  {
 1082|    626|	    if (r->spec->read)
  ------------------
  |  Branch (1082:10): [True: 626, False: 0]
  ------------------
 1083|    626|              return r->spec->read (r->context);
 1084|      0|            break;
 1085|    626|	  }
 1086|    626|    }
 1087|       |
 1088|      0|  if (r && !r->spec->read)
  ------------------
  |  Branch (1088:7): [True: 0, False: 0]
  |  Branch (1088:12): [True: 0, False: 0]
  ------------------
 1089|      0|    _gcry_fatal_error (GPG_ERR_DIGEST_ALGO,
 1090|      0|                       "requested algo has no fixed digest length");
 1091|      0|  else
 1092|      0|    _gcry_fatal_error (GPG_ERR_DIGEST_ALGO, "requested algo not in md context");
 1093|      0|  return NULL;
 1094|      0|}
md.c:md_get_algo:
 1342|  46.2k|{
 1343|  46.2k|  GcryDigestEntry *r = a->ctx->list;
 1344|       |
 1345|  46.2k|  if (r && r->next)
  ------------------
  |  Branch (1345:7): [True: 46.2k, False: 0]
  |  Branch (1345:12): [True: 0, False: 46.2k]
  ------------------
 1346|      0|    {
 1347|      0|      fips_signal_error ("possible usage error");
  ------------------
  |  |  459|      0|           _gcry_fips_signal_error (__FILE__, __LINE__, __FUNCTION__, 0, (a))
  ------------------
 1348|      0|      log_error ("WARNING: more than one algorithm in md_get_algo()\n");
  ------------------
  |  |  203|      0|#define log_error   _gcry_log_error
  ------------------
 1349|      0|    }
 1350|  46.2k|  return r ? r->spec->algo : 0;
  ------------------
  |  Branch (1350:10): [True: 46.2k, False: 0]
  ------------------
 1351|  46.2k|}
md.c:md_digest_length:
 1366|  49.3k|{
 1367|  49.3k|  const gcry_md_spec_t *spec;
 1368|       |
 1369|  49.3k|  spec = spec_from_algo (algorithm);
 1370|  49.3k|  return spec? spec->mdlen : 0;
  ------------------
  |  Branch (1370:10): [True: 49.1k, False: 223]
  ------------------
 1371|  49.3k|}
md.c:check_digest_algo:
  431|  10.1k|{
  432|  10.1k|  const gcry_md_spec_t *spec;
  433|       |
  434|  10.1k|  spec = spec_from_algo (algorithm);
  435|  10.1k|  if (spec && !spec->flags.disabled && (spec->flags.fips || !fips_mode ()))
  ------------------
  |  |  449|  5.88k|#define fips_mode() (!_gcry_no_fips_mode_required)
  ------------------
  |  Branch (435:7): [True: 10.1k, False: 0]
  |  Branch (435:15): [True: 10.1k, False: 0]
  |  Branch (435:41): [True: 4.30k, False: 5.88k]
  |  Branch (435:61): [True: 5.88k, False: 0]
  ------------------
  436|  10.1k|    return 0;
  437|       |
  438|      0|  return GPG_ERR_DIGEST_ALGO;
  439|       |
  440|  10.1k|}

_gcry_primegen_init:
  148|      1|{
  149|       |  /* This function was formerly used to initialize the primepool
  150|       |     Mutex. This has been replace by a static initialization.  */
  151|      1|  return 0;
  152|      1|}

_gcry_pk_init:
 1239|      1|{
 1240|      1|  return 0;
 1241|      1|}

_gcry_sha1_mixblock_init:
  373|  19.5k|{
  374|  19.5k|  sha1_init (hd, 0);
  375|  19.5k|}
_gcry_sha1_mixblock:
  532|   587k|{
  533|   587k|  u32 *p = blockof64byte;
  534|   587k|  unsigned int nburn;
  535|       |
  536|   587k|  nburn = (*hd->bctx.bwrite) (hd, blockof64byte, 1);
  537|   587k|  p[0] = hd->h0;
  538|   587k|  p[1] = hd->h1;
  539|   587k|  p[2] = hd->h2;
  540|   587k|  p[3] = hd->h3;
  541|   587k|  p[4] = hd->h4;
  542|       |
  543|   587k|  return nburn;
  544|   587k|}
_gcry_sha1_hash_buffer:
  658|  19.5k|{
  659|  19.5k|  gcry_buffer_t iov = { 0 };
  660|       |
  661|  19.5k|  iov.data = (void *)buffer;
  662|  19.5k|  iov.len = length;
  663|       |
  664|  19.5k|  _gcry_sha1_hash_buffers (outbuf, 20, &iov, 1);
  665|  19.5k|}
sha1.c:sha1_init:
  298|  83.0k|{
  299|  83.0k|  SHA1_CONTEXT *hd = context;
  300|  83.0k|  unsigned int features = _gcry_get_hw_features ();
  301|       |
  302|  83.0k|  (void)flags;
  303|       |
  304|  83.0k|  hd->h0 = 0x67452301;
  305|  83.0k|  hd->h1 = 0xefcdab89;
  306|  83.0k|  hd->h2 = 0x98badcfe;
  307|  83.0k|  hd->h3 = 0x10325476;
  308|  83.0k|  hd->h4 = 0xc3d2e1f0;
  309|       |
  310|  83.0k|  hd->bctx.nblocks = 0;
  311|  83.0k|  hd->bctx.nblocks_high = 0;
  312|  83.0k|  hd->bctx.count = 0;
  313|  83.0k|  hd->bctx.blocksize_shift = _gcry_ctz(64);
  314|       |
  315|       |  /* Order of feature checks is important here; last match will be
  316|       |   * selected.  Keep slower implementations at the top and faster at
  317|       |   * the bottom.  */
  318|  83.0k|  hd->bctx.bwrite = do_transform_generic;
  319|  83.0k|#ifdef USE_SSSE3
  320|  83.0k|  if ((features & HWF_INTEL_SSSE3) != 0)
  ------------------
  |  |  229|  83.0k|#define HWF_INTEL_SSSE3         (1 << 7)
  ------------------
  |  Branch (320:7): [True: 83.0k, False: 0]
  ------------------
  321|  83.0k|    hd->bctx.bwrite = do_sha1_transform_amd64_ssse3;
  322|  83.0k|#endif
  323|  83.0k|#ifdef USE_AVX
  324|       |  /* AVX implementation uses SHLD which is known to be slow on non-Intel CPUs.
  325|       |   * Therefore use this implementation on Intel CPUs only. */
  326|  83.0k|  if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_FAST_SHLD))
  ------------------
  |  |  234|  83.0k|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
                if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_FAST_SHLD))
  ------------------
  |  |  227|  83.0k|#define HWF_INTEL_FAST_SHLD     (1 << 5)
  ------------------
  |  Branch (326:7): [True: 83.0k, False: 0]
  |  Branch (326:37): [True: 83.0k, False: 0]
  ------------------
  327|  83.0k|    hd->bctx.bwrite = do_sha1_transform_amd64_avx;
  328|  83.0k|#endif
  329|  83.0k|#ifdef USE_BMI2
  330|  83.0k|  if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_BMI2))
  ------------------
  |  |  234|  83.0k|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
                if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_BMI2))
  ------------------
  |  |  228|  83.0k|#define HWF_INTEL_BMI2          (1 << 6)
  ------------------
  |  Branch (330:7): [True: 83.0k, False: 0]
  |  Branch (330:37): [True: 83.0k, False: 0]
  ------------------
  331|  83.0k|    hd->bctx.bwrite = do_sha1_transform_amd64_avx_bmi2;
  332|  83.0k|#endif
  333|  83.0k|#ifdef USE_AVX2
  334|  83.0k|  if ((features & HWF_INTEL_AVX2) && (features & HWF_INTEL_AVX) &&
  ------------------
  |  |  235|  83.0k|#define HWF_INTEL_AVX2          (1 << 13)
  ------------------
                if ((features & HWF_INTEL_AVX2) && (features & HWF_INTEL_AVX) &&
  ------------------
  |  |  234|  83.0k|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
  |  Branch (334:7): [True: 83.0k, False: 0]
  |  Branch (334:38): [True: 83.0k, False: 0]
  ------------------
  335|  83.0k|      (features & HWF_INTEL_BMI2))
  ------------------
  |  |  228|  83.0k|#define HWF_INTEL_BMI2          (1 << 6)
  ------------------
  |  Branch (335:7): [True: 83.0k, False: 0]
  ------------------
  336|  83.0k|    hd->bctx.bwrite = do_sha1_transform_amd64_avx2_bmi2;
  337|  83.0k|#endif
  338|  83.0k|#ifdef USE_SHAEXT
  339|  83.0k|  if ((features & HWF_INTEL_SHAEXT) && (features & HWF_INTEL_SSE4_1))
  ------------------
  |  |  238|  83.0k|#define HWF_INTEL_SHAEXT        (1 << 16)
  ------------------
                if ((features & HWF_INTEL_SHAEXT) && (features & HWF_INTEL_SSE4_1))
  ------------------
  |  |  230|      0|#define HWF_INTEL_SSE4_1        (1 << 8)
  ------------------
  |  Branch (339:7): [True: 0, False: 83.0k]
  |  Branch (339:40): [True: 0, False: 0]
  ------------------
  340|      0|    hd->bctx.bwrite = do_sha1_transform_intel_shaext;
  341|  83.0k|#endif
  342|       |#ifdef USE_NEON
  343|       |  if ((features & HWF_ARM_NEON) != 0)
  344|       |    hd->bctx.bwrite = do_sha1_transform_armv7_neon;
  345|       |#endif
  346|       |#ifdef USE_ARM_CE
  347|       |  if ((features & HWF_ARM_SHA1) != 0)
  348|       |    hd->bctx.bwrite = do_sha1_transform_armv8_ce;
  349|       |#endif
  350|       |#ifdef SHA1_USE_S390X_CRYPTO
  351|       |  hd->use_s390x_crypto = 0;
  352|       |  if ((features & HWF_S390X_MSA) != 0)
  353|       |    {
  354|       |      if ((kimd_query () & km_function_to_mask (KMID_FUNCTION_SHA1)) &&
  355|       |	  (klmd_query () & km_function_to_mask (KMID_FUNCTION_SHA1)))
  356|       |	{
  357|       |	  hd->bctx.bwrite = do_sha1_transform_s390x;
  358|       |	  hd->use_s390x_crypto = 1;
  359|       |	}
  360|       |    }
  361|       |#endif
  362|       |
  363|  83.0k|  (void)features;
  364|  83.0k|}
sha1.c:do_sha1_transform_amd64_avx_bmi2:
  176|   651k|{
  177|   651k|  SHA1_CONTEXT *hd = ctx;
  178|   651k|  return _gcry_sha1_transform_amd64_avx_bmi2 (&hd->h0, data, nblks)
  179|   651k|         + ASM_EXTRA_STACK;
  ------------------
  |  |  133|   651k|#  define ASM_EXTRA_STACK 0
  ------------------
  180|   651k|}
sha1.c:do_sha1_transform_amd64_avx2_bmi2:
  190|   671k|{
  191|   671k|  SHA1_CONTEXT *hd = ctx;
  192|       |
  193|       |  /* AVX2/BMI2 function only handles pair of blocks so nblks needs to be
  194|       |   * multiple of 2 and function does not handle zero nblks. Use AVX/BMI2
  195|       |   * code to handle these cases. */
  196|       |
  197|   671k|  if (nblks <= 1)
  ------------------
  |  Branch (197:7): [True: 651k, False: 19.8k]
  ------------------
  198|   651k|    return do_sha1_transform_amd64_avx_bmi2 (ctx, data, nblks);
  199|       |
  200|  19.8k|  if (nblks & 1)
  ------------------
  |  Branch (200:7): [True: 19.6k, False: 279]
  ------------------
  201|  19.6k|    {
  202|  19.6k|      (void)_gcry_sha1_transform_amd64_avx_bmi2 (&hd->h0, data, 1);
  203|  19.6k|      nblks--;
  204|  19.6k|      data += 64;
  205|  19.6k|    }
  206|       |
  207|  19.8k|  return _gcry_sha1_transform_amd64_avx2_bmi2 (&hd->h0, data, nblks)
  208|  19.8k|         + ASM_EXTRA_STACK;
  ------------------
  |  |  133|  19.8k|#  define ASM_EXTRA_STACK 0
  ------------------
  209|   671k|}
sha1.c:_gcry_sha1_hash_buffers:
  642|  19.5k|{
  643|  19.5k|  SHA1_CONTEXT hd;
  644|       |
  645|  19.5k|  (void)nbytes;
  646|       |
  647|  19.5k|  sha1_init (&hd, 0);
  648|  39.1k|  for (;iovcnt > 0; iov++, iovcnt--)
  ------------------
  |  Branch (648:9): [True: 19.5k, False: 19.5k]
  ------------------
  649|  19.5k|    _gcry_md_block_write (&hd,
  650|  19.5k|                          (const char*)iov[0].data + iov[0].off, iov[0].len);
  651|  19.5k|  sha1_final (&hd);
  652|  19.5k|  memcpy (outbuf, hd.bctx.buf, 20);
  653|  19.5k|}
sha1.c:sha1_final:
  556|  63.4k|{
  557|  63.4k|  SHA1_CONTEXT *hd = context;
  558|  63.4k|  u32 t, th, msb, lsb;
  559|  63.4k|  unsigned char *p;
  560|  63.4k|  unsigned int burn;
  561|       |
  562|  63.4k|  t = hd->bctx.nblocks;
  563|  63.4k|  if (sizeof t == sizeof hd->bctx.nblocks)
  ------------------
  |  Branch (563:7): [Folded - Ignored]
  ------------------
  564|      0|    th = hd->bctx.nblocks_high;
  565|  63.4k|  else
  566|  63.4k|    th = hd->bctx.nblocks >> 32;
  567|       |
  568|       |  /* multiply by 64 to make a byte count */
  569|  63.4k|  lsb = t << 6;
  570|  63.4k|  msb = (th << 6) | (t >> 26);
  571|       |  /* add the count */
  572|  63.4k|  t = lsb;
  573|  63.4k|  if( (lsb += hd->bctx.count) < t )
  ------------------
  |  Branch (573:7): [True: 0, False: 63.4k]
  ------------------
  574|      0|    msb++;
  575|       |  /* multiply by 8 to make a bit count */
  576|  63.4k|  t = lsb;
  577|  63.4k|  lsb <<= 3;
  578|  63.4k|  msb <<= 3;
  579|  63.4k|  msb |= t >> 29;
  580|       |
  581|  63.4k|  if (0)
  ------------------
  |  Branch (581:7): [Folded - Ignored]
  ------------------
  582|      0|    { }
  583|       |#ifdef SHA1_USE_S390X_CRYPTO
  584|       |  else if (hd->use_s390x_crypto)
  585|       |    {
  586|       |      burn = do_sha1_final_s390x (hd, hd->bctx.buf, hd->bctx.count, msb, lsb);
  587|       |    }
  588|       |#endif
  589|  63.4k|  else if (hd->bctx.count < 56)  /* enough room */
  ------------------
  |  Branch (589:12): [True: 63.2k, False: 206]
  ------------------
  590|  63.2k|    {
  591|  63.2k|      hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
  592|  63.2k|      if (hd->bctx.count < 56)
  ------------------
  |  Branch (592:11): [True: 63.0k, False: 195]
  ------------------
  593|  63.0k|	memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
  594|       |
  595|       |      /* append the 64 bit count */
  596|  63.2k|      buf_put_be32(hd->bctx.buf + 56, msb);
  597|  63.2k|      buf_put_be32(hd->bctx.buf + 60, lsb);
  598|  63.2k|      burn = (*hd->bctx.bwrite) ( hd, hd->bctx.buf, 1 );
  599|  63.2k|    }
  600|    206|  else  /* need one extra block */
  601|    206|    {
  602|    206|      hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
  603|       |      /* fill pad and next block with zeroes */
  604|    206|      memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
  605|       |
  606|       |      /* append the 64 bit count */
  607|    206|      buf_put_be32(hd->bctx.buf + 64 + 56, msb);
  608|    206|      buf_put_be32(hd->bctx.buf + 64 + 60, lsb);
  609|    206|      burn = (*hd->bctx.bwrite) ( hd, hd->bctx.buf, 2 );
  610|    206|    }
  611|       |
  612|  63.4k|  p = hd->bctx.buf;
  613|  63.4k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  614|  63.4k|  X(0);
  ------------------
  |  |  613|  63.4k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (613:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  615|  63.4k|  X(1);
  ------------------
  |  |  613|  63.4k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (613:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  616|  63.4k|  X(2);
  ------------------
  |  |  613|  63.4k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (613:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  617|  63.4k|  X(3);
  ------------------
  |  |  613|  63.4k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (613:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  618|  63.4k|  X(4);
  ------------------
  |  |  613|  63.4k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (613:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  619|  63.4k|#undef X
  620|       |
  621|  63.4k|  hd->bctx.count = 0;
  622|       |
  623|  63.4k|  _gcry_burn_stack (burn);
  ------------------
  |  |  371|  63.4k|	do { __gcry_burn_stack (bytes); \
  |  |  372|  63.4k|	     __gcry_burn_stack_dummy (); } while(0)
  |  |  ------------------
  |  |  |  |  364|  63.4k|#define  __gcry_burn_stack_dummy() asm volatile ("":::"memory")
  |  |  ------------------
  |  |  |  Branch (372:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  624|  63.4k|}
sha1.c:sha1_read:
  628|  43.8k|{
  629|  43.8k|  SHA1_CONTEXT *hd = context;
  630|       |
  631|  43.8k|  return hd->bctx.buf;
  632|  43.8k|}

sha256.c:sha256_common_init:
  287|  2.45k|{
  288|  2.45k|  unsigned int features = _gcry_get_hw_features ();
  289|       |
  290|  2.45k|  hd->bctx.nblocks = 0;
  291|  2.45k|  hd->bctx.nblocks_high = 0;
  292|  2.45k|  hd->bctx.count = 0;
  293|  2.45k|  hd->bctx.blocksize_shift = _gcry_ctz(64);
  294|       |
  295|       |  /* Order of feature checks is important here; last match will be
  296|       |   * selected.  Keep slower implementations at the top and faster at
  297|       |   * the bottom.  */
  298|  2.45k|  hd->bctx.bwrite = do_transform_generic;
  299|  2.45k|#ifdef USE_SSSE3
  300|  2.45k|  if ((features & HWF_INTEL_SSSE3) != 0)
  ------------------
  |  |  229|  2.45k|#define HWF_INTEL_SSSE3         (1 << 7)
  ------------------
  |  Branch (300:7): [True: 2.45k, False: 0]
  ------------------
  301|  2.45k|    hd->bctx.bwrite = do_sha256_transform_amd64_ssse3;
  302|  2.45k|#endif
  303|  2.45k|#ifdef USE_AVX
  304|       |  /* AVX implementation uses SHLD which is known to be slow on non-Intel CPUs.
  305|       |   * Therefore use this implementation on Intel CPUs only. */
  306|  2.45k|  if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_FAST_SHLD))
  ------------------
  |  |  234|  2.45k|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
                if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_FAST_SHLD))
  ------------------
  |  |  227|  2.45k|#define HWF_INTEL_FAST_SHLD     (1 << 5)
  ------------------
  |  Branch (306:7): [True: 2.45k, False: 0]
  |  Branch (306:37): [True: 2.45k, False: 0]
  ------------------
  307|  2.45k|    hd->bctx.bwrite = do_sha256_transform_amd64_avx;
  308|  2.45k|#endif
  309|  2.45k|#ifdef USE_AVX2
  310|  2.45k|  if ((features & HWF_INTEL_AVX2) && (features & HWF_INTEL_BMI2))
  ------------------
  |  |  235|  2.45k|#define HWF_INTEL_AVX2          (1 << 13)
  ------------------
                if ((features & HWF_INTEL_AVX2) && (features & HWF_INTEL_BMI2))
  ------------------
  |  |  228|  2.45k|#define HWF_INTEL_BMI2          (1 << 6)
  ------------------
  |  Branch (310:7): [True: 2.45k, False: 0]
  |  Branch (310:38): [True: 2.45k, False: 0]
  ------------------
  311|  2.45k|    hd->bctx.bwrite = do_sha256_transform_amd64_avx2;
  312|  2.45k|#endif
  313|  2.45k|#ifdef USE_SHAEXT
  314|  2.45k|  if ((features & HWF_INTEL_SHAEXT) && (features & HWF_INTEL_SSE4_1))
  ------------------
  |  |  238|  2.45k|#define HWF_INTEL_SHAEXT        (1 << 16)
  ------------------
                if ((features & HWF_INTEL_SHAEXT) && (features & HWF_INTEL_SSE4_1))
  ------------------
  |  |  230|      0|#define HWF_INTEL_SSE4_1        (1 << 8)
  ------------------
  |  Branch (314:7): [True: 0, False: 2.45k]
  |  Branch (314:40): [True: 0, False: 0]
  ------------------
  315|      0|    hd->bctx.bwrite = do_sha256_transform_intel_shaext;
  316|  2.45k|#endif
  317|       |#ifdef USE_ARM_CE
  318|       |  if ((features & HWF_ARM_SHA2) != 0)
  319|       |    hd->bctx.bwrite = do_sha256_transform_armv8_ce;
  320|       |#endif
  321|       |#ifdef USE_PPC_CRYPTO
  322|       |  if ((features & HWF_PPC_VCRYPTO) != 0)
  323|       |    hd->bctx.bwrite = do_sha256_transform_ppc8;
  324|       |  if ((features & HWF_PPC_VCRYPTO) != 0 && (features & HWF_PPC_ARCH_3_00) != 0)
  325|       |    hd->bctx.bwrite = do_sha256_transform_ppc9;
  326|       |#endif
  327|       |#ifdef USE_S390X_CRYPTO
  328|       |  hd->use_s390x_crypto = 0;
  329|       |  if ((features & HWF_S390X_MSA) != 0)
  330|       |    {
  331|       |      if ((kimd_query () & km_function_to_mask (KMID_FUNCTION_SHA256)) &&
  332|       |	  (klmd_query () & km_function_to_mask (KMID_FUNCTION_SHA256)))
  333|       |	{
  334|       |	  hd->bctx.bwrite = do_sha256_transform_s390x;
  335|       |	  hd->use_s390x_crypto = 1;
  336|       |	}
  337|       |    }
  338|       |#endif
  339|  2.45k|  (void)features;
  340|  2.45k|}
sha256.c:do_sha256_transform_amd64_avx2:
  184|  2.82k|{
  185|  2.82k|  SHA256_CONTEXT *hd = ctx;
  186|  2.82k|  return _gcry_sha256_transform_amd64_avx2 (data, hd->h, nblks)
  187|  2.82k|         + ASM_EXTRA_STACK;
  ------------------
  |  |  141|  2.82k|#  define ASM_EXTRA_STACK 0
  ------------------
  188|  2.82k|}
sha256.c:sha256_final:
  549|  2.45k|{
  550|  2.45k|  SHA256_CONTEXT *hd = context;
  551|  2.45k|  u32 t, th, msb, lsb;
  552|  2.45k|  byte *p;
  553|  2.45k|  unsigned int burn;
  554|       |
  555|  2.45k|  t = hd->bctx.nblocks;
  556|  2.45k|  if (sizeof t == sizeof hd->bctx.nblocks)
  ------------------
  |  Branch (556:7): [Folded - Ignored]
  ------------------
  557|      0|    th = hd->bctx.nblocks_high;
  558|  2.45k|  else
  559|  2.45k|    th = hd->bctx.nblocks >> 32;
  560|       |
  561|       |  /* multiply by 64 to make a byte count */
  562|  2.45k|  lsb = t << 6;
  563|  2.45k|  msb = (th << 6) | (t >> 26);
  564|       |  /* add the count */
  565|  2.45k|  t = lsb;
  566|  2.45k|  if ((lsb += hd->bctx.count) < t)
  ------------------
  |  Branch (566:7): [True: 0, False: 2.45k]
  ------------------
  567|      0|    msb++;
  568|       |  /* multiply by 8 to make a bit count */
  569|  2.45k|  t = lsb;
  570|  2.45k|  lsb <<= 3;
  571|  2.45k|  msb <<= 3;
  572|  2.45k|  msb |= t >> 29;
  573|       |
  574|  2.45k|  if (0)
  ------------------
  |  Branch (574:7): [Folded - Ignored]
  ------------------
  575|      0|    { }
  576|       |#ifdef USE_S390X_CRYPTO
  577|       |  else if (hd->use_s390x_crypto)
  578|       |    {
  579|       |      burn = do_sha256_final_s390x (hd, hd->bctx.buf, hd->bctx.count, msb, lsb);
  580|       |    }
  581|       |#endif
  582|  2.45k|  else if (hd->bctx.count < 56)  /* enough room */
  ------------------
  |  Branch (582:12): [True: 2.23k, False: 224]
  ------------------
  583|  2.23k|    {
  584|  2.23k|      hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
  585|  2.23k|      if (hd->bctx.count < 56)
  ------------------
  |  Branch (585:11): [True: 1.88k, False: 349]
  ------------------
  586|  1.88k|	memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
  587|       |
  588|       |      /* append the 64 bit count */
  589|  2.23k|      buf_put_be32(hd->bctx.buf + 56, msb);
  590|  2.23k|      buf_put_be32(hd->bctx.buf + 60, lsb);
  591|  2.23k|      burn = (*hd->bctx.bwrite) (hd, hd->bctx.buf, 1);
  592|  2.23k|    }
  593|    224|  else  /* need one extra block */
  594|    224|    {
  595|    224|      hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
  596|       |      /* fill pad and next block with zeroes */
  597|    224|      memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
  598|       |
  599|       |      /* append the 64 bit count */
  600|    224|      buf_put_be32(hd->bctx.buf + 64 + 56, msb);
  601|    224|      buf_put_be32(hd->bctx.buf + 64 + 60, lsb);
  602|    224|      burn = (*hd->bctx.bwrite) (hd, hd->bctx.buf, 2);
  603|    224|    }
  604|       |
  605|  2.45k|  p = hd->bctx.buf;
  606|  2.45k|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  607|  2.45k|  X(0);
  ------------------
  |  |  606|  2.45k|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  608|  2.45k|  X(1);
  ------------------
  |  |  606|  2.45k|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  609|  2.45k|  X(2);
  ------------------
  |  |  606|  2.45k|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  610|  2.45k|  X(3);
  ------------------
  |  |  606|  2.45k|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  611|  2.45k|  X(4);
  ------------------
  |  |  606|  2.45k|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  612|  2.45k|  X(5);
  ------------------
  |  |  606|  2.45k|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  613|  2.45k|  X(6);
  ------------------
  |  |  606|  2.45k|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  614|  2.45k|  X(7);
  ------------------
  |  |  606|  2.45k|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  615|  2.45k|#undef X
  616|       |
  617|  2.45k|  hd->bctx.count = 0;
  618|       |
  619|  2.45k|  _gcry_burn_stack (burn);
  ------------------
  |  |  371|  2.45k|	do { __gcry_burn_stack (bytes); \
  |  |  372|  2.45k|	     __gcry_burn_stack_dummy (); } while(0)
  |  |  ------------------
  |  |  |  |  364|  2.45k|#define  __gcry_burn_stack_dummy() asm volatile ("":::"memory")
  |  |  ------------------
  |  |  |  Branch (372:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  620|  2.45k|}
sha256.c:sha256_read:
  624|  2.45k|{
  625|  2.45k|  SHA256_CONTEXT *hd = context;
  626|       |
  627|  2.45k|  return hd->bctx.buf;
  628|  2.45k|}
sha256.c:sha256_init:
  345|  2.45k|{
  346|  2.45k|  SHA256_CONTEXT *hd = context;
  347|       |
  348|  2.45k|  (void)flags;
  349|       |
  350|  2.45k|  hd->h[0] = 0x6a09e667;
  351|  2.45k|  hd->h[1] = 0xbb67ae85;
  352|  2.45k|  hd->h[2] = 0x3c6ef372;
  353|  2.45k|  hd->h[3] = 0xa54ff53a;
  354|  2.45k|  hd->h[4] = 0x510e527f;
  355|  2.45k|  hd->h[5] = 0x9b05688c;
  356|  2.45k|  hd->h[6] = 0x1f83d9ab;
  357|  2.45k|  hd->h[7] = 0x5be0cd19;
  358|       |
  359|  2.45k|  sha256_common_init (hd);
  360|  2.45k|}

mpicoder.c:buf_put_be64:
  171|  18.8k|{
  172|  18.8k|  bufhelp_u64_t *out = _buf;
  173|  18.8k|  out->a = be_bswap64(val);
  ------------------
  |  |   75|  18.8k|# define be_bswap64(x) _gcry_bswap64(x)
  |  |  ------------------
  |  |  |  |   56|  18.8k|# define _gcry_bswap64 __builtin_bswap64
  |  |  ------------------
  ------------------
  174|  18.8k|}
mpicoder.c:buf_get_be64:
  161|  18.1k|{
  162|  18.1k|  return be_bswap64(((const bufhelp_u64_t *)_buf)->a);
  ------------------
  |  |   75|  18.1k|# define be_bswap64(x) _gcry_bswap64(x)
  |  |  ------------------
  |  |  |  |   56|  18.1k|# define _gcry_bswap64 __builtin_bswap64
  |  |  ------------------
  ------------------
  163|  18.1k|}

_gcry_mpi_normalize:
   57|   296k|{
   58|   296k|    if( mpi_is_opaque(a) )
  ------------------
  |  |  114|   296k|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 296k, False: 0]
  |  |  |  Branch (114:39): [True: 0, False: 296k]
  |  |  ------------------
  ------------------
   59|      0|	return;
   60|       |
   61|   298k|    for( ; a->nlimbs && !a->d[a->nlimbs-1]; a->nlimbs-- )
  ------------------
  |  Branch (61:12): [True: 27.7k, False: 271k]
  |  Branch (61:25): [True: 2.90k, False: 24.8k]
  ------------------
   62|  2.90k|	;
   63|   296k|}
_gcry_mpi_get_nbits:
   72|   247k|{
   73|   247k|    unsigned n;
   74|       |
   75|   247k|    if( mpi_is_opaque(a) ) {
  ------------------
  |  |  114|   247k|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 247k, False: 0]
  |  |  |  Branch (114:39): [True: 31.8k, False: 216k]
  |  |  ------------------
  ------------------
   76|  31.8k|	return a->sign; /* which holds the number of bits */
   77|  31.8k|    }
   78|       |
   79|   216k|    _gcry_mpi_normalize( a );
   80|   216k|    if( a->nlimbs ) {
  ------------------
  |  Branch (80:9): [True: 18.0k, False: 198k]
  ------------------
   81|  18.0k|	mpi_limb_t alimb = a->d[a->nlimbs-1];
   82|  18.0k|	if( alimb )
  ------------------
  |  Branch (82:6): [True: 18.0k, False: 0]
  ------------------
   83|  18.0k|	    count_leading_zeros( n, alimb );
  ------------------
  |  |  617|  18.0k|  do {                                                                  \
  |  |  618|  18.0k|    UDItype __cbtmp;                                                    \
  |  |  619|  18.0k|    __asm__ ("bsrq %1,%0"                                               \
  |  |  620|  18.0k|             : "=r" (__cbtmp) : "rm" ((UDItype)(x))                     \
  |  |  621|  18.0k|             __CLOBBER_CC);                                             \
  |  |  622|  18.0k|    (count) = __cbtmp ^ 63;                                             \
  |  |  623|  18.0k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (623:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
   84|      0|	else
   85|      0|	    n = BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   86|  18.0k|	n = BITS_PER_MPI_LIMB - n + (a->nlimbs-1) * BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|  18.0k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  18.0k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  18.0k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
              	n = BITS_PER_MPI_LIMB - n + (a->nlimbs-1) * BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|  18.0k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  18.0k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  18.0k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   87|  18.0k|    }
   88|   198k|    else
   89|   198k|	n = 0;
   90|   216k|    return n;
   91|   247k|}

_gcry_mpi_get_buffer:
  383|  68.1k|{
  384|  68.1k|  if (mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  |  566|  68.1k|#define mpi_get_flag(a,f)      _gcry_mpi_get_flag ((a), (f))
  |  |  ------------------
  |  |  |  Branch (566:32): [True: 0, False: 68.1k]
  |  |  ------------------
  ------------------
  385|      0|    {
  386|      0|      unsigned int nbits;
  387|      0|      byte *p = _gcry_mpi_get_opaque_copy (a, &nbits);
  388|       |
  389|      0|      if (r_nbytes)
  ------------------
  |  Branch (389:11): [True: 0, False: 0]
  ------------------
  390|      0|        *r_nbytes = (nbits+7)/8;
  391|       |
  392|      0|      return p;
  393|      0|    }
  394|  68.1k|  else
  395|  68.1k|    return do_get_buffer (a, fill_le, 0, r_nbytes, sign, 0);
  396|  68.1k|}
_gcry_mpi_scan:
  541|  79.8k|{
  542|  79.8k|  const unsigned char *buffer = (const unsigned char*)buffer_arg;
  543|  79.8k|  struct gcry_mpi *a = NULL;
  544|  79.8k|  unsigned int len;
  545|  79.8k|  int secure = (buffer && _gcry_is_secure (buffer));
  ------------------
  |  Branch (545:17): [True: 79.8k, False: 0]
  |  Branch (545:27): [True: 0, False: 79.8k]
  ------------------
  546|       |
  547|  79.8k|  if (buflen > MAX_EXTERN_SCAN_BYTES)
  ------------------
  |  |   37|  79.8k|#define MAX_EXTERN_SCAN_BYTES (16*1024*1024)
  ------------------
  |  Branch (547:7): [True: 0, False: 79.8k]
  ------------------
  548|      0|    {
  549|      0|      if (nscanned)
  ------------------
  |  Branch (549:11): [True: 0, False: 0]
  ------------------
  550|      0|        *nscanned = 0;
  551|      0|      return GPG_ERR_INV_OBJ;
  552|      0|    }
  553|       |
  554|  79.8k|  if (format == GCRYMPI_FMT_SSH)
  ------------------
  |  Branch (554:7): [True: 0, False: 79.8k]
  ------------------
  555|      0|    len = 0;
  556|  79.8k|  else
  557|  79.8k|    len = buflen;
  558|       |
  559|  79.8k|  if (format == GCRYMPI_FMT_STD)
  ------------------
  |  Branch (559:7): [True: 0, False: 79.8k]
  ------------------
  560|      0|    {
  561|      0|      const unsigned char *s = buffer;
  562|       |
  563|      0|      a = secure? mpi_alloc_secure ((len+BYTES_PER_MPI_LIMB-1)
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  |  Branch (563:11): [True: 0, False: 0]
  ------------------
  564|      0|                                    /BYTES_PER_MPI_LIMB)
  565|      0|                : mpi_alloc ((len+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
  ------------------
  |  |   97|      0|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  566|      0|      if (len)
  ------------------
  |  Branch (566:11): [True: 0, False: 0]
  ------------------
  567|      0|        {
  568|      0|          _gcry_mpi_set_buffer (a, s, len, 0);
  569|      0|          a->sign = !!(*s & 0x80);
  570|      0|          if (a->sign)
  ------------------
  |  Branch (570:15): [True: 0, False: 0]
  ------------------
  571|      0|            {
  572|      0|              onecompl (a);
  573|      0|              mpi_add_ui (a, a, 1);
  ------------------
  |  |  515|      0|#define mpi_add_ui(w,u,v)      _gcry_mpi_add_ui((w),(u),(v))
  ------------------
  574|      0|              a->sign = 1;
  575|      0|	    }
  576|      0|	}
  577|      0|      if (ret_mpi)
  ------------------
  |  Branch (577:11): [True: 0, False: 0]
  ------------------
  578|      0|        {
  579|      0|          mpi_normalize ( a );
  ------------------
  |  |  223|      0|#define mpi_normalize(a)       _gcry_mpi_normalize ((a))
  ------------------
  580|      0|          *ret_mpi = a;
  581|      0|	}
  582|      0|      else
  583|      0|        mpi_free(a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  584|      0|      if (nscanned)
  ------------------
  |  Branch (584:11): [True: 0, False: 0]
  ------------------
  585|      0|        *nscanned = len;
  586|      0|      return 0;
  587|      0|    }
  588|  79.8k|  else if (format == GCRYMPI_FMT_USG)
  ------------------
  |  Branch (588:12): [True: 0, False: 79.8k]
  ------------------
  589|      0|    {
  590|      0|      a = secure? mpi_alloc_secure ((len+BYTES_PER_MPI_LIMB-1)
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  |  Branch (590:11): [True: 0, False: 0]
  ------------------
  591|      0|                                    /BYTES_PER_MPI_LIMB)
  592|      0|                : mpi_alloc ((len+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
  ------------------
  |  |   97|      0|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  593|       |
  594|      0|      if (len)
  ------------------
  |  Branch (594:11): [True: 0, False: 0]
  ------------------
  595|      0|        _gcry_mpi_set_buffer (a, buffer, len, 0);
  596|      0|      if (ret_mpi)
  ------------------
  |  Branch (596:11): [True: 0, False: 0]
  ------------------
  597|      0|        {
  598|      0|          mpi_normalize ( a );
  ------------------
  |  |  223|      0|#define mpi_normalize(a)       _gcry_mpi_normalize ((a))
  ------------------
  599|      0|          *ret_mpi = a;
  600|      0|	}
  601|      0|      else
  602|      0|        mpi_free(a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  603|      0|      if (nscanned)
  ------------------
  |  Branch (603:11): [True: 0, False: 0]
  ------------------
  604|      0|        *nscanned = len;
  605|      0|      return 0;
  606|      0|    }
  607|  79.8k|  else if (format == GCRYMPI_FMT_PGP)
  ------------------
  |  Branch (607:12): [True: 79.8k, False: 0]
  ------------------
  608|  79.8k|    {
  609|  79.8k|      a = mpi_read_from_buffer (buffer, &len, secure);
  610|  79.8k|      if (nscanned)
  ------------------
  |  Branch (610:11): [True: 79.8k, False: 0]
  ------------------
  611|  79.8k|        *nscanned = len;
  612|  79.8k|      if (ret_mpi && a)
  ------------------
  |  Branch (612:11): [True: 79.8k, False: 0]
  |  Branch (612:22): [True: 79.8k, False: 0]
  ------------------
  613|  79.8k|        {
  614|  79.8k|          mpi_normalize (a);
  ------------------
  |  |  223|  79.8k|#define mpi_normalize(a)       _gcry_mpi_normalize ((a))
  ------------------
  615|  79.8k|          *ret_mpi = a;
  616|  79.8k|	}
  617|      0|      else if (a)
  ------------------
  |  Branch (617:16): [True: 0, False: 0]
  ------------------
  618|      0|        {
  619|      0|          mpi_free(a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  620|      0|          a = NULL;
  621|      0|        }
  622|  79.8k|      return a? 0 : GPG_ERR_INV_OBJ;
  ------------------
  |  Branch (622:14): [True: 79.8k, False: 0]
  ------------------
  623|  79.8k|    }
  624|      0|  else if (format == GCRYMPI_FMT_SSH)
  ------------------
  |  Branch (624:12): [True: 0, False: 0]
  ------------------
  625|      0|    {
  626|      0|      const unsigned char *s = buffer;
  627|      0|      size_t n;
  628|       |
  629|       |      /* This test is not strictly necessary and an assert (!len)
  630|       |         would be sufficient.  We keep this test in case we later
  631|       |         allow the BUFLEN argument to act as a sanitiy check.  Same
  632|       |         below. */
  633|      0|      if (len && len < 4)
  ------------------
  |  Branch (633:11): [True: 0, False: 0]
  |  Branch (633:18): [True: 0, False: 0]
  ------------------
  634|      0|        return GPG_ERR_TOO_SHORT;
  635|       |
  636|      0|      n = buf_get_be32 (s);
  637|      0|      s += 4;
  638|      0|      if (len)
  ------------------
  |  Branch (638:11): [True: 0, False: 0]
  ------------------
  639|      0|        len -= 4;
  640|      0|      if (len && n > len)
  ------------------
  |  Branch (640:11): [True: 0, False: 0]
  |  Branch (640:18): [True: 0, False: 0]
  ------------------
  641|      0|        return GPG_ERR_TOO_LARGE;
  642|       |
  643|      0|      a = secure? mpi_alloc_secure ((n+BYTES_PER_MPI_LIMB-1)
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  |  Branch (643:11): [True: 0, False: 0]
  ------------------
  644|      0|                                    /BYTES_PER_MPI_LIMB)
  645|      0|                : mpi_alloc ((n+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
  ------------------
  |  |   97|      0|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  646|      0|      if (n)
  ------------------
  |  Branch (646:11): [True: 0, False: 0]
  ------------------
  647|      0|        {
  648|      0|          _gcry_mpi_set_buffer( a, s, n, 0 );
  649|      0|          a->sign = !!(*s & 0x80);
  650|      0|          if (a->sign)
  ------------------
  |  Branch (650:15): [True: 0, False: 0]
  ------------------
  651|      0|            {
  652|      0|              onecompl (a);
  653|      0|              mpi_add_ui (a, a, 1);
  ------------------
  |  |  515|      0|#define mpi_add_ui(w,u,v)      _gcry_mpi_add_ui((w),(u),(v))
  ------------------
  654|      0|              a->sign = 1;
  655|      0|	    }
  656|      0|	}
  657|      0|      if (nscanned)
  ------------------
  |  Branch (657:11): [True: 0, False: 0]
  ------------------
  658|      0|        *nscanned = n+4;
  659|      0|      if (ret_mpi)
  ------------------
  |  Branch (659:11): [True: 0, False: 0]
  ------------------
  660|      0|        {
  661|      0|          mpi_normalize ( a );
  ------------------
  |  |  223|      0|#define mpi_normalize(a)       _gcry_mpi_normalize ((a))
  ------------------
  662|      0|          *ret_mpi = a;
  663|      0|        }
  664|      0|      else
  665|      0|        mpi_free(a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  666|      0|      return 0;
  667|      0|    }
  668|      0|  else if (format == GCRYMPI_FMT_HEX)
  ------------------
  |  Branch (668:12): [True: 0, False: 0]
  ------------------
  669|      0|    {
  670|      0|      size_t slen;
  671|       |      /* We can only handle C strings for now.  */
  672|      0|      if (buflen)
  ------------------
  |  Branch (672:11): [True: 0, False: 0]
  ------------------
  673|      0|        return GPG_ERR_INV_ARG;
  674|       |
  675|      0|      slen = strlen ((const char *)buffer);
  676|      0|      if (slen > MAX_EXTERN_SCAN_BYTES)
  ------------------
  |  |   37|      0|#define MAX_EXTERN_SCAN_BYTES (16*1024*1024)
  ------------------
  |  Branch (676:11): [True: 0, False: 0]
  ------------------
  677|      0|	return GPG_ERR_INV_OBJ;
  678|      0|      a = secure? mpi_alloc_secure ((((slen+1)/2)+BYTES_PER_MPI_LIMB-1)
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  |  Branch (678:11): [True: 0, False: 0]
  ------------------
  679|      0|				    /BYTES_PER_MPI_LIMB)
  680|      0|		: mpi_alloc((((slen+1)/2)+BYTES_PER_MPI_LIMB-1)
  ------------------
  |  |   97|      0|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  681|      0|			    /BYTES_PER_MPI_LIMB);
  682|      0|      if (mpi_fromstr (a, (const char *)buffer, slen))
  ------------------
  |  Branch (682:11): [True: 0, False: 0]
  ------------------
  683|      0|        {
  684|      0|          mpi_free (a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  685|      0|          return GPG_ERR_INV_OBJ;
  686|      0|        }
  687|      0|      if (ret_mpi)
  ------------------
  |  Branch (687:11): [True: 0, False: 0]
  ------------------
  688|      0|        {
  689|      0|          mpi_normalize ( a );
  ------------------
  |  |  223|      0|#define mpi_normalize(a)       _gcry_mpi_normalize ((a))
  ------------------
  690|      0|          *ret_mpi = a;
  691|      0|	}
  692|      0|      else
  693|      0|        mpi_free(a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  694|      0|      if (nscanned)
  ------------------
  |  Branch (694:11): [True: 0, False: 0]
  ------------------
  695|      0|        *nscanned = strlen ((const char*)buffer);
  696|      0|      return 0;
  697|      0|    }
  698|      0|  else
  699|      0|    return GPG_ERR_INV_ARG;
  700|  79.8k|}
_gcry_mpi_print:
  713|   136k|{
  714|   136k|  unsigned int nbits = mpi_get_nbits (a);
  ------------------
  |  |  552|   136k|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
  715|   136k|  size_t len;
  716|   136k|  size_t dummy_nwritten;
  717|   136k|  int negative;
  718|       |
  719|   136k|  if (!nwritten)
  ------------------
  |  Branch (719:7): [True: 0, False: 136k]
  ------------------
  720|      0|    nwritten = &dummy_nwritten;
  721|       |
  722|       |  /* Libgcrypt does no always care to set clear the sign if the value
  723|       |     is 0.  For printing this is a bit of a surprise, in particular
  724|       |     because if some of the formats don't support negative numbers but
  725|       |     should be able to print a zero.  Thus we need this extra test
  726|       |     for a negative number.  */
  727|   136k|  if (a->sign && _gcry_mpi_cmp_ui (a, 0))
  ------------------
  |  Branch (727:7): [True: 0, False: 136k]
  |  Branch (727:18): [True: 0, False: 0]
  ------------------
  728|      0|    negative = 1;
  729|   136k|  else
  730|   136k|    negative = 0;
  731|       |
  732|   136k|  len = buflen;
  733|   136k|  *nwritten = 0;
  734|   136k|  if (format == GCRYMPI_FMT_STD)
  ------------------
  |  Branch (734:7): [True: 0, False: 136k]
  ------------------
  735|      0|    {
  736|      0|      unsigned char *tmp;
  737|      0|      int extra = 0;
  738|      0|      unsigned int n;
  739|       |
  740|      0|      tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
  741|      0|      if (!tmp)
  ------------------
  |  Branch (741:11): [True: 0, False: 0]
  ------------------
  742|      0|        return gpg_err_code_from_syserror ();
  743|       |
  744|      0|      if (negative)
  ------------------
  |  Branch (744:11): [True: 0, False: 0]
  ------------------
  745|      0|        {
  746|      0|          twocompl (tmp, n);
  747|      0|          if (!(*tmp & 0x80))
  ------------------
  |  Branch (747:15): [True: 0, False: 0]
  ------------------
  748|      0|            {
  749|       |              /* Need to extend the sign.  */
  750|      0|              n++;
  751|      0|              extra = 2;
  752|      0|            }
  753|      0|        }
  754|      0|      else if (n && (*tmp & 0x80))
  ------------------
  |  Branch (754:16): [True: 0, False: 0]
  |  Branch (754:21): [True: 0, False: 0]
  ------------------
  755|      0|        {
  756|       |          /* Positive but the high bit of the returned buffer is set.
  757|       |             Thus we need to print an extra leading 0x00 so that the
  758|       |             output is interpreted as a positive number.  */
  759|      0|          n++;
  760|      0|          extra = 1;
  761|      0|	}
  762|       |
  763|      0|      if (buffer && n > len)
  ------------------
  |  Branch (763:11): [True: 0, False: 0]
  |  Branch (763:21): [True: 0, False: 0]
  ------------------
  764|      0|        {
  765|       |          /* The provided buffer is too short. */
  766|      0|          xfree (tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  767|      0|          return GPG_ERR_TOO_SHORT;
  768|      0|	}
  769|      0|      if (buffer)
  ------------------
  |  Branch (769:11): [True: 0, False: 0]
  ------------------
  770|      0|        {
  771|      0|          unsigned char *s = buffer;
  772|       |
  773|      0|          if (extra == 1)
  ------------------
  |  Branch (773:15): [True: 0, False: 0]
  ------------------
  774|      0|            *s++ = 0;
  775|      0|          else if (extra)
  ------------------
  |  Branch (775:20): [True: 0, False: 0]
  ------------------
  776|      0|            *s++ = 0xff;
  777|      0|          memcpy (s, tmp, n-!!extra);
  778|      0|	}
  779|      0|      xfree (tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  780|      0|      *nwritten = n;
  781|      0|      return 0;
  782|      0|    }
  783|   136k|  else if (format == GCRYMPI_FMT_USG)
  ------------------
  |  Branch (783:12): [True: 0, False: 136k]
  ------------------
  784|      0|    {
  785|      0|      unsigned int n = (nbits + 7)/8;
  786|       |
  787|       |      /* Note:  We ignore the sign for this format.  */
  788|       |      /* FIXME: for performance reasons we should put this into
  789|       |	 mpi_aprint because we can then use the buffer directly.  */
  790|       |
  791|      0|      if (buffer && n > len)
  ------------------
  |  Branch (791:11): [True: 0, False: 0]
  |  Branch (791:21): [True: 0, False: 0]
  ------------------
  792|      0|        return GPG_ERR_TOO_SHORT;
  793|      0|      if (buffer)
  ------------------
  |  Branch (793:11): [True: 0, False: 0]
  ------------------
  794|      0|        {
  795|      0|          unsigned char *tmp;
  796|       |
  797|      0|          tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
  798|      0|          if (!tmp)
  ------------------
  |  Branch (798:15): [True: 0, False: 0]
  ------------------
  799|      0|            return gpg_err_code_from_syserror ();
  800|      0|          memcpy (buffer, tmp, n);
  801|      0|          xfree (tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  802|      0|	}
  803|      0|      *nwritten = n;
  804|      0|      return 0;
  805|      0|    }
  806|   136k|  else if (format == GCRYMPI_FMT_PGP)
  ------------------
  |  Branch (806:12): [True: 136k, False: 0]
  ------------------
  807|   136k|    {
  808|   136k|      unsigned int n = (nbits + 7)/8;
  809|       |
  810|       |      /* The PGP format can only handle unsigned integers.  */
  811|   136k|      if (negative)
  ------------------
  |  Branch (811:11): [True: 0, False: 136k]
  ------------------
  812|      0|        return GPG_ERR_INV_ARG;
  813|       |
  814|   136k|      if (buffer && n+2 > len)
  ------------------
  |  Branch (814:11): [True: 68.1k, False: 68.1k]
  |  Branch (814:21): [True: 0, False: 68.1k]
  ------------------
  815|      0|        return GPG_ERR_TOO_SHORT;
  816|       |
  817|   136k|      if (buffer)
  ------------------
  |  Branch (817:11): [True: 68.1k, False: 68.1k]
  ------------------
  818|  68.1k|        {
  819|  68.1k|          unsigned char *tmp;
  820|  68.1k|          unsigned char *s = buffer;
  821|       |
  822|  68.1k|          s[0] = nbits >> 8;
  823|  68.1k|          s[1] = nbits;
  824|       |
  825|  68.1k|          tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
  826|  68.1k|          if (!tmp)
  ------------------
  |  Branch (826:15): [True: 0, False: 68.1k]
  ------------------
  827|      0|            return gpg_err_code_from_syserror ();
  828|  68.1k|          memcpy (s+2, tmp, n);
  829|  68.1k|          xfree (tmp);
  ------------------
  |  |  150|  68.1k|#define xfree(a)         _gcry_free ((a))
  ------------------
  830|  68.1k|	}
  831|   136k|      *nwritten = n+2;
  832|   136k|      return 0;
  833|   136k|    }
  834|      0|  else if (format == GCRYMPI_FMT_SSH)
  ------------------
  |  Branch (834:12): [True: 0, False: 0]
  ------------------
  835|      0|    {
  836|      0|      unsigned char *tmp;
  837|      0|      int extra = 0;
  838|      0|      unsigned int n;
  839|       |
  840|      0|      tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
  841|      0|      if (!tmp)
  ------------------
  |  Branch (841:11): [True: 0, False: 0]
  ------------------
  842|      0|        return gpg_err_code_from_syserror ();
  843|       |
  844|      0|      if (negative)
  ------------------
  |  Branch (844:11): [True: 0, False: 0]
  ------------------
  845|      0|        {
  846|      0|          twocompl (tmp, n);
  847|      0|          if (!(*tmp & 0x80))
  ------------------
  |  Branch (847:15): [True: 0, False: 0]
  ------------------
  848|      0|            {
  849|       |              /* Need to extend the sign.  */
  850|      0|              n++;
  851|      0|              extra = 2;
  852|      0|            }
  853|      0|        }
  854|      0|      else if (n && (*tmp & 0x80))
  ------------------
  |  Branch (854:16): [True: 0, False: 0]
  |  Branch (854:21): [True: 0, False: 0]
  ------------------
  855|      0|        {
  856|      0|          n++;
  857|      0|          extra=1;
  858|      0|	}
  859|       |
  860|      0|      if (buffer && n+4 > len)
  ------------------
  |  Branch (860:11): [True: 0, False: 0]
  |  Branch (860:21): [True: 0, False: 0]
  ------------------
  861|      0|        {
  862|      0|          xfree(tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  863|      0|          return GPG_ERR_TOO_SHORT;
  864|      0|	}
  865|       |
  866|      0|      if (buffer)
  ------------------
  |  Branch (866:11): [True: 0, False: 0]
  ------------------
  867|      0|        {
  868|      0|          unsigned char *s = buffer;
  869|       |
  870|      0|	  buf_put_be32 (s, n);
  871|      0|	  s += 4;
  872|      0|          if (extra == 1)
  ------------------
  |  Branch (872:15): [True: 0, False: 0]
  ------------------
  873|      0|            *s++ = 0;
  874|      0|          else if (extra)
  ------------------
  |  Branch (874:20): [True: 0, False: 0]
  ------------------
  875|      0|            *s++ = 0xff;
  876|      0|          memcpy (s, tmp, n-!!extra);
  877|      0|	}
  878|      0|      xfree (tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  879|      0|      *nwritten = 4+n;
  880|      0|      return 0;
  881|      0|    }
  882|      0|  else if (format == GCRYMPI_FMT_HEX)
  ------------------
  |  Branch (882:12): [True: 0, False: 0]
  ------------------
  883|      0|    {
  884|      0|      unsigned char *tmp;
  885|      0|      int i;
  886|      0|      int extra = 0;
  887|      0|      unsigned int n = 0;
  888|       |
  889|      0|      tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
  890|      0|      if (!tmp)
  ------------------
  |  Branch (890:11): [True: 0, False: 0]
  ------------------
  891|      0|        return gpg_err_code_from_syserror ();
  892|      0|      if (!n || (*tmp & 0x80))
  ------------------
  |  Branch (892:11): [True: 0, False: 0]
  |  Branch (892:17): [True: 0, False: 0]
  ------------------
  893|      0|        extra = 2;
  894|       |
  895|      0|      if (buffer && 2*n + extra + negative + 1 > len)
  ------------------
  |  Branch (895:11): [True: 0, False: 0]
  |  Branch (895:21): [True: 0, False: 0]
  ------------------
  896|      0|        {
  897|      0|          xfree(tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  898|      0|          return GPG_ERR_TOO_SHORT;
  899|      0|	}
  900|      0|      if (buffer)
  ------------------
  |  Branch (900:11): [True: 0, False: 0]
  ------------------
  901|      0|        {
  902|      0|	  static const u32 nibble2hex[] =
  903|      0|	  {
  904|      0|	    '0', '1', '2', '3', '4', '5', '6', '7',
  905|      0|	    '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
  906|      0|	  };
  907|      0|          unsigned char *s = buffer;
  908|       |
  909|      0|          if (negative)
  ------------------
  |  Branch (909:15): [True: 0, False: 0]
  ------------------
  910|      0|            *s++ = '-';
  911|      0|          if (extra)
  ------------------
  |  Branch (911:15): [True: 0, False: 0]
  ------------------
  912|      0|            {
  913|      0|              *s++ = '0';
  914|      0|              *s++ = '0';
  915|      0|	    }
  916|       |
  917|      0|	  for (i = 0; i + 4 < n; i += 4)
  ------------------
  |  Branch (917:16): [True: 0, False: 0]
  ------------------
  918|      0|	    {
  919|      0|	      u32 c = buf_get_be32(tmp + i);
  920|      0|	      u32 o1, o2;
  921|       |
  922|      0|	      o1 = nibble2hex[(c >> 28) & 0xF];
  923|      0|	      o1 <<= 8;
  924|      0|	      o1 |= nibble2hex[(c >> 24) & 0xF];
  925|      0|	      o1 <<= 8;
  926|      0|	      o1 |= nibble2hex[(c >> 20) & 0xF];
  927|      0|	      o1 <<= 8;
  928|      0|	      o1 |= nibble2hex[(c >> 16) & 0xF];
  929|       |
  930|      0|	      o2 = nibble2hex[(c >> 12) & 0xF];
  931|      0|	      o2 <<= 8;
  932|      0|	      o2 |= (u64)nibble2hex[(c >> 8) & 0xF];
  933|      0|	      o2 <<= 8;
  934|      0|	      o2 |= (u64)nibble2hex[(c >> 4) & 0xF];
  935|      0|	      o2 <<= 8;
  936|      0|	      o2 |= (u64)nibble2hex[(c >> 0) & 0xF];
  937|       |
  938|      0|	      buf_put_be32 (s + 0, o1);
  939|      0|	      buf_put_be32 (s + 4, o2);
  940|      0|	      s += 8;
  941|      0|	    }
  942|      0|          for (; i < n; i++)
  ------------------
  |  Branch (942:18): [True: 0, False: 0]
  ------------------
  943|      0|            {
  944|      0|              unsigned int c = tmp[i];
  945|       |
  946|      0|              *s++ = nibble2hex[c >> 4];
  947|      0|              *s++ = nibble2hex[c & 0xF];
  948|      0|	    }
  949|      0|          *s++ = 0;
  950|      0|          *nwritten = s - buffer;
  951|      0|	}
  952|      0|      else
  953|      0|        {
  954|      0|          *nwritten = 2*n + extra + negative + 1;
  955|      0|	}
  956|      0|      xfree (tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  957|      0|      return 0;
  958|      0|    }
  959|      0|  else
  960|      0|    return GPG_ERR_INV_ARG;
  961|   136k|}
mpicoder.c:do_get_buffer:
  294|  68.1k|{
  295|  68.1k|  unsigned char *p, *buffer, *retbuffer;
  296|  68.1k|  unsigned int length, tmp;
  297|  68.1k|  mpi_limb_t alimb;
  298|  68.1k|  int i;
  299|  68.1k|  size_t n, n2;
  300|       |
  301|  68.1k|  if (sign)
  ------------------
  |  Branch (301:7): [True: 0, False: 68.1k]
  ------------------
  302|      0|    *sign = a->sign;
  303|       |
  304|  68.1k|  *nbytes = a->nlimbs * BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  68.1k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  68.1k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  305|  68.1k|  n = *nbytes? *nbytes:1; /* Allocate at least one byte.  */
  ------------------
  |  Branch (305:7): [True: 5.64k, False: 62.5k]
  ------------------
  306|  68.1k|  if (n < fill_le)
  ------------------
  |  Branch (306:7): [True: 0, False: 68.1k]
  ------------------
  307|      0|    n = fill_le;
  308|  68.1k|  if (extraalloc < 0)
  ------------------
  |  Branch (308:7): [True: 0, False: 68.1k]
  ------------------
  309|      0|    n2 = n + -extraalloc;
  310|  68.1k|  else
  311|  68.1k|    n2 = n + extraalloc;
  312|       |
  313|  68.1k|  retbuffer = (force_secure || mpi_is_secure(a))? xtrymalloc_secure (n2)
  ------------------
  |  |  115|  68.1k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 68.1k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 68.1k]
  |  |  ------------------
  ------------------
                retbuffer = (force_secure || mpi_is_secure(a))? xtrymalloc_secure (n2)
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
  |  Branch (313:16): [True: 0, False: 68.1k]
  ------------------
  314|  68.1k|                                                : xtrymalloc (n2);
  ------------------
  |  |  138|   136k|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  315|  68.1k|  if (!retbuffer)
  ------------------
  |  Branch (315:7): [True: 0, False: 68.1k]
  ------------------
  316|      0|    return NULL;
  317|  68.1k|  if (extraalloc < 0)
  ------------------
  |  Branch (317:7): [True: 0, False: 68.1k]
  ------------------
  318|      0|    buffer = retbuffer + -extraalloc;
  319|  68.1k|  else
  320|  68.1k|    buffer = retbuffer;
  321|  68.1k|  p = buffer;
  322|       |
  323|  87.0k|  for (i=a->nlimbs-1; i >= 0; i--)
  ------------------
  |  Branch (323:23): [True: 18.8k, False: 68.1k]
  ------------------
  324|  18.8k|    {
  325|  18.8k|      alimb = a->d[i];
  326|       |#if BYTES_PER_MPI_LIMB == 4
  327|       |      buf_put_be32 (p, alimb);
  328|       |      p += 4;
  329|       |#elif BYTES_PER_MPI_LIMB == 8
  330|  18.8k|      buf_put_be64 (p, alimb);
  331|  18.8k|      p += 8;
  332|       |#else
  333|       |#     error please implement for this limb size.
  334|       |#endif
  335|  18.8k|    }
  336|       |
  337|  68.1k|  if (fill_le)
  ------------------
  |  Branch (337:7): [True: 0, False: 68.1k]
  ------------------
  338|      0|    {
  339|      0|      length = *nbytes;
  340|       |      /* Reverse buffer and pad with zeroes.  */
  341|      0|      for (i = 0; i + 8 < length / 2; i += 8)
  ------------------
  |  Branch (341:19): [True: 0, False: 0]
  ------------------
  342|      0|	{
  343|      0|	  u64 head = buf_get_be64 (buffer + i);
  344|      0|	  u64 tail = buf_get_be64 (buffer + length - 8 - i);
  345|      0|	  buf_put_le64 (buffer + length - 8 - i, head);
  346|      0|	  buf_put_le64 (buffer + i, tail);
  347|      0|	}
  348|      0|      if (i + 4 < length / 2)
  ------------------
  |  Branch (348:11): [True: 0, False: 0]
  ------------------
  349|      0|	{
  350|      0|	  u32 head = buf_get_be32 (buffer + i);
  351|      0|	  u32 tail = buf_get_be32 (buffer + length - 4 - i);
  352|      0|	  buf_put_le32 (buffer + length - 4 - i, head);
  353|      0|	  buf_put_le32 (buffer + i, tail);
  354|      0|	  i += 4;
  355|      0|	}
  356|      0|      for (; i < length/2; i++)
  ------------------
  |  Branch (356:14): [True: 0, False: 0]
  ------------------
  357|      0|        {
  358|      0|          tmp = buffer[i];
  359|      0|          buffer[i] = buffer[length-1-i];
  360|      0|          buffer[length-1-i] = tmp;
  361|      0|        }
  362|       |      /* Pad with zeroes.  */
  363|      0|      for (p = buffer + length; length < fill_le; length++)
  ------------------
  |  Branch (363:33): [True: 0, False: 0]
  ------------------
  364|      0|        *p++ = 0;
  365|      0|      *nbytes = length;
  366|       |
  367|      0|      return retbuffer;
  368|      0|    }
  369|       |
  370|       |  /* This is sub-optimal but we need to do the shift operation because
  371|       |     the caller has to free the returned buffer.  */
  372|  93.3k|  for (p=buffer; *nbytes && !*p; p++, --*nbytes)
  ------------------
  |  Branch (372:18): [True: 30.8k, False: 62.5k]
  |  Branch (372:29): [True: 25.1k, False: 5.64k]
  ------------------
  373|  25.1k|    ;
  374|  68.1k|  if (p != buffer)
  ------------------
  |  Branch (374:7): [True: 4.50k, False: 63.6k]
  ------------------
  375|  4.50k|    memmove (buffer, p, *nbytes);
  376|  68.1k|  return retbuffer;
  377|  68.1k|}
mpicoder.c:mpi_read_from_buffer:
   50|  79.8k|{
   51|  79.8k|  int i, j;
   52|  79.8k|  unsigned int nbits, nbytes, nlimbs, nread=0;
   53|  79.8k|  mpi_limb_t a;
   54|  79.8k|  gcry_mpi_t val = MPI_NULL;
  ------------------
  |  |   78|  79.8k|#define MPI_NULL NULL
  ------------------
   55|  79.8k|  unsigned int max_nread = *ret_nread;
   56|       |
   57|  79.8k|  if ( max_nread < 2 )
  ------------------
  |  Branch (57:8): [True: 0, False: 79.8k]
  ------------------
   58|      0|    goto leave;
   59|  79.8k|  nbits = buffer[0] << 8 | buffer[1];
   60|  79.8k|  if ( nbits > MAX_EXTERN_MPI_BITS )
  ------------------
  |  |   43|  79.8k|#define MAX_EXTERN_MPI_BITS 16384
  ------------------
  |  Branch (60:8): [True: 0, False: 79.8k]
  ------------------
   61|      0|    {
   62|       |/*       log_debug ("mpi too large (%u bits)\n", nbits); */
   63|      0|      goto leave;
   64|      0|    }
   65|  79.8k|  buffer += 2;
   66|  79.8k|  nread = 2;
   67|       |
   68|  79.8k|  nbytes = (nbits+7) / 8;
   69|  79.8k|  nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  79.8k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  79.8k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
                nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  79.8k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  79.8k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   70|  79.8k|  val = secure? mpi_alloc_secure (nlimbs) : mpi_alloc (nlimbs);
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
                val = secure? mpi_alloc_secure (nlimbs) : mpi_alloc (nlimbs);
  ------------------
  |  |   97|   159k|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  |  Branch (70:9): [True: 0, False: 79.8k]
  ------------------
   71|  79.8k|  i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  79.8k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  79.8k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
                i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  79.8k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  79.8k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   72|  79.8k|  i %= BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  79.8k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  79.8k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   73|  79.8k|  j= val->nlimbs = nlimbs;
   74|  79.8k|  val->sign = 0;
   75|   105k|  for ( ; j > 0; j-- )
  ------------------
  |  Branch (75:11): [True: 26.0k, False: 79.8k]
  ------------------
   76|  26.0k|    {
   77|  26.0k|      a = 0;
   78|  26.0k|      if (i == 0 && nread + BYTES_PER_MPI_LIMB <= max_nread)
  ------------------
  |  |    4|  18.1k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  18.1k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  |  Branch (78:11): [True: 18.1k, False: 7.86k]
  |  Branch (78:21): [True: 18.1k, False: 0]
  ------------------
   79|  18.1k|	{
   80|       |#if BYTES_PER_MPI_LIMB == 4
   81|       |	  a = buf_get_be32 (buffer);
   82|       |#elif BYTES_PER_MPI_LIMB == 8
   83|  18.1k|	  a = buf_get_be64 (buffer);
   84|       |#else
   85|       |#     error please implement for this limb size.
   86|       |#endif
   87|  18.1k|	  buffer += BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  18.1k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  18.1k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   88|  18.1k|	  nread += BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  18.1k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  18.1k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   89|  18.1k|	  i += BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  18.1k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  18.1k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   90|  18.1k|	}
   91|  43.3k|      for (; i < BYTES_PER_MPI_LIMB; i++ )
  ------------------
  |  |    4|  43.3k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  43.3k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  |  Branch (91:14): [True: 17.3k, False: 26.0k]
  ------------------
   92|  17.3k|        {
   93|  17.3k|          if ( ++nread > max_nread )
  ------------------
  |  Branch (93:16): [True: 0, False: 17.3k]
  ------------------
   94|      0|            {
   95|       |/*               log_debug ("mpi larger than buffer"); */
   96|      0|              mpi_free (val);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
   97|      0|              val = NULL;
   98|      0|              goto leave;
   99|      0|            }
  100|  17.3k|          a <<= 8;
  101|  17.3k|          a |= *buffer++;
  102|  17.3k|	}
  103|  26.0k|      i = 0;
  104|  26.0k|      val->d[j-1] = a;
  105|  26.0k|    }
  106|       |
  107|  79.8k| leave:
  108|  79.8k|  *ret_nread = nread;
  109|  79.8k|  return val;
  110|  79.8k|}

_gcry_mpi_init:
   67|      1|{
   68|      1|  int idx;
   69|      1|  unsigned long value;
   70|       |
   71|      7|  for (idx=0; idx < MPI_NUMBER_OF_CONSTANTS; idx++)
  ------------------
  |  |  144|      7|#define MPI_NUMBER_OF_CONSTANTS 6
  ------------------
  |  Branch (71:15): [True: 6, False: 1]
  ------------------
   72|      6|    {
   73|      6|      switch (idx)
   74|      6|        {
   75|      1|        case MPI_C_ZERO:  value = 0; break;
  ------------------
  |  Branch (75:9): [True: 1, False: 5]
  ------------------
   76|      1|        case MPI_C_ONE:   value = 1; break;
  ------------------
  |  Branch (76:9): [True: 1, False: 5]
  ------------------
   77|      1|        case MPI_C_TWO:   value = 2; break;
  ------------------
  |  Branch (77:9): [True: 1, False: 5]
  ------------------
   78|      1|        case MPI_C_THREE: value = 3; break;
  ------------------
  |  Branch (78:9): [True: 1, False: 5]
  ------------------
   79|      1|        case MPI_C_FOUR:  value = 4; break;
  ------------------
  |  Branch (79:9): [True: 1, False: 5]
  ------------------
   80|      1|        case MPI_C_EIGHT: value = 8; break;
  ------------------
  |  Branch (80:9): [True: 1, False: 5]
  ------------------
   81|      0|        default: log_bug ("invalid mpi_const selector %d\n", idx);
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  |  Branch (81:9): [True: 0, False: 6]
  ------------------
   82|      6|        }
   83|      6|      constants[idx] = mpi_alloc_set_ui (value);
  ------------------
  |  |  119|      6|#define mpi_alloc_set_ui(a)   _gcry_mpi_alloc_set_ui ((a))
  ------------------
   84|      6|      constants[idx]->flags = (16|32);
   85|      6|    }
   86|       |
   87|      1|  return 0;
   88|      1|}
_gcry_mpi_alloc:
  101|   162k|{
  102|   162k|    gcry_mpi_t a;
  103|       |
  104|   162k|    a = xmalloc( sizeof *a );
  ------------------
  |  |  144|   162k|#define xmalloc(a)       _gcry_xmalloc ((a))
  ------------------
  105|   162k|    a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 0 ) : NULL;
  ------------------
  |  |  178|  9.05k|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  |  Branch (105:12): [True: 9.05k, False: 153k]
  ------------------
  106|   162k|    a->alloced = nlimbs;
  107|   162k|    a->nlimbs = 0;
  108|   162k|    a->sign = 0;
  109|   162k|    a->flags = 0;
  110|   162k|    return a;
  111|   162k|}
_gcry_mpi_alloc_limb_space:
  131|  9.05k|{
  132|  9.05k|    mpi_ptr_t p;
  133|  9.05k|    size_t len;
  134|       |
  135|  9.05k|    len = (nlimbs ? nlimbs : 1) * sizeof (mpi_limb_t);
  ------------------
  |  Branch (135:12): [True: 9.05k, False: 0]
  ------------------
  136|  9.05k|    p = secure ? xmalloc_secure (len) : xmalloc (len);
  ------------------
  |  |  146|      0|#define xmalloc_secure(a)   _gcry_xmalloc_secure ((a))
  ------------------
                  p = secure ? xmalloc_secure (len) : xmalloc (len);
  ------------------
  |  |  144|  18.1k|#define xmalloc(a)       _gcry_xmalloc ((a))
  ------------------
  |  Branch (136:9): [True: 0, False: 9.05k]
  ------------------
  137|  9.05k|    if (! nlimbs)
  ------------------
  |  Branch (137:9): [True: 0, False: 9.05k]
  ------------------
  138|      0|      *p = 0;
  139|       |
  140|  9.05k|    return p;
  141|  9.05k|}
_gcry_mpi_free_limb_space:
  145|   162k|{
  146|   162k|  if (a)
  ------------------
  |  Branch (146:7): [True: 9.04k, False: 153k]
  ------------------
  147|  9.04k|    {
  148|  9.04k|      size_t len = nlimbs * sizeof(mpi_limb_t);
  149|       |
  150|       |      /* If we have information on the number of allocated limbs, we
  151|       |         better wipe that space out.  This is a failsafe feature if
  152|       |         secure memory has been disabled or was not properly
  153|       |         implemented in user provided allocation functions. */
  154|  9.04k|      if (len)
  ------------------
  |  Branch (154:11): [True: 9.04k, False: 0]
  ------------------
  155|  9.04k|        wipememory (a, len);
  ------------------
  |  |  398|  9.04k|#define wipememory(_ptr,_len) wipememory2((_ptr),0,(_len))
  |  |  ------------------
  |  |  |  |  388|  9.04k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|  9.04k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|  18.0k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 9.04k, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|  9.04k|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|  18.0k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|  9.04k|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|  9.04k|		else \
  |  |  |  |  393|  9.04k|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|  9.04k|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|  9.04k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  156|  9.04k|      xfree(a);
  ------------------
  |  |  150|  9.04k|#define xfree(a)         _gcry_free ((a))
  ------------------
  157|  9.04k|    }
  158|   162k|}
_gcry_mpi_free:
  223|  7.41M|{
  224|  7.41M|  if (!a )
  ------------------
  |  Branch (224:7): [True: 7.25M, False: 162k]
  ------------------
  225|  7.25M|    return;
  226|   162k|  if ((a->flags & 32))
  ------------------
  |  Branch (226:7): [True: 0, False: 162k]
  ------------------
  227|      0|  {
  228|      0|#if GPGRT_VERSION_NUMBER >= 0x011600  /* 1.22 */
  229|      0|    gpgrt_annotate_leaked_object(a);
  230|      0|#endif
  231|      0|    return; /* Never release a constant. */
  232|      0|  }
  233|   162k|  if ((a->flags & 4))
  ------------------
  |  Branch (233:7): [True: 81.9k, False: 80.5k]
  ------------------
  234|  81.9k|    xfree( a->d );
  ------------------
  |  |  150|  81.9k|#define xfree(a)         _gcry_free ((a))
  ------------------
  235|  80.5k|  else
  236|  80.5k|    {
  237|  80.5k|      _gcry_mpi_free_limb_space(a->d, a->alloced);
  238|  80.5k|    }
  239|       |  /* Check that the flags makes sense.  We better allow for bit 1
  240|       |     (value 2) for backward ABI compatibility.  */
  241|   162k|  if ((a->flags & ~(1|2|4|16
  ------------------
  |  Branch (241:7): [True: 0, False: 162k]
  ------------------
  242|   162k|                    |GCRYMPI_FLAG_USER1
  243|   162k|                    |GCRYMPI_FLAG_USER2
  244|   162k|                    |GCRYMPI_FLAG_USER3
  245|   162k|                    |GCRYMPI_FLAG_USER4)))
  246|      0|    log_bug("invalid flag value in mpi_free\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  247|   162k|  xfree (a);
  ------------------
  |  |  150|   162k|#define xfree(a)         _gcry_free ((a))
  ------------------
  248|   162k|}
_gcry_mpi_set_opaque:
  281|  81.9k|{
  282|  81.9k|  if (!a)
  ------------------
  |  Branch (282:7): [True: 81.9k, False: 0]
  ------------------
  283|  81.9k|    a = mpi_alloc(0);
  ------------------
  |  |   97|  81.9k|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  284|       |
  285|  81.9k|  if (mpi_is_immutable (a))
  ------------------
  |  |  113|  81.9k|#define mpi_is_immutable(a)   ((a)->flags&16)
  |  |  ------------------
  |  |  |  Branch (113:31): [True: 0, False: 81.9k]
  |  |  ------------------
  ------------------
  286|      0|    {
  287|      0|      mpi_immutable_failed ();
  ------------------
  |  |  110|      0|#define mpi_immutable_failed() _gcry_mpi_immutable_failed ()
  ------------------
  288|      0|      return a;
  289|      0|    }
  290|       |
  291|  81.9k|  if( a->flags & 4 )
  ------------------
  |  Branch (291:7): [True: 0, False: 81.9k]
  ------------------
  292|      0|    xfree (a->d);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  293|  81.9k|  else
  294|  81.9k|    _gcry_mpi_free_limb_space (a->d, a->alloced);
  295|       |
  296|  81.9k|  a->d = p;
  297|  81.9k|  a->alloced = 0;
  298|  81.9k|  a->nlimbs = 0;
  299|  81.9k|  a->sign  = nbits;
  300|  81.9k|  a->flags = 4 | (a->flags & (GCRYMPI_FLAG_USER1|GCRYMPI_FLAG_USER2
  301|  81.9k|                              |GCRYMPI_FLAG_USER3|GCRYMPI_FLAG_USER4));
  302|  81.9k|  if (_gcry_is_secure (a->d))
  ------------------
  |  Branch (302:7): [True: 0, False: 81.9k]
  ------------------
  303|      0|    a->flags |= 1;
  304|  81.9k|  return a;
  305|  81.9k|}
_gcry_mpi_get_opaque:
  325|  42.6k|{
  326|  42.6k|    if( !(a->flags & 4) )
  ------------------
  |  Branch (326:9): [True: 0, False: 42.6k]
  ------------------
  327|      0|	log_bug("mpi_get_opaque on normal mpi\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  328|  42.6k|    if( nbits )
  ------------------
  |  Branch (328:9): [True: 42.6k, False: 0]
  ------------------
  329|  42.6k|	*nbits = a->sign;
  330|  42.6k|    return a->d;
  331|  42.6k|}
_gcry_mpi_copy:
  357|  1.94k|{
  358|  1.94k|    int i;
  359|  1.94k|    gcry_mpi_t b;
  360|       |
  361|  1.94k|    if( a && (a->flags & 4) ) {
  ------------------
  |  Branch (361:9): [True: 1.51k, False: 427]
  |  Branch (361:14): [True: 800, False: 713]
  ------------------
  362|    800|        void *p = NULL;
  363|    800|        if (a->sign) {
  ------------------
  |  Branch (363:13): [True: 800, False: 0]
  ------------------
  364|    800|            p = _gcry_is_secure(a->d)? xmalloc_secure ((a->sign+7)/8)
  ------------------
  |  |  146|      0|#define xmalloc_secure(a)   _gcry_xmalloc_secure ((a))
  ------------------
  |  Branch (364:17): [True: 0, False: 800]
  ------------------
  365|    800|                                     : xmalloc ((a->sign+7)/8);
  ------------------
  |  |  144|  1.60k|#define xmalloc(a)       _gcry_xmalloc ((a))
  ------------------
  366|    800|            if (a->d)
  ------------------
  |  Branch (366:17): [True: 800, False: 0]
  ------------------
  367|    800|                memcpy( p, a->d, (a->sign+7)/8 );
  368|    800|        }
  369|    800|        b = mpi_set_opaque( NULL, p, a->sign );
  ------------------
  |  |  561|    800|#define mpi_set_opaque(a,b,c)  _gcry_mpi_set_opaque ((a), (b), (c))
  ------------------
  370|    800|        b->flags = a->flags;
  371|    800|        b->flags &= ~(16|32); /* Reset the immutable and constant flags.  */
  372|    800|    }
  373|  1.14k|    else if( a ) {
  ------------------
  |  Branch (373:14): [True: 713, False: 427]
  ------------------
  374|    713|	b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
  ------------------
  |  |  115|    713|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 713, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 713]
  |  |  ------------------
  ------------------
              	b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  375|    713|			    : mpi_alloc( a->nlimbs );
  ------------------
  |  |   97|  1.42k|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  376|    713|	b->nlimbs = a->nlimbs;
  377|    713|	b->sign = a->sign;
  378|    713|	b->flags  = a->flags;
  379|    713|        b->flags &= ~(16|32); /* Reset the immutable and constant flags.  */
  380|  1.48k|	for(i=0; i < b->nlimbs; i++ )
  ------------------
  |  Branch (380:11): [True: 772, False: 713]
  ------------------
  381|    772|	    b->d[i] = a->d[i];
  382|    713|    }
  383|    427|    else
  384|    427|	b = NULL;
  385|  1.94k|    return b;
  386|  1.94k|}
_gcry_mpi_alloc_set_ui:
  592|      6|{
  593|      6|    gcry_mpi_t w = mpi_alloc(1);
  ------------------
  |  |   97|      6|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  594|      6|    w->d[0] = u;
  595|      6|    w->nlimbs = u? 1:0;
  ------------------
  |  Branch (595:17): [True: 5, False: 1]
  ------------------
  596|      6|    w->sign = 0;
  597|      6|    return w;
  598|      6|}
_gcry_mpi_release:
  687|  7.41M|{
  688|  7.41M|    _gcry_mpi_free( a );
  689|  7.41M|}
_gcry_mpi_set_flag:
  721|  20.1k|{
  722|  20.1k|  switch (flag)
  723|  20.1k|    {
  724|      0|    case GCRYMPI_FLAG_SECURE:     mpi_set_secure(a); break;
  ------------------
  |  Branch (724:5): [True: 0, False: 20.1k]
  ------------------
  725|      0|    case GCRYMPI_FLAG_CONST:      a->flags |= (16|32); break;
  ------------------
  |  Branch (725:5): [True: 0, False: 20.1k]
  ------------------
  726|      0|    case GCRYMPI_FLAG_IMMUTABLE:  a->flags |= 16; break;
  ------------------
  |  Branch (726:5): [True: 0, False: 20.1k]
  ------------------
  727|       |
  728|  6.89k|    case GCRYMPI_FLAG_USER1:
  ------------------
  |  Branch (728:5): [True: 6.89k, False: 13.2k]
  ------------------
  729|  20.1k|    case GCRYMPI_FLAG_USER2:
  ------------------
  |  Branch (729:5): [True: 13.2k, False: 6.89k]
  ------------------
  730|  20.1k|    case GCRYMPI_FLAG_USER3:
  ------------------
  |  Branch (730:5): [True: 0, False: 20.1k]
  ------------------
  731|  20.1k|    case GCRYMPI_FLAG_USER4:      a->flags |= flag; break;
  ------------------
  |  Branch (731:5): [True: 0, False: 20.1k]
  ------------------
  732|       |
  733|      0|    case GCRYMPI_FLAG_OPAQUE:
  ------------------
  |  Branch (733:5): [True: 0, False: 20.1k]
  ------------------
  734|      0|    default: log_bug("invalid flag value\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  |  Branch (734:5): [True: 0, False: 20.1k]
  ------------------
  735|  20.1k|    }
  736|  20.1k|}
_gcry_mpi_get_flag:
  766|   203k|{
  767|   203k|  switch (flag)
  768|   203k|    {
  769|      0|    case GCRYMPI_FLAG_SECURE:    return !!(a->flags & 1);
  ------------------
  |  Branch (769:5): [True: 0, False: 203k]
  ------------------
  770|   178k|    case GCRYMPI_FLAG_OPAQUE:    return !!(a->flags & 4);
  ------------------
  |  Branch (770:5): [True: 178k, False: 24.5k]
  ------------------
  771|      0|    case GCRYMPI_FLAG_IMMUTABLE: return !!(a->flags & 16);
  ------------------
  |  Branch (771:5): [True: 0, False: 203k]
  ------------------
  772|      0|    case GCRYMPI_FLAG_CONST:     return !!(a->flags & 32);
  ------------------
  |  Branch (772:5): [True: 0, False: 203k]
  ------------------
  773|      0|    case GCRYMPI_FLAG_USER1:
  ------------------
  |  Branch (773:5): [True: 0, False: 203k]
  ------------------
  774|  24.5k|    case GCRYMPI_FLAG_USER2:
  ------------------
  |  Branch (774:5): [True: 24.5k, False: 178k]
  ------------------
  775|  24.5k|    case GCRYMPI_FLAG_USER3:
  ------------------
  |  Branch (775:5): [True: 0, False: 203k]
  ------------------
  776|  24.5k|    case GCRYMPI_FLAG_USER4:     return !!(a->flags & flag);
  ------------------
  |  Branch (776:5): [True: 0, False: 203k]
  ------------------
  777|      0|    default: log_bug("invalid flag value\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  |  Branch (777:5): [True: 0, False: 203k]
  ------------------
  778|   203k|    }
  779|       |  /*NOTREACHED*/
  780|      0|  return 0;
  781|   203k|}

_gcry_rngcsprng_initialize:
  317|      1|{
  318|      1|  if (!full)
  ------------------
  |  Branch (318:7): [True: 0, False: 1]
  ------------------
  319|      0|    initialize_basics ();
  320|      1|  else
  321|      1|    initialize ();
  322|      1|}
_gcry_rngcsprng_randomize:
  450|      1|{
  451|      1|  unsigned char *p;
  452|       |
  453|       |  /* Make sure we are initialized. */
  454|      1|  initialize ();
  455|       |
  456|       |  /* Handle our hack used for regression tests of Libgcrypt. */
  457|      1|  if ( quick_test && level > GCRY_STRONG_RANDOM )
  ------------------
  |  Branch (457:8): [True: 0, False: 1]
  |  Branch (457:22): [True: 0, False: 0]
  ------------------
  458|      0|    level = GCRY_STRONG_RANDOM;
  459|       |
  460|       |  /* Make sure the level is okay. */
  461|      1|  level &= 3;
  462|       |
  463|       |  /* Acquire the pool lock. */
  464|      1|  lock_pool ();
  465|       |
  466|       |  /* Update the statistics. */
  467|      1|  if (level >= GCRY_VERY_STRONG_RANDOM)
  ------------------
  |  Branch (467:7): [True: 0, False: 1]
  ------------------
  468|      0|    {
  469|      0|      rndstats.getbytes2 += length;
  470|      0|      rndstats.ngetbytes2++;
  471|      0|    }
  472|      1|  else
  473|      1|    {
  474|      1|      rndstats.getbytes1 += length;
  475|      1|      rndstats.ngetbytes1++;
  476|      1|    }
  477|       |
  478|       |  /* Read the random into the provided buffer. */
  479|      2|  for (p = buffer; length > 0;)
  ------------------
  |  Branch (479:20): [True: 1, False: 1]
  ------------------
  480|      1|    {
  481|      1|      size_t n;
  482|       |
  483|      1|      n = length > POOLSIZE? POOLSIZE : length;
  ------------------
  |  |   95|      1|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      1|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      1|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
                    n = length > POOLSIZE? POOLSIZE : length;
  ------------------
  |  |   95|      0|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      0|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      0|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  |  Branch (483:11): [True: 0, False: 1]
  ------------------
  484|      1|      read_pool (p, n, level);
  485|      1|      length -= n;
  486|      1|      p += n;
  487|      1|    }
  488|       |
  489|       |  /* Release the pool lock. */
  490|      1|  unlock_pool ();
  491|      1|}
_gcry_rngcsprng_fast_poll:
 1296|  48.9k|{
 1297|  48.9k|  initialize_basics ();
 1298|       |
 1299|  48.9k|  lock_pool ();
 1300|  48.9k|  if (rndpool)
  ------------------
  |  Branch (1300:7): [True: 48.9k, False: 0]
  ------------------
 1301|  48.9k|    {
 1302|       |      /* Yes, we are fully initialized. */
 1303|  48.9k|      do_fast_random_poll ();
 1304|  48.9k|    }
 1305|  48.9k|  unlock_pool ();
 1306|  48.9k|}
random-csprng.c:initialize_basics:
  234|  48.9k|{
  235|  48.9k|  static int initialized;
  236|       |
  237|  48.9k|  if (!initialized)
  ------------------
  |  Branch (237:7): [True: 1, False: 48.9k]
  ------------------
  238|      1|    {
  239|      1|      initialized = 1;
  240|       |
  241|       |      /* Make sure that we are still using the values we have
  242|       |         traditionally used for the random levels.  */
  243|      1|      gcry_assert (GCRY_WEAK_RANDOM == 0
  ------------------
  |  |  188|      1|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      2|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [Folded - Ignored]
  |  |  |  |  |  Branch (85:48): [Folded - Ignored]
  |  |  |  |  |  Branch (85:48): [Folded - Ignored]
  |  |  |  |  |  Branch (85:48): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      1|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  244|      1|                   && GCRY_STRONG_RANDOM == 1
  245|      1|                   && GCRY_VERY_STRONG_RANDOM == 2);
  246|      1|    }
  247|  48.9k|}
random-csprng.c:initialize:
  277|      2|{
  278|       |  /* Although the basic initialization should have happened already,
  279|       |     we call it here to make sure that all prerequisites are met.  */
  280|      2|  initialize_basics ();
  281|       |
  282|       |  /* Now we can look the pool and complete the initialization if
  283|       |     necessary.  */
  284|      2|  lock_pool ();
  285|      2|  if (!rndpool)
  ------------------
  |  Branch (285:7): [True: 1, False: 1]
  ------------------
  286|      1|    {
  287|       |      /* The data buffer is allocated somewhat larger, so that we can
  288|       |         use this extra space (which is allocated in secure memory) as
  289|       |         a temporary hash buffer */
  290|      1|      rndpool = (secure_alloc
  ------------------
  |  Branch (290:18): [True: 0, False: 1]
  ------------------
  291|      1|                 ? xcalloc_secure (1, POOLSIZE + BLOCKLEN)
  ------------------
  |  |  147|      0|#define xcalloc_secure(a,b) _gcry_xcalloc_secure ((a),(b))
  ------------------
  292|      1|                 : xcalloc (1, POOLSIZE + BLOCKLEN));
  ------------------
  |  |  145|      1|#define xcalloc(a,b)     _gcry_xcalloc ((a),(b))
  ------------------
  293|      1|      keypool = (secure_alloc
  ------------------
  |  Branch (293:18): [True: 0, False: 1]
  ------------------
  294|      1|                 ? xcalloc_secure (1, POOLSIZE + BLOCKLEN)
  ------------------
  |  |  147|      0|#define xcalloc_secure(a,b) _gcry_xcalloc_secure ((a),(b))
  ------------------
  295|      1|                 : xcalloc (1, POOLSIZE + BLOCKLEN));
  ------------------
  |  |  145|      1|#define xcalloc(a,b)     _gcry_xcalloc ((a),(b))
  ------------------
  296|       |
  297|       |      /* Setup the slow entropy gathering function.  The code requires
  298|       |         that this function exists. */
  299|      1|      slow_gather_fnc = getfnc_gather_random ();
  300|       |
  301|       |      /* Setup the fast entropy gathering function.  */
  302|      1|      fast_gather_fnc = getfnc_fast_random_poll ();
  303|       |
  304|      1|    }
  305|      2|  unlock_pool ();
  306|      2|}
random-csprng.c:getfnc_gather_random:
 1146|      1|{
 1147|      1|  int (*fnc)(void (*)(const void*, size_t, enum random_origins),
 1148|      1|             enum random_origins, size_t, int);
 1149|       |
 1150|      1|#if USE_RNDGETENTROPY
 1151|      1|  fnc = _gcry_rndgetentropy_gather_random;
 1152|      1|  return fnc;
 1153|      0|#endif
 1154|       |
 1155|       |#if USE_RNDOLDLINUX
 1156|       |  if ( !access (NAME_OF_DEV_RANDOM, R_OK)
 1157|       |       && !access (NAME_OF_DEV_URANDOM, R_OK))
 1158|       |    {
 1159|       |      fnc = _gcry_rndoldlinux_gather_random;
 1160|       |      return fnc;
 1161|       |    }
 1162|       |#endif
 1163|       |
 1164|       |#if USE_RNDEGD
 1165|       |  if ( _gcry_rndegd_connect_socket (1) != -1 )
 1166|       |    {
 1167|       |      fnc = _gcry_rndegd_gather_random;
 1168|       |      return fnc;
 1169|       |    }
 1170|       |#endif
 1171|       |
 1172|       |#if USE_RNDUNIX
 1173|       |  fnc = _gcry_rndunix_gather_random;
 1174|       |  return fnc;
 1175|       |#endif
 1176|       |
 1177|       |#if USE_RNDW32
 1178|       |  fnc = _gcry_rndw32_gather_random;
 1179|       |  return fnc;
 1180|       |#endif
 1181|       |
 1182|       |#if USE_RNDW32CE
 1183|       |  fnc = _gcry_rndw32ce_gather_random;
 1184|       |  return fnc;
 1185|       |#endif
 1186|       |
 1187|      0|  log_fatal (_("no entropy gathering module detected\n"));
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
                log_fatal (_("no entropy gathering module detected\n"));
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
 1188|       |
 1189|      0|  return NULL; /*NOTREACHED*/
 1190|      1|}
random-csprng.c:getfnc_fast_random_poll:
 1198|      1|{
 1199|       |#if USE_RNDW32
 1200|       |  return _gcry_rndw32_gather_random_fast;
 1201|       |#endif
 1202|       |#if USE_RNDW32CE
 1203|       |  return _gcry_rndw32ce_gather_random_fast;
 1204|       |#endif
 1205|      1|  return NULL;
 1206|      1|}
random-csprng.c:lock_pool:
  252|  48.9k|{
  253|  48.9k|  int err;
  254|       |
  255|  48.9k|  err = gpgrt_lock_lock (&pool_lock);
  256|  48.9k|  if (err)
  ------------------
  |  Branch (256:7): [True: 0, False: 48.9k]
  ------------------
  257|      0|    log_fatal ("failed to acquire the pool lock: %s\n", gpg_strerror (err));
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  258|  48.9k|  pool_is_locked = 1;
  259|  48.9k|}
random-csprng.c:unlock_pool:
  264|  48.9k|{
  265|  48.9k|  int err;
  266|       |
  267|  48.9k|  pool_is_locked = 0;
  268|  48.9k|  err = gpgrt_lock_unlock (&pool_lock);
  269|  48.9k|  if (err)
  ------------------
  |  Branch (269:7): [True: 0, False: 48.9k]
  ------------------
  270|      0|    log_fatal ("failed to release the pool lock: %s\n", gpg_strerror (err));
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  271|  48.9k|}
random-csprng.c:mix_pool:
  540|  19.5k|{
  541|  19.5k|  static unsigned char failsafe_digest[DIGESTLEN];
  542|  19.5k|  static int failsafe_digest_valid;
  543|       |
  544|  19.5k|  unsigned char *hashbuf = pool + POOLSIZE;
  ------------------
  |  |   95|  19.5k|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|  19.5k|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|  19.5k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  545|  19.5k|  unsigned char *p, *pend;
  546|  19.5k|  int i, n;
  547|  19.5k|  SHA1_CONTEXT md;
  548|  19.5k|  unsigned int nburn;
  549|       |
  550|       |#if DIGESTLEN != 20
  551|       |#error must have a digest length of 20 for SHA-1
  552|       |#endif
  553|       |
  554|  19.5k|  gcry_assert (pool_is_locked);
  ------------------
  |  |  188|  19.5k|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|  19.5k|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 19.5k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|  19.5k|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  555|      0|  _gcry_sha1_mixblock_init (&md);
  556|       |
  557|       |  /* pool_0 -> pool'.  */
  558|  19.5k|  pend = pool + POOLSIZE;
  ------------------
  |  |   95|  19.5k|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|  19.5k|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|  19.5k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  559|  19.5k|  memcpy (hashbuf, pend - DIGESTLEN, DIGESTLEN);
  ------------------
  |  |   89|  19.5k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  ------------------
                memcpy (hashbuf, pend - DIGESTLEN, DIGESTLEN);
  ------------------
  |  |   89|  19.5k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  ------------------
  560|  19.5k|  memcpy (hashbuf+DIGESTLEN, pool, BLOCKLEN-DIGESTLEN);
  ------------------
  |  |   89|  19.5k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  ------------------
                memcpy (hashbuf+DIGESTLEN, pool, BLOCKLEN-DIGESTLEN);
  ------------------
  |  |   88|  19.5k|#define BLOCKLEN  64   /* Hash this amount of bytes... */
  ------------------
                memcpy (hashbuf+DIGESTLEN, pool, BLOCKLEN-DIGESTLEN);
  ------------------
  |  |   89|  19.5k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  ------------------
  561|  19.5k|  nburn = _gcry_sha1_mixblock (&md, hashbuf);
  562|  19.5k|  memcpy (pool, hashbuf, DIGESTLEN);
  ------------------
  |  |   89|  19.5k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  ------------------
  563|       |
  564|  19.5k|  if (failsafe_digest_valid && pool == rndpool)
  ------------------
  |  Branch (564:7): [True: 19.5k, False: 1]
  |  Branch (564:32): [True: 19.5k, False: 1]
  ------------------
  565|  19.5k|    {
  566|   411k|      for (i=0; i < DIGESTLEN; i++)
  ------------------
  |  |   89|   411k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  ------------------
  |  Branch (566:17): [True: 391k, False: 19.5k]
  ------------------
  567|   391k|        pool[i] ^= failsafe_digest[i];
  568|  19.5k|    }
  569|       |
  570|       |  /* Loop for the remaining iterations.  */
  571|  19.5k|  p = pool;
  572|   587k|  for (n=1; n < POOLBLOCKS; n++)
  ------------------
  |  |   91|   587k|#define POOLBLOCKS 30
  ------------------
  |  Branch (572:13): [True: 568k, False: 19.5k]
  ------------------
  573|   568k|    {
  574|   568k|      if (p + BLOCKLEN < pend)
  ------------------
  |  |   88|   568k|#define BLOCKLEN  64   /* Hash this amount of bytes... */
  ------------------
  |  Branch (574:11): [True: 528k, False: 39.1k]
  ------------------
  575|   528k|        memcpy (hashbuf, p, BLOCKLEN);
  ------------------
  |  |   88|   528k|#define BLOCKLEN  64   /* Hash this amount of bytes... */
  ------------------
  576|  39.1k|      else
  577|  39.1k|        {
  578|  39.1k|          unsigned char *pp = p;
  579|       |
  580|  2.54M|          for (i=0; i < BLOCKLEN; i++ )
  ------------------
  |  |   88|  2.54M|#define BLOCKLEN  64   /* Hash this amount of bytes... */
  ------------------
  |  Branch (580:21): [True: 2.50M, False: 39.1k]
  ------------------
  581|  2.50M|            {
  582|  2.50M|              if ( pp >= pend )
  ------------------
  |  Branch (582:20): [True: 39.1k, False: 2.46M]
  ------------------
  583|  39.1k|                pp = pool;
  584|  2.50M|              hashbuf[i] = *pp++;
  585|  2.50M|	    }
  586|  39.1k|	}
  587|       |
  588|   568k|      _gcry_sha1_mixblock (&md, hashbuf);
  589|   568k|      p += DIGESTLEN;
  ------------------
  |  |   89|   568k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  ------------------
  590|   568k|      memcpy (p, hashbuf, DIGESTLEN);
  ------------------
  |  |   89|   568k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  ------------------
  591|   568k|    }
  592|       |
  593|       |  /* Our hash implementation does only leave small parts (64 bytes)
  594|       |     of the pool on the stack, so it is okay not to require secure
  595|       |     memory here.  Before we use this pool, it will be copied to the
  596|       |     help buffer anyway. */
  597|  19.5k|  if ( pool == rndpool)
  ------------------
  |  Branch (597:8): [True: 19.5k, False: 1]
  ------------------
  598|  19.5k|    {
  599|  19.5k|      _gcry_sha1_hash_buffer (failsafe_digest, pool, POOLSIZE);
  ------------------
  |  |   95|  19.5k|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|  19.5k|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|  19.5k|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  600|  19.5k|      failsafe_digest_valid = 1;
  601|  19.5k|    }
  602|       |
  603|  19.5k|  _gcry_burn_stack (nburn);
  ------------------
  |  |  371|  19.5k|	do { __gcry_burn_stack (bytes); \
  |  |  372|  19.5k|	     __gcry_burn_stack_dummy (); } while(0)
  |  |  ------------------
  |  |  |  |  364|  19.5k|#define  __gcry_burn_stack_dummy() asm volatile ("":::"memory")
  |  |  ------------------
  |  |  |  Branch (372:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  604|  19.5k|}
random-csprng.c:read_pool:
  951|      1|{
  952|      1|  int i;
  953|      1|  unsigned long *sp, *dp;
  954|       |  /* The volatile is there to make sure the compiler does not optimize
  955|       |     the code away in case the getpid function is badly attributed.
  956|       |     Note that we keep a pid in a static variable as well as in a
  957|       |     stack based one; the latter is to detect ill behaving thread
  958|       |     libraries, ignoring the pool mutexes. */
  959|      1|  static volatile pid_t my_pid = (pid_t)(-1);
  960|      1|  volatile pid_t my_pid2;
  961|       |
  962|      1|  gcry_assert (pool_is_locked);
  ------------------
  |  |  188|      1|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      1|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      1|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  963|       |
  964|      1| retry:
  965|       |  /* Get our own pid, so that we can detect a fork. */
  966|      1|  my_pid2 = getpid ();
  967|      1|  if (my_pid == (pid_t)(-1))
  ------------------
  |  Branch (967:7): [True: 1, False: 0]
  ------------------
  968|      1|    my_pid = my_pid2;
  969|      1|  if ( my_pid != my_pid2 )
  ------------------
  |  Branch (969:8): [True: 0, False: 1]
  ------------------
  970|      0|    {
  971|       |      /* We detected a plain fork; i.e. we are now the child.  Update
  972|       |         the static pid and add some randomness. */
  973|      0|      pid_t x;
  974|       |
  975|      0|      my_pid = my_pid2;
  976|      0|      x = my_pid;
  977|      0|      add_randomness (&x, sizeof(x), RANDOM_ORIGIN_INIT);
  978|      0|      just_mixed = 0; /* Make sure it will get mixed. */
  979|      0|    }
  980|       |
  981|      1|  gcry_assert (pool_is_locked);
  ------------------
  |  |  188|      1|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      1|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      1|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  982|       |
  983|       |  /* Our code does not allow to extract more than POOLSIZE.  Better
  984|       |     check it here. */
  985|      1|  if (length > POOLSIZE)
  ------------------
  |  |   95|      1|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      1|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      1|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  |  Branch (985:7): [True: 0, False: 1]
  ------------------
  986|      0|    {
  987|      0|      log_bug("too many random bits requested\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  988|      0|    }
  989|       |
  990|      1|  if (!pool_filled)
  ------------------
  |  Branch (990:7): [True: 1, False: 0]
  ------------------
  991|      1|    {
  992|      1|      if (read_seed_file() )
  ------------------
  |  Branch (992:11): [True: 0, False: 1]
  ------------------
  993|      0|        pool_filled = 1;
  994|      1|    }
  995|       |
  996|       |  /* For level 2 quality (key generation) we always make sure that the
  997|       |     pool has been seeded enough initially. */
  998|      1|  if (level == GCRY_VERY_STRONG_RANDOM && !did_initial_extra_seeding)
  ------------------
  |  Branch (998:7): [True: 0, False: 1]
  |  Branch (998:43): [True: 0, False: 0]
  ------------------
  999|      0|    {
 1000|      0|      size_t needed;
 1001|       |
 1002|      0|      pool_balance = 0;
 1003|      0|      needed = length - pool_balance;
 1004|      0|      if (needed < 16)  /* At least 128 bits.  */
  ------------------
  |  Branch (1004:11): [True: 0, False: 0]
  ------------------
 1005|      0|        needed = 16;
 1006|      0|      else if( needed > POOLSIZE )
  ------------------
  |  |   95|      0|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      0|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      0|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  |  Branch (1006:16): [True: 0, False: 0]
  ------------------
 1007|      0|        BUG ();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
 1008|      0|      read_random_source (RANDOM_ORIGIN_EXTRAPOLL, needed,
 1009|      0|                          GCRY_VERY_STRONG_RANDOM);
 1010|      0|      pool_balance += needed;
 1011|      0|      did_initial_extra_seeding = 1;
 1012|      0|    }
 1013|       |
 1014|       |  /* For level 2 make sure that there is enough random in the pool. */
 1015|      1|  if (level == GCRY_VERY_STRONG_RANDOM && pool_balance < length)
  ------------------
  |  Branch (1015:7): [True: 0, False: 1]
  |  Branch (1015:43): [True: 0, False: 0]
  ------------------
 1016|      0|    {
 1017|      0|      size_t needed;
 1018|       |
 1019|      0|      if (pool_balance < 0)
  ------------------
  |  Branch (1019:11): [True: 0, False: 0]
  ------------------
 1020|      0|        pool_balance = 0;
 1021|      0|      needed = length - pool_balance;
 1022|      0|      if (needed > POOLSIZE)
  ------------------
  |  |   95|      0|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      0|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      0|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  |  Branch (1022:11): [True: 0, False: 0]
  ------------------
 1023|      0|        BUG ();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
 1024|      0|      read_random_source (RANDOM_ORIGIN_EXTRAPOLL, needed,
 1025|      0|                          GCRY_VERY_STRONG_RANDOM);
 1026|      0|      pool_balance += needed;
 1027|      0|    }
 1028|       |
 1029|       |  /* Make sure the pool is filled. */
 1030|     26|  while (!pool_filled)
  ------------------
  |  Branch (1030:10): [True: 25, False: 1]
  ------------------
 1031|     25|    random_poll();
 1032|       |
 1033|       |  /* Always do a fast random poll (we have to use the unlocked version). */
 1034|      1|  do_fast_random_poll();
 1035|       |
 1036|       |  /* Mix the pid in so that we for sure won't deliver the same random
 1037|       |     after a fork. */
 1038|      1|  {
 1039|      1|    pid_t apid = my_pid;
 1040|      1|    add_randomness (&apid, sizeof (apid), RANDOM_ORIGIN_INIT);
 1041|      1|  }
 1042|       |
 1043|       |  /* Mix the pool (if add_randomness() didn't it). */
 1044|      1|  if (!just_mixed)
  ------------------
  |  Branch (1044:7): [True: 0, False: 1]
  ------------------
 1045|      0|    {
 1046|      0|      mix_pool(rndpool);
 1047|      0|      rndstats.mixrnd++;
 1048|      0|    }
 1049|       |
 1050|       |  /* Create a new pool. */
 1051|      1|  for(i=0,dp=(unsigned long*)(void*)keypool, sp=(unsigned long*)(void*)rndpool;
 1052|     76|      i < POOLWORDS; i++, dp++, sp++ )
  ------------------
  |  |   99|     76|#define POOLWORDS (POOLSIZE / SIZEOF_UNSIGNED_LONG)
  |  |  ------------------
  |  |  |  |   95|     76|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     76|#define POOLBLOCKS 30
  |  |  |  |  ------------------
  |  |  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  |  |  ------------------
  |  |  |  |  |  |   89|     76|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define POOLWORDS (POOLSIZE / SIZEOF_UNSIGNED_LONG)
  |  |  ------------------
  |  |  |  |  521|     76|#define SIZEOF_UNSIGNED_LONG 8
  |  |  ------------------
  ------------------
  |  Branch (1052:7): [True: 75, False: 1]
  ------------------
 1053|     75|    *dp = *sp + ADD_VALUE;
  ------------------
  |  |   80|     76|#define ADD_VALUE 0xa5a5a5a5a5a5a5a5
  ------------------
 1054|       |
 1055|       |  /* Mix both pools. */
 1056|      1|  mix_pool(rndpool); rndstats.mixrnd++;
 1057|      1|  mix_pool(keypool); rndstats.mixkey++;
 1058|       |
 1059|       |  /* Read the requested data.  We use a read pointer to read from a
 1060|       |     different position each time.  */
 1061|      9|  while (length--)
  ------------------
  |  Branch (1061:10): [True: 8, False: 1]
  ------------------
 1062|      8|    {
 1063|      8|      *buffer++ = keypool[pool_readpos++];
 1064|      8|      if (pool_readpos >= POOLSIZE)
  ------------------
  |  |   95|      8|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      8|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      8|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  |  Branch (1064:11): [True: 0, False: 8]
  ------------------
 1065|      0|        pool_readpos = 0;
 1066|      8|      pool_balance--;
 1067|      8|    }
 1068|       |
 1069|      1|  if (pool_balance < 0)
  ------------------
  |  Branch (1069:7): [True: 1, False: 0]
  ------------------
 1070|      1|    pool_balance = 0;
 1071|       |
 1072|       |  /* Clear the keypool. */
 1073|      1|  memset (keypool, 0, POOLSIZE);
  ------------------
  |  |   95|      1|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      1|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      1|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
 1074|       |
 1075|       |  /* We need to detect whether a fork has happened.  A fork might have
 1076|       |     an identical pool and thus the child and the parent could emit
 1077|       |     the very same random number.  This test here is to detect forks
 1078|       |     in a multi-threaded process.  It does not work with all thread
 1079|       |     implementations in particular not with pthreads.  However it is
 1080|       |     good enough for GNU Pth. */
 1081|      1|  if ( getpid () != my_pid2 )
  ------------------
  |  Branch (1081:8): [True: 0, False: 1]
  ------------------
 1082|      0|    {
 1083|      0|      pid_t x = getpid();
 1084|      0|      add_randomness (&x, sizeof(x), RANDOM_ORIGIN_INIT);
 1085|      0|      just_mixed = 0; /* Make sure it will get mixed. */
 1086|      0|      my_pid = x;     /* Also update the static pid. */
 1087|      0|      goto retry;
 1088|      0|    }
 1089|      1|}
random-csprng.c:read_seed_file:
  761|      1|{
  762|      1|  int fd;
  763|      1|  struct stat sb;
  764|      1|  unsigned char buffer[POOLSIZE];
  765|      1|  int n;
  766|       |
  767|      1|  gcry_assert (pool_is_locked);
  ------------------
  |  |  188|      1|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      1|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      1|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  768|       |
  769|      1|  if (!seed_file_name)
  ------------------
  |  Branch (769:7): [True: 1, False: 0]
  ------------------
  770|      1|    return 0;
  771|       |
  772|       |#ifdef HAVE_DOSISH_SYSTEM
  773|       |  fd = my_open (seed_file_name, O_RDONLY | O_BINARY, 0);
  774|       |#else
  775|      0|  fd = my_open (seed_file_name, O_RDONLY, 0);
  776|      0|#endif
  777|      0|  if( fd == -1 && errno == ENOENT)
  ------------------
  |  Branch (777:7): [True: 0, False: 0]
  |  Branch (777:19): [True: 0, False: 0]
  ------------------
  778|      0|    {
  779|      0|      allow_seed_file_update = 1;
  780|      0|      return 0;
  781|      0|    }
  782|       |
  783|      0|  if (fd == -1 )
  ------------------
  |  Branch (783:7): [True: 0, False: 0]
  ------------------
  784|      0|    {
  785|      0|      log_info(_("can't open `%s': %s\n"), seed_file_name, strerror(errno) );
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
                    log_info(_("can't open `%s': %s\n"), seed_file_name, strerror(errno) );
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
  786|      0|      return 0;
  787|      0|    }
  788|      0|  if (lock_seed_file (fd, seed_file_name, 0))
  ------------------
  |  Branch (788:7): [True: 0, False: 0]
  ------------------
  789|      0|    {
  790|      0|      close (fd);
  791|      0|      return 0;
  792|      0|    }
  793|      0|  if (fstat( fd, &sb ) )
  ------------------
  |  Branch (793:7): [True: 0, False: 0]
  ------------------
  794|      0|    {
  795|      0|      log_info(_("can't stat `%s': %s\n"), seed_file_name, strerror(errno) );
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
                    log_info(_("can't stat `%s': %s\n"), seed_file_name, strerror(errno) );
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
  796|      0|      close(fd);
  797|      0|      return 0;
  798|      0|    }
  799|      0|  if (!S_ISREG(sb.st_mode) )
  ------------------
  |  Branch (799:7): [True: 0, False: 0]
  ------------------
  800|      0|    {
  801|      0|      log_info(_("`%s' is not a regular file - ignored\n"), seed_file_name );
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
                    log_info(_("`%s' is not a regular file - ignored\n"), seed_file_name );
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
  802|      0|      close(fd);
  803|      0|      return 0;
  804|      0|    }
  805|      0|  if (!sb.st_size )
  ------------------
  |  Branch (805:7): [True: 0, False: 0]
  ------------------
  806|      0|    {
  807|      0|      log_info(_("note: random_seed file is empty\n") );
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
                    log_info(_("note: random_seed file is empty\n") );
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
  808|      0|      close(fd);
  809|      0|      allow_seed_file_update = 1;
  810|      0|      return 0;
  811|      0|    }
  812|      0|  if (sb.st_size != POOLSIZE )
  ------------------
  |  |   95|      0|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      0|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      0|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  |  Branch (812:7): [True: 0, False: 0]
  ------------------
  813|      0|    {
  814|      0|      log_info(_("warning: invalid size of random_seed file - not used\n") );
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
                    log_info(_("warning: invalid size of random_seed file - not used\n") );
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
  815|      0|      close(fd);
  816|      0|      return 0;
  817|      0|    }
  818|       |
  819|      0|  do
  820|      0|    {
  821|      0|      n = read( fd, buffer, POOLSIZE );
  ------------------
  |  |   95|      0|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      0|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      0|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  822|      0|    }
  823|      0|  while (n == -1 && errno == EINTR );
  ------------------
  |  Branch (823:10): [True: 0, False: 0]
  |  Branch (823:21): [True: 0, False: 0]
  ------------------
  824|       |
  825|      0|  if (n != POOLSIZE)
  ------------------
  |  |   95|      0|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      0|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      0|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  |  Branch (825:7): [True: 0, False: 0]
  ------------------
  826|      0|    {
  827|      0|      log_fatal(_("can't read `%s': %s\n"), seed_file_name,strerror(errno) );
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
                    log_fatal(_("can't read `%s': %s\n"), seed_file_name,strerror(errno) );
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
  828|      0|      close(fd);/*NOTREACHED*/
  829|      0|      return 0;
  830|      0|    }
  831|       |
  832|      0|  close(fd);
  833|       |
  834|      0|  add_randomness( buffer, POOLSIZE, RANDOM_ORIGIN_INIT );
  ------------------
  |  |   95|      0|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      0|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      0|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  835|       |  /* add some minor entropy to the pool now (this will also force a mixing) */
  836|      0|  {
  837|      0|    pid_t x = getpid();
  838|      0|    add_randomness( &x, sizeof(x), RANDOM_ORIGIN_INIT );
  839|      0|  }
  840|      0|  {
  841|      0|    time_t x = time(NULL);
  842|      0|    add_randomness( &x, sizeof(x), RANDOM_ORIGIN_INIT );
  843|      0|  }
  844|      0|  {
  845|      0|    clock_t x = clock();
  846|      0|    add_randomness( &x, sizeof(x), RANDOM_ORIGIN_INIT );
  847|      0|  }
  848|       |
  849|       |  /* And read a few bytes from our entropy source.  If we have the
  850|       |   * Jitter RNG we can fast get a lot of entropy.  Thus we read 1024
  851|       |   * bits from that source.
  852|       |   *
  853|       |   * Without the Jitter RNG we keep the old method of reading only a
  854|       |   * few bytes usually from /dev/urandom which won't block.  */
  855|      0|  if (_gcry_rndjent_get_version (NULL))
  ------------------
  |  Branch (855:7): [True: 0, False: 0]
  ------------------
  856|      0|    read_random_source (RANDOM_ORIGIN_INIT, 128, GCRY_STRONG_RANDOM);
  857|      0|  else
  858|      0|    read_random_source (RANDOM_ORIGIN_INIT, 32, GCRY_STRONG_RANDOM);
  859|       |
  860|      0|  allow_seed_file_update = 1;
  861|      0|  return 1;
  862|      0|}
random-csprng.c:read_random_source:
 1312|     25|{
 1313|     25|  if ( !slow_gather_fnc )
  ------------------
  |  Branch (1313:8): [True: 0, False: 25]
  ------------------
 1314|      0|    log_fatal ("Slow entropy gathering module not yet initialized\n");
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
 1315|       |
 1316|     25|  if (slow_gather_fnc (add_randomness, origin, length, level) < 0)
  ------------------
  |  Branch (1316:7): [True: 0, False: 25]
  ------------------
 1317|      0|    log_fatal ("No way to gather entropy for the RNG\n");
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
 1318|     25|}
random-csprng.c:random_poll:
 1135|     25|{
 1136|     25|  rndstats.slowpolls++;
 1137|     25|  read_random_source (RANDOM_ORIGIN_SLOWPOLL, POOLSIZE/5, GCRY_STRONG_RANDOM);
  ------------------
  |  |   95|     25|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|     25|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|     25|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
 1138|     25|}
random-csprng.c:add_randomness:
 1098|   293k|{
 1099|   293k|  const unsigned char *p = buffer;
 1100|   293k|  size_t count = 0;
 1101|       |
 1102|   293k|  gcry_assert (pool_is_locked);
  ------------------
  |  |  188|   293k|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|   293k|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 293k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|   293k|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
 1103|       |
 1104|      0|  rndstats.addbytes += length;
 1105|   293k|  rndstats.naddbytes++;
 1106|  12.0M|  while (length-- )
  ------------------
  |  Branch (1106:10): [True: 11.7M, False: 293k]
  ------------------
 1107|  11.7M|    {
 1108|  11.7M|      rndpool[pool_writepos++] ^= *p++;
 1109|  11.7M|      count++;
 1110|  11.7M|      if (pool_writepos >= POOLSIZE )
  ------------------
  |  |   95|  11.7M|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|  11.7M|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|  11.7M|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  |  Branch (1110:11): [True: 19.5k, False: 11.7M]
  ------------------
 1111|  19.5k|        {
 1112|       |          /* It is possible that we are invoked before the pool is
 1113|       |             filled using an unreliable origin of entropy, for example
 1114|       |             the fast random poll.  To avoid flagging the pool as
 1115|       |             filled in this case, we track the initial filling state
 1116|       |             separately.  See also the remarks about the seed file. */
 1117|  19.5k|          if (origin >= RANDOM_ORIGIN_SLOWPOLL && !pool_filled)
  ------------------
  |  Branch (1117:15): [True: 5, False: 19.5k]
  |  Branch (1117:51): [True: 5, False: 0]
  ------------------
 1118|      5|            {
 1119|      5|              pool_filled_counter += count;
 1120|      5|              count = 0;
 1121|      5|              if (pool_filled_counter >= POOLSIZE)
  ------------------
  |  |   95|      5|#define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   91|      5|#define POOLBLOCKS 30
  |  |  ------------------
  |  |               #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
  |  |  ------------------
  |  |  |  |   89|      5|#define DIGESTLEN 20   /* ... into a digest of this length (sha-1). */
  |  |  ------------------
  ------------------
  |  Branch (1121:19): [True: 1, False: 4]
  ------------------
 1122|      1|                pool_filled = 1;
 1123|      5|            }
 1124|  19.5k|          pool_writepos = 0;
 1125|  19.5k|          mix_pool(rndpool); rndstats.mixrnd++;
 1126|  19.5k|          just_mixed = !length;
 1127|  19.5k|	}
 1128|  11.7M|    }
 1129|   293k|}
random-csprng.c:do_fast_random_poll:
 1212|  48.9k|{
 1213|  48.9k|  gcry_assert (pool_is_locked);
  ------------------
  |  |  188|  48.9k|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|  48.9k|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 48.9k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|  48.9k|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
 1214|       |
 1215|      0|  rndstats.fastpolls++;
 1216|       |
 1217|  48.9k|  if (fast_gather_fnc)
  ------------------
  |  Branch (1217:7): [True: 0, False: 48.9k]
  ------------------
 1218|      0|    fast_gather_fnc (add_randomness, RANDOM_ORIGIN_FASTPOLL);
 1219|       |
 1220|       |  /* Continue with the generic functions. */
 1221|       |#if HAVE_GETHRTIME
 1222|       |  {
 1223|       |    hrtime_t tv;
 1224|       |    tv = gethrtime();
 1225|       |    add_randomness( &tv, sizeof(tv), RANDOM_ORIGIN_FASTPOLL );
 1226|       |  }
 1227|       |#elif HAVE_GETTIMEOFDAY
 1228|  48.9k|  {
 1229|  48.9k|    struct timeval tv;
 1230|  48.9k|    if( gettimeofday( &tv, NULL ) )
  ------------------
  |  Branch (1230:9): [True: 0, False: 48.9k]
  ------------------
 1231|      0|      BUG();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
 1232|  48.9k|    add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), RANDOM_ORIGIN_FASTPOLL );
 1233|  48.9k|    add_randomness( &tv.tv_usec, sizeof(tv.tv_usec), RANDOM_ORIGIN_FASTPOLL );
 1234|  48.9k|  }
 1235|       |#elif HAVE_CLOCK_GETTIME
 1236|       |  {	struct timespec tv;
 1237|       |  if( clock_gettime( CLOCK_REALTIME, &tv ) == -1 )
 1238|       |    BUG();
 1239|       |  add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), RANDOM_ORIGIN_FASTPOLL );
 1240|       |  add_randomness( &tv.tv_nsec, sizeof(tv.tv_nsec), RANDOM_ORIGIN_FASTPOLL );
 1241|       |  }
 1242|       |#else /* use times */
 1243|       |# ifndef HAVE_DOSISH_SYSTEM
 1244|       |  {	struct tms buf;
 1245|       |  times( &buf );
 1246|       |  add_randomness( &buf, sizeof buf, RANDOM_ORIGIN_FASTPOLL );
 1247|       |  }
 1248|       |# endif
 1249|       |#endif
 1250|       |
 1251|      0|#ifdef HAVE_GETRUSAGE
 1252|      0|# ifdef RUSAGE_SELF
 1253|      0|  {
 1254|  48.9k|    struct rusage buf;
 1255|       |    /* QNX/Neutrino does return ENOSYS - so we just ignore it and add
 1256|       |       whatever is in buf.  In a chroot environment it might not work
 1257|       |       at all (i.e. because /proc/ is not accessible), so we better
 1258|       |       ignore all error codes and hope for the best. */
 1259|  48.9k|    getrusage (RUSAGE_SELF, &buf );
 1260|  48.9k|    add_randomness( &buf, sizeof buf, RANDOM_ORIGIN_FASTPOLL );
 1261|  48.9k|    memset( &buf, 0, sizeof buf );
 1262|  48.9k|  }
 1263|       |# else /*!RUSAGE_SELF*/
 1264|       |#  ifdef __GCC__
 1265|       |#   warning There is no RUSAGE_SELF on this system
 1266|       |#  endif
 1267|       |# endif /*!RUSAGE_SELF*/
 1268|  48.9k|#endif /*HAVE_GETRUSAGE*/
 1269|       |
 1270|       |  /* Time and clock are available on all systems - so we better do it
 1271|       |     just in case one of the above functions didn't work.  */
 1272|  48.9k|  {
 1273|  48.9k|    time_t x = time(NULL);
 1274|  48.9k|    add_randomness( &x, sizeof(x), RANDOM_ORIGIN_FASTPOLL );
 1275|  48.9k|  }
 1276|  48.9k|  {
 1277|  48.9k|    clock_t x = clock();
 1278|  48.9k|    add_randomness( &x, sizeof(x), RANDOM_ORIGIN_FASTPOLL );
 1279|  48.9k|  }
 1280|       |
 1281|       |  /* If the system features a fast hardware RNG, read some bytes from
 1282|       |     there.  */
 1283|  48.9k|  _gcry_rndhw_poll_fast (add_randomness, RANDOM_ORIGIN_FASTPOLL);
 1284|  48.9k|}

_gcry_set_preferred_rng_type:
  166|      1|{
  167|      1|  static int any_init;
  168|       |
  169|      1|  if (!type)
  ------------------
  |  Branch (169:7): [True: 1, False: 0]
  ------------------
  170|      1|    {
  171|      1|      any_init = 1;
  172|      1|    }
  173|      0|  else if (type == GCRY_RNG_TYPE_STANDARD)
  ------------------
  |  Branch (173:12): [True: 0, False: 0]
  ------------------
  174|      0|    {
  175|      0|      rng_types.standard = 1;
  176|      0|    }
  177|      0|  else if (any_init)
  ------------------
  |  Branch (177:12): [True: 0, False: 0]
  ------------------
  178|      0|    {
  179|       |      /* After any initialization has been done we only allow to
  180|       |         upgrade to the standard RNG (handled above).  All other
  181|       |         requests are ignored.  The idea is that the application needs
  182|       |         to declare a preference for a weaker RNG as soon as possible
  183|       |         and before any library sets a preference.  We assume that a
  184|       |         library which uses Libgcrypt calls an init function very
  185|       |         early.  This way --- even if the library gets initialized
  186|       |         early by the application --- it is unlikely that it can
  187|       |         select a lower priority RNG.
  188|       |
  189|       |         This scheme helps to ensure that existing unmodified
  190|       |         applications (e.g. gpg2), which don't known about the new RNG
  191|       |         selection system, will continue to use the standard RNG and
  192|       |         not be tricked by some library to use a lower priority RNG.
  193|       |         There are some loopholes here but at least most GnuPG stuff
  194|       |         should be save because it calls src_c{gcry_control
  195|       |         (GCRYCTL_SUSPEND_SECMEM_WARN);} quite early and thus inhibits
  196|       |         switching to a low priority RNG.
  197|       |       */
  198|      0|    }
  199|      0|  else if (type == GCRY_RNG_TYPE_FIPS)
  ------------------
  |  Branch (199:12): [True: 0, False: 0]
  ------------------
  200|      0|    {
  201|      0|      rng_types.fips = 1;
  202|      0|    }
  203|      0|  else if (type == GCRY_RNG_TYPE_SYSTEM)
  ------------------
  |  Branch (203:12): [True: 0, False: 0]
  ------------------
  204|      0|    {
  205|      0|      rng_types.system = 1;
  206|      0|    }
  207|      1|}
_gcry_random_initialize:
  217|      1|{
  218|      1|  if (fips_mode ())
  ------------------
  |  |  449|      1|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  219|      0|    _gcry_rngdrbg_inititialize (full);
  220|      1|  else if (rng_types.standard)
  ------------------
  |  Branch (220:12): [True: 0, False: 1]
  ------------------
  221|      0|    _gcry_rngcsprng_initialize (full);
  222|      1|  else if (rng_types.fips)
  ------------------
  |  Branch (222:12): [True: 0, False: 1]
  ------------------
  223|      0|    _gcry_rngdrbg_inititialize (full);
  224|      1|  else if (rng_types.system)
  ------------------
  |  Branch (224:12): [True: 0, False: 1]
  ------------------
  225|      0|    _gcry_rngsystem_initialize (full);
  226|      1|  else
  227|      1|    _gcry_rngcsprng_initialize (full);
  228|      1|}
_gcry_randomize:
  395|      1|{
  396|      1|  do_randomize (buffer, length, level);
  397|      1|}
_gcry_fast_random_poll:
  447|  48.9k|{
  448|  48.9k|  if (fips_mode ())
  ------------------
  |  |  449|  48.9k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 48.9k]
  |  |  ------------------
  ------------------
  449|      0|    ; /* No need for this in fips mode.  */
  450|  48.9k|  else if (rng_types.standard)
  ------------------
  |  Branch (450:12): [True: 0, False: 48.9k]
  ------------------
  451|      0|    _gcry_rngcsprng_fast_poll ();
  452|  48.9k|  else if (rng_types.fips)
  ------------------
  |  Branch (452:12): [True: 0, False: 48.9k]
  ------------------
  453|      0|    ;
  454|  48.9k|  else if (rng_types.system)
  ------------------
  |  Branch (454:12): [True: 0, False: 48.9k]
  ------------------
  455|      0|    ;
  456|  48.9k|  else /* default */
  457|  48.9k|    _gcry_rngcsprng_fast_poll ();
  458|  48.9k|}
_gcry_create_nonce:
  465|      1|{
  466|      1|  static unsigned char nonce_buffer[20+8];
  467|      1|  static int nonce_buffer_initialized = 0;
  468|      1|  static volatile pid_t my_pid; /* The volatile is there to make sure the
  469|       |                                   compiler does not optimize the code away
  470|       |                                   in case the getpid function is badly
  471|       |                                   attributed. */
  472|      1|  volatile pid_t apid;
  473|      1|  unsigned char *p;
  474|      1|  size_t n;
  475|      1|  int err;
  476|       |
  477|       |  /* First check whether we shall use the FIPS nonce generator.  This
  478|       |     is only done in FIPS mode, in all other modes, we use our own
  479|       |     nonce generator which is seeded by the RNG actual in use.  */
  480|      1|  if (fips_mode ())
  ------------------
  |  |  449|      1|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  481|      0|    {
  482|      0|      _gcry_rngdrbg_randomize (buffer, length, GCRY_WEAK_RANDOM);
  483|      0|      return;
  484|      0|    }
  485|       |
  486|       |  /* This is the nonce generator, which formerly lived in
  487|       |     random-csprng.c.  It is now used by all RNG types except when in
  488|       |     FIPS mode (not that this means it is also used if the FIPS RNG
  489|       |     has been selected but we are not in fips mode).  */
  490|       |
  491|       |  /* Make sure we are initialized. */
  492|      1|  _gcry_random_initialize (1);
  493|       |
  494|       |  /* Acquire the nonce buffer lock. */
  495|      1|  err = gpgrt_lock_lock (&nonce_buffer_lock);
  496|      1|  if (err)
  ------------------
  |  Branch (496:7): [True: 0, False: 1]
  ------------------
  497|      0|    log_fatal ("failed to acquire the nonce buffer lock: %s\n",
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  498|      0|               gpg_strerror (err));
  499|       |
  500|      1|  apid = getpid ();
  501|       |  /* The first time initialize our buffer. */
  502|      1|  if (!nonce_buffer_initialized)
  ------------------
  |  Branch (502:7): [True: 1, False: 0]
  ------------------
  503|      1|    {
  504|      1|      time_t atime = time (NULL);
  505|      1|      pid_t xpid = apid;
  506|       |
  507|      1|      my_pid = apid;
  508|       |
  509|      1|      if ((sizeof apid + sizeof atime) > sizeof nonce_buffer)
  ------------------
  |  Branch (509:11): [Folded - Ignored]
  ------------------
  510|      0|        BUG ();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  511|       |
  512|       |      /* Initialize the first 20 bytes with a reasonable value so that
  513|       |         a failure of gcry_randomize won't affect us too much.  Don't
  514|       |         care about the uninitialized remaining bytes. */
  515|      1|      p = nonce_buffer;
  516|      1|      memcpy (p, &xpid, sizeof xpid);
  517|      1|      p += sizeof xpid;
  518|      1|      memcpy (p, &atime, sizeof atime);
  519|       |
  520|       |      /* Initialize the never changing private part of 64 bits. */
  521|      1|      _gcry_randomize (nonce_buffer+20, 8, GCRY_WEAK_RANDOM);
  522|       |
  523|      1|      nonce_buffer_initialized = 1;
  524|      1|    }
  525|      0|  else if ( my_pid != apid )
  ------------------
  |  Branch (525:13): [True: 0, False: 0]
  ------------------
  526|      0|    {
  527|       |      /* We forked. Need to reseed the buffer - doing this for the
  528|       |         private part should be sufficient. */
  529|      0|      do_randomize (nonce_buffer+20, 8, GCRY_WEAK_RANDOM);
  530|       |      /* Update the pid so that we won't run into here again and
  531|       |         again. */
  532|      0|      my_pid = apid;
  533|      0|    }
  534|       |
  535|       |  /* Create the nonce by hashing the entire buffer, returning the hash
  536|       |     and updating the first 20 bytes of the buffer with this hash. */
  537|      2|  for (p = buffer; length > 0; length -= n, p += n)
  ------------------
  |  Branch (537:20): [True: 1, False: 1]
  ------------------
  538|      1|    {
  539|      1|      _gcry_sha1_hash_buffer (nonce_buffer,
  540|      1|                              nonce_buffer, sizeof nonce_buffer);
  541|      1|      n = length > 20? 20 : length;
  ------------------
  |  Branch (541:11): [True: 0, False: 1]
  ------------------
  542|      1|      memcpy (p, nonce_buffer, n);
  543|      1|    }
  544|       |
  545|       |  /* Release the nonce buffer lock. */
  546|      1|  err = gpgrt_lock_unlock (&nonce_buffer_lock);
  547|      1|  if (err)
  ------------------
  |  Branch (547:7): [True: 0, False: 1]
  ------------------
  548|      0|    log_fatal ("failed to release the nonce buffer lock: %s\n",
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  549|      0|               gpg_strerror (err));
  550|      1|}
random.c:do_randomize:
  344|      1|{
  345|      1|  if (fips_mode ())
  ------------------
  |  |  449|      1|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  346|      0|    _gcry_rngdrbg_randomize (buffer, length, level);
  347|      1|  else if (rng_types.standard)
  ------------------
  |  Branch (347:12): [True: 0, False: 1]
  ------------------
  348|      0|    _gcry_rngcsprng_randomize (buffer, length, level);
  349|      1|  else if (rng_types.fips)
  ------------------
  |  Branch (349:12): [True: 0, False: 1]
  ------------------
  350|      0|    _gcry_rngdrbg_randomize (buffer, length, level);
  351|      1|  else if (rng_types.system)
  ------------------
  |  Branch (351:12): [True: 0, False: 1]
  ------------------
  352|      0|    _gcry_rngsystem_randomize (buffer, length, level);
  353|      1|  else /* default */
  354|      1|    _gcry_rngcsprng_randomize (buffer, length, level);
  355|      1|}

_gcry_rndgetentropy_gather_random:
   44|     25|{
   45|     25|  byte buffer[256];
   46|       |
   47|     25|  if (!add)
  ------------------
  |  Branch (47:7): [True: 0, False: 25]
  ------------------
   48|      0|    {
   49|       |      /* Special mode to release resouces.  */
   50|      0|      _gcry_rndjent_fini ();
   51|      0|      return 0;
   52|      0|    }
   53|       |
   54|       |  /* When using a blocking random generator try to get some entropy
   55|       |   * from the jitter based RNG.  In this case we take up to 50% of the
   56|       |   * remaining requested bytes.  */
   57|     25|  if (level >= GCRY_VERY_STRONG_RANDOM)
  ------------------
  |  Branch (57:7): [True: 0, False: 25]
  ------------------
   58|      0|    {
   59|      0|      size_t n;
   60|       |
   61|      0|      n = _gcry_rndjent_poll (add, origin, length/2);
   62|      0|      if (n > length/2)
  ------------------
  |  Branch (62:11): [True: 0, False: 0]
  ------------------
   63|      0|        n = length/2;
   64|      0|      if (length > 1)
  ------------------
  |  Branch (64:11): [True: 0, False: 0]
  ------------------
   65|      0|        length -= n;
   66|      0|    }
   67|       |
   68|       |  /* Enter the loop.  */
   69|     50|  while (length)
  ------------------
  |  Branch (69:10): [True: 25, False: 25]
  ------------------
   70|     25|    {
   71|     25|      int ret;
   72|     25|      size_t nbytes;
   73|       |
   74|       |      /* For a modern operating system, we use the new getentropy
   75|       |       * function.  That call guarantees that the kernel's RNG has
   76|       |       * been properly seeded before returning any data.  This is
   77|       |       * different from /dev/urandom which may, due to its
   78|       |       * non-blocking semantics, return data even if the kernel has
   79|       |       * not been properly seeded.  And it differs from /dev/random by
   80|       |       * never blocking once the kernel is seeded.  */
   81|     25|      do
   82|     25|        {
   83|     25|          _gcry_pre_syscall ();
   84|     25|          if (fips_mode ())
  ------------------
  |  |  449|     25|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 25]
  |  |  ------------------
  ------------------
   85|      0|            {
   86|       |              /* DRBG chaining defined in SP 800-90A (rev 1) specify
   87|       |               * the upstream (kernel) DRBG needs to be reseeded for
   88|       |               * initialization of downstream (libgcrypt) DRBG. For this
   89|       |               * in RHEL, we repurposed the GRND_RANDOM flag of getrandom API.
   90|       |               * The libgcrypt DRBG is initialized with 48B of entropy, but
   91|       |               * the kernel can provide only 32B at a time after reseeding
   92|       |               * so we need to limit our requests to 32B here.
   93|       |               * This is clarified in IG 7.19 / IG D.K. for FIPS 140-2 / 3
   94|       |               * and might not be applicable on other FIPS modules not running
   95|       |               * RHEL kernel.
   96|       |               */
   97|      0|              nbytes = length < 32 ? length : 32;
  ------------------
  |  Branch (97:24): [True: 0, False: 0]
  ------------------
   98|      0|              ret = getrandom (buffer, nbytes, GRND_RANDOM);
   99|      0|            }
  100|     25|          else
  101|     25|            {
  102|     25|              nbytes = length < sizeof (buffer) ? length : sizeof (buffer);
  ------------------
  |  Branch (102:24): [True: 25, False: 0]
  ------------------
  103|     25|              ret = getentropy (buffer, nbytes);
  104|     25|            }
  105|     25|          _gcry_post_syscall ();
  106|     25|        }
  107|     25|      while (ret == -1 && errno == EINTR);
  ------------------
  |  Branch (107:14): [True: 0, False: 25]
  |  Branch (107:27): [True: 0, False: 0]
  ------------------
  108|       |
  109|     25|      if (ret == -1 && errno == ENOSYS)
  ------------------
  |  Branch (109:11): [True: 0, False: 25]
  |  Branch (109:24): [True: 0, False: 0]
  ------------------
  110|      0|        log_fatal ("getentropy is not supported: %s\n", strerror (errno));
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  111|     25|      else
  112|     25|        { /* getentropy is supported.  Some sanity checks.  */
  113|     25|          if (ret == -1)
  ------------------
  |  Branch (113:15): [True: 0, False: 25]
  ------------------
  114|      0|            log_fatal ("unexpected error from getentropy: %s\n",
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  115|      0|                       strerror (errno));
  116|       |
  117|     25|          (*add) (buffer, nbytes, origin);
  118|     25|          length -= nbytes;
  119|     25|        }
  120|     25|    }
  121|     25|  wipememory (buffer, sizeof buffer);
  ------------------
  |  |  398|     25|#define wipememory(_ptr,_len) wipememory2((_ptr),0,(_len))
  |  |  ------------------
  |  |  |  |  388|     25|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|     25|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|     50|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [Folded - Ignored]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|      0|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|      0|		else \
  |  |  |  |  393|      0|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|     25|	      } else { \
  |  |  |  |  395|     25|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|     25|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|     25|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|     25|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|     25|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|     25|	      } \
  |  |  |  |  397|     25|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  122|       |
  123|     25|  return 0; /* success */
  124|     25|}

_gcry_rndhw_poll_fast:
  185|  48.9k|{
  186|  48.9k|  (void)add;
  187|  48.9k|  (void)origin;
  188|       |
  189|  48.9k|#ifdef USE_DRNG
  190|  48.9k|  if ((_gcry_get_hw_features () & HWF_INTEL_RDRAND))
  ------------------
  |  |  233|  48.9k|#define HWF_INTEL_RDRAND        (1 << 11)
  ------------------
  |  Branch (190:7): [True: 48.9k, False: 0]
  ------------------
  191|  48.9k|    poll_drng (add, origin, 1);
  192|  48.9k|#endif
  193|  48.9k|#ifdef USE_PADLOCK
  194|  48.9k|  if ((_gcry_get_hw_features () & HWF_PADLOCK_RNG))
  ------------------
  |  |  221|  48.9k|#define HWF_PADLOCK_RNG         (1 << 0)
  ------------------
  |  Branch (194:7): [True: 0, False: 48.9k]
  ------------------
  195|      0|    poll_padlock (add, origin, 1);
  196|  48.9k|#endif
  197|  48.9k|}
rndhw.c:poll_drng:
  159|  48.9k|{
  160|  48.9k|  volatile unsigned long buffer[8] __attribute__ ((aligned (8)));
  161|  48.9k|  unsigned int nbytes = sizeof (buffer);
  162|       |
  163|  48.9k|  (void)fast;
  164|       |
  165|  48.9k|  if (!rdrand_nlong (buffer, DIM(buffer)))
  ------------------
  |  |  104|  48.9k|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (165:7): [True: 0, False: 48.9k]
  ------------------
  166|      0|    return 0;
  167|  48.9k|  (*add)((void *)buffer, nbytes, origin);
  168|  48.9k|  return nbytes;
  169|  48.9k|}
rndhw.c:rdrand_nlong:
  149|  48.9k|{
  150|   440k|  while (count--)
  ------------------
  |  Branch (150:10): [True: 391k, False: 48.9k]
  ------------------
  151|   391k|    if (!rdrand_long(v++))
  ------------------
  |  Branch (151:9): [True: 0, False: 391k]
  ------------------
  152|      0|      return 0;
  153|  48.9k|  return 1;
  154|  48.9k|}
rndhw.c:rdrand_long:
  133|   391k|{
  134|   391k|  int ok;
  135|   391k|  asm volatile ("1: " RDRAND_LONG "\n\t"
  136|   391k|                "jc 2f\n\t"
  137|   391k|                "decl %0\n\t"
  138|   391k|                "jnz 1b\n\t"
  139|   391k|                "2:"
  140|   391k|                : "=r" (ok), "=a" (*v)
  141|   391k|                : "0" (RDRAND_RETRY_LOOPS)
  ------------------
  |  |  124|   391k|# define RDRAND_RETRY_LOOPS	10
  ------------------
  142|   391k|                : "cc", "memory");
  143|   391k|  return ok;
  144|   391k|}

_gcry_initialize_fips_mode:
  165|      1|{
  166|      1|  static int done;
  167|      1|  gpg_error_t err;
  168|       |
  169|       |  /* Make sure we are not accidentally called twice.  */
  170|      1|  if (done)
  ------------------
  |  Branch (170:7): [True: 0, False: 1]
  ------------------
  171|      0|    {
  172|      0|      if ( fips_mode () )
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  173|      0|        {
  174|      0|          fips_new_state (STATE_FATALERROR);
  175|      0|          fips_noreturn ();
  ------------------
  |  |  489|      0|#define fips_noreturn()  (_gcry_fips_noreturn ())
  ------------------
  176|      0|        }
  177|       |      /* If not in fips mode an assert is sufficient.  */
  178|      0|      gcry_assert (!done);
  ------------------
  |  |  188|      0|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      0|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      0|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  179|      0|    }
  180|      0|  done = 1;
  181|       |
  182|       |  /* If the calling application explicitly requested fipsmode, do so.  */
  183|      1|  if (force)
  ------------------
  |  Branch (183:7): [True: 0, False: 1]
  ------------------
  184|      0|    {
  185|      0|      gcry_assert (!_gcry_no_fips_mode_required);
  ------------------
  |  |  188|      0|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      0|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      0|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  186|      0|      goto leave;
  187|      0|    }
  188|       |
  189|       |  /* If the system explicitly requested fipsmode, do so.  */
  190|      1|  if (check_fips_system_setting ())
  ------------------
  |  Branch (190:7): [True: 0, False: 1]
  ------------------
  191|      0|    {
  192|      0|      gcry_assert (!_gcry_no_fips_mode_required);
  ------------------
  |  |  188|      0|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      0|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      0|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  193|      0|      goto leave;
  194|      0|    }
  195|       |
  196|       |  /* Fips not not requested, set flag.  */
  197|      1|  _gcry_no_fips_mode_required = 1;
  198|       |
  199|      1| leave:
  200|      1|  if (!_gcry_no_fips_mode_required)
  ------------------
  |  Branch (200:7): [True: 0, False: 1]
  ------------------
  201|      0|    {
  202|       |      /* Yes, we are in FIPS mode.  */
  203|       |
  204|       |      /* Intitialize the lock to protect the FSM.  */
  205|      0|      err = gpgrt_lock_init (&fsm_lock);
  206|      0|      if (err)
  ------------------
  |  Branch (206:11): [True: 0, False: 0]
  ------------------
  207|      0|        {
  208|       |          /* If that fails we can't do anything but abort the
  209|       |             process. We need to use log_info so that the FSM won't
  210|       |             get involved.  */
  211|      0|          log_info ("FATAL: failed to create the FSM lock in libgcrypt: %s\n",
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
  212|      0|                    gpg_strerror (err));
  213|      0|#ifdef HAVE_SYSLOG
  214|      0|          syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
  215|      0|                  "creating FSM lock failed: %s - abort",
  216|      0|                  gpg_strerror (err));
  217|      0|#endif /*HAVE_SYSLOG*/
  218|      0|          abort ();
  219|      0|        }
  220|       |
  221|       |      /* Now get us into the INIT state.  */
  222|      0|      fips_new_state (STATE_INIT);
  223|      0|    }
  224|       |
  225|      1|  return;
  226|      1|}
_gcry_fips_is_operational:
  290|      1|{
  291|      1|  int result;
  292|       |
  293|      1|  if (!fips_mode ())
  ------------------
  |  |  449|      1|#define fips_mode() (!_gcry_no_fips_mode_required)
  ------------------
  |  Branch (293:7): [True: 1, False: 0]
  ------------------
  294|      1|    result = 1;
  295|      0|  else
  296|      0|    {
  297|      0|      lock_fsm ();
  298|      0|      if (current_state == STATE_INIT)
  ------------------
  |  Branch (298:11): [True: 0, False: 0]
  ------------------
  299|      0|        {
  300|       |          /* If we are still in the INIT state, we need to run the
  301|       |             selftests so that the FSM can eventually get into
  302|       |             operational state.  Given that we would need a 2-phase
  303|       |             initialization of libgcrypt, but that has traditionally
  304|       |             not been enforced, we use this on demand self-test
  305|       |             checking.  Note that Proper applications would do the
  306|       |             application specific libgcrypt initialization between a
  307|       |             gcry_check_version() and gcry_control
  308|       |             (GCRYCTL_INITIALIZATION_FINISHED) where the latter will
  309|       |             run the selftests.  The drawback of these on-demand
  310|       |             self-tests are a small chance that self-tests are
  311|       |             performed by several threads; that is no problem because
  312|       |             our FSM make sure that we won't oversee any error. */
  313|      0|          unlock_fsm ();
  314|      0|          _gcry_fips_run_selftests (0);
  315|       |
  316|       |          /* Release resources for random.  */
  317|      0|          _gcry_random_close_fds ();
  318|      0|          lock_fsm ();
  319|      0|        }
  320|       |
  321|      0|      result = (current_state == STATE_OPERATIONAL);
  322|      0|      unlock_fsm ();
  323|      0|    }
  324|      1|  return result;
  325|      1|}
fips.c:check_fips_system_setting:
   95|      1|{
   96|       |  /* Do we have the environment variable set?  */
   97|      1|  if (getenv ("LIBGCRYPT_FORCE_FIPS_MODE"))
  ------------------
  |  Branch (97:7): [True: 0, False: 1]
  ------------------
   98|      0|    return 1;
   99|       |
  100|       |  /* For testing the system it is useful to override the system
  101|       |     provided detection of the FIPS mode and force FIPS mode using a
  102|       |     file.  The filename is hardwired so that there won't be any
  103|       |     confusion on whether /etc/gcrypt/ or /usr/local/etc/gcrypt/ is
  104|       |     actually used.  The file itself may be empty.  */
  105|      1|  if ( !access (FIPS_FORCE_FILE, F_OK) )
  ------------------
  |  |   37|      1|#define FIPS_FORCE_FILE "/etc/gcrypt/fips_enabled"
  ------------------
  |  Branch (105:8): [True: 0, False: 1]
  ------------------
  106|      0|    return 1;
  107|       |
  108|       |  /* Checking based on /proc file properties.  */
  109|      1|  {
  110|      1|    static const char procfname[] = "/proc/sys/crypto/fips_enabled";
  111|      1|    FILE *fp;
  112|      1|    int saved_errno;
  113|       |
  114|      1|    fp = fopen (procfname, "r");
  115|      1|    if (fp)
  ------------------
  |  Branch (115:9): [True: 1, False: 0]
  ------------------
  116|      1|      {
  117|      1|        char line[256];
  118|       |
  119|      1|        if (fgets (line, sizeof line, fp) && atoi (line))
  ------------------
  |  Branch (119:13): [True: 1, False: 0]
  |  Branch (119:46): [True: 0, False: 1]
  ------------------
  120|      0|          {
  121|       |            /* System is in fips mode.  */
  122|      0|            fclose (fp);
  123|      0|            return 1;
  124|      0|          }
  125|      1|        fclose (fp);
  126|      1|      }
  127|      0|    else if ((saved_errno = errno) != ENOENT
  ------------------
  |  Branch (127:14): [True: 0, False: 0]
  ------------------
  128|      0|             && saved_errno != EACCES
  ------------------
  |  Branch (128:17): [True: 0, False: 0]
  ------------------
  129|      0|             && !access ("/proc/version", F_OK) )
  ------------------
  |  Branch (129:17): [True: 0, False: 0]
  ------------------
  130|      0|      {
  131|       |        /* Problem reading the fips file despite that we have the proc
  132|       |           file system.  We better stop right away. */
  133|      0|        log_info ("FATAL: error reading `%s' in libgcrypt: %s\n",
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
  134|      0|                  procfname, strerror (saved_errno));
  135|      0|#ifdef HAVE_SYSLOG
  136|      0|        syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
  137|      0|                "reading `%s' failed: %s - abort",
  138|      0|                procfname, strerror (saved_errno));
  139|      0|#endif /*HAVE_SYSLOG*/
  140|      0|        abort ();
  141|      0|      }
  142|      1|  }
  143|       |
  144|      1|  return 0;
  145|      1|}

_gcry_global_is_operational:
  182|      1|{
  183|      1|  if (!_gcry_global_any_init_done)
  ------------------
  |  Branch (183:7): [True: 1, False: 0]
  ------------------
  184|      1|    {
  185|      1|#ifdef HAVE_SYSLOG
  186|      1|      syslog (LOG_USER|LOG_WARNING, "Libgcrypt warning: "
  187|      1|              "missing initialization - please fix the application");
  188|      1|#endif /*HAVE_SYSLOG*/
  189|      1|      global_init ();
  190|      1|    }
  191|      1|  return _gcry_fips_is_operational ();
  192|      1|}
_gcry_malloc:
 1009|  9.03M|{
 1010|  9.03M|  void *mem = NULL;
 1011|       |
 1012|  9.03M|  do_malloc (n, 0, &mem);
 1013|       |
 1014|  9.03M|  return mem;
 1015|  9.03M|}
_gcry_is_secure:
 1036|   333k|{
 1037|   333k|  if (no_secure_memory)
  ------------------
  |  Branch (1037:7): [True: 0, False: 333k]
  ------------------
 1038|      0|    return 0;
 1039|   333k|  if (is_secure_func)
  ------------------
  |  Branch (1039:7): [True: 0, False: 333k]
  ------------------
 1040|      0|    return is_secure_func (a) ;
 1041|   333k|  return _gcry_private_is_secure (a);
 1042|   333k|}
_gcry_free:
 1078|  10.2M|{
 1079|  10.2M|  int save_errno;
 1080|       |
 1081|  10.2M|  if (!p)
  ------------------
  |  Branch (1081:7): [True: 1.17M, False: 9.08M]
  ------------------
 1082|  1.17M|    return;
 1083|       |
 1084|       |  /* In case ERRNO is set we better save it so that the free machinery
 1085|       |     may not accidentally change ERRNO.  We restore it only if it was
 1086|       |     already set to comply with the usual C semantic for ERRNO.  */
 1087|  9.08M|  save_errno = errno;
 1088|  9.08M|  if (free_func)
  ------------------
  |  Branch (1088:7): [True: 0, False: 9.08M]
  ------------------
 1089|      0|    free_func (p);
 1090|  9.08M|  else
 1091|  9.08M|    _gcry_private_free (p);
 1092|       |
 1093|  9.08M|  if (save_errno && save_errno != errno)
  ------------------
  |  Branch (1093:7): [True: 9.08M, False: 7]
  |  Branch (1093:21): [True: 0, False: 9.08M]
  ------------------
 1094|      0|    gpg_err_set_errno (save_errno);
 1095|  9.08M|}
_gcry_calloc:
 1099|   275k|{
 1100|   275k|  size_t bytes;
 1101|   275k|  void *p;
 1102|       |
 1103|   275k|  bytes = n * m; /* size_t is unsigned so the behavior on overflow is
 1104|       |                    defined. */
 1105|   275k|  if (m && bytes / m != n)
  ------------------
  |  Branch (1105:7): [True: 275k, False: 0]
  |  Branch (1105:12): [True: 0, False: 275k]
  ------------------
 1106|      0|    {
 1107|      0|      gpg_err_set_errno (ENOMEM);
 1108|      0|      return NULL;
 1109|      0|    }
 1110|       |
 1111|   275k|  p = _gcry_malloc (bytes);
 1112|   275k|  if (p)
  ------------------
  |  Branch (1112:7): [True: 275k, False: 0]
  ------------------
 1113|   275k|    memset (p, 0, bytes);
 1114|   275k|  return p;
 1115|   275k|}
_gcry_strdup:
 1163|  1.69k|{
 1164|  1.69k|  return _gcry_strdup_core (string, 0);
 1165|  1.69k|}
_gcry_xmalloc:
 1169|  8.19M|{
 1170|  8.19M|  void *p;
 1171|       |
 1172|  8.19M|  while ( !(p = _gcry_malloc( n )) )
  ------------------
  |  Branch (1172:11): [True: 0, False: 8.19M]
  ------------------
 1173|      0|    {
 1174|      0|      if ( fips_mode ()
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1175|      0|           || !outofcore_handler
  ------------------
  |  Branch (1175:15): [True: 0, False: 0]
  ------------------
 1176|      0|           || !outofcore_handler (outofcore_handler_value, n, 0) )
  ------------------
  |  Branch (1176:15): [True: 0, False: 0]
  ------------------
 1177|      0|        {
 1178|      0|          _gcry_fatal_error (gpg_err_code_from_errno (errno), NULL);
 1179|      0|        }
 1180|      0|    }
 1181|  8.19M|    return p;
 1182|  8.19M|}
_gcry_xrealloc:
 1186|  25.5k|{
 1187|  25.5k|  void *p;
 1188|       |
 1189|  25.5k|  while (!(p = _gcry_realloc_core (a, n, 1)))
  ------------------
  |  Branch (1189:10): [True: 0, False: 25.5k]
  ------------------
 1190|      0|    {
 1191|      0|      if ( fips_mode ()
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1192|      0|           || !outofcore_handler
  ------------------
  |  Branch (1192:15): [True: 0, False: 0]
  ------------------
 1193|      0|           || !outofcore_handler (outofcore_handler_value, n,
  ------------------
  |  Branch (1193:15): [True: 0, False: 0]
  ------------------
 1194|      0|                                  _gcry_is_secure(a)? 3:2))
  ------------------
  |  Branch (1194:35): [True: 0, False: 0]
  ------------------
 1195|      0|        {
 1196|      0|          _gcry_fatal_error (gpg_err_code_from_errno (errno), NULL );
 1197|      0|	}
 1198|      0|    }
 1199|  25.5k|    return p;
 1200|  25.5k|}
_gcry_xmalloc_secure:
 1204|  58.5k|{
 1205|  58.5k|  void *p;
 1206|       |
 1207|  58.5k|  while (!(p = _gcry_malloc_secure_core (n, 1)))
  ------------------
  |  Branch (1207:10): [True: 0, False: 58.5k]
  ------------------
 1208|      0|    {
 1209|      0|      if ( fips_mode ()
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1210|      0|           || !outofcore_handler
  ------------------
  |  Branch (1210:15): [True: 0, False: 0]
  ------------------
 1211|      0|           || !outofcore_handler (outofcore_handler_value, n, 1) )
  ------------------
  |  Branch (1211:15): [True: 0, False: 0]
  ------------------
 1212|      0|        {
 1213|      0|          _gcry_fatal_error (gpg_err_code_from_errno (errno),
 1214|      0|                             _("out of core in secure memory"));
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
 1215|      0|	}
 1216|      0|    }
 1217|  58.5k|  return p;
 1218|  58.5k|}
_gcry_xcalloc:
 1223|  7.36M|{
 1224|  7.36M|  size_t nbytes;
 1225|  7.36M|  void *p;
 1226|       |
 1227|  7.36M|  nbytes = n * m;
 1228|  7.36M|  if (m && nbytes / m != n)
  ------------------
  |  Branch (1228:7): [True: 7.36M, False: 0]
  |  Branch (1228:12): [True: 0, False: 7.36M]
  ------------------
 1229|      0|    {
 1230|      0|      gpg_err_set_errno (ENOMEM);
 1231|      0|      _gcry_fatal_error(gpg_err_code_from_errno (errno), NULL );
 1232|      0|    }
 1233|       |
 1234|  7.36M|  p = _gcry_xmalloc ( nbytes );
 1235|  7.36M|  memset ( p, 0, nbytes );
 1236|  7.36M|  return p;
 1237|  7.36M|}
_gcry_xcalloc_secure:
 1241|  58.5k|{
 1242|  58.5k|  size_t nbytes;
 1243|  58.5k|  void *p;
 1244|       |
 1245|  58.5k|  nbytes = n * m;
 1246|  58.5k|  if (m && nbytes / m != n)
  ------------------
  |  Branch (1246:7): [True: 58.5k, False: 0]
  |  Branch (1246:12): [True: 0, False: 58.5k]
  ------------------
 1247|      0|    {
 1248|      0|      gpg_err_set_errno (ENOMEM);
 1249|      0|      _gcry_fatal_error(gpg_err_code_from_errno (errno), NULL );
 1250|      0|    }
 1251|       |
 1252|  58.5k|  p = _gcry_xmalloc_secure ( nbytes );
 1253|  58.5k|  memset ( p, 0, nbytes );
 1254|  58.5k|  return p;
 1255|  58.5k|}
_gcry_xstrdup:
 1259|   169k|{
 1260|   169k|  char *p;
 1261|       |
 1262|   169k|  while ( !(p = _gcry_strdup_core (string, 1)) )
  ------------------
  |  Branch (1262:11): [True: 0, False: 169k]
  ------------------
 1263|      0|    {
 1264|      0|      size_t n = strlen (string);
 1265|      0|      int is_sec = !!_gcry_is_secure (string);
 1266|       |
 1267|      0|      if (fips_mode ()
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1268|      0|          || !outofcore_handler
  ------------------
  |  Branch (1268:14): [True: 0, False: 0]
  ------------------
 1269|      0|          || !outofcore_handler (outofcore_handler_value, n, is_sec) )
  ------------------
  |  Branch (1269:14): [True: 0, False: 0]
  ------------------
 1270|      0|        {
 1271|      0|          _gcry_fatal_error (gpg_err_code_from_errno (errno),
 1272|      0|                             is_sec? _("out of core in secure memory"):NULL);
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
  |  Branch (1272:30): [True: 0, False: 0]
  ------------------
 1273|      0|	}
 1274|      0|    }
 1275|       |
 1276|   169k|  return p;
 1277|   169k|}
_gcry_pre_syscall:
 1283|     25|{
 1284|     25|  if (pre_syscall_func)
  ------------------
  |  Branch (1284:7): [True: 0, False: 25]
  ------------------
 1285|      0|    pre_syscall_func ();
 1286|     25|}
_gcry_post_syscall:
 1292|     25|{
 1293|     25|  if (post_syscall_func)
  ------------------
  |  Branch (1293:7): [True: 0, False: 25]
  ------------------
 1294|      0|    post_syscall_func ();
 1295|     25|}
global.c:global_init:
   91|      1|{
   92|      1|  gcry_error_t err = 0;
   93|       |
   94|      1|  if (_gcry_global_any_init_done)
  ------------------
  |  Branch (94:7): [True: 0, False: 1]
  ------------------
   95|      0|    return;
   96|      1|  _gcry_global_any_init_done = 1;
   97|       |
   98|       |  /* Tell the random module that we have seen an init call.  */
   99|      1|  _gcry_set_preferred_rng_type (0);
  100|       |
  101|       |  /* Get the system call clamp functions.  */
  102|      1|  if (!pre_syscall_func)
  ------------------
  |  Branch (102:7): [True: 1, False: 0]
  ------------------
  103|      1|    gpgrt_get_syscall_clamp (&pre_syscall_func, &post_syscall_func);
  104|       |
  105|       |  /* See whether the system is in FIPS mode.  This needs to come as
  106|       |     early as possible but after ATH has been initialized.  */
  107|      1|  _gcry_initialize_fips_mode (force_fips_mode);
  108|       |
  109|       |  /* Before we do any other initialization we need to test available
  110|       |     hardware features.  */
  111|      1|  _gcry_detect_hw_features ();
  112|       |
  113|       |  /* Initialize the modules - this is mainly allocating some memory and
  114|       |     creating mutexes.  */
  115|      1|  err = _gcry_cipher_init ();
  116|      1|  if (err)
  ------------------
  |  Branch (116:7): [True: 0, False: 1]
  ------------------
  117|      0|    goto fail;
  118|      1|  err = _gcry_md_init ();
  119|      1|  if (err)
  ------------------
  |  Branch (119:7): [True: 0, False: 1]
  ------------------
  120|      0|    goto fail;
  121|      1|  err = _gcry_mac_init ();
  122|      1|  if (err)
  ------------------
  |  Branch (122:7): [True: 0, False: 1]
  ------------------
  123|      0|    goto fail;
  124|      1|  err = _gcry_pk_init ();
  125|      1|  if (err)
  ------------------
  |  Branch (125:7): [True: 0, False: 1]
  ------------------
  126|      0|    goto fail;
  127|      1|  err = _gcry_primegen_init ();
  128|      1|  if (err)
  ------------------
  |  Branch (128:7): [True: 0, False: 1]
  ------------------
  129|      0|    goto fail;
  130|      1|  err = _gcry_secmem_module_init ();
  131|      1|  if (err)
  ------------------
  |  Branch (131:7): [True: 0, False: 1]
  ------------------
  132|      0|    goto fail;
  133|      1|  err = _gcry_mpi_init ();
  134|      1|  if (err)
  ------------------
  |  Branch (134:7): [True: 0, False: 1]
  ------------------
  135|      0|    goto fail;
  136|       |
  137|      1|  return;
  138|       |
  139|      1| fail:
  140|      0|  BUG ();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  141|      1|}
global.c:do_malloc:
  974|  9.09M|{
  975|  9.09M|  gcry_err_code_t err = 0;
  976|  9.09M|  void *m;
  977|       |
  978|  9.09M|  if ((flags & GCRY_ALLOC_FLAG_SECURE) && !no_secure_memory)
  ------------------
  |  |  423|  9.09M|#define GCRY_ALLOC_FLAG_SECURE (1 << 0)
  ------------------
  |  Branch (978:7): [True: 58.5k, False: 9.03M]
  |  Branch (978:43): [True: 58.5k, False: 0]
  ------------------
  979|  58.5k|    {
  980|  58.5k|      if (alloc_secure_func)
  ------------------
  |  Branch (980:11): [True: 0, False: 58.5k]
  ------------------
  981|      0|	m = (*alloc_secure_func) (n);
  982|  58.5k|      else
  983|  58.5k|	m = _gcry_private_malloc_secure (n, !!(flags & GCRY_ALLOC_FLAG_XHINT));
  ------------------
  |  |  424|  58.5k|#define GCRY_ALLOC_FLAG_XHINT  (1 << 1)  /* Called from xmalloc.  */
  ------------------
  984|  58.5k|    }
  985|  9.03M|  else
  986|  9.03M|    {
  987|  9.03M|      if (alloc_func)
  ------------------
  |  Branch (987:11): [True: 0, False: 9.03M]
  ------------------
  988|      0|	m = (*alloc_func) (n);
  989|  9.03M|      else
  990|  9.03M|	m = _gcry_private_malloc (n);
  991|  9.03M|    }
  992|       |
  993|  9.09M|  if (!m)
  ------------------
  |  Branch (993:7): [True: 10.3k, False: 9.08M]
  ------------------
  994|  10.3k|    {
  995|       |      /* Make sure that ERRNO has been set in case a user supplied
  996|       |         memory handler didn't it correctly. */
  997|  10.3k|      if (!errno)
  ------------------
  |  Branch (997:11): [True: 0, False: 10.3k]
  ------------------
  998|      0|        gpg_err_set_errno (ENOMEM);
  999|  10.3k|      err = gpg_err_code_from_errno (errno);
 1000|  10.3k|    }
 1001|  9.08M|  else
 1002|  9.08M|    *mem = m;
 1003|       |
 1004|  9.09M|  return err;
 1005|  9.09M|}
global.c:_gcry_malloc_secure_core:
 1019|  58.5k|{
 1020|  58.5k|  void *mem = NULL;
 1021|       |
 1022|  58.5k|  do_malloc (n, (GCRY_ALLOC_FLAG_SECURE | (xhint? GCRY_ALLOC_FLAG_XHINT:0)),
  ------------------
  |  |  423|  58.5k|#define GCRY_ALLOC_FLAG_SECURE (1 << 0)
  ------------------
                do_malloc (n, (GCRY_ALLOC_FLAG_SECURE | (xhint? GCRY_ALLOC_FLAG_XHINT:0)),
  ------------------
  |  |  424|  58.5k|#define GCRY_ALLOC_FLAG_XHINT  (1 << 1)  /* Called from xmalloc.  */
  ------------------
  |  Branch (1022:44): [True: 58.5k, False: 0]
  ------------------
 1023|  58.5k|             &mem);
 1024|       |
 1025|  58.5k|  return mem;
 1026|  58.5k|}
global.c:_gcry_realloc_core:
 1046|  25.5k|{
 1047|  25.5k|  void *p;
 1048|       |
 1049|       |  /* To avoid problems with non-standard realloc implementations and
 1050|       |     our own secmem_realloc, we divert to malloc and free here.  */
 1051|  25.5k|  if (!a)
  ------------------
  |  Branch (1051:7): [True: 5.78k, False: 19.7k]
  ------------------
 1052|  5.78k|    return _gcry_malloc (n);
 1053|  19.7k|  if (!n)
  ------------------
  |  Branch (1053:7): [True: 0, False: 19.7k]
  ------------------
 1054|      0|    {
 1055|      0|      xfree (a);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1056|      0|      return NULL;
 1057|      0|    }
 1058|       |
 1059|  19.7k|  if (realloc_func)
  ------------------
  |  Branch (1059:7): [True: 0, False: 19.7k]
  ------------------
 1060|      0|    p = realloc_func (a, n);
 1061|  19.7k|  else
 1062|  19.7k|    p =  _gcry_private_realloc (a, n, xhint);
 1063|  19.7k|  if (!p && !errno)
  ------------------
  |  Branch (1063:7): [True: 0, False: 19.7k]
  |  Branch (1063:13): [True: 0, False: 0]
  ------------------
 1064|      0|    gpg_err_set_errno (ENOMEM);
 1065|  19.7k|  return p;
 1066|  19.7k|}
global.c:_gcry_strdup_core:
 1140|   170k|{
 1141|   170k|  char *string_cp = NULL;
 1142|   170k|  size_t string_n = 0;
 1143|       |
 1144|   170k|  string_n = strlen (string);
 1145|       |
 1146|   170k|  if (_gcry_is_secure (string))
  ------------------
  |  Branch (1146:7): [True: 0, False: 170k]
  ------------------
 1147|      0|    string_cp = _gcry_malloc_secure_core (string_n + 1, xhint);
 1148|   170k|  else
 1149|   170k|    string_cp = _gcry_malloc (string_n + 1);
 1150|       |
 1151|   170k|  if (string_cp)
  ------------------
  |  Branch (1151:7): [True: 170k, False: 0]
  ------------------
 1152|   170k|    strcpy (string_cp, string);
 1153|       |
 1154|   170k|  return string_cp;
 1155|   170k|}

_gcry_hwf_detect_x86:
  465|      1|{
  466|      1|#if defined (HAS_X86_CPUID)
  467|      1|  return detect_x86_gnuc ();
  468|       |#else
  469|       |  return 0;
  470|       |#endif
  471|      1|}
hwf-x86.c:detect_x86_gnuc:
  177|      1|{
  178|      1|  union
  179|      1|  {
  180|      1|    char c[12+1];
  181|      1|    unsigned int ui[3];
  182|      1|  } vendor_id;
  183|      1|  unsigned int features, features2;
  184|      1|  unsigned int os_supports_avx_avx2_registers = 0;
  185|      1|  unsigned int os_supports_avx512_registers = 0;
  186|      1|  unsigned int max_cpuid_level;
  187|      1|  unsigned int fms, family, model;
  188|      1|  unsigned int result = 0;
  189|      1|  unsigned int avoid_vpgather = 0;
  190|      1|  unsigned int is_amd_cpu = 0;
  191|       |
  192|      1|  (void)os_supports_avx_avx2_registers;
  193|      1|  (void)os_supports_avx512_registers;
  194|       |
  195|      1|  if (!is_cpuid_available())
  ------------------
  |  Branch (195:7): [True: 0, False: 1]
  ------------------
  196|      0|    return 0;
  197|       |
  198|      1|  get_cpuid(0, &max_cpuid_level, &vendor_id.ui[0], &vendor_id.ui[2],
  199|      1|            &vendor_id.ui[1]);
  200|      1|  vendor_id.c[12] = 0;
  201|       |
  202|      1|  if (0)
  ------------------
  |  Branch (202:7): [Folded - Ignored]
  ------------------
  203|      0|    ; /* Just to make "else if" and ifdef macros look pretty.  */
  204|      1|#ifdef ENABLE_PADLOCK_SUPPORT
  205|      1|  else if (!strcmp (vendor_id.c, "CentaurHauls"))
  ------------------
  |  Branch (205:12): [True: 0, False: 1]
  ------------------
  206|      0|    {
  207|       |      /* This is a VIA CPU.  Check what PadLock features we have.  */
  208|       |
  209|       |      /* Check for extended centaur (EAX).  */
  210|      0|      get_cpuid(0xC0000000, &features, NULL, NULL, NULL);
  211|       |
  212|       |      /* Has extended centaur features? */
  213|      0|      if (features > 0xC0000000)
  ------------------
  |  Branch (213:11): [True: 0, False: 0]
  ------------------
  214|      0|        {
  215|       |           /* Ask for the extended feature flags (EDX). */
  216|      0|           get_cpuid(0xC0000001, NULL, NULL, NULL, &features);
  217|       |
  218|       |           /* Test bits 2 and 3 to see whether the RNG exists and is enabled. */
  219|      0|           if ((features & 0x0C) == 0x0C)
  ------------------
  |  Branch (219:16): [True: 0, False: 0]
  ------------------
  220|      0|             result |= HWF_PADLOCK_RNG;
  ------------------
  |  |  221|      0|#define HWF_PADLOCK_RNG         (1 << 0)
  ------------------
  221|       |
  222|       |           /* Test bits 6 and 7 to see whether the ACE exists and is enabled. */
  223|      0|           if ((features & 0xC0) == 0xC0)
  ------------------
  |  Branch (223:16): [True: 0, False: 0]
  ------------------
  224|      0|             result |= HWF_PADLOCK_AES;
  ------------------
  |  |  222|      0|#define HWF_PADLOCK_AES         (1 << 1)
  ------------------
  225|       |
  226|       |           /* Test bits 10 and 11 to see whether the PHE exists and is
  227|       |              enabled.  */
  228|      0|           if ((features & 0xC00) == 0xC00)
  ------------------
  |  Branch (228:16): [True: 0, False: 0]
  ------------------
  229|      0|             result |= HWF_PADLOCK_SHA;
  ------------------
  |  |  223|      0|#define HWF_PADLOCK_SHA         (1 << 2)
  ------------------
  230|       |
  231|       |           /* Test bits 12 and 13 to see whether the MONTMUL exists and is
  232|       |              enabled.  */
  233|      0|           if ((features & 0x3000) == 0x3000)
  ------------------
  |  Branch (233:16): [True: 0, False: 0]
  ------------------
  234|      0|             result |= HWF_PADLOCK_MMUL;
  ------------------
  |  |  224|      0|#define HWF_PADLOCK_MMUL        (1 << 3)
  ------------------
  235|      0|        }
  236|      0|    }
  237|      1|#endif /*ENABLE_PADLOCK_SUPPORT*/
  238|      1|  else if (!strcmp (vendor_id.c, "GenuineIntel"))
  ------------------
  |  Branch (238:12): [True: 1, False: 0]
  ------------------
  239|      1|    {
  240|       |      /* This is an Intel CPU.  */
  241|      1|      result |= HWF_INTEL_CPU;
  ------------------
  |  |  226|      1|#define HWF_INTEL_CPU           (1 << 4)
  ------------------
  242|      1|    }
  243|      0|  else if (!strcmp (vendor_id.c, "AuthenticAMD"))
  ------------------
  |  Branch (243:12): [True: 0, False: 0]
  ------------------
  244|      0|    {
  245|       |      /* This is an AMD CPU.  */
  246|      0|      is_amd_cpu = 1;
  247|      0|    }
  248|       |
  249|       |  /* Detect Intel features, that might also be supported by other
  250|       |     vendors.  */
  251|       |
  252|       |  /* Get CPU family/model/stepping (EAX) and Intel feature flags (ECX, EDX).  */
  253|      1|  get_cpuid(1, &fms, NULL, &features, &features2);
  254|       |
  255|      1|  family = ((fms & 0xf00) >> 8) + ((fms & 0xff00000) >> 20);
  256|      1|  model = ((fms & 0xf0) >> 4) + ((fms & 0xf0000) >> 12);
  257|       |
  258|      1|#ifdef ENABLE_PCLMUL_SUPPORT
  259|       |  /* Test bit 1 for PCLMUL.  */
  260|      1|  if (features & 0x00000002)
  ------------------
  |  Branch (260:7): [True: 1, False: 0]
  ------------------
  261|      1|     result |= HWF_INTEL_PCLMUL;
  ------------------
  |  |  231|      1|#define HWF_INTEL_PCLMUL        (1 << 9)
  ------------------
  262|      1|#endif
  263|       |  /* Test bit 9 for SSSE3.  */
  264|      1|  if (features & 0x00000200)
  ------------------
  |  Branch (264:7): [True: 1, False: 0]
  ------------------
  265|      1|     result |= HWF_INTEL_SSSE3;
  ------------------
  |  |  229|      1|#define HWF_INTEL_SSSE3         (1 << 7)
  ------------------
  266|       |  /* Test bit 19 for SSE4.1.  */
  267|      1|  if (features & 0x00080000)
  ------------------
  |  Branch (267:7): [True: 1, False: 0]
  ------------------
  268|      1|     result |= HWF_INTEL_SSE4_1;
  ------------------
  |  |  230|      1|#define HWF_INTEL_SSE4_1        (1 << 8)
  ------------------
  269|      1|#ifdef ENABLE_AESNI_SUPPORT
  270|       |  /* Test bit 25 for AES-NI.  */
  271|      1|  if (features & 0x02000000)
  ------------------
  |  Branch (271:7): [True: 1, False: 0]
  ------------------
  272|      1|     result |= HWF_INTEL_AESNI;
  ------------------
  |  |  232|      1|#define HWF_INTEL_AESNI         (1 << 10)
  ------------------
  273|      1|#endif /*ENABLE_AESNI_SUPPORT*/
  274|      1|#if defined(ENABLE_AVX_SUPPORT) || defined(ENABLE_AVX2_SUPPORT) \
  275|      1|    || defined(ENABLE_AVX512_SUPPORT)
  276|       |  /* Test bit 27 for OSXSAVE (required for AVX/AVX2/AVX512).  */
  277|      1|  if (features & 0x08000000)
  ------------------
  |  Branch (277:7): [True: 1, False: 0]
  ------------------
  278|      1|    {
  279|      1|      unsigned int xmm_ymm_mask = (1 << 2) | (1 << 1);
  280|      1|      unsigned int zmm15_ymm31_k7_mask = (1 << 7) | (1 << 6) | (1 << 5);
  281|      1|      unsigned int xgetbv = get_xgetbv();
  282|       |
  283|       |      /* Check that OS has enabled both XMM and YMM state support.  */
  284|      1|      if ((xgetbv & xmm_ymm_mask) == xmm_ymm_mask)
  ------------------
  |  Branch (284:11): [True: 1, False: 0]
  ------------------
  285|      1|        os_supports_avx_avx2_registers = 1;
  286|       |
  287|       |      /* Check that OS has enabled full AVX512 state support.  */
  288|      1|      if ((xgetbv & zmm15_ymm31_k7_mask) == zmm15_ymm31_k7_mask)
  ------------------
  |  Branch (288:11): [True: 0, False: 1]
  ------------------
  289|      0|        os_supports_avx512_registers = 1;
  290|      1|    }
  291|      1|#endif
  292|      1|#ifdef ENABLE_AVX_SUPPORT
  293|       |  /* Test bit 28 for AVX.  */
  294|      1|  if (features & 0x10000000)
  ------------------
  |  Branch (294:7): [True: 1, False: 0]
  ------------------
  295|      1|    if (os_supports_avx_avx2_registers)
  ------------------
  |  Branch (295:9): [True: 1, False: 0]
  ------------------
  296|      1|      result |= HWF_INTEL_AVX;
  ------------------
  |  |  234|      1|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
  297|      1|#endif /*ENABLE_AVX_SUPPORT*/
  298|      1|#ifdef ENABLE_DRNG_SUPPORT
  299|       |  /* Test bit 30 for RDRAND.  */
  300|      1|  if (features & 0x40000000)
  ------------------
  |  Branch (300:7): [True: 1, False: 0]
  ------------------
  301|      1|     result |= HWF_INTEL_RDRAND;
  ------------------
  |  |  233|      1|#define HWF_INTEL_RDRAND        (1 << 11)
  ------------------
  302|      1|#endif /*ENABLE_DRNG_SUPPORT*/
  303|       |
  304|       |  /* Test bit 4 of EDX for TSC.  */
  305|      1|  if (features2 & 0x00000010)
  ------------------
  |  Branch (305:7): [True: 1, False: 0]
  ------------------
  306|      1|    result |= HWF_INTEL_RDTSC;
  ------------------
  |  |  237|      1|#define HWF_INTEL_RDTSC         (1 << 15)
  ------------------
  307|       |
  308|       |  /* Check additional Intel feature flags.  Early Intel P5 processors report
  309|       |   * too high max_cpuid_level, so don't check level 7 if processor does not
  310|       |   * support SSE3 (as cpuid:7 contains only features for newer processors).
  311|       |   * Source: http://www.sandpile.org/x86/cpuid.htm  */
  312|      1|  if (max_cpuid_level >= 7 && (features & 0x00000001))
  ------------------
  |  Branch (312:7): [True: 1, False: 0]
  |  Branch (312:31): [True: 1, False: 0]
  ------------------
  313|      1|    {
  314|       |      /* Get CPUID:7 contains further Intel feature flags. */
  315|      1|      get_cpuid(7, NULL, &features, &features2, NULL);
  316|       |
  317|       |      /* Test bit 8 for BMI2.  */
  318|      1|      if (features & 0x00000100)
  ------------------
  |  Branch (318:11): [True: 1, False: 0]
  ------------------
  319|      1|          result |= HWF_INTEL_BMI2;
  ------------------
  |  |  228|      1|#define HWF_INTEL_BMI2          (1 << 6)
  ------------------
  320|       |
  321|      1|#ifdef ENABLE_AVX2_SUPPORT
  322|       |      /* Test bit 5 for AVX2.  */
  323|      1|      if (features & 0x00000020)
  ------------------
  |  Branch (323:11): [True: 1, False: 0]
  ------------------
  324|      1|        if (os_supports_avx_avx2_registers)
  ------------------
  |  Branch (324:13): [True: 1, False: 0]
  ------------------
  325|      1|          result |= HWF_INTEL_AVX2;
  ------------------
  |  |  235|      1|#define HWF_INTEL_AVX2          (1 << 13)
  ------------------
  326|      1|#endif /*ENABLE_AVX_SUPPORT*/
  327|       |
  328|       |      /* Test bit 29 for SHA Extensions. */
  329|      1|      if (features & (1 << 29))
  ------------------
  |  Branch (329:11): [True: 0, False: 1]
  ------------------
  330|      0|        result |= HWF_INTEL_SHAEXT;
  ------------------
  |  |  238|      0|#define HWF_INTEL_SHAEXT        (1 << 16)
  ------------------
  331|       |
  332|      1|#if defined(ENABLE_AVX2_SUPPORT) && defined(ENABLE_AESNI_SUPPORT) && \
  333|      1|    defined(ENABLE_PCLMUL_SUPPORT)
  334|       |      /* Test features2 bit 9 for VAES and features2 bit 10 for VPCLMULDQD */
  335|      1|      if ((features2 & 0x00000200) && (features2 & 0x00000400))
  ------------------
  |  Branch (335:11): [True: 0, False: 1]
  |  Branch (335:39): [True: 0, False: 0]
  ------------------
  336|      0|        result |= HWF_INTEL_VAES_VPCLMUL;
  ------------------
  |  |  239|      0|#define HWF_INTEL_VAES_VPCLMUL  (1 << 17)
  ------------------
  337|      1|#endif
  338|       |
  339|      1|#ifdef ENABLE_AVX512_SUPPORT
  340|       |      /* Test for AVX512 features. List of features is selected so that
  341|       |       * supporting CPUs are new enough not to suffer from reduced clock
  342|       |       * frequencies when AVX512 is used, which was issue on early AVX512
  343|       |       * capable CPUs.
  344|       |       *  - AVX512F (features bit 16)
  345|       |       *  - AVX512DQ (features bit 17)
  346|       |       *  - AVX512IFMA (features bit 21)
  347|       |       *  - AVX512CD (features bit 28)
  348|       |       *  - AVX512BW (features bit 30)
  349|       |       *  - AVX512VL (features bit 31)
  350|       |       *  - AVX512_VBMI (features2 bit 1)
  351|       |       *  - AVX512_VBMI2 (features2 bit 6)
  352|       |       *  - AVX512_VNNI (features2 bit 11)
  353|       |       *  - AVX512_BITALG (features2 bit 12)
  354|       |       *  - AVX512_VPOPCNTDQ (features2 bit 14)
  355|       |       */
  356|      1|      if (os_supports_avx512_registers
  ------------------
  |  Branch (356:11): [True: 0, False: 1]
  ------------------
  357|      1|	  && (features & (1 << 16))
  ------------------
  |  Branch (357:7): [True: 0, False: 0]
  ------------------
  358|      1|	  && (features & (1 << 17))
  ------------------
  |  Branch (358:7): [True: 0, False: 0]
  ------------------
  359|      1|	  && (features & (1 << 21))
  ------------------
  |  Branch (359:7): [True: 0, False: 0]
  ------------------
  360|      1|	  && (features & (1 << 28))
  ------------------
  |  Branch (360:7): [True: 0, False: 0]
  ------------------
  361|      1|	  && (features & (1 << 30))
  ------------------
  |  Branch (361:7): [True: 0, False: 0]
  ------------------
  362|      1|	  && (features & (1U << 31))
  ------------------
  |  Branch (362:7): [True: 0, False: 0]
  ------------------
  363|      1|	  && (features2 & (1 << 1))
  ------------------
  |  Branch (363:7): [True: 0, False: 0]
  ------------------
  364|      1|	  && (features2 & (1 << 6))
  ------------------
  |  Branch (364:7): [True: 0, False: 0]
  ------------------
  365|      1|	  && (features2 & (1 << 11))
  ------------------
  |  Branch (365:7): [True: 0, False: 0]
  ------------------
  366|      1|	  && (features2 & (1 << 12))
  ------------------
  |  Branch (366:7): [True: 0, False: 0]
  ------------------
  367|      1|	  && (features2 & (1 << 14)))
  ------------------
  |  Branch (367:7): [True: 0, False: 0]
  ------------------
  368|      0|	result |= HWF_INTEL_AVX512;
  ------------------
  |  |  240|      0|#define HWF_INTEL_AVX512        (1 << 18)
  ------------------
  369|      1|#endif
  370|       |
  371|       |      /* Test features2 bit 6 for GFNI (Galois field new instructions).
  372|       |       * These instructions are available for SSE/AVX/AVX2/AVX512. */
  373|      1|      if (features2 & (1 << 6))
  ------------------
  |  Branch (373:11): [True: 0, False: 1]
  ------------------
  374|      0|        result |= HWF_INTEL_GFNI;
  ------------------
  |  |  241|      0|#define HWF_INTEL_GFNI          (1 << 19)
  ------------------
  375|      1|    }
  376|       |
  377|      1|  if ((result & HWF_INTEL_CPU) && family == 6)
  ------------------
  |  |  226|      1|#define HWF_INTEL_CPU           (1 << 4)
  ------------------
  |  Branch (377:7): [True: 1, False: 0]
  |  Branch (377:35): [True: 1, False: 0]
  ------------------
  378|      1|    {
  379|       |      /* These Intel Core processor models have SHLD/SHRD instruction that
  380|       |       * can do integer rotation faster actual ROL/ROR instructions. */
  381|      1|      switch (model)
  ------------------
  |  Branch (381:15): [True: 0, False: 1]
  ------------------
  382|      1|	{
  383|      0|	case 0x2A:
  ------------------
  |  Branch (383:2): [True: 0, False: 1]
  ------------------
  384|      0|	case 0x2D:
  ------------------
  |  Branch (384:2): [True: 0, False: 1]
  ------------------
  385|      0|	case 0x3A:
  ------------------
  |  Branch (385:2): [True: 0, False: 1]
  ------------------
  386|      0|	case 0x3C:
  ------------------
  |  Branch (386:2): [True: 0, False: 1]
  ------------------
  387|      0|	case 0x3F:
  ------------------
  |  Branch (387:2): [True: 0, False: 1]
  ------------------
  388|      0|	case 0x45:
  ------------------
  |  Branch (388:2): [True: 0, False: 1]
  ------------------
  389|      0|	case 0x46:
  ------------------
  |  Branch (389:2): [True: 0, False: 1]
  ------------------
  390|      0|	case 0x3D:
  ------------------
  |  Branch (390:2): [True: 0, False: 1]
  ------------------
  391|      1|	case 0x4F:
  ------------------
  |  Branch (391:2): [True: 1, False: 0]
  ------------------
  392|      1|	case 0x56:
  ------------------
  |  Branch (392:2): [True: 0, False: 1]
  ------------------
  393|      1|	case 0x47:
  ------------------
  |  Branch (393:2): [True: 0, False: 1]
  ------------------
  394|      1|	case 0x4E:
  ------------------
  |  Branch (394:2): [True: 0, False: 1]
  ------------------
  395|      1|	case 0x5E:
  ------------------
  |  Branch (395:2): [True: 0, False: 1]
  ------------------
  396|      1|	case 0x8E:
  ------------------
  |  Branch (396:2): [True: 0, False: 1]
  ------------------
  397|      1|	case 0x9E:
  ------------------
  |  Branch (397:2): [True: 0, False: 1]
  ------------------
  398|      1|	case 0x55:
  ------------------
  |  Branch (398:2): [True: 0, False: 1]
  ------------------
  399|      1|	case 0x66:
  ------------------
  |  Branch (399:2): [True: 0, False: 1]
  ------------------
  400|      1|	  result |= HWF_INTEL_FAST_SHLD;
  ------------------
  |  |  227|      1|#define HWF_INTEL_FAST_SHLD     (1 << 5)
  ------------------
  401|      1|	  break;
  402|      1|	}
  403|       |
  404|       |      /* These Intel Core processors that have AVX2 have slow VPGATHER and
  405|       |       * should be avoided for table-lookup use. */
  406|      1|      switch (model)
  ------------------
  |  Branch (406:15): [True: 1, False: 0]
  ------------------
  407|      1|	{
  408|      0|	case 0x3C:
  ------------------
  |  Branch (408:2): [True: 0, False: 1]
  ------------------
  409|      0|	case 0x3F:
  ------------------
  |  Branch (409:2): [True: 0, False: 1]
  ------------------
  410|      0|	case 0x45:
  ------------------
  |  Branch (410:2): [True: 0, False: 1]
  ------------------
  411|      0|	case 0x46:
  ------------------
  |  Branch (411:2): [True: 0, False: 1]
  ------------------
  412|       |	  /* Haswell */
  413|      0|	  avoid_vpgather |= 1;
  414|      0|	  break;
  415|      1|	}
  416|      1|    }
  417|      0|  else if (is_amd_cpu)
  ------------------
  |  Branch (417:12): [True: 0, False: 0]
  ------------------
  418|      0|    {
  419|       |      /* Non-AVX512 AMD CPUs (pre-Zen4) have slow VPGATHER and should be
  420|       |       * avoided for table-lookup use. */
  421|      0|      avoid_vpgather |= !(result & HWF_INTEL_AVX512);
  ------------------
  |  |  240|      0|#define HWF_INTEL_AVX512        (1 << 18)
  ------------------
  422|      0|    }
  423|      0|  else
  424|      0|    {
  425|       |      /* Avoid VPGATHER for non-Intel/non-AMD CPUs as testing is needed to
  426|       |       * make sure it is fast enough. */
  427|      0|      avoid_vpgather |= 1;
  428|      0|    }
  429|       |
  430|       |#ifdef ENABLE_FORCE_SOFT_HWFEATURES
  431|       |  /* Soft HW features mark functionality that is available on all systems
  432|       |   * but not feasible to use because of slow HW implementation. */
  433|       |
  434|       |  /* Some implementations are disabled for non-Intel CPUs. Mark
  435|       |   * current CPU as Intel one to enable those implementations. */
  436|       |  result |= HWF_INTEL_CPU;
  437|       |
  438|       |  /* SHLD is faster at rotating register than actual ROR/ROL instructions
  439|       |   * on older Intel systems (~sandy-bridge era). However, SHLD is very
  440|       |   * slow on almost anything else and later Intel processors have faster
  441|       |   * ROR/ROL. Therefore in regular build HWF_INTEL_FAST_SHLD is enabled
  442|       |   * only for those Intel processors that benefit from the SHLD
  443|       |   * instruction. Enabled here unconditionally as requested. */
  444|       |  result |= HWF_INTEL_FAST_SHLD;
  445|       |
  446|       |  /* VPGATHER instructions are used for look-up table based
  447|       |   * implementations which require VPGATHER to be fast enough to beat
  448|       |   * regular parallelized look-up table implementations (see Twofish).
  449|       |   * So far, only Intel processors beginning with Skylake and AMD
  450|       |   * processors starting with Zen4 have had VPGATHER fast enough to be
  451|       |   * enabled. Enable VPGATHER here unconditionally as requested. */
  452|       |  avoid_vpgather = 0;
  453|       |#endif
  454|       |
  455|      1|  if ((result & HWF_INTEL_AVX2) && !avoid_vpgather)
  ------------------
  |  |  235|      1|#define HWF_INTEL_AVX2          (1 << 13)
  ------------------
  |  Branch (455:7): [True: 1, False: 0]
  |  Branch (455:36): [True: 1, False: 0]
  ------------------
  456|      1|    result |= HWF_INTEL_FAST_VPGATHER;
  ------------------
  |  |  236|      1|#define HWF_INTEL_FAST_VPGATHER (1 << 14)
  ------------------
  457|       |
  458|      1|  return result;
  459|      1|}
hwf-x86.c:is_cpuid_available:
  128|      1|{
  129|      1|  return 1;
  130|      1|}
hwf-x86.c:get_cpuid:
  135|      3|{
  136|      3|  unsigned int regs[4];
  137|       |
  138|      3|  asm volatile
  139|      3|    ("cpuid\n\t"
  140|      3|     : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3])
  141|      3|     : "0" (in), "1" (0), "2" (0), "3" (0)
  142|      3|     : "cc"
  143|      3|     );
  144|       |
  145|      3|  if (eax)
  ------------------
  |  Branch (145:7): [True: 2, False: 1]
  ------------------
  146|      2|    *eax = regs[0];
  147|      3|  if (ebx)
  ------------------
  |  Branch (147:7): [True: 2, False: 1]
  ------------------
  148|      2|    *ebx = regs[1];
  149|      3|  if (ecx)
  ------------------
  |  Branch (149:7): [True: 3, False: 0]
  ------------------
  150|      3|    *ecx = regs[2];
  151|      3|  if (edx)
  ------------------
  |  Branch (151:7): [True: 2, False: 1]
  ------------------
  152|      2|    *edx = regs[3];
  153|      3|}
hwf-x86.c:get_xgetbv:
  158|      1|{
  159|      1|  unsigned int t_eax, t_edx;
  160|       |
  161|      1|  asm volatile
  162|      1|    ("xgetbv\n\t"
  163|      1|     : "=a" (t_eax), "=d" (t_edx)
  164|      1|     : "c" (0)
  165|      1|    );
  166|       |
  167|      1|  return t_eax;
  168|      1|}

_gcry_get_hw_features:
  148|   198k|{
  149|   198k|  return hw_features;
  150|   198k|}
_gcry_detect_hw_features:
  227|      1|{
  228|      1|  hw_features = 0;
  229|       |
  230|      1|  parse_hwf_deny_file ();
  231|       |
  232|      1|#if defined (HAVE_CPU_ARCH_X86)
  233|      1|  {
  234|      1|    hw_features = _gcry_hwf_detect_x86 ();
  235|      1|  }
  236|       |#elif defined (HAVE_CPU_ARCH_ARM)
  237|       |  {
  238|       |    hw_features = _gcry_hwf_detect_arm ();
  239|       |  }
  240|       |#elif defined (HAVE_CPU_ARCH_PPC)
  241|       |  {
  242|       |    hw_features = _gcry_hwf_detect_ppc ();
  243|       |  }
  244|       |#elif defined (HAVE_CPU_ARCH_S390X)
  245|       |  {
  246|       |    hw_features = _gcry_hwf_detect_s390x ();
  247|       |  }
  248|       |#endif
  249|      1|  hw_features &= ~disabled_hw_features;
  250|      1|}
hwfeatures.c:parse_hwf_deny_file:
  171|      1|{
  172|      1|  const char *fname = HWF_DENY_FILE;
  ------------------
  |  |   36|      1|#define HWF_DENY_FILE "/etc/gcrypt/hwf.deny"
  ------------------
  173|      1|  FILE *fp;
  174|      1|  char buffer[256];
  175|      1|  char *p, *pend;
  176|      1|  int lnr = 0;
  177|       |
  178|      1|  fp = fopen (fname, "r");
  179|      1|  if (!fp)
  ------------------
  |  Branch (179:7): [True: 1, False: 0]
  ------------------
  180|      1|    return;
  181|       |
  182|      0|  for (;;)
  183|      0|    {
  184|      0|      if (!fgets (buffer, sizeof buffer, fp))
  ------------------
  |  Branch (184:11): [True: 0, False: 0]
  ------------------
  185|      0|        {
  186|      0|          if (!feof (fp))
  ------------------
  |  Branch (186:15): [True: 0, False: 0]
  ------------------
  187|      0|            {
  188|      0|#ifdef HAVE_SYSLOG
  189|      0|              syslog (LOG_USER|LOG_WARNING,
  190|      0|                      "Libgcrypt warning: error reading '%s', line %d",
  191|      0|                      fname, lnr);
  192|      0|#endif /*HAVE_SYSLOG*/
  193|      0|            }
  194|      0|          fclose (fp);
  195|      0|          return;
  196|      0|        }
  197|      0|      lnr++;
  198|      0|      for (p=buffer; my_isascii (*p) && isspace (*p); p++)
  ------------------
  |  |  107|      0|#define my_isascii(c) (!((c) & 0x80))
  |  |  ------------------
  |  |  |  Branch (107:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  199|      0|        ;
  200|      0|      pend = strchr (p, '\n');
  201|      0|      if (pend)
  ------------------
  |  Branch (201:11): [True: 0, False: 0]
  ------------------
  202|      0|        *pend = 0;
  203|      0|      pend = p + (*p? (strlen (p)-1):0);
  ------------------
  |  Branch (203:19): [True: 0, False: 0]
  ------------------
  204|      0|      for ( ;pend > p; pend--)
  ------------------
  |  Branch (204:14): [True: 0, False: 0]
  ------------------
  205|      0|        if (my_isascii (*pend) && isspace (*pend))
  ------------------
  |  |  107|      0|#define my_isascii(c) (!((c) & 0x80))
  |  |  ------------------
  |  |  |  Branch (107:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  206|      0|          *pend = 0;
  207|      0|      if (!*p || *p == '#')
  ------------------
  |  Branch (207:11): [True: 0, False: 0]
  |  Branch (207:18): [True: 0, False: 0]
  ------------------
  208|      0|        continue;
  209|       |
  210|      0|      if (_gcry_disable_hw_feature (p) == GPG_ERR_INV_NAME)
  ------------------
  |  Branch (210:11): [True: 0, False: 0]
  ------------------
  211|      0|        {
  212|      0|#ifdef HAVE_SYSLOG
  213|      0|          syslog (LOG_USER|LOG_WARNING,
  214|      0|                  "Libgcrypt warning: unknown feature in '%s', line %d",
  215|      0|                  fname, lnr);
  216|      0|#endif /*HAVE_SYSLOG*/
  217|      0|        }
  218|      0|    }
  219|      0|}

_gcry_set_log_handler:
  102|      1|{
  103|      1|    log_handler = f;
  104|      1|    log_handler_value = opaque;
  105|      1|}
_gcry_fast_wipememory:
  508|   250k|{
  509|       |  /* Note: This function is called from wipememory/wipememory2 only if LEN
  510|       |     is large or unknown at compile time. New wipe function alternatives
  511|       |     need to be checked before adding to this function. New implementations
  512|       |     need to be faster than wipememory/wipememory2 macros in 'g10lib.h'.
  513|       |
  514|       |     Following implementations were found to have suboptimal performance:
  515|       |
  516|       |     - [_WIN32/mingw32] SecureZeroMemory; Inline function, equivalent to
  517|       |       volatile byte buffer set: while(buflen--) (volatile char *)(buf++)=set;
  518|       |   */
  519|   250k|#ifdef HAVE_EXPLICIT_BZERO
  520|   250k|  explicit_bzero (ptr, len);
  521|       |#elif defined(HAVE_EXPLICIT_MEMSET)
  522|       |  explicit_memset (ptr, 0, len);
  523|       |#else
  524|       |  memset_ptr (ptr, 0, len);
  525|       |#endif
  526|   250k|}
_gcry_fast_wipememory2:
  531|   175k|{
  532|       |#ifdef HAVE_EXPLICIT_MEMSET
  533|       |  explicit_memset (ptr, set, len);
  534|       |#else
  535|   175k|#ifdef HAVE_EXPLICIT_BZERO
  536|   175k|  if (set == 0)
  ------------------
  |  Branch (536:7): [True: 0, False: 175k]
  ------------------
  537|      0|    {
  538|      0|      explicit_bzero (ptr, len);
  539|      0|      return;
  540|      0|    }
  541|   175k|#endif
  542|       |
  543|   175k|  memset_ptr (ptr, set, len);
  544|   175k|#endif
  545|   175k|}
__gcry_burn_stack:
  550|  85.4k|{
  551|  85.4k|#ifdef HAVE_VLA
  552|       |  /* (bytes == 0 ? 1 : bytes) == (!bytes + bytes) */
  553|  85.4k|  unsigned int buflen = ((!bytes + bytes) + 63) & ~63;
  554|  85.4k|  char buf[buflen];
  555|       |
  556|  85.4k|  _gcry_fast_wipememory (buf, buflen);
  557|       |#else
  558|       |  volatile char buf[64];
  559|       |
  560|       |  _gcry_fast_wipememory (buf, sizeof buf);
  561|       |
  562|       |  if (bytes > sizeof buf)
  563|       |      _gcry_burn_stack (bytes - sizeof buf);
  564|       |#endif
  565|  85.4k|}

_gcry_secmem_module_init:
  568|      1|{
  569|       |  /* Not anymore needed.  */
  570|      1|  return 0;
  571|      1|}
_gcry_secmem_malloc:
  689|  58.5k|{
  690|  58.5k|  void *p;
  691|       |
  692|  58.5k|  SECMEM_LOCK;
  ------------------
  |  |  109|  58.5k|#define SECMEM_LOCK   gpgrt_lock_lock   (&secmem_lock)
  ------------------
  693|  58.5k|  p = _gcry_secmem_malloc_internal (size, xhint);
  694|  58.5k|  SECMEM_UNLOCK;
  ------------------
  |  |  110|  58.5k|#define SECMEM_UNLOCK gpgrt_lock_unlock (&secmem_lock)
  ------------------
  695|       |
  696|  58.5k|  return p;
  697|  58.5k|}
_gcry_secmem_free:
  740|  58.5k|{
  741|  58.5k|  int mine;
  742|       |
  743|  58.5k|  if (!a)
  ------------------
  |  Branch (743:7): [True: 0, False: 58.5k]
  ------------------
  744|      0|    return 1; /* Tell caller that we handled it.  */
  745|       |
  746|  58.5k|  SECMEM_LOCK;
  ------------------
  |  |  109|  58.5k|#define SECMEM_LOCK   gpgrt_lock_lock   (&secmem_lock)
  ------------------
  747|  58.5k|  mine = _gcry_secmem_free_internal (a);
  748|  58.5k|  SECMEM_UNLOCK;
  ------------------
  |  |  110|  58.5k|#define SECMEM_UNLOCK gpgrt_lock_unlock (&secmem_lock)
  ------------------
  749|  58.5k|  return mine;
  750|  58.5k|}
_gcry_private_is_secure:
  801|  9.43M|{
  802|  9.43M|  pooldesc_t *pool;
  803|       |
  804|       |  /* We do no lock here because once a pool is allocated it will not
  805|       |   * be removed anymore (except for gcry_secmem_term).  Further, as
  806|       |   * assigment of POOL->NEXT in new pool structure is visible in
  807|       |   * this thread before assigment of MAINPOOL.NEXT, pool list can be
  808|       |   * iterated locklessly.  This visiblity is ensured by memory barrier
  809|       |   * between POOL->NEXT and MAINPOOL.NEXT assignments in
  810|       |   * _gcry_secmem_malloc_internal. */
  811|  18.8M|  for (pool = &mainpool; pool; pool = pool->next)
  ------------------
  |  Branch (811:26): [True: 9.43M, False: 9.37M]
  ------------------
  812|  9.43M|    if (pool->okay && ptr_into_pool_p (pool, p))
  ------------------
  |  Branch (812:9): [True: 9.40M, False: 32.5k]
  |  Branch (812:23): [True: 58.5k, False: 9.34M]
  ------------------
  813|  58.5k|      return 1;
  814|       |
  815|  9.37M|  return 0;
  816|  9.43M|}
secmem.c:_gcry_secmem_init_internal:
  506|      1|{
  507|      1|  pooldesc_t *pool;
  508|       |
  509|      1|  pool = &mainpool;
  510|      1|  if (!n)
  ------------------
  |  Branch (510:7): [True: 0, False: 1]
  ------------------
  511|      0|    {
  512|       |#ifdef USE_CAPABILITIES
  513|       |      /* drop all capabilities */
  514|       |      if (!no_priv_drop)
  515|       |        {
  516|       |          cap_t cap;
  517|       |
  518|       |          cap = cap_from_text ("all-eip");
  519|       |          cap_set_proc (cap);
  520|       |          cap_free (cap);
  521|       |        }
  522|       |
  523|       |#elif !defined(HAVE_DOSISH_SYSTEM)
  524|      0|      uid_t uid;
  525|       |
  526|      0|      disable_secmem = 1;
  527|      0|      uid = getuid ();
  528|      0|      if (uid != geteuid ())
  ------------------
  |  Branch (528:11): [True: 0, False: 0]
  ------------------
  529|      0|	{
  530|      0|	  if (setuid (uid) || getuid () != geteuid () || !setuid (0))
  ------------------
  |  Branch (530:8): [True: 0, False: 0]
  |  Branch (530:24): [True: 0, False: 0]
  |  Branch (530:51): [True: 0, False: 0]
  ------------------
  531|      0|	    log_fatal ("failed to drop setuid\n");
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  532|      0|	}
  533|      0|#endif
  534|      0|    }
  535|      1|  else
  536|      1|    {
  537|      1|      if (n < MINIMUM_POOL_SIZE)
  ------------------
  |  |   47|      1|#define MINIMUM_POOL_SIZE 16384
  ------------------
  |  Branch (537:11): [True: 0, False: 1]
  ------------------
  538|      0|	n = MINIMUM_POOL_SIZE;
  ------------------
  |  |   47|      0|#define MINIMUM_POOL_SIZE 16384
  ------------------
  539|      1|      if (! pool->okay)
  ------------------
  |  Branch (539:11): [True: 1, False: 0]
  ------------------
  540|      1|	{
  541|      1|	  init_pool (pool, n);
  542|      1|	  lock_pool_pages (pool->mem, n);
  543|      1|	}
  544|      0|      else
  545|      0|	log_error ("Oops, secure memory pool already initialized\n");
  ------------------
  |  |  203|      0|#define log_error   _gcry_log_error
  ------------------
  546|      1|    }
  547|      1|}
secmem.c:init_pool:
  370|      1|{
  371|      1|  memblock_t *mb;
  372|       |
  373|      1|  pool->size = n;
  374|       |
  375|      1|  if (disable_secmem)
  ------------------
  |  Branch (375:7): [True: 0, False: 1]
  ------------------
  376|      0|    log_bug ("secure memory is disabled");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  377|       |
  378|       |
  379|      1|#if HAVE_MMAP
  380|      1|  {
  381|      1|    size_t pgsize;
  382|      1|    long int pgsize_val;
  383|       |
  384|      1|# if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
  385|      1|    pgsize_val = sysconf (_SC_PAGESIZE);
  386|       |# elif defined(HAVE_GETPAGESIZE)
  387|       |    pgsize_val = getpagesize ();
  388|       |# else
  389|       |    pgsize_val = -1;
  390|       |# endif
  391|      1|    pgsize = (pgsize_val > 0)? pgsize_val:DEFAULT_PAGE_SIZE;
  ------------------
  |  |   49|      1|#define DEFAULT_PAGE_SIZE 4096
  ------------------
  |  Branch (391:14): [True: 1, False: 0]
  ------------------
  392|       |
  393|      1|    pool->size = (pool->size + pgsize - 1) & ~(pgsize - 1);
  394|      1|# ifdef MAP_ANONYMOUS
  395|      1|    pool->mem = mmap (0, pool->size, PROT_READ | PROT_WRITE,
  396|      1|                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  397|       |# else /* map /dev/zero instead */
  398|       |    {
  399|       |      int fd;
  400|       |
  401|       |      fd = open ("/dev/zero", O_RDWR);
  402|       |      if (fd == -1)
  403|       |        {
  404|       |          log_error ("can't open /dev/zero: %s\n", strerror (errno));
  405|       |          pool->mem = (void *) -1;
  406|       |        }
  407|       |      else
  408|       |        {
  409|       |          pool->mem = mmap (0, pool->size,
  410|       |                           (PROT_READ | PROT_WRITE), MAP_PRIVATE, fd, 0);
  411|       |          close (fd);
  412|       |        }
  413|       |    }
  414|       |# endif
  415|      1|    if (pool->mem == (void *) -1)
  ------------------
  |  Branch (415:9): [True: 0, False: 1]
  ------------------
  416|      0|      log_info ("can't mmap pool of %u bytes: %s - using malloc\n",
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
  417|      0|                (unsigned) pool->size, strerror (errno));
  418|      1|    else
  419|      1|      {
  420|      1|        pool->is_mmapped = 1;
  421|      1|        pool->okay = 1;
  422|      1|      }
  423|      1|  }
  424|      1|#endif /*HAVE_MMAP*/
  425|       |
  426|      1|  if (!pool->okay)
  ------------------
  |  Branch (426:7): [True: 0, False: 1]
  ------------------
  427|      0|    {
  428|      0|      pool->mem = malloc (pool->size);
  429|      0|      if (!pool->mem)
  ------------------
  |  Branch (429:11): [True: 0, False: 0]
  ------------------
  430|      0|	log_fatal ("can't allocate memory pool of %u bytes\n",
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  431|      0|		   (unsigned) pool->size);
  432|      0|      else
  433|      0|	pool->okay = 1;
  434|      0|    }
  435|       |
  436|       |  /* Initialize first memory block.  */
  437|      1|  mb = (memblock_t *) pool->mem;
  438|      1|  mb->size = pool->size - BLOCK_HEAD_SIZE;
  ------------------
  |  |  115|      1|  offsetof (memblock_t, aligned)
  ------------------
  439|      1|  mb->flags = 0;
  440|      1|}
secmem.c:lock_pool_pages:
  291|      1|{
  292|      1|#if defined(HAVE_MLOCK)
  293|      1|  uid_t uid;
  294|      1|  int err;
  295|       |
  296|      1|  uid = getuid ();
  297|       |
  298|       |#ifdef HAVE_BROKEN_MLOCK
  299|       |  /* Under HP/UX mlock segfaults if called by non-root.  Note, we have
  300|       |     noch checked whether mlock does really work under AIX where we
  301|       |     also detected a broken nlock.  Note further, that using plock ()
  302|       |     is not a good idea under AIX. */
  303|       |  if (uid)
  304|       |    {
  305|       |      errno = EPERM;
  306|       |      err = -1;
  307|       |    }
  308|       |  else
  309|       |    {
  310|       |      err = no_mlock? 0 : mlock (p, n);
  311|       |    }
  312|       |#else /* !HAVE_BROKEN_MLOCK */
  313|      1|  err = no_mlock? 0 : mlock (p, n);
  ------------------
  |  Branch (313:9): [True: 0, False: 1]
  ------------------
  314|      1|#endif /* !HAVE_BROKEN_MLOCK */
  315|       |
  316|       |  /* Test whether we are running setuid(0).  */
  317|      1|  if (uid && ! geteuid ())
  ------------------
  |  Branch (317:7): [True: 0, False: 1]
  |  Branch (317:14): [True: 0, False: 0]
  ------------------
  318|      0|    {
  319|       |      /* Yes, we are.  */
  320|      0|      if (!no_priv_drop)
  ------------------
  |  Branch (320:11): [True: 0, False: 0]
  ------------------
  321|      0|        {
  322|       |          /* Check that we really dropped the privs.
  323|       |           * Note: setuid(0) should always fail */
  324|      0|          if (setuid (uid) || getuid () != geteuid () || !setuid (0))
  ------------------
  |  Branch (324:15): [True: 0, False: 0]
  |  Branch (324:31): [True: 0, False: 0]
  |  Branch (324:58): [True: 0, False: 0]
  ------------------
  325|      0|            log_fatal ("failed to reset uid: %s\n", strerror (errno));
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  326|      0|        }
  327|      0|    }
  328|       |
  329|      1|  if (err)
  ------------------
  |  Branch (329:7): [True: 0, False: 1]
  ------------------
  330|      0|    {
  331|      0|      if (errno != EPERM
  ------------------
  |  Branch (331:11): [True: 0, False: 0]
  ------------------
  332|      0|#ifdef EAGAIN	/* BSD and also Linux may return this. */
  333|      0|	  && errno != EAGAIN
  ------------------
  |  Branch (333:7): [True: 0, False: 0]
  ------------------
  334|      0|#endif
  335|      0|#ifdef ENOSYS	/* Some SCOs return this (function not implemented). */
  336|      0|	  && errno != ENOSYS
  ------------------
  |  Branch (336:7): [True: 0, False: 0]
  ------------------
  337|      0|#endif
  338|      0|#ifdef ENOMEM  /* Linux might return this. */
  339|      0|            && errno != ENOMEM
  ------------------
  |  Branch (339:16): [True: 0, False: 0]
  ------------------
  340|      0|#endif
  341|      0|	  )
  342|      0|	log_error ("can't lock memory: %s\n", strerror (errno));
  ------------------
  |  |  203|      0|#define log_error   _gcry_log_error
  ------------------
  343|      0|      show_warning = 1;
  344|      0|      not_locked = 1;
  345|      0|    }
  346|       |
  347|       |#elif defined ( __QNX__ )
  348|       |  /* QNX does not page at all, so the whole secure memory stuff does
  349|       |   * not make much sense.  However it is still of use because it
  350|       |   * wipes out the memory on a free().
  351|       |   * Therefore it is sufficient to suppress the warning.  */
  352|       |  (void)p;
  353|       |  (void)n;
  354|       |#elif defined (HAVE_DOSISH_SYSTEM) || defined (__CYGWIN__)
  355|       |    /* It does not make sense to print such a warning, given the fact that
  356|       |     * this whole Windows !@#$% and their user base are inherently insecure. */
  357|       |  (void)p;
  358|       |  (void)n;
  359|       |#else
  360|       |  (void)p;
  361|       |  (void)n;
  362|       |  if (!no_mlock)
  363|       |    log_info ("Please note that you don't have secure memory on this system\n");
  364|       |#endif
  365|      1|}
secmem.c:_gcry_secmem_malloc_internal:
  576|  58.5k|{
  577|  58.5k|  pooldesc_t *pool;
  578|  58.5k|  memblock_t *mb;
  579|       |
  580|  58.5k|  pool = &mainpool;
  581|       |
  582|  58.5k|  if (!pool->okay)
  ------------------
  |  Branch (582:7): [True: 1, False: 58.5k]
  ------------------
  583|      1|    {
  584|       |      /* Try to initialize the pool if the user forgot about it.  */
  585|      1|      _gcry_secmem_init_internal (STANDARD_POOL_SIZE);
  ------------------
  |  |   48|      1|#define STANDARD_POOL_SIZE 32768
  ------------------
  586|      1|      if (!pool->okay)
  ------------------
  |  Branch (586:11): [True: 0, False: 1]
  ------------------
  587|      0|        {
  588|      0|          log_info (_("operation is not possible without "
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
                        log_info (_("operation is not possible without "
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
  589|      0|                      "initialized secure memory\n"));
  590|      0|          gpg_err_set_errno (ENOMEM);
  591|      0|          return NULL;
  592|      0|        }
  593|      1|    }
  594|  58.5k|  if (not_locked && fips_mode ())
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (594:7): [True: 0, False: 58.5k]
  ------------------
  595|      0|    {
  596|      0|      log_info (_("secure memory pool is not locked while in FIPS mode\n"));
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
                    log_info (_("secure memory pool is not locked while in FIPS mode\n"));
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
  597|      0|      gpg_err_set_errno (ENOMEM);
  598|      0|      return NULL;
  599|      0|    }
  600|  58.5k|  if (show_warning && !suspend_warning)
  ------------------
  |  Branch (600:7): [True: 0, False: 58.5k]
  |  Branch (600:23): [True: 0, False: 0]
  ------------------
  601|      0|    {
  602|      0|      show_warning = 0;
  603|      0|      print_warn ();
  604|      0|    }
  605|       |
  606|       |  /* Blocks are always a multiple of 32. */
  607|  58.5k|  size = ((size + 31) / 32) * 32;
  608|       |
  609|  58.5k|  mb = mb_get_new (pool, (memblock_t *) pool->mem, size);
  610|  58.5k|  if (mb)
  ------------------
  |  Branch (610:7): [True: 58.5k, False: 0]
  ------------------
  611|  58.5k|    {
  612|  58.5k|      stats_update (pool, mb->size, 0);
  613|  58.5k|      return &mb->aligned.c;
  614|  58.5k|    }
  615|       |
  616|       |  /* If we are called from xmalloc style functions resort to the
  617|       |   * overflow pools to return memory.  We don't do this in FIPS mode,
  618|       |   * though.  If the auto-expand option is active we do the expanding
  619|       |   * also for the standard malloc functions.
  620|       |   *
  621|       |   * The idea of using them by default only for the xmalloc function
  622|       |   * is so that a user can control whether memory will be allocated in
  623|       |   * the initial created mlock protected secmem area or may also be
  624|       |   * allocated from the overflow pools.  */
  625|      0|  if ((xhint || auto_expand) && !fips_mode ())
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  ------------------
  |  Branch (625:8): [True: 0, False: 0]
  |  Branch (625:17): [True: 0, False: 0]
  |  Branch (625:33): [True: 0, False: 0]
  ------------------
  626|      0|    {
  627|       |      /* Check whether we can allocate from the overflow pools.  */
  628|      0|      for (pool = pool->next; pool; pool = pool->next)
  ------------------
  |  Branch (628:31): [True: 0, False: 0]
  ------------------
  629|      0|        {
  630|      0|          mb = mb_get_new (pool, (memblock_t *) pool->mem, size);
  631|      0|          if (mb)
  ------------------
  |  Branch (631:15): [True: 0, False: 0]
  ------------------
  632|      0|            {
  633|      0|              stats_update (pool, mb->size, 0);
  634|      0|              return &mb->aligned.c;
  635|      0|            }
  636|      0|        }
  637|       |      /* Allocate a new overflow pool.  We put a new pool right after
  638|       |       * the mainpool so that the next allocation will happen in that
  639|       |       * pool and not in one of the older pools.  When this new pool
  640|       |       * gets full we will try to find space in the older pools.  */
  641|      0|      pool = calloc (1, sizeof *pool);
  642|      0|      if (!pool)
  ------------------
  |  Branch (642:11): [True: 0, False: 0]
  ------------------
  643|      0|        return NULL;  /* Not enough memory for a new pool descriptor.  */
  644|      0|      pool->size = auto_expand? auto_expand : STANDARD_POOL_SIZE;
  ------------------
  |  |   48|      0|#define STANDARD_POOL_SIZE 32768
  ------------------
  |  Branch (644:20): [True: 0, False: 0]
  ------------------
  645|      0|      pool->mem = malloc (pool->size);
  646|      0|      if (!pool->mem)
  ------------------
  |  Branch (646:11): [True: 0, False: 0]
  ------------------
  647|      0|        {
  648|      0|          free (pool);
  649|      0|          return NULL; /* Not enough memory available for a new pool.  */
  650|      0|        }
  651|       |      /* Initialize first memory block.  */
  652|      0|      mb = (memblock_t *) pool->mem;
  653|      0|      mb->size = pool->size - BLOCK_HEAD_SIZE;
  ------------------
  |  |  115|      0|  offsetof (memblock_t, aligned)
  ------------------
  654|      0|      mb->flags = 0;
  655|       |
  656|      0|      pool->okay = 1;
  657|       |
  658|       |      /* Take care: in _gcry_private_is_secure we do not lock and thus
  659|       |       * we assume that the second assignment below is atomic.  Memory
  660|       |       * barrier prevents reordering of stores to new pool structure after
  661|       |       * MAINPOOL.NEXT assigment and prevents _gcry_private_is_secure seeing
  662|       |       * non-initialized POOL->NEXT pointers.  */
  663|      0|      pool->next = mainpool.next;
  664|      0|      memory_barrier();
  665|      0|      mainpool.next = pool;
  666|       |
  667|       |      /* After the first time we allocated an overflow pool, print a
  668|       |       * warning.  */
  669|      0|      if (!pool->next)
  ------------------
  |  Branch (669:11): [True: 0, False: 0]
  ------------------
  670|      0|        print_warn ();
  671|       |
  672|       |      /* Allocate.  */
  673|      0|      mb = mb_get_new (pool, (memblock_t *) pool->mem, size);
  674|      0|      if (mb)
  ------------------
  |  Branch (674:11): [True: 0, False: 0]
  ------------------
  675|      0|        {
  676|      0|          stats_update (pool, mb->size, 0);
  677|      0|          return &mb->aligned.c;
  678|      0|        }
  679|      0|    }
  680|       |
  681|      0|  return NULL;
  682|      0|}
secmem.c:mb_get_new:
  242|  58.5k|{
  243|  58.5k|  memblock_t *mb, *mb_split;
  244|       |
  245|  58.5k|  for (mb = block; ptr_into_pool_p (pool, mb); mb = mb_get_next (pool, mb))
  ------------------
  |  Branch (245:20): [True: 58.5k, False: 0]
  ------------------
  246|  58.5k|    if (! (mb->flags & MB_FLAG_ACTIVE) && mb->size >= size)
  ------------------
  |  |   60|  58.5k|#define MB_FLAG_ACTIVE (1 << 0)
  ------------------
  |  Branch (246:9): [True: 58.5k, False: 0]
  |  Branch (246:43): [True: 58.5k, False: 0]
  ------------------
  247|  58.5k|      {
  248|       |	/* Found a free block.  */
  249|  58.5k|	mb->flags |= MB_FLAG_ACTIVE;
  ------------------
  |  |   60|  58.5k|#define MB_FLAG_ACTIVE (1 << 0)
  ------------------
  250|       |
  251|  58.5k|	if (mb->size - size > BLOCK_HEAD_SIZE)
  ------------------
  |  |  115|  58.5k|  offsetof (memblock_t, aligned)
  ------------------
  |  Branch (251:6): [True: 58.5k, False: 0]
  ------------------
  252|  58.5k|	  {
  253|       |	    /* Split block.  */
  254|       |
  255|  58.5k|	    mb_split = (memblock_t *) (void *) (((char *) mb) + BLOCK_HEAD_SIZE
  ------------------
  |  |  115|  58.5k|  offsetof (memblock_t, aligned)
  ------------------
  256|  58.5k|						+ size);
  257|  58.5k|	    mb_split->size = mb->size - size - BLOCK_HEAD_SIZE;
  ------------------
  |  |  115|  58.5k|  offsetof (memblock_t, aligned)
  ------------------
  258|  58.5k|	    mb_split->flags = 0;
  259|       |
  260|  58.5k|	    mb->size = size;
  261|       |
  262|  58.5k|	    mb_merge (pool, mb_split);
  263|       |
  264|  58.5k|	  }
  265|       |
  266|  58.5k|	break;
  267|  58.5k|      }
  268|       |
  269|  58.5k|  if (! ptr_into_pool_p (pool, mb))
  ------------------
  |  Branch (269:7): [True: 0, False: 58.5k]
  ------------------
  270|      0|    {
  271|      0|      gpg_err_set_errno (ENOMEM);
  272|      0|      mb = NULL;
  273|      0|    }
  274|       |
  275|  58.5k|  return mb;
  276|  58.5k|}
secmem.c:mb_merge:
  224|   117k|{
  225|   117k|  memblock_t *mb_prev, *mb_next;
  226|       |
  227|   117k|  mb_prev = mb_get_prev (pool, mb);
  228|   117k|  mb_next = mb_get_next (pool, mb);
  229|       |
  230|   117k|  if (mb_prev && (! (mb_prev->flags & MB_FLAG_ACTIVE)))
  ------------------
  |  |   60|  58.5k|#define MB_FLAG_ACTIVE (1 << 0)
  ------------------
  |  Branch (230:7): [True: 58.5k, False: 58.5k]
  |  Branch (230:18): [True: 0, False: 58.5k]
  ------------------
  231|      0|    {
  232|      0|      mb_prev->size += BLOCK_HEAD_SIZE + mb->size;
  ------------------
  |  |  115|      0|  offsetof (memblock_t, aligned)
  ------------------
  233|      0|      mb = mb_prev;
  234|      0|    }
  235|   117k|  if (mb_next && (! (mb_next->flags & MB_FLAG_ACTIVE)))
  ------------------
  |  |   60|  58.5k|#define MB_FLAG_ACTIVE (1 << 0)
  ------------------
  |  Branch (235:7): [True: 58.5k, False: 58.5k]
  |  Branch (235:18): [True: 58.5k, False: 0]
  ------------------
  236|  58.5k|    mb->size += BLOCK_HEAD_SIZE + mb_next->size;
  ------------------
  |  |  115|  58.5k|  offsetof (memblock_t, aligned)
  ------------------
  237|   117k|}
secmem.c:mb_get_prev:
  199|   117k|{
  200|   117k|  memblock_t *mb_prev, *mb_next;
  201|       |
  202|   117k|  if (mb == pool->mem)
  ------------------
  |  Branch (202:7): [True: 58.5k, False: 58.5k]
  ------------------
  203|  58.5k|    mb_prev = NULL;
  204|  58.5k|  else
  205|  58.5k|    {
  206|  58.5k|      mb_prev = (memblock_t *) pool->mem;
  207|  58.5k|      while (1)
  ------------------
  |  Branch (207:14): [Folded - Ignored]
  ------------------
  208|  58.5k|	{
  209|  58.5k|	  mb_next = mb_get_next (pool, mb_prev);
  210|  58.5k|	  if (mb_next == mb)
  ------------------
  |  Branch (210:8): [True: 58.5k, False: 0]
  ------------------
  211|  58.5k|	    break;
  212|      0|	  else
  213|      0|	    mb_prev = mb_next;
  214|  58.5k|	}
  215|  58.5k|    }
  216|       |
  217|   117k|  return mb_prev;
  218|   117k|}
secmem.c:mb_get_next:
  184|   175k|{
  185|   175k|  memblock_t *mb_next;
  186|       |
  187|   175k|  mb_next = (memblock_t *) (void *) ((char *) mb + BLOCK_HEAD_SIZE + mb->size);
  ------------------
  |  |  115|   175k|  offsetof (memblock_t, aligned)
  ------------------
  188|       |
  189|   175k|  if (! ptr_into_pool_p (pool, mb_next))
  ------------------
  |  Branch (189:7): [True: 58.5k, False: 117k]
  ------------------
  190|  58.5k|    mb_next = NULL;
  191|       |
  192|   175k|  return mb_next;
  193|   175k|}
secmem.c:stats_update:
  168|   117k|{
  169|   117k|  if (add)
  ------------------
  |  Branch (169:7): [True: 58.5k, False: 58.5k]
  ------------------
  170|  58.5k|    {
  171|  58.5k|      pool->cur_alloced += add;
  172|  58.5k|      pool->cur_blocks++;
  173|  58.5k|    }
  174|   117k|  if (sub)
  ------------------
  |  Branch (174:7): [True: 58.5k, False: 58.5k]
  ------------------
  175|  58.5k|    {
  176|  58.5k|      pool->cur_alloced -= sub;
  177|  58.5k|      pool->cur_blocks--;
  178|  58.5k|    }
  179|   117k|}
secmem.c:_gcry_secmem_free_internal:
  701|  58.5k|{
  702|  58.5k|  pooldesc_t *pool;
  703|  58.5k|  memblock_t *mb;
  704|  58.5k|  int size;
  705|       |
  706|  58.5k|  for (pool = &mainpool; pool; pool = pool->next)
  ------------------
  |  Branch (706:26): [True: 58.5k, False: 0]
  ------------------
  707|  58.5k|    if (pool->okay && ptr_into_pool_p (pool, a))
  ------------------
  |  Branch (707:9): [True: 58.5k, False: 0]
  |  Branch (707:23): [True: 58.5k, False: 0]
  ------------------
  708|  58.5k|      break;
  709|  58.5k|  if (!pool)
  ------------------
  |  Branch (709:7): [True: 0, False: 58.5k]
  ------------------
  710|      0|    return 0; /* A does not belong to use.  */
  711|       |
  712|  58.5k|  mb = ADDR_TO_BLOCK (a);
  ------------------
  |  |  119|  58.5k|  (memblock_t *) (void *) ((char *) addr - BLOCK_HEAD_SIZE)
  |  |  ------------------
  |  |  |  |  115|  58.5k|  offsetof (memblock_t, aligned)
  |  |  ------------------
  ------------------
  713|  58.5k|  size = mb->size;
  714|       |
  715|       |  /* This does not make much sense: probably this memory is held in the
  716|       |   * cache. We do it anyway: */
  717|  58.5k|#define MB_WIPE_OUT(byte) \
  718|  58.5k|  wipememory2 (((char *) mb + BLOCK_HEAD_SIZE), (byte), size)
  719|       |
  720|  58.5k|  MB_WIPE_OUT (0xff);
  ------------------
  |  |  718|  58.5k|  wipememory2 (((char *) mb + BLOCK_HEAD_SIZE), (byte), size)
  |  |  ------------------
  |  |  |  |  388|  58.5k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|  58.5k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|   117k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 58.5k, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|  58.5k|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|   117k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|  58.5k|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|  58.5k|		else \
  |  |  |  |  393|  58.5k|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|  58.5k|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|  58.5k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  721|  58.5k|  MB_WIPE_OUT (0xaa);
  ------------------
  |  |  718|  58.5k|  wipememory2 (((char *) mb + BLOCK_HEAD_SIZE), (byte), size)
  |  |  ------------------
  |  |  |  |  388|  58.5k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|  58.5k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|   117k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 58.5k, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|  58.5k|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|   117k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|  58.5k|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|  58.5k|		else \
  |  |  |  |  393|  58.5k|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|  58.5k|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|  58.5k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  722|  58.5k|  MB_WIPE_OUT (0x55);
  ------------------
  |  |  718|  58.5k|  wipememory2 (((char *) mb + BLOCK_HEAD_SIZE), (byte), size)
  |  |  ------------------
  |  |  |  |  388|  58.5k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|  58.5k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|   117k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 58.5k, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|  58.5k|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|   117k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|  58.5k|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|  58.5k|		else \
  |  |  |  |  393|  58.5k|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|  58.5k|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|  58.5k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  723|  58.5k|  MB_WIPE_OUT (0x00);
  ------------------
  |  |  718|  58.5k|  wipememory2 (((char *) mb + BLOCK_HEAD_SIZE), (byte), size)
  |  |  ------------------
  |  |  |  |  388|  58.5k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|  58.5k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|   117k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 58.5k, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|  58.5k|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|   117k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|  58.5k|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|  58.5k|		else \
  |  |  |  |  393|  58.5k|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|  58.5k|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|  58.5k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  724|       |
  725|       |  /* Update stats.  */
  726|  58.5k|  stats_update (pool, 0, size);
  727|       |
  728|  58.5k|  mb->flags &= ~MB_FLAG_ACTIVE;
  ------------------
  |  |   60|  58.5k|#define MB_FLAG_ACTIVE (1 << 0)
  ------------------
  729|       |
  730|  58.5k|  mb_merge (pool, mb);
  731|       |
  732|  58.5k|  return 1; /* Freed.  */
  733|  58.5k|}
secmem.c:ptr_into_pool_p:
  154|  9.75M|{
  155|       |  /* We need to convert pointers to addresses.  This is required by
  156|       |     C-99 6.5.8 to avoid undefined behaviour.  See also
  157|       |     http://lists.gnupg.org/pipermail/gcrypt-devel/2007-February/001102.html
  158|       |  */
  159|  9.75M|  uintptr_t p_addr    = (uintptr_t)p;
  160|  9.75M|  uintptr_t pool_addr = (uintptr_t)pool->mem;
  161|       |
  162|  9.75M|  return p_addr >= pool_addr && p_addr <  pool_addr + pool->size;
  ------------------
  |  Branch (162:10): [True: 409k, False: 9.34M]
  |  Branch (162:33): [True: 351k, False: 58.5k]
  ------------------
  163|  9.75M|}

_gcry_private_malloc:
   66|  9.03M|{
   67|  9.03M|  if (!n)
  ------------------
  |  Branch (67:7): [True: 10.3k, False: 9.02M]
  ------------------
   68|  10.3k|    {
   69|  10.3k|      gpg_err_set_errno (EINVAL);
   70|  10.3k|      return NULL; /* Allocating 0 bytes is undefined - we better return
   71|       |                      an error to detect such coding errors.  */
   72|  10.3k|    }
   73|       |
   74|  9.02M|  return malloc( n );
   75|  9.03M|}
_gcry_private_malloc_secure:
   85|  58.5k|{
   86|  58.5k|  if (!n)
  ------------------
  |  Branch (86:7): [True: 0, False: 58.5k]
  ------------------
   87|      0|    {
   88|      0|      gpg_err_set_errno (EINVAL);
   89|      0|      return NULL; /* Allocating 0 bytes is undefined - better return an
   90|       |                      error to detect such coding errors.  */
   91|      0|    }
   92|       |
   93|  58.5k|  return _gcry_secmem_malloc (n, xhint);
   94|  58.5k|}
_gcry_private_realloc:
  104|  19.7k|{
  105|  19.7k|  if ( _gcry_private_is_secure(a) )
  ------------------
  |  Branch (105:8): [True: 0, False: 19.7k]
  ------------------
  106|      0|    {
  107|      0|      return _gcry_secmem_realloc (a, n, xhint);
  108|      0|    }
  109|  19.7k|  else
  110|  19.7k|    {
  111|  19.7k|      return realloc( a, n );
  112|  19.7k|    }
  113|  19.7k|}
_gcry_private_free:
  121|  9.08M|{
  122|  9.08M|  unsigned char *p = a;
  123|  9.08M|  unsigned char *freep;
  124|       |
  125|  9.08M|  if (!p)
  ------------------
  |  Branch (125:7): [True: 0, False: 9.08M]
  ------------------
  126|      0|    return;
  127|       |
  128|  9.08M|  freep = p;
  129|       |
  130|  9.08M|  if (!_gcry_private_is_secure (freep) ||
  ------------------
  |  Branch (130:7): [True: 9.02M, False: 58.5k]
  ------------------
  131|  9.08M|      !_gcry_secmem_free (freep))
  ------------------
  |  Branch (131:7): [True: 0, False: 58.5k]
  ------------------
  132|  9.02M|    {
  133|  9.02M|      free (freep);
  134|  9.02M|    }
  135|  9.08M|}

gcry_mpi_release:
  283|  7.41M|{
  284|  7.41M|  _gcry_mpi_release (a);
  285|  7.41M|}
gcry_mpi_copy:
  289|  1.94k|{
  290|  1.94k|  return _gcry_mpi_copy (a);
  291|  1.94k|}
gcry_mpi_scan:
  357|  79.8k|{
  358|  79.8k|  return gpg_error (_gcry_mpi_scan (ret_mpi, format, buffer, buflen, nscanned));
  359|  79.8k|}
gcry_mpi_print:
  366|   136k|{
  367|   136k|  return gpg_error (_gcry_mpi_print (format, buffer, buflen, nwritten, a));
  368|   136k|}
gcry_mpi_get_nbits:
  634|   111k|{
  635|   111k|  return _gcry_mpi_get_nbits (a);
  636|   111k|}
gcry_mpi_set_opaque:
  682|  81.1k|{
  683|  81.1k|  return _gcry_mpi_set_opaque (a, p, nbits);
  684|  81.1k|}
gcry_mpi_get_opaque:
  694|  42.6k|{
  695|  42.6k|  return _gcry_mpi_get_opaque (a, nbits);
  696|  42.6k|}
gcry_mpi_set_flag:
  700|  20.1k|{
  701|  20.1k|  _gcry_mpi_set_flag (a, flag);
  702|  20.1k|}
gcry_mpi_get_flag:
  712|   135k|{
  713|   135k|  return _gcry_mpi_get_flag (a, flag);
  714|   135k|}
gcry_cipher_algo_info:
  837|   142k|{
  838|   142k|  if (!fips_is_operational ())
  ------------------
  |  |  477|   142k|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 1, False: 142k]
  |  |  ------------------
  |  |  478|   142k|                _gcry_global_is_operational() : \
  |  |  479|   142k|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|   284k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 142k, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (838:7): [True: 0, False: 142k]
  ------------------
  839|      0|    return gpg_error (fips_not_operational ());
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
  840|       |
  841|   142k|  return gpg_error (_gcry_cipher_algo_info (algo, what, buffer, nbytes));
  842|   142k|}
gcry_md_open:
 1194|  48.9k|{
 1195|  48.9k|  if (!fips_is_operational ())
  ------------------
  |  |  477|  48.9k|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 48.9k]
  |  |  ------------------
  |  |  478|  48.9k|                _gcry_global_is_operational() : \
  |  |  479|  48.9k|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|  97.9k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 48.9k, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1195:7): [True: 0, False: 48.9k]
  ------------------
 1196|      0|    {
 1197|      0|      *h = NULL;
 1198|      0|      return gpg_error (fips_not_operational ());
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1199|      0|    }
 1200|       |
 1201|  48.9k|  return gpg_error (_gcry_md_open (h, algo, flags));
 1202|  48.9k|}
gcry_md_close:
 1206|  79.7k|{
 1207|  79.7k|  _gcry_md_close (hd);
 1208|  79.7k|}
gcry_md_reset:
 1231|  12.8k|{
 1232|  12.8k|  _gcry_md_reset (hd);
 1233|  12.8k|}
gcry_md_ctl:
 1237|  57.8k|{
 1238|  57.8k|  if (!fips_is_operational ())
  ------------------
  |  |  477|  57.8k|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 57.8k]
  |  |  ------------------
  |  |  478|  57.8k|                _gcry_global_is_operational() : \
  |  |  479|  57.8k|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|   115k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 57.8k, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1238:7): [True: 0, False: 57.8k]
  ------------------
 1239|      0|    return gpg_error (fips_not_operational ());
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1240|  57.8k|  return gpg_error (_gcry_md_ctl (hd, cmd, buffer, buflen));
 1241|  57.8k|}
gcry_md_write:
 1245|  99.8k|{
 1246|  99.8k|  if (!fips_is_operational ())
  ------------------
  |  |  477|  99.8k|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 99.8k]
  |  |  ------------------
  |  |  478|  99.8k|                _gcry_global_is_operational() : \
  |  |  479|  99.8k|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|   199k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 99.8k, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1246:7): [True: 0, False: 99.8k]
  ------------------
 1247|      0|    {
 1248|      0|      (void)fips_not_operational ();
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1249|      0|      return;
 1250|      0|    }
 1251|  99.8k|  _gcry_md_write (hd, buffer, length);
 1252|  99.8k|}
gcry_md_read:
 1256|  46.9k|{
 1257|  46.9k|  return _gcry_md_read (hd, algo);
 1258|  46.9k|}
gcry_md_get_algo:
 1294|  46.2k|{
 1295|  46.2k|  if (!fips_is_operational ())
  ------------------
  |  |  477|  46.2k|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 46.2k]
  |  |  ------------------
  |  |  478|  46.2k|                _gcry_global_is_operational() : \
  |  |  479|  46.2k|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|  92.5k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 46.2k, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1295:7): [True: 0, False: 46.2k]
  ------------------
 1296|      0|    {
 1297|      0|      (void)fips_not_operational ();
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1298|      0|      fips_signal_error ("used in non-operational state");
  ------------------
  |  |  459|      0|           _gcry_fips_signal_error (__FILE__, __LINE__, __FUNCTION__, 0, (a))
  ------------------
 1299|      0|      return 0;
 1300|      0|    }
 1301|  46.2k|  return _gcry_md_get_algo (hd);
 1302|  46.2k|}
gcry_md_get_algo_dlen:
 1306|  49.3k|{
 1307|  49.3k|  return _gcry_md_get_algo_dlen (algo);
 1308|  49.3k|}
gcry_md_algo_info:
 1339|  10.1k|{
 1340|  10.1k|  return gpg_error (_gcry_md_algo_info (algo, what, buffer, nbytes));
 1341|  10.1k|}
gcry_create_nonce:
 1486|      1|{
 1487|      1|  if (!fips_is_operational ())
  ------------------
  |  |  477|      1|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 1]
  |  |  ------------------
  |  |  478|      1|                _gcry_global_is_operational() : \
  |  |  479|      1|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|      2|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 1, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1487:7): [True: 0, False: 1]
  ------------------
 1488|      0|    {
 1489|      0|      (void)fips_not_operational ();
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1490|      0|      fips_signal_fatal_error ("called in non-operational state");
  ------------------
  |  |  461|      0|           _gcry_fips_signal_error (__FILE__, __LINE__, __FUNCTION__, 1, (a))
  ------------------
 1491|      0|      fips_noreturn ();
  ------------------
  |  |  489|      0|#define fips_noreturn()  (_gcry_fips_noreturn ())
  ------------------
 1492|      0|    }
 1493|      1|  _gcry_create_nonce (buffer, length);
 1494|      1|}
gcry_set_log_handler:
 1614|      1|{
 1615|      1|  _gcry_set_log_handler (f, opaque);
 1616|      1|}
gcry_malloc:
 1626|   221k|{
 1627|   221k|  return _gcry_malloc (n);
 1628|   221k|}
gcry_calloc:
 1632|   275k|{
 1633|   275k|  return _gcry_calloc (n, m);
 1634|   275k|}
gcry_strdup:
 1656|  1.69k|{
 1657|  1.69k|  return _gcry_strdup (string);
 1658|  1.69k|}
gcry_xmalloc:
 1662|   662k|{
 1663|   662k|  return _gcry_xmalloc (n);
 1664|   662k|}
gcry_xcalloc:
 1668|  7.36M|{
 1669|  7.36M|  return _gcry_xcalloc (n, m);
 1670|  7.36M|}
gcry_xcalloc_secure:
 1680|  58.5k|{
 1681|  58.5k|  return _gcry_xcalloc_secure (n, m);
 1682|  58.5k|}
gcry_xrealloc:
 1686|  25.5k|{
 1687|  25.5k|  return _gcry_xrealloc (a, n);
 1688|  25.5k|}
gcry_xstrdup:
 1692|   169k|{
 1693|   169k|  return _gcry_xstrdup (a);
 1694|   169k|}
gcry_free:
 1698|  9.83M|{
 1699|  9.83M|  _gcry_free (a);
 1700|  9.83M|}

_gpg_err_code_from_errno:
   36|  10.3k|{
   37|  10.3k|  int idx;
   38|       |
   39|  10.3k|  if (!err)
  ------------------
  |  Branch (39:7): [True: 0, False: 10.3k]
  ------------------
   40|      0|    return GPG_ERR_NO_ERROR;
   41|       |
   42|  10.3k|  idx = errno_to_idx (err);
  ------------------
  |  |  151|  10.3k|#define errno_to_idx(code) (0 ? -1 \
  |  |  ------------------
  |  |  |  Branch (151:29): [Folded - Ignored]
  |  |  ------------------
  |  |  152|  10.3k|  : ((code >= 1) && (code <= 11)) ? (code - 1) \
  |  |  ------------------
  |  |  |  Branch (152:6): [True: 10.3k, False: 0]
  |  |  |  Branch (152:21): [True: 0, False: 10.3k]
  |  |  ------------------
  |  |  153|  10.3k|  : ((code >= 11) && (code <= 35)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (153:6): [True: 10.3k, False: 0]
  |  |  |  Branch (153:22): [True: 10.3k, False: 0]
  |  |  ------------------
  |  |  154|  10.3k|  : ((code >= 35) && (code <= 40)) ? (code - -1) \
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 0, False: 0]
  |  |  |  Branch (154:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  155|      0|  : ((code >= 42) && (code <= 57)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  Branch (155:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|  : ((code >= 59) && (code <= 95)) ? (code - 1) \
  |  |  ------------------
  |  |  |  Branch (156:6): [True: 0, False: 0]
  |  |  |  Branch (156:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|  : ((code >= 95) && (code <= 125)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (157:6): [True: 0, False: 0]
  |  |  |  Branch (157:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  158|      0|  : -1)
  ------------------
   43|       |
   44|  10.3k|  if (idx < 0)
  ------------------
  |  Branch (44:7): [True: 0, False: 10.3k]
  ------------------
   45|      0|    return GPG_ERR_UNKNOWN_ERRNO;
   46|       |
   47|  10.3k|  return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx];
  ------------------
  |  |  584|  10.3k|#define GPG_ERR_SYSTEM_ERROR	(1 << 15)
  ------------------
   48|  10.3k|}
_gpg_err_code_from_syserror:
   56|  10.3k|{
   57|  10.3k|  int err = errno;
   58|  10.3k|  int idx;
   59|       |
   60|  10.3k|  if (!err)
  ------------------
  |  Branch (60:7): [True: 0, False: 10.3k]
  ------------------
   61|      0|    return GPG_ERR_MISSING_ERRNO;
   62|       |
   63|  10.3k|  idx = errno_to_idx (err);
  ------------------
  |  |  151|  10.3k|#define errno_to_idx(code) (0 ? -1 \
  |  |  ------------------
  |  |  |  Branch (151:29): [Folded - Ignored]
  |  |  ------------------
  |  |  152|  10.3k|  : ((code >= 1) && (code <= 11)) ? (code - 1) \
  |  |  ------------------
  |  |  |  Branch (152:6): [True: 10.3k, False: 0]
  |  |  |  Branch (152:21): [True: 4, False: 10.3k]
  |  |  ------------------
  |  |  153|  10.3k|  : ((code >= 11) && (code <= 35)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (153:6): [True: 10.3k, False: 0]
  |  |  |  Branch (153:22): [True: 10.3k, False: 0]
  |  |  ------------------
  |  |  154|  10.3k|  : ((code >= 35) && (code <= 40)) ? (code - -1) \
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 0, False: 0]
  |  |  |  Branch (154:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  155|      0|  : ((code >= 42) && (code <= 57)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  Branch (155:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|  : ((code >= 59) && (code <= 95)) ? (code - 1) \
  |  |  ------------------
  |  |  |  Branch (156:6): [True: 0, False: 0]
  |  |  |  Branch (156:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|  : ((code >= 95) && (code <= 125)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (157:6): [True: 0, False: 0]
  |  |  |  Branch (157:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  158|      0|  : -1)
  ------------------
   64|       |
   65|  10.3k|  if (idx < 0)
  ------------------
  |  Branch (65:7): [True: 0, False: 10.3k]
  ------------------
   66|      0|    return GPG_ERR_UNKNOWN_ERRNO;
   67|       |
   68|  10.3k|  return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx];
  ------------------
  |  |  584|  10.3k|#define GPG_ERR_SYSTEM_ERROR	(1 << 15)
  ------------------
   69|  10.3k|}

_gpg_err_code_to_errno:
   33|  10.4k|{
   34|  10.4k|  if (!(code & GPG_ERR_SYSTEM_ERROR))
  ------------------
  |  |  584|  10.4k|#define GPG_ERR_SYSTEM_ERROR	(1 << 15)
  ------------------
  |  Branch (34:7): [True: 0, False: 10.4k]
  ------------------
   35|      0|    return 0;
   36|  10.4k|  code &= ~GPG_ERR_SYSTEM_ERROR;
  ------------------
  |  |  584|  10.4k|#define GPG_ERR_SYSTEM_ERROR	(1 << 15)
  ------------------
   37|       |
   38|  10.4k|  if (code < sizeof (err_code_to_errno) / sizeof (err_code_to_errno[0]))
  ------------------
  |  Branch (38:7): [True: 10.3k, False: 117]
  ------------------
   39|  10.3k|    return err_code_to_errno[code];
   40|    117|  else
   41|    117|    return 0;
   42|  10.4k|}

strerror.c:msgidxof:
  913|   297k|{
  914|   297k|  return (0 ? 0
  ------------------
  |  Branch (914:11): [Folded - Ignored]
  ------------------
  915|   297k|  : ((code >= 0) && (code <= 213)) ? (code - 0)
  ------------------
  |  Branch (915:6): [True: 297k, False: 0]
  |  Branch (915:21): [True: 297k, False: 117]
  ------------------
  916|   297k|  : ((code >= 217) && (code <= 271)) ? (code - 3)
  ------------------
  |  Branch (916:6): [True: 117, False: 0]
  |  Branch (916:23): [True: 0, False: 117]
  ------------------
  917|    117|  : ((code >= 273) && (code <= 281)) ? (code - 4)
  ------------------
  |  Branch (917:6): [True: 117, False: 0]
  |  Branch (917:23): [True: 0, False: 117]
  ------------------
  918|    117|  : ((code >= 300) && (code <= 319)) ? (code - 22)
  ------------------
  |  Branch (918:6): [True: 117, False: 0]
  |  Branch (918:23): [True: 0, False: 117]
  ------------------
  919|    117|  : ((code >= 666) && (code <= 666)) ? (code - 368)
  ------------------
  |  Branch (919:6): [True: 117, False: 0]
  |  Branch (919:23): [True: 0, False: 117]
  ------------------
  920|    117|  : ((code >= 711) && (code <= 718)) ? (code - 412)
  ------------------
  |  Branch (920:6): [True: 117, False: 0]
  |  Branch (920:23): [True: 0, False: 117]
  ------------------
  921|    117|  : ((code >= 721) && (code <= 729)) ? (code - 414)
  ------------------
  |  Branch (921:6): [True: 117, False: 0]
  |  Branch (921:23): [True: 0, False: 117]
  ------------------
  922|    117|  : ((code >= 750) && (code <= 752)) ? (code - 434)
  ------------------
  |  Branch (922:6): [True: 117, False: 0]
  |  Branch (922:23): [True: 0, False: 117]
  ------------------
  923|    117|  : ((code >= 754) && (code <= 782)) ? (code - 435)
  ------------------
  |  Branch (923:6): [True: 117, False: 0]
  |  Branch (923:23): [True: 0, False: 117]
  ------------------
  924|    117|  : ((code >= 784) && (code <= 789)) ? (code - 436)
  ------------------
  |  Branch (924:6): [True: 117, False: 0]
  |  Branch (924:23): [True: 0, False: 117]
  ------------------
  925|    117|  : ((code >= 800) && (code <= 804)) ? (code - 446)
  ------------------
  |  Branch (925:6): [True: 117, False: 0]
  |  Branch (925:23): [True: 0, False: 117]
  ------------------
  926|    117|  : ((code >= 815) && (code <= 822)) ? (code - 456)
  ------------------
  |  Branch (926:6): [True: 117, False: 0]
  |  Branch (926:23): [True: 0, False: 117]
  ------------------
  927|    117|  : ((code >= 832) && (code <= 839)) ? (code - 465)
  ------------------
  |  Branch (927:6): [True: 117, False: 0]
  |  Branch (927:23): [True: 0, False: 117]
  ------------------
  928|    117|  : ((code >= 844) && (code <= 844)) ? (code - 469)
  ------------------
  |  Branch (928:6): [True: 117, False: 0]
  |  Branch (928:23): [True: 0, False: 117]
  ------------------
  929|    117|  : ((code >= 848) && (code <= 848)) ? (code - 472)
  ------------------
  |  Branch (929:6): [True: 117, False: 0]
  |  Branch (929:23): [True: 0, False: 117]
  ------------------
  930|    117|  : ((code >= 881) && (code <= 891)) ? (code - 504)
  ------------------
  |  Branch (930:6): [True: 117, False: 0]
  |  Branch (930:23): [True: 0, False: 117]
  ------------------
  931|    117|  : ((code >= 1024) && (code <= 1039)) ? (code - 636)
  ------------------
  |  Branch (931:6): [True: 117, False: 0]
  |  Branch (931:24): [True: 0, False: 117]
  ------------------
  932|    117|  : ((code >= 1500) && (code <= 1528)) ? (code - 1096)
  ------------------
  |  Branch (932:6): [True: 117, False: 0]
  |  Branch (932:24): [True: 0, False: 117]
  ------------------
  933|    117|  : ((code >= 1600) && (code <= 1601)) ? (code - 1167)
  ------------------
  |  Branch (933:6): [True: 117, False: 0]
  |  Branch (933:24): [True: 0, False: 117]
  ------------------
  934|    117|  : ((code >= 16381) && (code <= 16383)) ? (code - 15946)
  ------------------
  |  Branch (934:6): [True: 117, False: 0]
  |  Branch (934:25): [True: 117, False: 0]
  ------------------
  935|    117|  : 16384 - 15946);
  936|   297k|}

strsource.c:msgidxof:
   83|   176k|{
   84|   176k|  return (0 ? 0
  ------------------
  |  Branch (84:11): [Folded - Ignored]
  ------------------
   85|   176k|  : ((code >= 0) && (code <= 17)) ? (code - 0)
  ------------------
  |  Branch (85:6): [True: 176k, False: 0]
  |  Branch (85:21): [True: 176k, False: 0]
  ------------------
   86|   176k|  : ((code >= 31) && (code <= 35)) ? (code - 13)
  ------------------
  |  Branch (86:6): [True: 0, False: 0]
  |  Branch (86:22): [True: 0, False: 0]
  ------------------
   87|      0|  : 36 - 13);
   88|   176k|}

_gpgrt_estream_format:
 1492|  22.8M|{
 1493|       |  /* Buffer to hold the argspecs and a pointer to it.*/
 1494|  22.8M|  struct argspec_s argspecs_buffer[DEFAULT_MAX_ARGSPECS];
 1495|  22.8M|  argspec_t argspecs = argspecs_buffer;
 1496|  22.8M|  size_t argspecs_len;  /* Number of specifications in ARGSPECS.  */
 1497|       |
 1498|       |  /* Buffer to hold the description for the values.  */
 1499|  22.8M|  struct valueitem_s valuetable_buffer[DEFAULT_MAX_VALUES];
 1500|  22.8M|  valueitem_t valuetable = valuetable_buffer;
 1501|       |
 1502|  22.8M|  int rc;        /* Return code. */
 1503|  22.8M|  size_t argidx; /* Used to index the argspecs array.  */
 1504|  22.8M|  size_t validx; /* Used to index the valuetable.  */
 1505|  22.8M|  int max_pos;   /* Highest argument position.  */
 1506|       |
 1507|  22.8M|  size_t nbytes = 0; /* Keep track of the number of bytes passed to
 1508|       |                        the output function.  */
 1509|       |
 1510|  22.8M|  int myerrno = errno; /* Save the errno for use with "%m". */
 1511|       |
 1512|       |
 1513|       |  /* Parse the arguments to come up with descriptive list.  We can't
 1514|       |     do this on the fly because we need to support positional
 1515|       |     arguments. */
 1516|  22.8M|  rc = parse_format (format, &argspecs, DIM(argspecs_buffer), &argspecs_len);
  ------------------
  |  |   93|  22.8M|# define DIM(array) (sizeof (array) / sizeof (*array))
  ------------------
 1517|  22.8M|  if (rc)
  ------------------
  |  Branch (1517:7): [True: 0, False: 22.8M]
  ------------------
 1518|      0|    goto leave;
 1519|       |
 1520|       |  /* Check that all ARG_POS fields are set.  */
 1521|  65.1M|  for (argidx=0,max_pos=0; argidx < argspecs_len; argidx++)
  ------------------
  |  Branch (1521:28): [True: 42.3M, False: 22.8M]
  ------------------
 1522|  42.3M|    {
 1523|  42.3M|      if (argspecs[argidx].arg_pos != -1
  ------------------
  |  Branch (1523:11): [True: 42.3M, False: 0]
  ------------------
 1524|  42.3M|          && argspecs[argidx].arg_pos > max_pos)
  ------------------
  |  Branch (1524:14): [True: 0, False: 42.3M]
  ------------------
 1525|      0|        max_pos = argspecs[argidx].arg_pos;
 1526|  42.3M|      if (argspecs[argidx].width_pos > max_pos)
  ------------------
  |  Branch (1526:11): [True: 0, False: 42.3M]
  ------------------
 1527|      0|        max_pos = argspecs[argidx].width_pos;
 1528|  42.3M|      if (argspecs[argidx].precision_pos > max_pos)
  ------------------
  |  Branch (1528:11): [True: 0, False: 42.3M]
  ------------------
 1529|      0|        max_pos = argspecs[argidx].precision_pos;
 1530|  42.3M|    }
 1531|  22.8M|  if (!max_pos)
  ------------------
  |  Branch (1531:7): [True: 22.8M, False: 0]
  ------------------
 1532|  22.8M|    {
 1533|       |      /* Fill in all the positions.  */
 1534|  65.1M|      for (argidx=0; argidx < argspecs_len; argidx++)
  ------------------
  |  Branch (1534:22): [True: 42.3M, False: 22.8M]
  ------------------
 1535|  42.3M|        {
 1536|  42.3M|          if (argspecs[argidx].width == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  42.3M|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1536:15): [True: 1.38k, False: 42.3M]
  ------------------
 1537|  1.38k|            argspecs[argidx].width_pos = ++max_pos;
 1538|  42.3M|          if (argspecs[argidx].precision == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  42.3M|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1538:15): [True: 3, False: 42.3M]
  ------------------
 1539|      3|            argspecs[argidx].precision_pos = ++max_pos;
 1540|  42.3M|          if (argspecs[argidx].arg_pos != -1 )
  ------------------
  |  Branch (1540:15): [True: 42.3M, False: 0]
  ------------------
 1541|  42.3M|            argspecs[argidx].arg_pos = ++max_pos;
 1542|  42.3M|        }
 1543|  22.8M|    }
 1544|      0|  else
 1545|      0|    {
 1546|       |      /* Check that they are all filled.   More test are done later.  */
 1547|      0|      for (argidx=0; argidx < argspecs_len; argidx++)
  ------------------
  |  Branch (1547:22): [True: 0, False: 0]
  ------------------
 1548|      0|        {
 1549|      0|          if (!argspecs[argidx].arg_pos
  ------------------
  |  Branch (1549:15): [True: 0, False: 0]
  ------------------
 1550|      0|              || (argspecs[argidx].width == STAR_FIELD_VALUE
  ------------------
  |  |  133|      0|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1550:19): [True: 0, False: 0]
  ------------------
 1551|      0|                  && !argspecs[argidx].width_pos)
  ------------------
  |  Branch (1551:22): [True: 0, False: 0]
  ------------------
 1552|      0|              || (argspecs[argidx].precision == STAR_FIELD_VALUE
  ------------------
  |  |  133|      0|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1552:19): [True: 0, False: 0]
  ------------------
 1553|      0|                  && !argspecs[argidx].precision_pos))
  ------------------
  |  Branch (1553:22): [True: 0, False: 0]
  ------------------
 1554|      0|            goto leave_einval;
 1555|      0|        }
 1556|      0|    }
 1557|       |  /* Check that there is no overflow in max_pos and that it has a
 1558|       |     reasonable length.  There may never be more elements than the
 1559|       |     number of characters in FORMAT.  */
 1560|  22.8M|  if (max_pos < 0 || max_pos >= strlen (format))
  ------------------
  |  Branch (1560:7): [True: 0, False: 22.8M]
  |  Branch (1560:22): [True: 0, False: 22.8M]
  ------------------
 1561|      0|    goto leave_einval;
 1562|       |
 1563|       |#ifdef DEBUG
 1564|       |    dump_argspecs (argspecs, argspecs_len);
 1565|       |#endif
 1566|       |
 1567|       |  /* Allocate a table to hold the values.  If it is small enough we
 1568|       |     use a stack allocated buffer.  */
 1569|  22.8M|  if (max_pos > DIM(valuetable_buffer))
  ------------------
  |  |   93|  22.8M|# define DIM(array) (sizeof (array) / sizeof (*array))
  ------------------
  |  Branch (1569:7): [True: 35.7k, False: 22.8M]
  ------------------
 1570|  35.7k|    {
 1571|  35.7k|      valuetable = calloc (max_pos, sizeof *valuetable);
 1572|  35.7k|      if (!valuetable)
  ------------------
  |  Branch (1572:11): [True: 0, False: 35.7k]
  ------------------
 1573|      0|        goto leave_error;
 1574|  35.7k|    }
 1575|  22.8M|  else
 1576|  22.8M|    {
 1577|   205M|      for (validx=0; validx < DIM(valuetable_buffer); validx++)
  ------------------
  |  |   93|   205M|# define DIM(array) (sizeof (array) / sizeof (*array))
  ------------------
  |  Branch (1577:22): [True: 182M, False: 22.8M]
  ------------------
 1578|   182M|        {
 1579|   182M|          valuetable[validx].vt = VALTYPE_UNSUPPORTED;
 1580|   182M|          memset (&valuetable[validx].value, 0,
 1581|   182M|                  sizeof valuetable[validx].value);
 1582|   182M|        }
 1583|  22.8M|    }
 1584|  65.1M|  for (argidx=0; argidx < argspecs_len; argidx++)
  ------------------
  |  Branch (1584:18): [True: 42.3M, False: 22.8M]
  ------------------
 1585|  42.3M|    {
 1586|  42.3M|      if (argspecs[argidx].arg_pos != - 1)
  ------------------
  |  Branch (1586:11): [True: 42.3M, False: 0]
  ------------------
 1587|  42.3M|        {
 1588|  42.3M|          validx = argspecs[argidx].arg_pos - 1;
 1589|  42.3M|          if (valuetable[validx].vt)
  ------------------
  |  Branch (1589:15): [True: 0, False: 42.3M]
  ------------------
 1590|      0|            goto leave_einval; /* Already defined. */
 1591|  42.3M|          valuetable[validx].vt = argspecs[argidx].vt;
 1592|  42.3M|        }
 1593|  42.3M|      if (argspecs[argidx].width == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  42.3M|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1593:11): [True: 1.38k, False: 42.3M]
  ------------------
 1594|  1.38k|        {
 1595|  1.38k|          validx = argspecs[argidx].width_pos - 1;
 1596|  1.38k|          if (valuetable[validx].vt)
  ------------------
  |  Branch (1596:15): [True: 0, False: 1.38k]
  ------------------
 1597|      0|            goto leave_einval; /* Already defined.  */
 1598|  1.38k|          valuetable[validx].vt = VALTYPE_INT;
 1599|  1.38k|        }
 1600|  42.3M|      if (argspecs[argidx].precision == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  42.3M|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1600:11): [True: 3, False: 42.3M]
  ------------------
 1601|      3|        {
 1602|      3|          validx = argspecs[argidx].precision_pos - 1;
 1603|      3|          if (valuetable[validx].vt)
  ------------------
  |  Branch (1603:15): [True: 0, False: 3]
  ------------------
 1604|      0|            goto leave_einval; /* Already defined.  */
 1605|      3|          valuetable[validx].vt = VALTYPE_INT;
 1606|      3|        }
 1607|  42.3M|    }
 1608|       |
 1609|       |  /* Read all the arguments.  This will error out for unsupported
 1610|       |     types and for not given positional arguments. */
 1611|  22.8M|  rc = read_values (valuetable, max_pos, vaargs);
 1612|  22.8M|  if (rc)
  ------------------
  |  Branch (1612:7): [True: 0, False: 22.8M]
  ------------------
 1613|      0|    goto leave_einval;
 1614|       |
 1615|       |/*   for (validx=0; validx < max_pos; validx++) */
 1616|       |/*     fprintf (stderr, "%2d: vt=%d\n", validx, valuetable[validx].vt); */
 1617|       |
 1618|       |  /* Everything has been collected, go ahead with the formatting.  */
 1619|  22.8M|  rc = do_format (outfnc, outfncarg, sf, sfvalue, format,
 1620|  22.8M|                  argspecs, argspecs_len, valuetable, myerrno, &nbytes);
 1621|       |
 1622|  22.8M|  goto leave;
 1623|       |
 1624|      0| leave_einval:
 1625|      0|  _set_errno (EINVAL);
  ------------------
  |  |  113|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (113:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1626|      0| leave_error:
 1627|      0|  rc = -1;
 1628|  22.8M| leave:
 1629|  22.8M|  if (valuetable != valuetable_buffer)
  ------------------
  |  Branch (1629:7): [True: 35.7k, False: 22.8M]
  ------------------
 1630|  35.7k|    free (valuetable);
 1631|  22.8M|  if (argspecs != argspecs_buffer)
  ------------------
  |  Branch (1631:7): [True: 529k, False: 22.3M]
  ------------------
 1632|   529k|    free (argspecs);
 1633|  22.8M|  return rc;
 1634|      0|}
_gpgrt_estream_vsnprintf:
 1733|  6.92M|{
 1734|  6.92M|  struct fixed_buffer_parm_s parm;
 1735|  6.92M|  int rc;
 1736|       |
 1737|  6.92M|  parm.size = bufsize;
 1738|  6.92M|  parm.count = 0;
 1739|  6.92M|  parm.used = 0;
 1740|  6.92M|  parm.buffer = bufsize?buf:NULL;
  ------------------
  |  Branch (1740:17): [True: 6.92M, False: 0]
  ------------------
 1741|  6.92M|  rc = _gpgrt_estream_format (fixed_buffer_out, &parm, NULL, NULL,
 1742|  6.92M|                              format, arg_ptr);
 1743|  6.92M|  if (!rc)
  ------------------
  |  Branch (1743:7): [True: 6.92M, False: 0]
  ------------------
 1744|  6.92M|    rc = fixed_buffer_out (&parm, "", 1); /* Print terminating Nul.  */
 1745|  6.92M|  if (rc == -1)
  ------------------
  |  Branch (1745:7): [True: 0, False: 6.92M]
  ------------------
 1746|      0|    return -1;
 1747|  6.92M|  if (bufsize && buf && parm.size && parm.count >= parm.size)
  ------------------
  |  Branch (1747:7): [True: 6.92M, False: 0]
  |  Branch (1747:18): [True: 6.92M, False: 0]
  |  Branch (1747:25): [True: 6.92M, False: 0]
  |  Branch (1747:38): [True: 0, False: 6.92M]
  ------------------
 1748|      0|    buf[parm.size-1] = 0;
 1749|       |
 1750|  6.92M|  parm.count--; /* Do not count the trailing nul.  */
 1751|  6.92M|  return (int)parm.count; /* Return number of bytes which would have
 1752|       |                             been written.  */
 1753|  6.92M|}
estream-printf.c:parse_format:
  445|  22.8M|{
  446|  22.8M|  const char *s;
  447|  22.8M|  argspec_t argspecs = *argspecs_addr;
  448|  22.8M|  argspec_t arg;
  449|  22.8M|  size_t argcount = 0;
  450|       |
  451|  22.8M|  if (!format)
  ------------------
  |  Branch (451:7): [True: 0, False: 22.8M]
  ------------------
  452|      0|    goto leave_einval;
  453|       |
  454|   365M|  for (; *format; format++)
  ------------------
  |  Branch (454:10): [True: 342M, False: 22.8M]
  ------------------
  455|   342M|    {
  456|   342M|      unsigned int flags;
  457|   342M|      int width, precision;
  458|   342M|      lenmod_t lenmod;
  459|   342M|      conspec_t conspec;
  460|   342M|      int arg_pos, width_pos, precision_pos;
  461|       |
  462|   342M|      if (*format != '%')
  ------------------
  |  Branch (462:11): [True: 300M, False: 42.3M]
  ------------------
  463|   300M|        continue;
  464|  42.3M|      s = ++format;
  465|  42.3M|      if (!*s)
  ------------------
  |  Branch (465:11): [True: 0, False: 42.3M]
  ------------------
  466|      0|        goto leave_einval;
  467|  42.3M|      if (*s == '%')
  ------------------
  |  Branch (467:11): [True: 0, False: 42.3M]
  ------------------
  468|      0|        continue; /* Just a quoted percent.  */
  469|       |
  470|       |      /* First check whether there is a positional argument.  */
  471|  42.3M|      arg_pos = 0; /* No positional argument given.  */
  472|  42.3M|      if (*s >= '1' && *s <= '9')
  ------------------
  |  Branch (472:11): [True: 21.4M, False: 20.8M]
  |  Branch (472:24): [True: 82.8k, False: 21.3M]
  ------------------
  473|  82.8k|        {
  474|  82.8k|          const char *save_s = s;
  475|       |
  476|  82.8k|          arg_pos = (*s++ - '0');
  477|  82.8k|          for (; *s >= '0' && *s <= '9'; s++)
  ------------------
  |  Branch (477:18): [True: 82.8k, False: 0]
  |  Branch (477:31): [True: 3, False: 82.8k]
  ------------------
  478|      3|            arg_pos = 10*arg_pos + (*s - '0');
  479|  82.8k|          if (arg_pos < 0)
  ------------------
  |  Branch (479:15): [True: 0, False: 82.8k]
  ------------------
  480|      0|            goto leave_einval; /* Overflow during conversion.  */
  481|  82.8k|          if (*s == '$')
  ------------------
  |  Branch (481:15): [True: 0, False: 82.8k]
  ------------------
  482|      0|            s++;
  483|  82.8k|          else
  484|  82.8k|            {
  485|  82.8k|              arg_pos = 0;
  486|  82.8k|              s = save_s;
  487|  82.8k|            }
  488|  82.8k|        }
  489|       |
  490|       |      /* Parse the flags.  */
  491|  42.3M|      flags = 0;
  492|  63.1M|      for ( ; *s; s++)
  ------------------
  |  Branch (492:15): [True: 63.1M, False: 0]
  ------------------
  493|  63.1M|        {
  494|  63.1M|          switch (*s)
  495|  63.1M|            {
  496|      0|            case '\'': flags |= FLAG_GROUPING; break;
  ------------------
  |  |  136|      0|#define FLAG_GROUPING   1
  ------------------
  |  Branch (496:13): [True: 0, False: 63.1M]
  ------------------
  497|      0|            case '-': flags |= FLAG_LEFT_JUST; break;
  ------------------
  |  |  137|      0|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (497:13): [True: 0, False: 63.1M]
  ------------------
  498|      0|            case '+': flags |= FLAG_PLUS_SIGN; break;
  ------------------
  |  |  138|      0|#define FLAG_PLUS_SIGN  4
  ------------------
  |  Branch (498:13): [True: 0, False: 63.1M]
  ------------------
  499|      0|            case ' ': flags |= FLAG_SPACE_PLUS; break;
  ------------------
  |  |  139|      0|#define FLAG_SPACE_PLUS 8
  ------------------
  |  Branch (499:13): [True: 0, False: 63.1M]
  ------------------
  500|      0|            case '#': flags |= FLAG_ALT_CONV; break;
  ------------------
  |  |  140|      0|#define FLAG_ALT_CONV   16
  ------------------
  |  Branch (500:13): [True: 0, False: 63.1M]
  ------------------
  501|  20.8M|            case '0': flags |= FLAG_ZERO_PAD; break;
  ------------------
  |  |  141|  20.8M|#define FLAG_ZERO_PAD   32
  ------------------
  |  Branch (501:13): [True: 20.8M, False: 42.3M]
  ------------------
  502|  42.3M|            default:
  ------------------
  |  Branch (502:13): [True: 42.3M, False: 20.8M]
  ------------------
  503|  42.3M|              goto flags_parsed;
  504|  63.1M|            }
  505|  63.1M|        }
  506|  42.3M|    flags_parsed:
  507|       |
  508|       |      /* Parse the field width.  */
  509|  42.3M|      width_pos = 0;
  510|  42.3M|      if (*s == '*')
  ------------------
  |  Branch (510:11): [True: 1.38k, False: 42.3M]
  ------------------
  511|  1.38k|        {
  512|  1.38k|          width = STAR_FIELD_VALUE;
  ------------------
  |  |  133|  1.38k|#define STAR_FIELD_VALUE (-2)
  ------------------
  513|  1.38k|          s++;
  514|       |          /* If we have a positional argument, another one might also
  515|       |             be used to give the position of the star's value. */
  516|  1.38k|          if (arg_pos && *s >= '1' && *s <= '9')
  ------------------
  |  Branch (516:15): [True: 0, False: 1.38k]
  |  Branch (516:26): [True: 0, False: 0]
  |  Branch (516:39): [True: 0, False: 0]
  ------------------
  517|      0|            {
  518|      0|              width_pos = (*s++ - '0');
  519|      0|              for (; *s >= '0' && *s <= '9'; s++)
  ------------------
  |  Branch (519:22): [True: 0, False: 0]
  |  Branch (519:35): [True: 0, False: 0]
  ------------------
  520|      0|                width_pos = 10*width_pos + (*s - '0');
  521|      0|              if (width_pos < 1)
  ------------------
  |  Branch (521:19): [True: 0, False: 0]
  ------------------
  522|      0|                goto leave_einval; /* Overflow during conversion.  */
  523|      0|              if (*s != '$')
  ------------------
  |  Branch (523:19): [True: 0, False: 0]
  ------------------
  524|      0|                goto leave_einval; /* Not followed by $.  */
  525|      0|              s++;
  526|      0|            }
  527|  1.38k|        }
  528|  42.3M|      else if ( *s >= '0' && *s <= '9')
  ------------------
  |  Branch (528:17): [True: 42.3M, False: 3]
  |  Branch (528:30): [True: 20.9M, False: 21.3M]
  ------------------
  529|  20.9M|        {
  530|  20.9M|          width = (*s++ - '0');
  531|  20.9M|          for (; *s >= '0' && *s <= '9'; s++)
  ------------------
  |  Branch (531:18): [True: 20.9M, False: 0]
  |  Branch (531:31): [True: 3, False: 20.9M]
  ------------------
  532|      3|            {
  533|      3|              if (!width && *s == '0')
  ------------------
  |  Branch (533:19): [True: 0, False: 3]
  |  Branch (533:29): [True: 0, False: 0]
  ------------------
  534|      0|                goto leave_einval; /* Leading zeroes are not allowed.
  535|       |                                      Fixme: check what other
  536|       |                                      implementations do. */
  537|      3|              width = 10*width + (*s - '0');
  538|      3|            }
  539|  20.9M|          if (width < 0)
  ------------------
  |  Branch (539:15): [True: 0, False: 20.9M]
  ------------------
  540|      0|            goto leave_einval; /* Overflow during conversion.  */
  541|  20.9M|        }
  542|  21.3M|      else
  543|  21.3M|        width = NO_FIELD_VALUE;
  ------------------
  |  |  132|  21.3M|#define NO_FIELD_VALUE   (-1)
  ------------------
  544|       |
  545|       |      /* Parse the precision.  */
  546|  42.3M|      precision_pos = 0;
  547|  42.3M|      precision = NO_FIELD_VALUE;
  ------------------
  |  |  132|  42.3M|#define NO_FIELD_VALUE   (-1)
  ------------------
  548|  42.3M|      if (*s == '.')
  ------------------
  |  Branch (548:11): [True: 3, False: 42.3M]
  ------------------
  549|      3|        {
  550|      3|          int ignore_value = (s[1] == '-');
  551|       |
  552|      3|          s++;
  553|      3|          if (*s == '*')
  ------------------
  |  Branch (553:15): [True: 3, False: 0]
  ------------------
  554|      3|            {
  555|      3|              precision = STAR_FIELD_VALUE;
  ------------------
  |  |  133|      3|#define STAR_FIELD_VALUE (-2)
  ------------------
  556|      3|              s++;
  557|       |              /* If we have a positional argument, another one might also
  558|       |                 be used to give the position of the star's value. */
  559|      3|              if (arg_pos && *s >= '1' && *s <= '9')
  ------------------
  |  Branch (559:19): [True: 0, False: 3]
  |  Branch (559:30): [True: 0, False: 0]
  |  Branch (559:43): [True: 0, False: 0]
  ------------------
  560|      0|                {
  561|      0|                  precision_pos = (*s++ - '0');
  562|      0|                  for (; *s >= '0' && *s <= '9'; s++)
  ------------------
  |  Branch (562:26): [True: 0, False: 0]
  |  Branch (562:39): [True: 0, False: 0]
  ------------------
  563|      0|                    precision_pos = 10*precision_pos + (*s - '0');
  564|      0|                  if (precision_pos < 1)
  ------------------
  |  Branch (564:23): [True: 0, False: 0]
  ------------------
  565|      0|                    goto leave_einval; /* Overflow during conversion.  */
  566|      0|                  if (*s != '$')
  ------------------
  |  Branch (566:23): [True: 0, False: 0]
  ------------------
  567|      0|                    goto leave_einval; /* Not followed by $.  */
  568|      0|                  s++;
  569|      0|                }
  570|      3|            }
  571|      0|          else if ( *s >= '0' && *s <= '9')
  ------------------
  |  Branch (571:21): [True: 0, False: 0]
  |  Branch (571:34): [True: 0, False: 0]
  ------------------
  572|      0|            {
  573|      0|              precision = (*s++ - '0');
  574|      0|              for (; *s >= '0' && *s <= '9'; s++)
  ------------------
  |  Branch (574:22): [True: 0, False: 0]
  |  Branch (574:35): [True: 0, False: 0]
  ------------------
  575|      0|                {
  576|      0|                  if (!precision && *s == '0')
  ------------------
  |  Branch (576:23): [True: 0, False: 0]
  |  Branch (576:37): [True: 0, False: 0]
  ------------------
  577|      0|                    goto leave_einval; /* Leading zeroes are not allowed.
  578|       |                                          Fixme: check what other
  579|       |                                          implementations do. */
  580|      0|                  precision = 10*precision + (*s - '0');
  581|      0|                }
  582|      0|              if (precision < 0)
  ------------------
  |  Branch (582:19): [True: 0, False: 0]
  ------------------
  583|      0|                goto leave_einval; /* Overflow during conversion.  */
  584|      0|            }
  585|      0|          else
  586|      0|            precision = 0;
  587|      3|          if (ignore_value)
  ------------------
  |  Branch (587:15): [True: 0, False: 3]
  ------------------
  588|      0|            precision = NO_FIELD_VALUE;
  ------------------
  |  |  132|      0|#define NO_FIELD_VALUE   (-1)
  ------------------
  589|      3|        }
  590|       |
  591|       |      /* Parse the length modifiers.  */
  592|  42.3M|      switch (*s)
  593|  42.3M|        {
  594|    288|        case 'h':
  ------------------
  |  Branch (594:9): [True: 288, False: 42.3M]
  ------------------
  595|    288|          if (s[1] == 'h')
  ------------------
  |  Branch (595:15): [True: 0, False: 288]
  ------------------
  596|      0|            {
  597|      0|              lenmod = LENMOD_CHAR;
  598|      0|              s++;
  599|      0|            }
  600|    288|          else
  601|    288|            lenmod = LENMOD_SHORT;
  602|    288|          s++;
  603|    288|          break;
  604|  15.2M|        case 'l':
  ------------------
  |  Branch (604:9): [True: 15.2M, False: 27.0M]
  ------------------
  605|  15.2M|          if (s[1] == 'l')
  ------------------
  |  Branch (605:15): [True: 0, False: 15.2M]
  ------------------
  606|      0|            {
  607|      0|              lenmod = LENMOD_LONGLONG;
  608|      0|              s++;
  609|      0|            }
  610|  15.2M|          else
  611|  15.2M|            lenmod = LENMOD_LONG;
  612|  15.2M|          s++;
  613|  15.2M|          break;
  614|      0|        case 'j': lenmod = LENMOD_INTMAX; s++; break;
  ------------------
  |  Branch (614:9): [True: 0, False: 42.3M]
  ------------------
  615|      0|        case 'z': lenmod = LENMOD_SIZET; s++; break;
  ------------------
  |  Branch (615:9): [True: 0, False: 42.3M]
  ------------------
  616|      0|        case 't': lenmod = LENMOD_PTRDIFF; s++; break;
  ------------------
  |  Branch (616:9): [True: 0, False: 42.3M]
  ------------------
  617|      0|        case 'L': lenmod = LENMOD_LONGDBL; s++; break;
  ------------------
  |  Branch (617:9): [True: 0, False: 42.3M]
  ------------------
  618|  27.0M|        default:  lenmod = LENMOD_NONE; break;
  ------------------
  |  Branch (618:9): [True: 27.0M, False: 15.2M]
  ------------------
  619|  42.3M|        }
  620|       |
  621|       |      /* Parse the conversion specifier.  */
  622|  42.3M|      switch (*s)
  623|  42.3M|        {
  624|  2.17M|        case 'd':
  ------------------
  |  Branch (624:9): [True: 2.17M, False: 40.1M]
  ------------------
  625|  2.17M|        case 'i': conspec = CONSPEC_DECIMAL; break;
  ------------------
  |  Branch (625:9): [True: 0, False: 42.3M]
  ------------------
  626|      0|        case 'o': conspec = CONSPEC_OCTAL; break;
  ------------------
  |  Branch (626:9): [True: 0, False: 42.3M]
  ------------------
  627|  1.64M|        case 'u': conspec = CONSPEC_UNSIGNED; break;
  ------------------
  |  Branch (627:9): [True: 1.64M, False: 40.6M]
  ------------------
  628|  6.64M|        case 'x': conspec = CONSPEC_HEX; break;
  ------------------
  |  Branch (628:9): [True: 6.64M, False: 35.6M]
  ------------------
  629|  14.2M|        case 'X': conspec = CONSPEC_HEX_UP; break;
  ------------------
  |  Branch (629:9): [True: 14.2M, False: 28.0M]
  ------------------
  630|      0|        case 'f': conspec = CONSPEC_FLOAT; break;
  ------------------
  |  Branch (630:9): [True: 0, False: 42.3M]
  ------------------
  631|      0|        case 'F': conspec = CONSPEC_FLOAT_UP; break;
  ------------------
  |  Branch (631:9): [True: 0, False: 42.3M]
  ------------------
  632|      0|        case 'e': conspec = CONSPEC_EXP; break;
  ------------------
  |  Branch (632:9): [True: 0, False: 42.3M]
  ------------------
  633|      0|        case 'E': conspec = CONSPEC_EXP_UP; break;
  ------------------
  |  Branch (633:9): [True: 0, False: 42.3M]
  ------------------
  634|      0|        case 'g': conspec = CONSPEC_F_OR_G; break;
  ------------------
  |  Branch (634:9): [True: 0, False: 42.3M]
  ------------------
  635|      0|        case 'G': conspec = CONSPEC_F_OR_G_UP; break;
  ------------------
  |  Branch (635:9): [True: 0, False: 42.3M]
  ------------------
  636|      0|        case 'a': conspec = CONSPEC_HEX_EXP; break;
  ------------------
  |  Branch (636:9): [True: 0, False: 42.3M]
  ------------------
  637|      0|        case 'A': conspec = CONSPEC_HEX_EXP_UP; break;
  ------------------
  |  Branch (637:9): [True: 0, False: 42.3M]
  ------------------
  638|  9.70k|        case 'c': conspec = CONSPEC_CHAR; break;
  ------------------
  |  Branch (638:9): [True: 9.70k, False: 42.3M]
  ------------------
  639|  17.5M|        case 's': conspec = CONSPEC_STRING; break;
  ------------------
  |  Branch (639:9): [True: 17.5M, False: 24.7M]
  ------------------
  640|  1.14k|        case 'p': conspec = CONSPEC_POINTER; break;
  ------------------
  |  Branch (640:9): [True: 1.14k, False: 42.3M]
  ------------------
  641|      0|        case 'n': conspec = CONSPEC_BYTES_SO_FAR; break;
  ------------------
  |  Branch (641:9): [True: 0, False: 42.3M]
  ------------------
  642|      0|        case 'C': conspec = CONSPEC_CHAR; lenmod = LENMOD_LONG; break;
  ------------------
  |  Branch (642:9): [True: 0, False: 42.3M]
  ------------------
  643|      0|        case 'S': conspec = CONSPEC_STRING; lenmod = LENMOD_LONG; break;
  ------------------
  |  Branch (643:9): [True: 0, False: 42.3M]
  ------------------
  644|      0|        case 'm': conspec = CONSPEC_STRERROR; arg_pos = -1; break;
  ------------------
  |  Branch (644:9): [True: 0, False: 42.3M]
  ------------------
  645|      0|        default: conspec = CONSPEC_UNKNOWN;
  ------------------
  |  Branch (645:9): [True: 0, False: 42.3M]
  ------------------
  646|  42.3M|        }
  647|       |
  648|       |      /* Save the args. */
  649|  42.3M|      if (argcount >= max_argspecs)
  ------------------
  |  Branch (649:11): [True: 529k, False: 41.7M]
  ------------------
  650|   529k|        {
  651|       |          /* We either need to allocate a new array instead of the
  652|       |             caller provided one or realloc the array.  Instead of
  653|       |             using realloc we allocate a new one and release the
  654|       |             original one then. */
  655|   529k|          size_t n, newmax;
  656|   529k|          argspec_t newarg;
  657|       |
  658|   529k|          newmax = max_argspecs + ARGSPECS_BUMP_VALUE;
  ------------------
  |  |  129|   529k|#define ARGSPECS_BUMP_VALUE   10
  ------------------
  659|   529k|          if (newmax <= max_argspecs)
  ------------------
  |  Branch (659:15): [True: 0, False: 529k]
  ------------------
  660|      0|            goto leave_einval;  /* Too many arguments. */
  661|   529k|          newarg = calloc (newmax, sizeof *newarg);
  662|   529k|          if (!newarg)
  ------------------
  |  Branch (662:15): [True: 0, False: 529k]
  ------------------
  663|      0|            goto leave;
  664|  3.17M|          for (n=0; n < argcount; n++)
  ------------------
  |  Branch (664:21): [True: 2.64M, False: 529k]
  ------------------
  665|  2.64M|            newarg[n] = argspecs[n];
  666|   529k|          if (argspecs != *argspecs_addr)
  ------------------
  |  Branch (666:15): [True: 0, False: 529k]
  ------------------
  667|      0|            free (argspecs);
  668|   529k|          argspecs = newarg;
  669|   529k|          max_argspecs = newmax;
  670|   529k|        }
  671|       |
  672|  42.3M|      arg = argspecs + argcount;
  673|  42.3M|      arg->length = s - format + 2;
  674|  42.3M|      arg->flags = flags;
  675|  42.3M|      arg->width = width;
  676|  42.3M|      arg->precision = precision;
  677|  42.3M|      arg->lenmod = lenmod;
  678|  42.3M|      arg->conspec = conspec;
  679|  42.3M|      arg->arg_pos = arg_pos;
  680|  42.3M|      arg->width_pos = width_pos;
  681|  42.3M|      arg->precision_pos = precision_pos;
  682|  42.3M|      compute_type (arg);
  683|  42.3M|      argcount++;
  684|  42.3M|      format = s;
  685|  42.3M|    }
  686|       |
  687|  22.8M|  *argspecs_addr = argspecs;
  688|  22.8M|  *r_argspecs_count = argcount;
  689|  22.8M|  return 0; /* Success.  */
  690|       |
  691|      0| leave_einval:
  692|      0|  _set_errno (EINVAL);
  ------------------
  |  |  113|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (113:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
  693|      0| leave:
  694|      0|  if (argspecs != *argspecs_addr)
  ------------------
  |  Branch (694:7): [True: 0, False: 0]
  ------------------
  695|      0|    free (argspecs);
  696|      0|  *argspecs_addr = NULL;
  697|      0|  return -1;
  698|      0|}
estream-printf.c:compute_type:
  345|  42.3M|{
  346|  42.3M|  switch (arg->conspec)
  ------------------
  |  Branch (346:11): [True: 0, False: 42.3M]
  ------------------
  347|  42.3M|    {
  348|      0|    case CONSPEC_UNKNOWN:
  ------------------
  |  Branch (348:5): [True: 0, False: 42.3M]
  ------------------
  349|      0|      arg->vt = VALTYPE_UNSUPPORTED;
  350|      0|      break;
  351|       |
  352|  2.17M|    case CONSPEC_DECIMAL:
  ------------------
  |  Branch (352:5): [True: 2.17M, False: 40.1M]
  ------------------
  353|  2.17M|      switch (arg->lenmod)
  354|  2.17M|        {
  355|      0|        case LENMOD_CHAR: arg->vt = VALTYPE_SCHAR; break;
  ------------------
  |  Branch (355:9): [True: 0, False: 2.17M]
  ------------------
  356|      0|        case LENMOD_SHORT: arg->vt = VALTYPE_SHORT; break;
  ------------------
  |  Branch (356:9): [True: 0, False: 2.17M]
  ------------------
  357|      0|        case LENMOD_LONG: arg->vt = VALTYPE_LONG; break;
  ------------------
  |  Branch (357:9): [True: 0, False: 2.17M]
  ------------------
  358|      0|        case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG; break;
  ------------------
  |  Branch (358:9): [True: 0, False: 2.17M]
  ------------------
  359|      0|        case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX; break;
  ------------------
  |  Branch (359:9): [True: 0, False: 2.17M]
  ------------------
  360|      0|        case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break;
  ------------------
  |  Branch (360:9): [True: 0, False: 2.17M]
  ------------------
  361|      0|        case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break;
  ------------------
  |  Branch (361:9): [True: 0, False: 2.17M]
  ------------------
  362|  2.17M|        default: arg->vt = VALTYPE_INT; break;
  ------------------
  |  Branch (362:9): [True: 2.17M, False: 0]
  ------------------
  363|  2.17M|        }
  364|  2.17M|      break;
  365|       |
  366|  2.17M|    case CONSPEC_OCTAL:
  ------------------
  |  Branch (366:5): [True: 0, False: 42.3M]
  ------------------
  367|  1.64M|    case CONSPEC_UNSIGNED:
  ------------------
  |  Branch (367:5): [True: 1.64M, False: 40.6M]
  ------------------
  368|  8.29M|    case CONSPEC_HEX:
  ------------------
  |  Branch (368:5): [True: 6.64M, False: 35.6M]
  ------------------
  369|  22.5M|    case CONSPEC_HEX_UP:
  ------------------
  |  Branch (369:5): [True: 14.2M, False: 28.0M]
  ------------------
  370|  22.5M|      switch (arg->lenmod)
  371|  22.5M|        {
  372|      0|        case LENMOD_CHAR: arg->vt = VALTYPE_UCHAR; break;
  ------------------
  |  Branch (372:9): [True: 0, False: 22.5M]
  ------------------
  373|    288|        case LENMOD_SHORT: arg->vt = VALTYPE_USHORT; break;
  ------------------
  |  Branch (373:9): [True: 288, False: 22.5M]
  ------------------
  374|  15.2M|        case LENMOD_LONG: arg->vt = VALTYPE_ULONG; break;
  ------------------
  |  Branch (374:9): [True: 15.2M, False: 7.29M]
  ------------------
  375|      0|        case LENMOD_LONGLONG: arg->vt = VALTYPE_ULONGLONG; break;
  ------------------
  |  Branch (375:9): [True: 0, False: 22.5M]
  ------------------
  376|      0|        case LENMOD_INTMAX: arg->vt = VALTYPE_UINTMAX; break;
  ------------------
  |  Branch (376:9): [True: 0, False: 22.5M]
  ------------------
  377|      0|        case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break;
  ------------------
  |  Branch (377:9): [True: 0, False: 22.5M]
  ------------------
  378|      0|        case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break;
  ------------------
  |  Branch (378:9): [True: 0, False: 22.5M]
  ------------------
  379|  7.29M|        default: arg->vt = VALTYPE_UINT; break;
  ------------------
  |  Branch (379:9): [True: 7.29M, False: 15.2M]
  ------------------
  380|  22.5M|        }
  381|  22.5M|      break;
  382|       |
  383|  22.5M|    case CONSPEC_FLOAT:
  ------------------
  |  Branch (383:5): [True: 0, False: 42.3M]
  ------------------
  384|      0|    case CONSPEC_FLOAT_UP:
  ------------------
  |  Branch (384:5): [True: 0, False: 42.3M]
  ------------------
  385|      0|    case CONSPEC_EXP:
  ------------------
  |  Branch (385:5): [True: 0, False: 42.3M]
  ------------------
  386|      0|    case CONSPEC_EXP_UP:
  ------------------
  |  Branch (386:5): [True: 0, False: 42.3M]
  ------------------
  387|      0|    case CONSPEC_F_OR_G:
  ------------------
  |  Branch (387:5): [True: 0, False: 42.3M]
  ------------------
  388|      0|    case CONSPEC_F_OR_G_UP:
  ------------------
  |  Branch (388:5): [True: 0, False: 42.3M]
  ------------------
  389|      0|    case CONSPEC_HEX_EXP:
  ------------------
  |  Branch (389:5): [True: 0, False: 42.3M]
  ------------------
  390|      0|    case CONSPEC_HEX_EXP_UP:
  ------------------
  |  Branch (390:5): [True: 0, False: 42.3M]
  ------------------
  391|      0|      switch (arg->lenmod)
  392|      0|        {
  393|      0|        case LENMOD_LONGDBL: arg->vt = VALTYPE_LONGDOUBLE; break;
  ------------------
  |  Branch (393:9): [True: 0, False: 0]
  ------------------
  394|      0|        case LENMOD_LONG: arg->vt = VALTYPE_DOUBLE; break;
  ------------------
  |  Branch (394:9): [True: 0, False: 0]
  ------------------
  395|      0|        default: arg->vt = VALTYPE_DOUBLE; break;
  ------------------
  |  Branch (395:9): [True: 0, False: 0]
  ------------------
  396|      0|        }
  397|      0|      break;
  398|       |
  399|  9.70k|    case CONSPEC_CHAR:
  ------------------
  |  Branch (399:5): [True: 9.70k, False: 42.3M]
  ------------------
  400|  9.70k|      arg->vt = VALTYPE_INT;
  401|  9.70k|      break;
  402|       |
  403|  17.5M|    case CONSPEC_STRING:
  ------------------
  |  Branch (403:5): [True: 17.5M, False: 24.7M]
  ------------------
  404|  17.5M|      arg->vt = VALTYPE_STRING;
  405|  17.5M|      break;
  406|       |
  407|  1.14k|    case CONSPEC_POINTER:
  ------------------
  |  Branch (407:5): [True: 1.14k, False: 42.3M]
  ------------------
  408|  1.14k|      arg->vt = VALTYPE_POINTER;
  409|  1.14k|      break;
  410|       |
  411|      0|    case CONSPEC_STRERROR:
  ------------------
  |  Branch (411:5): [True: 0, False: 42.3M]
  ------------------
  412|      0|      arg->vt = VALTYPE_STRING;
  413|      0|      break;
  414|       |
  415|      0|    case CONSPEC_BYTES_SO_FAR:
  ------------------
  |  Branch (415:5): [True: 0, False: 42.3M]
  ------------------
  416|      0|      switch (arg->lenmod)
  417|      0|        {
  418|      0|        case LENMOD_CHAR: arg->vt = VALTYPE_SCHAR_PTR; break;
  ------------------
  |  Branch (418:9): [True: 0, False: 0]
  ------------------
  419|      0|        case LENMOD_SHORT: arg->vt = VALTYPE_SHORT_PTR; break;
  ------------------
  |  Branch (419:9): [True: 0, False: 0]
  ------------------
  420|      0|        case LENMOD_LONG: arg->vt = VALTYPE_LONG_PTR; break;
  ------------------
  |  Branch (420:9): [True: 0, False: 0]
  ------------------
  421|      0|        case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG_PTR; break;
  ------------------
  |  Branch (421:9): [True: 0, False: 0]
  ------------------
  422|      0|        case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX_PTR; break;
  ------------------
  |  Branch (422:9): [True: 0, False: 0]
  ------------------
  423|      0|        case LENMOD_SIZET: arg->vt = VALTYPE_SIZE_PTR; break;
  ------------------
  |  Branch (423:9): [True: 0, False: 0]
  ------------------
  424|      0|        case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF_PTR; break;
  ------------------
  |  Branch (424:9): [True: 0, False: 0]
  ------------------
  425|      0|        default: arg->vt = VALTYPE_INT_PTR; break;
  ------------------
  |  Branch (425:9): [True: 0, False: 0]
  ------------------
  426|      0|        }
  427|      0|      break;
  428|       |
  429|  42.3M|    }
  430|  42.3M|}
estream-printf.c:read_values:
  706|  22.8M|{
  707|  22.8M|  int validx;
  708|       |
  709|  65.1M|  for (validx=0; validx < valuetable_len; validx++)
  ------------------
  |  Branch (709:18): [True: 42.3M, False: 22.8M]
  ------------------
  710|  42.3M|    {
  711|  42.3M|      value_t *value = &valuetable[validx].value;
  712|  42.3M|      valtype_t vt = valuetable[validx].vt;
  713|       |
  714|  42.3M|      switch (vt)
  715|  42.3M|        {
  716|      0|        case VALTYPE_CHAR: value->a_char = va_arg (vaargs, int); break;
  ------------------
  |  Branch (716:9): [True: 0, False: 42.3M]
  ------------------
  717|      0|        case VALTYPE_CHAR_PTR:
  ------------------
  |  Branch (717:9): [True: 0, False: 42.3M]
  ------------------
  718|      0|          value->a_char_ptr = va_arg (vaargs, char *);
  719|      0|          break;
  720|      0|        case VALTYPE_SCHAR: value->a_schar = va_arg (vaargs, int); break;
  ------------------
  |  Branch (720:9): [True: 0, False: 42.3M]
  ------------------
  721|      0|        case VALTYPE_SCHAR_PTR:
  ------------------
  |  Branch (721:9): [True: 0, False: 42.3M]
  ------------------
  722|      0|          value->a_schar_ptr = va_arg (vaargs, signed char *);
  723|      0|          break;
  724|      0|        case VALTYPE_UCHAR: value->a_uchar = va_arg (vaargs, int); break;
  ------------------
  |  Branch (724:9): [True: 0, False: 42.3M]
  ------------------
  725|      0|        case VALTYPE_SHORT: value->a_short = va_arg (vaargs, int); break;
  ------------------
  |  Branch (725:9): [True: 0, False: 42.3M]
  ------------------
  726|    288|        case VALTYPE_USHORT: value->a_ushort = va_arg (vaargs, int); break;
  ------------------
  |  Branch (726:9): [True: 288, False: 42.3M]
  ------------------
  727|      0|        case VALTYPE_SHORT_PTR:
  ------------------
  |  Branch (727:9): [True: 0, False: 42.3M]
  ------------------
  728|      0|          value->a_short_ptr = va_arg (vaargs, short *);
  729|      0|          break;
  730|  2.18M|        case VALTYPE_INT:
  ------------------
  |  Branch (730:9): [True: 2.18M, False: 40.1M]
  ------------------
  731|  2.18M|          value->a_int = va_arg (vaargs, int);
  732|  2.18M|          break;
  733|      0|        case VALTYPE_INT_PTR:
  ------------------
  |  Branch (733:9): [True: 0, False: 42.3M]
  ------------------
  734|      0|          value->a_int_ptr = va_arg (vaargs, int *);
  735|      0|          break;
  736|  7.29M|        case VALTYPE_UINT:
  ------------------
  |  Branch (736:9): [True: 7.29M, False: 35.0M]
  ------------------
  737|  7.29M|          value->a_uint = va_arg (vaargs, unsigned int);
  738|  7.29M|          break;
  739|      0|        case VALTYPE_LONG:
  ------------------
  |  Branch (739:9): [True: 0, False: 42.3M]
  ------------------
  740|      0|          value->a_long = va_arg (vaargs, long);
  741|      0|          break;
  742|  15.2M|        case VALTYPE_ULONG:
  ------------------
  |  Branch (742:9): [True: 15.2M, False: 27.0M]
  ------------------
  743|  15.2M|          value->a_ulong = va_arg (vaargs, unsigned long);
  744|  15.2M|          break;
  745|      0|        case VALTYPE_LONG_PTR:
  ------------------
  |  Branch (745:9): [True: 0, False: 42.3M]
  ------------------
  746|      0|          value->a_long_ptr = va_arg (vaargs, long *);
  747|      0|          break;
  748|      0|#ifdef HAVE_LONG_LONG_INT
  749|      0|        case VALTYPE_LONGLONG:
  ------------------
  |  Branch (749:9): [True: 0, False: 42.3M]
  ------------------
  750|      0|          value->a_longlong = va_arg (vaargs, long long int);
  751|      0|          break;
  752|      0|        case VALTYPE_ULONGLONG:
  ------------------
  |  Branch (752:9): [True: 0, False: 42.3M]
  ------------------
  753|      0|          value->a_ulonglong = va_arg (vaargs, unsigned long long int);
  754|      0|          break;
  755|      0|        case VALTYPE_LONGLONG_PTR:
  ------------------
  |  Branch (755:9): [True: 0, False: 42.3M]
  ------------------
  756|      0|          value->a_longlong_ptr = va_arg (vaargs, long long *);
  757|      0|          break;
  758|      0|#endif
  759|      0|        case VALTYPE_DOUBLE:
  ------------------
  |  Branch (759:9): [True: 0, False: 42.3M]
  ------------------
  760|      0|          value->a_double = va_arg (vaargs, double);
  761|      0|          break;
  762|      0|#ifdef HAVE_LONG_DOUBLE
  763|      0|        case VALTYPE_LONGDOUBLE:
  ------------------
  |  Branch (763:9): [True: 0, False: 42.3M]
  ------------------
  764|      0|          value->a_longdouble = va_arg (vaargs, long double);
  765|      0|          break;
  766|      0|#endif
  767|  17.5M|        case VALTYPE_STRING:
  ------------------
  |  Branch (767:9): [True: 17.5M, False: 24.7M]
  ------------------
  768|  17.5M|          value->a_string = va_arg (vaargs, const char *);
  769|  17.5M|          break;
  770|  1.14k|        case VALTYPE_POINTER:
  ------------------
  |  Branch (770:9): [True: 1.14k, False: 42.3M]
  ------------------
  771|  1.14k|          value->a_void_ptr = va_arg (vaargs, void *);
  772|  1.14k|          break;
  773|      0|#ifdef HAVE_INTMAX_T
  774|      0|        case VALTYPE_INTMAX:
  ------------------
  |  Branch (774:9): [True: 0, False: 42.3M]
  ------------------
  775|      0|          value->a_intmax = va_arg (vaargs, intmax_t);
  776|      0|          break;
  777|      0|        case VALTYPE_INTMAX_PTR:
  ------------------
  |  Branch (777:9): [True: 0, False: 42.3M]
  ------------------
  778|      0|          value->a_intmax_ptr = va_arg (vaargs, intmax_t *);
  779|      0|          break;
  780|      0|#endif
  781|      0|#ifdef HAVE_UINTMAX_T
  782|      0|        case VALTYPE_UINTMAX:
  ------------------
  |  Branch (782:9): [True: 0, False: 42.3M]
  ------------------
  783|      0|          value->a_uintmax = va_arg (vaargs, uintmax_t);
  784|      0|          break;
  785|      0|#endif
  786|      0|        case VALTYPE_SIZE:
  ------------------
  |  Branch (786:9): [True: 0, False: 42.3M]
  ------------------
  787|      0|          value->a_size = va_arg (vaargs, size_t);
  788|      0|          break;
  789|      0|        case VALTYPE_SIZE_PTR:
  ------------------
  |  Branch (789:9): [True: 0, False: 42.3M]
  ------------------
  790|      0|          value->a_size_ptr = va_arg (vaargs, size_t *);
  791|      0|          break;
  792|      0|#ifdef HAVE_PTRDIFF_T
  793|      0|        case VALTYPE_PTRDIFF:
  ------------------
  |  Branch (793:9): [True: 0, False: 42.3M]
  ------------------
  794|      0|          value->a_ptrdiff = va_arg (vaargs, ptrdiff_t);
  795|      0|          break;
  796|      0|        case VALTYPE_PTRDIFF_PTR:
  ------------------
  |  Branch (796:9): [True: 0, False: 42.3M]
  ------------------
  797|      0|          value->a_ptrdiff_ptr = va_arg (vaargs, ptrdiff_t *);
  798|      0|          break;
  799|      0|#endif
  800|      0|        default: /* Unsupported type.  */
  ------------------
  |  Branch (800:9): [True: 0, False: 42.3M]
  ------------------
  801|      0|          return -1;
  802|  42.3M|        }
  803|  42.3M|    }
  804|  22.8M|  return 0;
  805|  22.8M|}
estream-printf.c:do_format:
 1354|  22.8M|{
 1355|  22.8M|  int rc = 0;
 1356|  22.8M|  const char *s;
 1357|  22.8M|  argspec_t arg = argspecs;
 1358|  22.8M|  int argidx = 0; /* Only used for assertion.  */
 1359|  22.8M|  size_t n;
 1360|  22.8M|  value_t value;
 1361|  22.8M|  int string_no = 0;  /* Number of processed "%s" args.  */
 1362|       |
 1363|  22.8M|  s = format;
 1364|   365M|  while ( *s )
  ------------------
  |  Branch (1364:11): [True: 342M, False: 22.8M]
  ------------------
 1365|   342M|    {
 1366|   342M|      if (*s != '%')
  ------------------
  |  Branch (1366:11): [True: 300M, False: 42.3M]
  ------------------
 1367|   300M|        {
 1368|   300M|          s++;
 1369|   300M|          continue;
 1370|   300M|        }
 1371|  42.3M|      if (s != format)
  ------------------
  |  Branch (1371:11): [True: 25.2M, False: 17.0M]
  ------------------
 1372|  25.2M|        {
 1373|  25.2M|          rc = outfnc (outfncarg, format, (n=s-format));
 1374|  25.2M|          if (rc)
  ------------------
  |  Branch (1374:15): [True: 0, False: 25.2M]
  ------------------
 1375|      0|            return rc;
 1376|  25.2M|          *nbytes += n;
 1377|  25.2M|        }
 1378|  42.3M|      if (s[1] == '%')
  ------------------
  |  Branch (1378:11): [True: 0, False: 42.3M]
  ------------------
 1379|      0|        {
 1380|       |          /* Note that this code ignores one trailing percent escape -
 1381|       |             this is however okay as the args parser must have
 1382|       |             detected this already.  */
 1383|      0|          rc = outfnc (outfncarg, s, 1);
 1384|      0|          if (rc)
  ------------------
  |  Branch (1384:15): [True: 0, False: 0]
  ------------------
 1385|      0|            return rc;
 1386|      0|          *nbytes += 1;
 1387|      0|          s += 2;
 1388|      0|          format = s;
 1389|      0|          continue;
 1390|      0|        }
 1391|       |
 1392|       |      /* Save the next start.  */
 1393|  42.3M|      s += arg->length;
 1394|  42.3M|      format = s;
 1395|       |
 1396|  42.3M|      gpgrt_assert (argidx < argspecs_len);
  ------------------
  |  |  577|  42.3M|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 42.3M, False: 0]
  |  |  ------------------
  |  |  578|  42.3M|   ? (void) 0                                                   \
  |  |  579|  42.3M|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 1397|      0|      argidx++;
 1398|       |
 1399|       |      /* Apply indirect field width and precision values.  */
 1400|  42.3M|      if (arg->width == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  42.3M|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1400:11): [True: 1.38k, False: 42.3M]
  ------------------
 1401|  1.38k|        {
 1402|  1.38k|          gpgrt_assert (valuetable[arg->width_pos-1].vt == VALTYPE_INT);
  ------------------
  |  |  577|  1.38k|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 1.38k, False: 0]
  |  |  ------------------
  |  |  578|  1.38k|   ? (void) 0                                                   \
  |  |  579|  1.38k|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 1403|      0|          arg->width = valuetable[arg->width_pos-1].value.a_int;
 1404|  1.38k|          if (arg->width < 0)
  ------------------
  |  Branch (1404:15): [True: 0, False: 1.38k]
  ------------------
 1405|      0|            {
 1406|      0|              arg->width = -arg->width;
 1407|      0|              arg->flags |= FLAG_LEFT_JUST;
  ------------------
  |  |  137|      0|#define FLAG_LEFT_JUST  2
  ------------------
 1408|      0|            }
 1409|  1.38k|        }
 1410|  42.3M|      if (arg->precision == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  42.3M|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1410:11): [True: 3, False: 42.3M]
  ------------------
 1411|      3|        {
 1412|      3|          gpgrt_assert (valuetable[arg->precision_pos-1].vt == VALTYPE_INT);
  ------------------
  |  |  577|      3|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 3, False: 0]
  |  |  ------------------
  |  |  578|      3|   ? (void) 0                                                   \
  |  |  579|      3|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 1413|      0|          arg->precision = valuetable[arg->precision_pos-1].value.a_int;
 1414|      3|          if (arg->precision < 0)
  ------------------
  |  Branch (1414:15): [True: 0, False: 3]
  ------------------
 1415|      0|            arg->precision = NO_FIELD_VALUE;
  ------------------
  |  |  132|      0|#define NO_FIELD_VALUE   (-1)
  ------------------
 1416|      3|        }
 1417|       |
 1418|  42.3M|      if (arg->arg_pos == -1 && arg->conspec == CONSPEC_STRERROR)
  ------------------
  |  Branch (1418:11): [True: 0, False: 42.3M]
  |  Branch (1418:33): [True: 0, False: 0]
  ------------------
 1419|      0|        value.a_string = strerror (myerrno);
 1420|  42.3M|      else
 1421|  42.3M|        {
 1422|  42.3M|          gpgrt_assert (arg->vt == valuetable[arg->arg_pos-1].vt);
  ------------------
  |  |  577|  42.3M|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 42.3M, False: 0]
  |  |  ------------------
  |  |  578|  42.3M|   ? (void) 0                                                   \
  |  |  579|  42.3M|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 1423|      0|          value = valuetable[arg->arg_pos-1].value;
 1424|  42.3M|        }
 1425|       |
 1426|      0|      switch (arg->conspec)
  ------------------
  |  Branch (1426:15): [True: 0, False: 42.3M]
  ------------------
 1427|  42.3M|        {
 1428|      0|        case CONSPEC_UNKNOWN: gpgrt_assert (!"bug"); break;
  ------------------
  |  |  577|      0|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [Folded - Ignored]
  |  |  ------------------
  |  |  578|      0|   ? (void) 0                                                   \
  |  |  579|      0|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
  |  Branch (1428:9): [True: 0, False: 42.3M]
  ------------------
 1429|       |
 1430|  2.17M|        case CONSPEC_DECIMAL:
  ------------------
  |  Branch (1430:9): [True: 2.17M, False: 40.1M]
  ------------------
 1431|  3.81M|        case CONSPEC_UNSIGNED:
  ------------------
  |  Branch (1431:9): [True: 1.64M, False: 40.6M]
  ------------------
 1432|  3.81M|        case CONSPEC_OCTAL:
  ------------------
  |  Branch (1432:9): [True: 0, False: 42.3M]
  ------------------
 1433|  10.4M|        case CONSPEC_HEX:
  ------------------
  |  Branch (1433:9): [True: 6.64M, False: 35.6M]
  ------------------
 1434|  24.7M|        case CONSPEC_HEX_UP:
  ------------------
  |  Branch (1434:9): [True: 14.2M, False: 28.0M]
  ------------------
 1435|  24.7M|          rc = pr_integer (outfnc, outfncarg, arg, value, nbytes);
 1436|  24.7M|          break;
 1437|      0|        case CONSPEC_FLOAT:
  ------------------
  |  Branch (1437:9): [True: 0, False: 42.3M]
  ------------------
 1438|      0|        case CONSPEC_FLOAT_UP:
  ------------------
  |  Branch (1438:9): [True: 0, False: 42.3M]
  ------------------
 1439|      0|        case CONSPEC_EXP:
  ------------------
  |  Branch (1439:9): [True: 0, False: 42.3M]
  ------------------
 1440|      0|        case CONSPEC_EXP_UP:
  ------------------
  |  Branch (1440:9): [True: 0, False: 42.3M]
  ------------------
 1441|      0|        case CONSPEC_F_OR_G:
  ------------------
  |  Branch (1441:9): [True: 0, False: 42.3M]
  ------------------
 1442|      0|        case CONSPEC_F_OR_G_UP:
  ------------------
  |  Branch (1442:9): [True: 0, False: 42.3M]
  ------------------
 1443|      0|        case CONSPEC_HEX_EXP:
  ------------------
  |  Branch (1443:9): [True: 0, False: 42.3M]
  ------------------
 1444|      0|        case CONSPEC_HEX_EXP_UP:
  ------------------
  |  Branch (1444:9): [True: 0, False: 42.3M]
  ------------------
 1445|      0|          rc = pr_float (outfnc, outfncarg, arg, value, nbytes);
 1446|      0|          break;
 1447|  9.70k|        case CONSPEC_CHAR:
  ------------------
  |  Branch (1447:9): [True: 9.70k, False: 42.3M]
  ------------------
 1448|  9.70k|          rc = pr_char (outfnc, outfncarg, arg, value, nbytes);
 1449|  9.70k|          break;
 1450|  17.5M|        case CONSPEC_STRING:
  ------------------
  |  Branch (1450:9): [True: 17.5M, False: 24.7M]
  ------------------
 1451|  17.5M|          rc = pr_string (outfnc, outfncarg, arg, value, nbytes,
 1452|  17.5M|                          sf, sfvalue, string_no++);
 1453|  17.5M|          break;
 1454|      0|        case CONSPEC_STRERROR:
  ------------------
  |  Branch (1454:9): [True: 0, False: 42.3M]
  ------------------
 1455|      0|          rc = pr_string (outfnc, outfncarg, arg, value, nbytes,
 1456|      0|                          NULL, NULL, 0);
 1457|      0|          break;
 1458|  1.14k|        case CONSPEC_POINTER:
  ------------------
  |  Branch (1458:9): [True: 1.14k, False: 42.3M]
  ------------------
 1459|  1.14k|          rc = pr_pointer (outfnc, outfncarg, arg, value, nbytes);
 1460|  1.14k|          break;
 1461|      0|        case CONSPEC_BYTES_SO_FAR:
  ------------------
  |  Branch (1461:9): [True: 0, False: 42.3M]
  ------------------
 1462|      0|          rc = pr_bytes_so_far (outfnc, outfncarg, arg, value, nbytes);
 1463|      0|          break;
 1464|  42.3M|        }
 1465|  42.3M|      if (rc)
  ------------------
  |  Branch (1465:11): [True: 0, False: 42.3M]
  ------------------
 1466|      0|        return rc;
 1467|  42.3M|      arg++;
 1468|  42.3M|    }
 1469|       |
 1470|       |  /* Print out any trailing stuff. */
 1471|  22.8M|  n = s - format;
 1472|  22.8M|  rc = n? outfnc (outfncarg, format, n) : 0;
  ------------------
  |  Branch (1472:8): [True: 11.5M, False: 11.2M]
  ------------------
 1473|  22.8M|  if (!rc)
  ------------------
  |  Branch (1473:7): [True: 22.8M, False: 0]
  ------------------
 1474|  22.8M|    *nbytes += n;
 1475|       |
 1476|  22.8M|  return rc;
 1477|  22.8M|}
estream-printf.c:pr_integer:
  840|  24.7M|{
  841|  24.7M|  int rc;
  842|  24.7M|#ifdef HAVE_LONG_LONG_INT
  843|  24.7M|  unsigned long long aulong;
  844|       |#else
  845|       |  unsigned long aulong;
  846|       |#endif
  847|  24.7M|  char numbuf[100];
  848|  24.7M|  char *p, *pend;
  849|  24.7M|  size_t n;
  850|  24.7M|  char signchar = 0;
  851|  24.7M|  int n_prec;  /* Number of extra precision digits required.  */
  852|  24.7M|  int n_extra; /* Extra number of prefix or sign characters.  */
  853|       |
  854|  24.7M|  if (arg->conspec == CONSPEC_DECIMAL)
  ------------------
  |  Branch (854:7): [True: 2.17M, False: 22.5M]
  ------------------
  855|  2.17M|    {
  856|  2.17M|#ifdef HAVE_LONG_LONG_INT
  857|  2.17M|      long long along;
  858|       |#else
  859|       |      long along;
  860|       |#endif
  861|       |
  862|  2.17M|      switch (arg->vt)
  863|  2.17M|        {
  864|      0|        case VALTYPE_SHORT: along = value.a_short; break;
  ------------------
  |  Branch (864:9): [True: 0, False: 2.17M]
  ------------------
  865|  2.17M|        case VALTYPE_INT: along = value.a_int; break;
  ------------------
  |  Branch (865:9): [True: 2.17M, False: 0]
  ------------------
  866|      0|        case VALTYPE_LONG: along = value.a_long; break;
  ------------------
  |  Branch (866:9): [True: 0, False: 2.17M]
  ------------------
  867|      0|#ifdef HAVE_LONG_LONG_INT
  868|      0|        case VALTYPE_LONGLONG: along = value.a_longlong; break;
  ------------------
  |  Branch (868:9): [True: 0, False: 2.17M]
  ------------------
  869|      0|        case VALTYPE_SIZE: along = value.a_size; break;
  ------------------
  |  Branch (869:9): [True: 0, False: 2.17M]
  ------------------
  870|      0|# ifdef HAVE_INTMAX_T
  871|      0|        case VALTYPE_INTMAX: along = value.a_intmax; break;
  ------------------
  |  Branch (871:9): [True: 0, False: 2.17M]
  ------------------
  872|      0|# endif
  873|      0|# ifdef HAVE_PTRDIFF_T
  874|      0|        case VALTYPE_PTRDIFF: along = value.a_ptrdiff; break;
  ------------------
  |  Branch (874:9): [True: 0, False: 2.17M]
  ------------------
  875|      0|# endif
  876|      0|#endif /*HAVE_LONG_LONG_INT*/
  877|      0|        default:
  ------------------
  |  Branch (877:9): [True: 0, False: 2.17M]
  ------------------
  878|      0|          return -1;
  879|  2.17M|        }
  880|  2.17M|      if (along < 0)
  ------------------
  |  Branch (880:11): [True: 0, False: 2.17M]
  ------------------
  881|      0|        {
  882|      0|          aulong = -along;
  883|      0|          signchar = '-';
  884|      0|        }
  885|  2.17M|      else
  886|  2.17M|        aulong = along;
  887|  2.17M|    }
  888|  22.5M|  else
  889|  22.5M|    {
  890|  22.5M|      switch (arg->vt)
  891|  22.5M|        {
  892|    288|        case VALTYPE_USHORT: aulong = value.a_ushort; break;
  ------------------
  |  Branch (892:9): [True: 288, False: 22.5M]
  ------------------
  893|  7.29M|        case VALTYPE_UINT: aulong = value.a_uint; break;
  ------------------
  |  Branch (893:9): [True: 7.29M, False: 15.2M]
  ------------------
  894|  15.2M|        case VALTYPE_ULONG: aulong = value.a_ulong; break;
  ------------------
  |  Branch (894:9): [True: 15.2M, False: 7.29M]
  ------------------
  895|      0|#ifdef HAVE_LONG_LONG_INT
  896|      0|        case VALTYPE_ULONGLONG: aulong = value.a_ulonglong; break;
  ------------------
  |  Branch (896:9): [True: 0, False: 22.5M]
  ------------------
  897|      0|        case VALTYPE_SIZE: aulong = value.a_size; break;
  ------------------
  |  Branch (897:9): [True: 0, False: 22.5M]
  ------------------
  898|      0|# ifdef HAVE_UINTMAX_T
  899|      0|        case VALTYPE_UINTMAX: aulong = value.a_uintmax; break;
  ------------------
  |  Branch (899:9): [True: 0, False: 22.5M]
  ------------------
  900|      0|# endif
  901|      0|# ifdef HAVE_PTRDIFF_T
  902|      0|        case VALTYPE_PTRDIFF: aulong = value.a_ptrdiff; break;
  ------------------
  |  Branch (902:9): [True: 0, False: 22.5M]
  ------------------
  903|      0|# endif
  904|      0|#endif /*HAVE_LONG_LONG_INT*/
  905|      0|        default:
  ------------------
  |  Branch (905:9): [True: 0, False: 22.5M]
  ------------------
  906|      0|          return -1;
  907|  22.5M|        }
  908|  22.5M|    }
  909|       |
  910|  24.7M|  if (signchar == '-')
  ------------------
  |  Branch (910:7): [True: 0, False: 24.7M]
  ------------------
  911|      0|    ;
  912|  24.7M|  else if ((arg->flags & FLAG_PLUS_SIGN))
  ------------------
  |  |  138|  24.7M|#define FLAG_PLUS_SIGN  4
  ------------------
  |  Branch (912:12): [True: 0, False: 24.7M]
  ------------------
  913|      0|    signchar = '+';
  914|  24.7M|  else if ((arg->flags & FLAG_SPACE_PLUS))
  ------------------
  |  |  139|  24.7M|#define FLAG_SPACE_PLUS 8
  ------------------
  |  Branch (914:12): [True: 0, False: 24.7M]
  ------------------
  915|      0|    signchar = ' ';
  916|       |
  917|  24.7M|  n_extra = !!signchar;
  918|       |
  919|       |  /* We build the string up backwards.  */
  920|  24.7M|  p = pend = numbuf + DIM(numbuf);
  ------------------
  |  |   93|  24.7M|# define DIM(array) (sizeof (array) / sizeof (*array))
  ------------------
  921|  24.7M|  if ((!aulong && !arg->precision))
  ------------------
  |  Branch (921:8): [True: 3.30M, False: 21.4M]
  |  Branch (921:19): [True: 0, False: 3.30M]
  ------------------
  922|      0|    ;
  923|  24.7M|  else if (arg->conspec == CONSPEC_DECIMAL
  ------------------
  |  Branch (923:12): [True: 2.17M, False: 22.5M]
  ------------------
  924|  24.7M|           || arg->conspec == CONSPEC_UNSIGNED)
  ------------------
  |  Branch (924:15): [True: 1.64M, False: 20.8M]
  ------------------
  925|  3.81M|    {
  926|  3.81M|      int grouping = -1;
  927|  3.81M|      const char * grouping_string =
  928|  3.81M|#ifdef HAVE_LANGINFO_THOUSEP
  929|  3.81M|        nl_langinfo(THOUSEP);
  930|       |#else
  931|       |        "'";
  932|       |#endif
  933|       |
  934|  3.81M|      do
  935|  7.52M|        {
  936|  7.52M|          if ((arg->flags & FLAG_GROUPING)
  ------------------
  |  |  136|  7.52M|#define FLAG_GROUPING   1
  ------------------
  |  Branch (936:15): [True: 0, False: 7.52M]
  ------------------
  937|  7.52M|              && (++grouping == 3) && *grouping_string)
  ------------------
  |  Branch (937:18): [True: 0, False: 0]
  |  Branch (937:39): [True: 0, False: 0]
  ------------------
  938|      0|            {
  939|      0|              *--p = *grouping_string;
  940|      0|              grouping = 0;
  941|      0|            }
  942|  7.52M|          *--p = '0' + (aulong % 10);
  943|  7.52M|          aulong /= 10;
  944|  7.52M|        }
  945|  7.52M|      while (aulong);
  ------------------
  |  Branch (945:14): [True: 3.71M, False: 3.81M]
  ------------------
  946|  3.81M|    }
  947|  20.8M|  else if (arg->conspec == CONSPEC_OCTAL)
  ------------------
  |  Branch (947:12): [True: 0, False: 20.8M]
  ------------------
  948|      0|    {
  949|      0|      do
  950|      0|        {
  951|      0|          *--p = '0' + (aulong % 8);
  952|      0|          aulong /= 8;
  953|      0|        }
  954|      0|      while (aulong);
  ------------------
  |  Branch (954:14): [True: 0, False: 0]
  ------------------
  955|      0|      if ((arg->flags & FLAG_ALT_CONV) && *p != '0')
  ------------------
  |  |  140|      0|#define FLAG_ALT_CONV   16
  ------------------
  |  Branch (955:11): [True: 0, False: 0]
  |  Branch (955:43): [True: 0, False: 0]
  ------------------
  956|      0|        *--p = '0';
  957|      0|    }
  958|  20.8M|  else /* HEX or HEXUP */
  959|  20.8M|    {
  960|  20.8M|      const char *digits = ((arg->conspec == CONSPEC_HEX)
  ------------------
  |  Branch (960:29): [True: 6.64M, False: 14.2M]
  ------------------
  961|  20.8M|                            ? "0123456789abcdef" : "0123456789ABCDEF");
  962|  20.8M|      do
  963|  95.1M|        {
  964|  95.1M|          *--p = digits[(aulong % 16)];
  965|  95.1M|          aulong /= 16;
  966|  95.1M|        }
  967|  95.1M|      while (aulong);
  ------------------
  |  Branch (967:14): [True: 74.2M, False: 20.8M]
  ------------------
  968|  20.8M|      if ((arg->flags & FLAG_ALT_CONV))
  ------------------
  |  |  140|  20.8M|#define FLAG_ALT_CONV   16
  ------------------
  |  Branch (968:11): [True: 0, False: 20.8M]
  ------------------
  969|      0|        n_extra += 2;
  970|  20.8M|    }
  971|       |
  972|  24.7M|  n = pend - p;
  973|       |
  974|  24.7M|  if ((arg->flags & FLAG_ZERO_PAD)
  ------------------
  |  |  141|  24.7M|#define FLAG_ZERO_PAD   32
  ------------------
  |  Branch (974:7): [True: 20.8M, False: 3.82M]
  ------------------
  975|  24.7M|      && arg->precision == NO_FIELD_VALUE && !(arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  132|  45.5M|#define NO_FIELD_VALUE   (-1)
  ------------------
                    && arg->precision == NO_FIELD_VALUE && !(arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  137|  20.8M|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (975:10): [True: 20.8M, False: 0]
  |  Branch (975:46): [True: 20.8M, False: 0]
  ------------------
  976|  24.7M|      && n && arg->width - n_extra > n )
  ------------------
  |  Branch (976:10): [True: 20.8M, False: 0]
  |  Branch (976:15): [True: 16.6M, False: 4.22M]
  ------------------
  977|  16.6M|    n_prec = arg->width - n_extra - n;
  978|  8.04M|  else if (arg->precision > 0 && arg->precision > n)
  ------------------
  |  Branch (978:12): [True: 0, False: 8.04M]
  |  Branch (978:34): [True: 0, False: 0]
  ------------------
  979|      0|    n_prec = arg->precision - n;
  980|  8.04M|  else
  981|  8.04M|    n_prec = 0;
  982|       |
  983|  24.7M|  if (!(arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  137|  24.7M|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (983:7): [True: 24.7M, False: 0]
  ------------------
  984|  24.7M|      && arg->width >= 0 && arg->width - n_extra > n
  ------------------
  |  Branch (984:10): [True: 20.9M, False: 3.74M]
  |  Branch (984:29): [True: 16.6M, False: 4.28M]
  ------------------
  985|  24.7M|      && arg->width - n_extra - n >= n_prec )
  ------------------
  |  Branch (985:10): [True: 16.6M, False: 0]
  ------------------
  986|  16.6M|    {
  987|  16.6M|      rc = pad_out (outfnc, outfncarg, ' ',
  988|  16.6M|                    arg->width - n_extra - n - n_prec, nbytes);
  989|  16.6M|      if (rc)
  ------------------
  |  Branch (989:11): [True: 0, False: 16.6M]
  ------------------
  990|      0|        return rc;
  991|  16.6M|    }
  992|       |
  993|  24.7M|  if (signchar)
  ------------------
  |  Branch (993:7): [True: 0, False: 24.7M]
  ------------------
  994|      0|    {
  995|      0|      rc = outfnc (outfncarg, &signchar, 1);
  996|      0|      if (rc)
  ------------------
  |  Branch (996:11): [True: 0, False: 0]
  ------------------
  997|      0|        return rc;
  998|      0|      *nbytes += 1;
  999|      0|    }
 1000|       |
 1001|  24.7M|  if ((arg->flags & FLAG_ALT_CONV)
  ------------------
  |  |  140|  24.7M|#define FLAG_ALT_CONV   16
  ------------------
  |  Branch (1001:7): [True: 0, False: 24.7M]
  ------------------
 1002|  24.7M|      && (arg->conspec == CONSPEC_HEX || arg->conspec == CONSPEC_HEX_UP))
  ------------------
  |  Branch (1002:11): [True: 0, False: 0]
  |  Branch (1002:42): [True: 0, False: 0]
  ------------------
 1003|      0|    {
 1004|      0|      rc = outfnc (outfncarg, arg->conspec == CONSPEC_HEX? "0x": "0X", 2);
  ------------------
  |  Branch (1004:31): [True: 0, False: 0]
  ------------------
 1005|      0|      if (rc)
  ------------------
  |  Branch (1005:11): [True: 0, False: 0]
  ------------------
 1006|      0|        return rc;
 1007|      0|      *nbytes += 2;
 1008|      0|    }
 1009|       |
 1010|  24.7M|  if (n_prec)
  ------------------
  |  Branch (1010:7): [True: 16.6M, False: 8.04M]
  ------------------
 1011|  16.6M|    {
 1012|  16.6M|      rc = pad_out (outfnc, outfncarg, '0', n_prec, nbytes);
 1013|  16.6M|      if (rc)
  ------------------
  |  Branch (1013:11): [True: 0, False: 16.6M]
  ------------------
 1014|      0|        return rc;
 1015|  16.6M|    }
 1016|       |
 1017|  24.7M|  rc = outfnc (outfncarg, p, pend - p);
 1018|  24.7M|  if (rc)
  ------------------
  |  Branch (1018:7): [True: 0, False: 24.7M]
  ------------------
 1019|      0|    return rc;
 1020|  24.7M|  *nbytes += pend - p;
 1021|       |
 1022|  24.7M|  if ((arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  137|  24.7M|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (1022:7): [True: 0, False: 24.7M]
  ------------------
 1023|  24.7M|      && arg->width >= 0 && arg->width - n_extra - n_prec > n)
  ------------------
  |  Branch (1023:10): [True: 0, False: 0]
  |  Branch (1023:29): [True: 0, False: 0]
  ------------------
 1024|      0|    {
 1025|      0|      rc = pad_out (outfnc, outfncarg, ' ',
 1026|      0|                    arg->width - n_extra - n_prec - n, nbytes);
 1027|      0|      if (rc)
  ------------------
  |  Branch (1027:11): [True: 0, False: 0]
  ------------------
 1028|      0|        return rc;
 1029|      0|    }
 1030|       |
 1031|  24.7M|  return 0;
 1032|  24.7M|}
estream-printf.c:pad_out:
  814|  33.3M|{
  815|  33.3M|  char buf[32];
  816|  33.3M|  size_t n;
  817|  33.3M|  int rc;
  818|       |
  819|  50.0M|  while (count > 0)
  ------------------
  |  Branch (819:10): [True: 16.6M, False: 33.3M]
  ------------------
  820|  16.6M|    {
  821|  16.6M|      n = (count <= sizeof buf)? count : sizeof buf;
  ------------------
  |  Branch (821:11): [True: 16.6M, False: 453]
  ------------------
  822|  16.6M|      memset (buf, padchar, n);
  823|  16.6M|      rc = outfnc (outfncarg, buf, n);
  824|  16.6M|      if (rc)
  ------------------
  |  Branch (824:11): [True: 0, False: 16.6M]
  ------------------
  825|      0|        return rc;
  826|  16.6M|      *nbytes += n;
  827|  16.6M|      count -= n;
  828|  16.6M|    }
  829|       |
  830|  33.3M|  return 0;
  831|  33.3M|}
estream-printf.c:pr_char:
 1169|  9.70k|{
 1170|  9.70k|  int rc;
 1171|  9.70k|  char buf[1];
 1172|       |
 1173|  9.70k|  if (arg->vt != VALTYPE_INT)
  ------------------
  |  Branch (1173:7): [True: 0, False: 9.70k]
  ------------------
 1174|      0|    return -1;
 1175|  9.70k|  buf[0] = (unsigned int)value.a_int;
 1176|  9.70k|  rc = outfnc (outfncarg, buf, 1);
 1177|  9.70k|  if(rc)
  ------------------
  |  Branch (1177:6): [True: 0, False: 9.70k]
  ------------------
 1178|      0|    return rc;
 1179|  9.70k|  *nbytes += 1;
 1180|       |
 1181|  9.70k|  return 0;
 1182|  9.70k|}
estream-printf.c:pr_string:
 1190|  17.5M|{
 1191|  17.5M|  int rc;
 1192|  17.5M|  size_t n;
 1193|  17.5M|  const char *string, *s;
 1194|       |
 1195|  17.5M|  if (arg->vt != VALTYPE_STRING)
  ------------------
  |  Branch (1195:7): [True: 0, False: 17.5M]
  ------------------
 1196|      0|    return -1;
 1197|  17.5M|  if (sf)
  ------------------
  |  Branch (1197:7): [True: 16.2M, False: 1.31M]
  ------------------
 1198|  16.2M|    string = sf (value.a_string, string_no, sfvalue);
 1199|  1.31M|  else
 1200|  1.31M|    string = value.a_string;
 1201|       |
 1202|  17.5M|  if (!string)
  ------------------
  |  Branch (1202:7): [True: 0, False: 17.5M]
  ------------------
 1203|      0|    string = "(null)";
 1204|  17.5M|  if (arg->precision >= 0)
  ------------------
  |  Branch (1204:7): [True: 3, False: 17.5M]
  ------------------
 1205|      3|    {
 1206|       |      /* Test for nul after N so that we can pass a non-nul terminated
 1207|       |         string.  */
 1208|     51|      for (n=0,s=string; n < arg->precision && *s; s++)
  ------------------
  |  Branch (1208:26): [True: 48, False: 3]
  |  Branch (1208:48): [True: 48, False: 0]
  ------------------
 1209|     48|        n++;
 1210|      3|    }
 1211|  17.5M|  else
 1212|  17.5M|    n = strlen (string);
 1213|       |
 1214|  17.5M|  if (!(arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  137|  17.5M|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (1214:7): [True: 17.5M, False: 0]
  ------------------
 1215|  17.5M|      && arg->width >= 0 && arg->width > n )
  ------------------
  |  Branch (1215:10): [True: 1.38k, False: 17.5M]
  |  Branch (1215:29): [True: 1.38k, False: 0]
  ------------------
 1216|  1.38k|    {
 1217|  1.38k|      rc = pad_out (outfnc, outfncarg, ' ', arg->width - n, nbytes);
 1218|  1.38k|      if (rc)
  ------------------
  |  Branch (1218:11): [True: 0, False: 1.38k]
  ------------------
 1219|      0|        goto leave;
 1220|  1.38k|    }
 1221|       |
 1222|  17.5M|  rc = outfnc (outfncarg, string, n);
 1223|  17.5M|  if (rc)
  ------------------
  |  Branch (1223:7): [True: 0, False: 17.5M]
  ------------------
 1224|      0|    goto leave;
 1225|  17.5M|  *nbytes += n;
 1226|       |
 1227|  17.5M|  if ((arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  137|  17.5M|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (1227:7): [True: 0, False: 17.5M]
  ------------------
 1228|  17.5M|      && arg->width >= 0 && arg->width > n)
  ------------------
  |  Branch (1228:10): [True: 0, False: 0]
  |  Branch (1228:29): [True: 0, False: 0]
  ------------------
 1229|      0|    {
 1230|      0|      rc = pad_out (outfnc, outfncarg, ' ', arg->width - n, nbytes);
 1231|      0|      if (rc)
  ------------------
  |  Branch (1231:11): [True: 0, False: 0]
  ------------------
 1232|      0|        goto leave;
 1233|      0|    }
 1234|       |
 1235|  17.5M|  rc = 0;
 1236|       |
 1237|  17.5M| leave:
 1238|  17.5M|  if (sf) /* Tell the filter to release resources.  */
  ------------------
  |  Branch (1238:7): [True: 16.2M, False: 1.31M]
  ------------------
 1239|  16.2M|    sf (value.a_string, -1, sfvalue);
 1240|       |
 1241|  17.5M|  return rc;
 1242|  17.5M|}
estream-printf.c:pr_pointer:
 1249|  1.14k|{
 1250|  1.14k|  int rc;
 1251|       |#if defined(HAVE_LONG_LONG_INT) && (SIZEOF_UNSIGNED_LONG < SIZEOF_VOID_P)
 1252|       |  unsigned long long aulong;
 1253|       |#else
 1254|  1.14k|  unsigned long aulong;
 1255|  1.14k|#endif
 1256|  1.14k|  char numbuf[100];
 1257|  1.14k|  char *p, *pend;
 1258|       |
 1259|  1.14k|  if (arg->vt != VALTYPE_POINTER)
  ------------------
  |  Branch (1259:7): [True: 0, False: 1.14k]
  ------------------
 1260|      0|    return -1;
 1261|       |  /* We assume that a pointer can be converted to an unsigned long.
 1262|       |     That is not correct for a 64 bit Windows, but then we assume that
 1263|       |     long long is supported and usable for storing a pointer.  */
 1264|       |#if defined(HAVE_LONG_LONG_INT) && (SIZEOF_UNSIGNED_LONG < SIZEOF_VOID_P)
 1265|       |  aulong = (unsigned long long)value.a_void_ptr;
 1266|       |#else
 1267|  1.14k|  aulong = (unsigned long)value.a_void_ptr;
 1268|  1.14k|#endif
 1269|       |
 1270|  1.14k|  p = pend = numbuf + DIM(numbuf);
  ------------------
  |  |   93|  1.14k|# define DIM(array) (sizeof (array) / sizeof (*array))
  ------------------
 1271|  1.14k|  do
 1272|  7.98k|    {
 1273|  7.98k|      *--p = "0123456789abcdefx"[(aulong % 16)];
 1274|  7.98k|      aulong /= 16;
 1275|  7.98k|    }
 1276|  7.98k|  while (aulong);
  ------------------
  |  Branch (1276:10): [True: 6.84k, False: 1.14k]
  ------------------
 1277|  11.4k|  while ((pend-p) < 2*sizeof (aulong))
  ------------------
  |  Branch (1277:10): [True: 10.2k, False: 1.14k]
  ------------------
 1278|  10.2k|    *--p = '0';
 1279|  1.14k|  *--p = 'x';
 1280|  1.14k|  *--p = '0';
 1281|       |
 1282|  1.14k|  rc = outfnc (outfncarg, p, pend - p);
 1283|  1.14k|  if (rc)
  ------------------
  |  Branch (1283:7): [True: 0, False: 1.14k]
  ------------------
 1284|      0|    return rc;
 1285|  1.14k|  *nbytes += pend - p;
 1286|       |
 1287|  1.14k|  return 0;
 1288|  1.14k|}
estream-printf.c:fixed_buffer_out:
 1704|  34.0M|{
 1705|  34.0M|  struct fixed_buffer_parm_s *parm = outfncarg;
 1706|       |
 1707|  34.0M|  parm->count += buflen;
 1708|       |
 1709|  34.0M|  if (!parm->buffer)
  ------------------
  |  Branch (1709:7): [True: 0, False: 34.0M]
  ------------------
 1710|      0|    ;
 1711|  34.0M|  else if (parm->used + buflen < parm->size)
  ------------------
  |  Branch (1711:12): [True: 34.0M, False: 0]
  ------------------
 1712|  34.0M|    {
 1713|       |      /* Handle the common case that everything fits into the buffer
 1714|       |         separately.  */
 1715|  34.0M|      memcpy (parm->buffer + parm->used, buf, buflen);
 1716|  34.0M|      parm->used += buflen;
 1717|  34.0M|    }
 1718|      0|  else
 1719|      0|    {
 1720|       |      /* The slow version of above.  */
 1721|      0|      for ( ;buflen && parm->used < parm->size; buflen--)
  ------------------
  |  Branch (1721:14): [True: 0, False: 0]
  |  Branch (1721:24): [True: 0, False: 0]
  ------------------
 1722|      0|        parm->buffer[parm->used++] = *buf++;
 1723|      0|    }
 1724|       |
 1725|  34.0M|  return 0;
 1726|  34.0M|}

_gpgrt_estream_init:
  595|      2|{
  596|      2|  static int initialized;
  597|       |
  598|      2|  if (!initialized)
  ------------------
  |  Branch (598:7): [True: 2, False: 0]
  ------------------
  599|      2|    {
  600|      2|      initialized = 1;
  601|      2|      atexit (do_deinit);
  602|      2|    }
  603|      2|  return 0;
  604|      2|}
_gpgrt_fopen:
 3509|  58.8k|{
 3510|  58.8k|  unsigned int modeflags, cmode, xmode;
 3511|  58.8k|  int create_called = 0;
 3512|  58.8k|  estream_t stream = NULL;
 3513|  58.8k|  void *cookie = NULL;
 3514|  58.8k|  int err;
 3515|  58.8k|  struct cookie_io_functions_s *functions;
 3516|  58.8k|  es_syshd_t syshd;
 3517|  58.8k|  int kind;
 3518|       |
 3519|  58.8k|  err = parse_mode (mode, &modeflags, &xmode, &cmode);
 3520|  58.8k|  if (err)
  ------------------
  |  Branch (3520:7): [True: 0, False: 58.8k]
  ------------------
 3521|      0|    goto leave;
 3522|       |
 3523|       |  /* Convenience hack so that we can use /dev/null on Windows.  */
 3524|       |#ifdef HAVE_W32_SYSTEM
 3525|       |  if (path && !strcmp (path, "/dev/null"))
 3526|       |    path = "nul";
 3527|       |#endif
 3528|       |
 3529|       |#ifdef HAVE_W32_SYSTEM
 3530|       |  if ((xmode & X_SYSOPEN))
 3531|       |    {
 3532|       |      kind = BACKEND_W32;
 3533|       |      functions = &estream_functions_w32;
 3534|       |      syshd.type = ES_SYSHD_HANDLE;
 3535|       |      err = func_file_create_w32 (&cookie, &syshd.u.handle,
 3536|       |                                  path, modeflags, cmode);
 3537|       |    }
 3538|       |  else
 3539|       |#endif /* W32 */
 3540|  58.8k|    {
 3541|  58.8k|      kind = BACKEND_FD;
 3542|  58.8k|      functions = &estream_functions_fd;
 3543|  58.8k|      syshd.type = ES_SYSHD_FD;
  ------------------
  |  | 1255|  58.8k|#define ES_SYSHD_FD     GPGRT_SYSHD_FD
  ------------------
 3544|  58.8k|      err = func_file_create (&cookie, &syshd.u.fd,
 3545|  58.8k|                              path, modeflags, cmode);
 3546|  58.8k|    }
 3547|  58.8k|  if (err)
  ------------------
  |  Branch (3547:7): [True: 2, False: 58.8k]
  ------------------
 3548|      2|    goto leave;
 3549|       |
 3550|  58.8k|  create_called = 1;
 3551|  58.8k|  err = create_stream (&stream, cookie, &syshd, kind,
 3552|  58.8k|                       *functions, modeflags, xmode, 0);
 3553|  58.8k|  if (err)
  ------------------
  |  Branch (3553:7): [True: 0, False: 58.8k]
  ------------------
 3554|      0|    goto leave;
 3555|       |
 3556|  58.8k|  if (stream && path)
  ------------------
  |  Branch (3556:7): [True: 58.8k, False: 0]
  |  Branch (3556:17): [True: 58.8k, False: 0]
  ------------------
 3557|  58.8k|    fname_set_internal (stream, path, 1);
 3558|       |
 3559|  58.8k| leave:
 3560|  58.8k|  if (err && create_called)
  ------------------
  |  Branch (3560:7): [True: 2, False: 58.8k]
  |  Branch (3560:14): [True: 0, False: 2]
  ------------------
 3561|      0|    functions->public.func_close (cookie);
 3562|       |
 3563|  58.8k|  return stream;
 3564|  58.8k|}
_gpgrt__get_std_stream:
 4001|      3|{
 4002|      3|  estream_list_t list_obj;
 4003|      3|  estream_t stream = NULL;
 4004|       |
 4005|      3|  fd %= 3; /* We only allow 0, 1 or 2 but we don't want to return an error. */
 4006|       |
 4007|      3|  lock_list ();
 4008|       |
 4009|      5|  for (list_obj = estream_list; list_obj; list_obj = list_obj->next)
  ------------------
  |  Branch (4009:33): [True: 3, False: 2]
  ------------------
 4010|      3|    if (list_obj->stream && list_obj->stream->intern->is_stdstream
  ------------------
  |  Branch (4010:9): [True: 3, False: 0]
  |  Branch (4010:29): [True: 2, False: 1]
  ------------------
 4011|      3|        && list_obj->stream->intern->stdstream_fd == fd)
  ------------------
  |  Branch (4011:12): [True: 1, False: 1]
  ------------------
 4012|      1|      {
 4013|      1|	stream = list_obj->stream;
 4014|      1|	break;
 4015|      1|      }
 4016|      3|  if (!stream)
  ------------------
  |  Branch (4016:7): [True: 2, False: 1]
  ------------------
 4017|      2|    {
 4018|       |      /* Standard stream not yet created.  We first try to create them
 4019|       |         from registered file descriptors.  */
 4020|      2|      if (!fd && custom_std_fds_valid[0])
  ------------------
  |  Branch (4020:11): [True: 0, False: 2]
  |  Branch (4020:18): [True: 0, False: 0]
  ------------------
 4021|      0|        stream = do_fdopen (custom_std_fds[0], "r", 1, 1);
 4022|      2|      else if (fd == 1 && custom_std_fds_valid[1])
  ------------------
  |  Branch (4022:16): [True: 1, False: 1]
  |  Branch (4022:27): [True: 0, False: 1]
  ------------------
 4023|      0|        stream = do_fdopen (custom_std_fds[1], "a", 1, 1);
 4024|      2|      else if (custom_std_fds_valid[2])
  ------------------
  |  Branch (4024:16): [True: 0, False: 2]
  ------------------
 4025|      0|        stream = do_fdopen (custom_std_fds[2], "a", 1, 1);
 4026|       |
 4027|      2|      if (!stream)
  ------------------
  |  Branch (4027:11): [True: 2, False: 0]
  ------------------
 4028|      2|        {
 4029|       |          /* Second try is to use the standard C streams.  */
 4030|      2|          if (!fd)
  ------------------
  |  Branch (4030:15): [True: 0, False: 2]
  ------------------
 4031|      0|            stream = do_fpopen (stdin, "r", 1, 1);
 4032|      2|          else if (fd == 1)
  ------------------
  |  Branch (4032:20): [True: 1, False: 1]
  ------------------
 4033|      1|            stream = do_fpopen (stdout, "a", 1, 1);
 4034|      1|          else
 4035|      1|            stream = do_fpopen (stderr, "a", 1, 1);
 4036|      2|        }
 4037|       |
 4038|      2|      if (!stream)
  ------------------
  |  Branch (4038:11): [True: 0, False: 2]
  ------------------
 4039|      0|        {
 4040|       |          /* Last try: Create a bit bucket.  */
 4041|      0|          stream = do_fpopen (NULL, fd? "a":"r", 0, 1);
  ------------------
  |  Branch (4041:37): [True: 0, False: 0]
  ------------------
 4042|      0|          if (!stream)
  ------------------
  |  Branch (4042:15): [True: 0, False: 0]
  ------------------
 4043|      0|            {
 4044|      0|              fprintf (stderr, "fatal: error creating a dummy estream"
 4045|      0|                       " for %d: %s\n", fd, strerror (errno));
 4046|      0|              _gpgrt_abort();
 4047|      0|            }
 4048|      0|        }
 4049|       |
 4050|      2|      stream->intern->is_stdstream = 1;
 4051|      2|      stream->intern->stdstream_fd = fd;
 4052|      2|      if (fd == 2)
  ------------------
  |  Branch (4052:11): [True: 1, False: 1]
  ------------------
 4053|      1|        es_set_buffering (stream, NULL, _IOLBF, 0);
 4054|      2|      fname_set_internal (stream,
 4055|      2|                          fd == 0? "[stdin]" :
  ------------------
  |  Branch (4055:27): [True: 0, False: 2]
  ------------------
 4056|      2|                          fd == 1? "[stdout]" : "[stderr]", 0);
  ------------------
  |  Branch (4056:27): [True: 1, False: 1]
  ------------------
 4057|      2|    }
 4058|       |
 4059|      3|  unlock_list ();
 4060|      3|  return stream;
 4061|      3|}
_gpgrt_fclose:
 4144|  58.8k|{
 4145|  58.8k|  int err;
 4146|       |
 4147|  58.8k|  err = do_close (stream, 0, 0);
 4148|       |
 4149|  58.8k|  return err;
 4150|  58.8k|}
_gpgrt_flockfile:
 4302|  9.93M|{
 4303|  9.93M|  lock_stream (stream);
 4304|  9.93M|}
_gpgrt_funlockfile:
 4316|  9.93M|{
 4317|  9.93M|  unlock_stream (stream);
 4318|  9.93M|}
_gpgrt_ferror_unlocked:
 4401|   118k|{
 4402|   118k|  return stream->intern->indicators.err;
 4403|   118k|}
_gpgrt_ferror:
 4408|  58.9k|{
 4409|  58.9k|  int ret;
 4410|       |
 4411|  58.9k|  lock_stream (stream);
 4412|  58.9k|  ret = _gpgrt_ferror_unlocked (stream);
 4413|  58.9k|  unlock_stream (stream);
 4414|       |
 4415|  58.9k|  return ret;
 4416|  58.9k|}
_gpgrt_fseeko:
 4500|  6.86M|{
 4501|  6.86M|  int err;
 4502|       |
 4503|  6.86M|  lock_stream (stream);
 4504|  6.86M|  err = es_seek (stream, offset, whence, NULL);
 4505|  6.86M|  unlock_stream (stream);
 4506|       |
 4507|  6.86M|  return err;
 4508|  6.86M|}
_gpgrt_ftello:
 4526|   117k|{
 4527|   117k|  gpgrt_off_t ret = -1;
 4528|       |
 4529|   117k|  lock_stream (stream);
 4530|   117k|  ret = es_offset_calculate (stream);
 4531|   117k|  unlock_stream (stream);
 4532|       |
 4533|   117k|  return ret;
 4534|   117k|}
_gpgrt__getc_underflow:
 4573|   117k|{
 4574|   117k|  int err;
 4575|   117k|  unsigned char c;
 4576|   117k|  size_t bytes_read;
 4577|       |
 4578|   117k|  err = es_readn (stream, &c, 1, &bytes_read);
 4579|       |
 4580|   117k|  return (err || (! bytes_read)) ? EOF : c;
  ------------------
  |  Branch (4580:11): [True: 0, False: 117k]
  |  Branch (4580:18): [True: 58.9k, False: 58.9k]
  ------------------
 4581|   117k|}
_gpgrt__putc_overflow:
 4586|   183k|{
 4587|   183k|  unsigned char d = c;
 4588|   183k|  int err;
 4589|       |
 4590|   183k|  err = es_writen (stream, &d, 1, NULL);
 4591|       |
 4592|   183k|  return err ? EOF : c;
  ------------------
  |  Branch (4592:10): [True: 0, False: 183k]
  ------------------
 4593|   183k|}
_gpgrt_fgetc:
 4598|   353k|{
 4599|   353k|  int ret;
 4600|       |
 4601|   353k|  lock_stream (stream);
 4602|   353k|  ret = _gpgrt_getc_unlocked (stream);
  ------------------
  |  |  395|   353k|  (((!(stream)->flags.writing)					\
  |  |  ------------------
  |  |  |  Branch (395:5): [True: 353k, False: 0]
  |  |  ------------------
  |  |  396|   353k|    && ((stream)->data_offset < (stream)->data_len)		\
  |  |  ------------------
  |  |  |  Branch (396:8): [True: 235k, False: 117k]
  |  |  ------------------
  |  |  397|   353k|    && (! (stream)->unread_data_len))				\
  |  |  ------------------
  |  |  |  Branch (397:8): [True: 235k, False: 0]
  |  |  ------------------
  |  |  398|   353k|  ? ((int) (stream)->buffer[((stream)->data_offset)++])		\
  |  |  399|   353k|  : _gpgrt__getc_underflow ((stream)))
  ------------------
 4603|   353k|  unlock_stream (stream);
 4604|       |
 4605|   353k|  return ret;
 4606|   353k|}
_gpgrt_fputc:
 4611|   700k|{
 4612|   700k|  int ret;
 4613|       |
 4614|   700k|  lock_stream (stream);
 4615|   700k|  ret = _gpgrt_putc_unlocked (c, stream);
  ------------------
  |  |  402|   700k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 700k, False: 0]
  |  |  ------------------
  |  |  403|   700k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 700k, False: 82]
  |  |  ------------------
  |  |  404|   700k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [True: 517k, False: 183k]
  |  |  ------------------
  |  |  405|   700k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|   700k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 4616|   700k|  unlock_stream (stream);
 4617|       |
 4618|   700k|  return ret;
 4619|   700k|}
_gpgrt_fread:
 4679|  58.9k|{
 4680|  58.9k|  size_t ret, bytes;
 4681|       |
 4682|  58.9k|  if (size && nitems)
  ------------------
  |  Branch (4682:7): [True: 58.9k, False: 0]
  |  Branch (4682:15): [True: 58.9k, False: 0]
  ------------------
 4683|  58.9k|    {
 4684|  58.9k|      lock_stream (stream);
 4685|  58.9k|      es_readn (stream, ptr, size * nitems, &bytes);
 4686|  58.9k|      unlock_stream (stream);
 4687|       |
 4688|  58.9k|      ret = bytes / size;
 4689|  58.9k|    }
 4690|      0|  else
 4691|      0|    ret = 0;
 4692|       |
 4693|  58.9k|  return ret;
 4694|  58.9k|}
_gpgrt_fwrite:
 4700|      1|{
 4701|      1|  size_t ret, bytes;
 4702|       |
 4703|      1|  if (size && nitems)
  ------------------
  |  Branch (4703:7): [True: 1, False: 0]
  |  Branch (4703:15): [True: 1, False: 0]
  ------------------
 4704|      1|    {
 4705|      1|      lock_stream (stream);
 4706|      1|      es_writen (stream, ptr, size * nitems, &bytes);
 4707|      1|      unlock_stream (stream);
 4708|       |
 4709|      1|      ret = bytes / size;
 4710|      1|    }
 4711|      0|  else
 4712|      0|    ret = 0;
 4713|       |
 4714|      1|  return ret;
 4715|      1|}
_gpgrt_fputs:
 4762|   124k|{
 4763|   124k|  size_t length;
 4764|   124k|  int err;
 4765|       |
 4766|   124k|  length = strlen (s);
 4767|   124k|  lock_stream (stream);
 4768|   124k|  err = es_writen (stream, s, length, NULL);
 4769|   124k|  unlock_stream (stream);
 4770|       |
 4771|   124k|  return err ? EOF : 0;
  ------------------
  |  Branch (4771:10): [True: 0, False: 124k]
  ------------------
 4772|   124k|}
_gpgrt_vfprintf_unlocked:
 4961|  9.93M|{
 4962|  9.93M|  return do_print_stream (stream, sf, sfvalue, format, ap);
 4963|  9.93M|}
_gpgrt_vfprintf:
 4971|  5.43M|{
 4972|  5.43M|  int ret;
 4973|       |
 4974|  5.43M|  lock_stream (stream);
 4975|  5.43M|  ret = do_print_stream (stream, sf, sfvalue, format, ap);
 4976|  5.43M|  unlock_stream (stream);
 4977|       |
 4978|  5.43M|  return ret;
 4979|  5.43M|}
_gpgrt_fprintf_unlocked:
 4985|   567k|{
 4986|   567k|  int ret;
 4987|       |
 4988|   567k|  va_list ap;
 4989|   567k|  va_start (ap, format);
 4990|   567k|  ret = do_print_stream (stream, NULL, NULL, format, ap);
 4991|   567k|  va_end (ap);
 4992|       |
 4993|   567k|  return ret;
 4994|   567k|}
_gpgrt_setvbuf:
 5145|      2|{
 5146|      2|  int err;
 5147|       |
 5148|      2|  if ((type == _IOFBF || type == _IOLBF || type == _IONBF)
  ------------------
  |  Branch (5148:8): [True: 0, False: 2]
  |  Branch (5148:26): [True: 2, False: 0]
  |  Branch (5148:44): [True: 0, False: 0]
  ------------------
 5149|      2|      && (!buf || size || type == _IONBF))
  ------------------
  |  Branch (5149:11): [True: 2, False: 0]
  |  Branch (5149:19): [True: 0, False: 0]
  |  Branch (5149:27): [True: 0, False: 0]
  ------------------
 5150|      2|    {
 5151|      2|      lock_stream (stream);
 5152|      2|      err = es_set_buffering (stream, buf, type, size);
 5153|      2|      unlock_stream (stream);
 5154|      2|    }
 5155|      0|  else
 5156|      0|    {
 5157|      0|      _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5158|      0|      err = -1;
 5159|      0|    }
 5160|       |
 5161|      2|  return err;
 5162|      2|}
_gpgrt_write_sanitized:
 5665|  22.9k|{
 5666|  22.9k|  const unsigned char *p = buffer;
 5667|  22.9k|  size_t count = 0;
 5668|  22.9k|  int ret;
 5669|       |
 5670|  22.9k|  lock_stream (stream);
 5671|  1.17M|  for (; length; length--, p++, count++)
  ------------------
  |  Branch (5671:10): [True: 1.15M, False: 22.9k]
  ------------------
 5672|  1.15M|    {
 5673|  1.15M|      if (*p < 0x20
  ------------------
  |  Branch (5673:11): [True: 677k, False: 479k]
  ------------------
 5674|  1.15M|          || *p == 0x7f
  ------------------
  |  Branch (5674:14): [True: 2.06k, False: 477k]
  ------------------
 5675|  1.15M|          || (delimiters
  ------------------
  |  Branch (5675:15): [True: 4.00k, False: 473k]
  ------------------
 5676|   477k|              && (strchr (delimiters, *p) || *p == '\\')))
  ------------------
  |  Branch (5676:19): [True: 408, False: 3.59k]
  |  Branch (5676:46): [True: 605, False: 2.98k]
  ------------------
 5677|   680k|        {
 5678|   680k|          _gpgrt_putc_unlocked ('\\', stream);
  ------------------
  |  |  402|   680k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 680k, False: 0]
  |  |  ------------------
  |  |  403|   680k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 680k, False: 39]
  |  |  ------------------
  |  |  404|   680k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|   680k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|   680k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5679|   680k|          count++;
 5680|   680k|          if (*p == '\n')
  ------------------
  |  Branch (5680:15): [True: 17.3k, False: 663k]
  ------------------
 5681|  17.3k|            {
 5682|  17.3k|              _gpgrt_putc_unlocked ('n', stream);
  ------------------
  |  |  402|  17.3k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 17.3k, False: 0]
  |  |  ------------------
  |  |  403|  17.3k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 17.2k, False: 47]
  |  |  ------------------
  |  |  404|  17.3k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|  17.3k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  17.3k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5683|  17.3k|              count++;
 5684|  17.3k|            }
 5685|   663k|          else if (*p == '\r')
  ------------------
  |  Branch (5685:20): [True: 14.1k, False: 649k]
  ------------------
 5686|  14.1k|            {
 5687|  14.1k|              _gpgrt_putc_unlocked ('r', stream);
  ------------------
  |  |  402|  14.1k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 14.1k, False: 0]
  |  |  ------------------
  |  |  403|  14.1k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 14.1k, False: 10]
  |  |  ------------------
  |  |  404|  14.1k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|  14.1k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  14.1k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5688|  14.1k|              count++;
 5689|  14.1k|            }
 5690|   649k|          else if (*p == '\f')
  ------------------
  |  Branch (5690:20): [True: 4.02k, False: 645k]
  ------------------
 5691|  4.02k|            {
 5692|  4.02k|              _gpgrt_putc_unlocked ('f', stream);
  ------------------
  |  |  402|  4.02k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 4.02k, False: 0]
  |  |  ------------------
  |  |  403|  4.02k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 4.00k, False: 15]
  |  |  ------------------
  |  |  404|  4.02k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|  4.02k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  4.02k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5693|  4.02k|              count++;
 5694|  4.02k|            }
 5695|   645k|          else if (*p == '\v')
  ------------------
  |  Branch (5695:20): [True: 1.89k, False: 643k]
  ------------------
 5696|  1.89k|            {
 5697|  1.89k|              _gpgrt_putc_unlocked ('v', stream);
  ------------------
  |  |  402|  1.89k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 1.89k, False: 0]
  |  |  ------------------
  |  |  403|  1.89k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 1.87k, False: 19]
  |  |  ------------------
  |  |  404|  1.89k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|  1.89k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  1.89k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5698|  1.89k|              count++;
 5699|  1.89k|            }
 5700|   643k|          else if (*p == '\b')
  ------------------
  |  Branch (5700:20): [True: 5.46k, False: 637k]
  ------------------
 5701|  5.46k|            {
 5702|  5.46k|              _gpgrt_putc_unlocked ('b', stream);
  ------------------
  |  |  402|  5.46k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 5.46k, False: 0]
  |  |  ------------------
  |  |  403|  5.46k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 5.45k, False: 10]
  |  |  ------------------
  |  |  404|  5.46k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|  5.46k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  5.46k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5703|  5.46k|              count++;
 5704|  5.46k|            }
 5705|   637k|          else if (!*p)
  ------------------
  |  Branch (5705:20): [True: 69.9k, False: 567k]
  ------------------
 5706|  69.9k|            {
 5707|  69.9k|              _gpgrt_putc_unlocked('0', stream);
  ------------------
  |  |  402|  69.9k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 69.9k, False: 0]
  |  |  ------------------
  |  |  403|  69.9k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 69.9k, False: 20]
  |  |  ------------------
  |  |  404|  69.9k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|  69.9k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  69.9k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5708|  69.9k|              count++;
 5709|  69.9k|            }
 5710|   567k|          else
 5711|   567k|            {
 5712|   567k|              _gpgrt_fprintf_unlocked (stream, "x%02x", *p);
 5713|   567k|              count += 3;
 5714|   567k|            }
 5715|   680k|	}
 5716|   476k|      else
 5717|   476k|        {
 5718|   476k|          _gpgrt_putc_unlocked (*p, stream);
  ------------------
  |  |  402|   476k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 476k, False: 0]
  |  |  ------------------
  |  |  403|   476k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 476k, False: 25]
  |  |  ------------------
  |  |  404|   476k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [True: 476k, False: 0]
  |  |  ------------------
  |  |  405|   476k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|   476k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5719|   476k|          count++;
 5720|   476k|        }
 5721|  1.15M|    }
 5722|       |
 5723|  22.9k|  if (bytes_written)
  ------------------
  |  Branch (5723:7): [True: 0, False: 22.9k]
  ------------------
 5724|      0|    *bytes_written = count;
 5725|  22.9k|  ret =  _gpgrt_ferror_unlocked (stream)? -1 : 0;
  ------------------
  |  Branch (5725:10): [True: 0, False: 22.9k]
  ------------------
 5726|  22.9k|  unlock_stream (stream);
 5727|       |
 5728|  22.9k|  return ret;
 5729|  22.9k|}
_gpgrt_write_hexstring:
 5740|  36.3k|{
 5741|  36.3k|  int ret;
 5742|  36.3k|  const unsigned char *s;
 5743|  36.3k|  size_t count = 0;
 5744|       |
 5745|  36.3k|  (void)reserved;
 5746|       |
 5747|  36.3k|#define tohex(n) ((n) < 10 ? ((n) + '0') : (((n) - 10) + 'A'))
 5748|       |
 5749|  36.3k|  if (!length)
  ------------------
  |  Branch (5749:7): [True: 0, False: 36.3k]
  ------------------
 5750|      0|    return 0;
 5751|       |
 5752|  36.3k|  lock_stream (stream);
 5753|       |
 5754|   350k|  for (s = buffer; length; s++, length--)
  ------------------
  |  Branch (5754:20): [True: 313k, False: 36.3k]
  ------------------
 5755|   313k|    {
 5756|   313k|      _gpgrt_putc_unlocked ( tohex ((*s>>4)&15), stream);
  ------------------
  |  |  402|   313k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 313k, False: 0]
  |  |  ------------------
  |  |  403|   313k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 313k, False: 27]
  |  |  ------------------
  |  |  404|   627k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [True: 313k, False: 0]
  |  |  |  Branch (404:9): [True: 259k, False: 54.5k]
  |  |  ------------------
  |  |  405|   627k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  ------------------
  |  |  |  Branch (405:60): [True: 259k, False: 54.5k]
  |  |  ------------------
  |  |  406|   313k|  : _gpgrt__putc_overflow ((c), (stream)))
  |  |  ------------------
  |  |  |  Branch (406:29): [True: 22, False: 5]
  |  |  ------------------
  ------------------
 5757|   313k|      _gpgrt_putc_unlocked ( tohex (*s&15), stream);
  ------------------
  |  |  402|   313k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 313k, False: 0]
  |  |  ------------------
  |  |  403|   313k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 313k, False: 32]
  |  |  ------------------
  |  |  404|   627k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [True: 313k, False: 0]
  |  |  |  Branch (404:9): [True: 220k, False: 93.2k]
  |  |  ------------------
  |  |  405|   627k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  ------------------
  |  |  |  Branch (405:60): [True: 220k, False: 93.2k]
  |  |  ------------------
  |  |  406|   313k|  : _gpgrt__putc_overflow ((c), (stream)))
  |  |  ------------------
  |  |  |  Branch (406:29): [True: 16, False: 16]
  |  |  ------------------
  ------------------
 5758|   313k|      count += 2;
 5759|   313k|    }
 5760|       |
 5761|  36.3k|  if (bytes_written)
  ------------------
  |  Branch (5761:7): [True: 0, False: 36.3k]
  ------------------
 5762|      0|    *bytes_written = count;
 5763|  36.3k|  ret = _gpgrt_ferror_unlocked (stream)? -1 : 0;
  ------------------
  |  Branch (5763:9): [True: 0, False: 36.3k]
  ------------------
 5764|       |
 5765|  36.3k|  unlock_stream (stream);
 5766|       |
 5767|  36.3k|  return ret;
 5768|       |
 5769|  36.3k|#undef tohex
 5770|  36.3k|}
estream.c:parse_mode:
 2101|  58.8k|{
 2102|  58.8k|  unsigned int omode, oflags, cmode;
 2103|  58.8k|  int got_cmode = 0;
 2104|       |
 2105|  58.8k|  *r_xmode = 0;
 2106|       |
 2107|  58.8k|  switch (*modestr)
 2108|  58.8k|    {
 2109|  58.8k|    case 'r':
  ------------------
  |  Branch (2109:5): [True: 58.8k, False: 5]
  ------------------
 2110|  58.8k|      omode = O_RDONLY;
 2111|  58.8k|      oflags = 0;
 2112|  58.8k|      break;
 2113|      2|    case 'w':
  ------------------
  |  Branch (2113:5): [True: 2, False: 58.8k]
  ------------------
 2114|      2|      omode = O_WRONLY;
 2115|      2|      oflags = O_TRUNC | O_CREAT;
 2116|      2|      break;
 2117|      3|    case 'a':
  ------------------
  |  Branch (2117:5): [True: 3, False: 58.8k]
  ------------------
 2118|      3|      omode = O_WRONLY;
 2119|      3|      oflags = O_APPEND | O_CREAT;
 2120|      3|      break;
 2121|      0|    default:
  ------------------
  |  Branch (2121:5): [True: 0, False: 58.8k]
  ------------------
 2122|      0|      _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2123|      0|      return -1;
 2124|  58.8k|    }
 2125|   117k|  for (modestr++; *modestr; modestr++)
  ------------------
  |  Branch (2125:19): [True: 58.8k, False: 58.8k]
  ------------------
 2126|  58.8k|    {
 2127|  58.8k|      switch (*modestr)
 2128|  58.8k|        {
 2129|      0|        case '+':
  ------------------
  |  Branch (2129:9): [True: 0, False: 58.8k]
  ------------------
 2130|      0|          omode = O_RDWR;
 2131|      0|          break;
 2132|  58.8k|        case 'b':
  ------------------
  |  Branch (2132:9): [True: 58.8k, False: 0]
  ------------------
 2133|  58.8k|          oflags |= O_BINARY;
  ------------------
  |  |  106|  58.8k|# define O_BINARY 0
  ------------------
 2134|  58.8k|          break;
 2135|      0|        case 'x':
  ------------------
  |  Branch (2135:9): [True: 0, False: 58.8k]
  ------------------
 2136|      0|          oflags |= O_EXCL;
 2137|      0|          break;
 2138|      0|        case ',':
  ------------------
  |  Branch (2138:9): [True: 0, False: 58.8k]
  ------------------
 2139|      0|          goto keyvalue;
 2140|      0|        default: /* Ignore unknown flags.  */
  ------------------
  |  Branch (2140:9): [True: 0, False: 58.8k]
  ------------------
 2141|      0|          break;
 2142|  58.8k|        }
 2143|  58.8k|    }
 2144|       |
 2145|  58.8k| keyvalue:
 2146|       |  /* Parse key/value pairs (similar to fopen on mainframes).  */
 2147|  58.8k|  for (cmode=0; *modestr == ','; modestr += strcspn (modestr, ","))
  ------------------
  |  Branch (2147:17): [True: 0, False: 58.8k]
  ------------------
 2148|      0|    {
 2149|      0|      modestr++;
 2150|      0|      modestr += strspn (modestr, " \t");
 2151|      0|      if (!strncmp (modestr, "mode=", 5))
  ------------------
  |  Branch (2151:11): [True: 0, False: 0]
  ------------------
 2152|      0|        {
 2153|      0|          static struct {
 2154|      0|            char letter;
 2155|      0|            unsigned int value;
 2156|      0|          } table[] = { { '-', 0 },
 2157|      0|                        { 'r', S_IRUSR }, { 'w', S_IWUSR }, { 'x', S_IXUSR },
 2158|      0|                        { 'r', S_IRGRP }, { 'w', S_IWGRP }, { 'x', S_IXGRP },
 2159|      0|                        { 'r', S_IROTH }, { 'w', S_IWOTH }, { 'x', S_IXOTH }};
 2160|      0|          int idx;
 2161|       |
 2162|      0|          got_cmode = 1;
 2163|      0|          modestr += 5;
 2164|       |          /* For now we only support a string as used by ls(1) and no
 2165|       |             octal numbers.  The first character must be a dash.  */
 2166|      0|          for (idx=0; idx < 10 && *modestr; idx++, modestr++)
  ------------------
  |  Branch (2166:23): [True: 0, False: 0]
  |  Branch (2166:35): [True: 0, False: 0]
  ------------------
 2167|      0|            {
 2168|      0|              if (*modestr == table[idx].letter)
  ------------------
  |  Branch (2168:19): [True: 0, False: 0]
  ------------------
 2169|      0|                cmode |= table[idx].value;
 2170|      0|              else if (*modestr != '-')
  ------------------
  |  Branch (2170:24): [True: 0, False: 0]
  ------------------
 2171|      0|                break;
 2172|      0|            }
 2173|      0|          if (*modestr && !strchr (" \t,", *modestr))
  ------------------
  |  Branch (2173:15): [True: 0, False: 0]
  |  Branch (2173:27): [True: 0, False: 0]
  ------------------
 2174|      0|            {
 2175|      0|              _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2176|      0|              return -1;
 2177|      0|            }
 2178|      0|        }
 2179|      0|      else if (!strncmp (modestr, "samethread", 10))
  ------------------
  |  Branch (2179:16): [True: 0, False: 0]
  ------------------
 2180|      0|        {
 2181|      0|          modestr += 10;
 2182|      0|          if (*modestr && !strchr (" \t,", *modestr))
  ------------------
  |  Branch (2182:15): [True: 0, False: 0]
  |  Branch (2182:27): [True: 0, False: 0]
  ------------------
 2183|      0|            {
 2184|      0|              _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2185|      0|              return -1;
 2186|      0|            }
 2187|      0|          *r_xmode |= X_SAMETHREAD;
  ------------------
  |  | 2044|      0|#define X_SAMETHREAD	(1 << 0)
  ------------------
 2188|      0|        }
 2189|      0|      else if (!strncmp (modestr, "nonblock", 8))
  ------------------
  |  Branch (2189:16): [True: 0, False: 0]
  ------------------
 2190|      0|        {
 2191|      0|          modestr += 8;
 2192|      0|          if (*modestr && !strchr (" \t,", *modestr))
  ------------------
  |  Branch (2192:15): [True: 0, False: 0]
  |  Branch (2192:27): [True: 0, False: 0]
  ------------------
 2193|      0|            {
 2194|      0|              _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2195|      0|              return -1;
 2196|      0|            }
 2197|      0|          oflags |= O_NONBLOCK;
 2198|       |#if HAVE_W32_SYSTEM
 2199|       |          /* Currently, nonblock implies pollable on Windows.  */
 2200|       |          *r_xmode |= X_POLLABLE;
 2201|       |#endif
 2202|      0|        }
 2203|      0|      else if (!strncmp (modestr, "sysopen", 7))
  ------------------
  |  Branch (2203:16): [True: 0, False: 0]
  ------------------
 2204|      0|        {
 2205|      0|          modestr += 7;
 2206|      0|          if (*modestr && !strchr (" \t,", *modestr))
  ------------------
  |  Branch (2206:15): [True: 0, False: 0]
  |  Branch (2206:27): [True: 0, False: 0]
  ------------------
 2207|      0|            {
 2208|      0|              _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2209|      0|              return -1;
 2210|      0|            }
 2211|      0|          *r_xmode |= X_SYSOPEN;
  ------------------
  |  | 2045|      0|#define X_SYSOPEN	(1 << 1)
  ------------------
 2212|      0|        }
 2213|      0|      else if (!strncmp (modestr, "pollable", 8))
  ------------------
  |  Branch (2213:16): [True: 0, False: 0]
  ------------------
 2214|      0|        {
 2215|      0|          modestr += 8;
 2216|      0|          if (*modestr && !strchr (" \t,", *modestr))
  ------------------
  |  Branch (2216:15): [True: 0, False: 0]
  |  Branch (2216:27): [True: 0, False: 0]
  ------------------
 2217|      0|            {
 2218|      0|              _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2219|      0|              return -1;
 2220|      0|            }
 2221|      0|          *r_xmode |= X_POLLABLE;
  ------------------
  |  | 2046|      0|#define X_POLLABLE	(1 << 2)
  ------------------
 2222|      0|        }
 2223|      0|    }
 2224|  58.8k|  if (!got_cmode)
  ------------------
  |  Branch (2224:7): [True: 58.8k, False: 0]
  ------------------
 2225|  58.8k|    cmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
 2226|       |
 2227|  58.8k|  *modeflags = (omode | oflags);
 2228|  58.8k|  if (r_cmode)
  ------------------
  |  Branch (2228:7): [True: 58.8k, False: 0]
  ------------------
 2229|  58.8k|    *r_cmode = cmode;
 2230|  58.8k|  return 0;
 2231|  58.8k|}
estream.c:func_fd_read:
 1008|   117k|{
 1009|   117k|  estream_cookie_fd_t file_cookie = cookie;
 1010|   117k|  gpgrt_ssize_t bytes_read;
 1011|       |
 1012|   117k|  trace (("enter: cookie=%p buffer=%p size=%d", cookie, buffer, (int)size));
  ------------------
  |  |  189|   117k|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1013|       |
 1014|   117k|  if (!size)
  ------------------
  |  Branch (1014:7): [True: 0, False: 117k]
  ------------------
 1015|      0|    bytes_read = -1; /* We don't know whether anything is pending.  */
 1016|   117k|  else if (IS_INVALID_FD (file_cookie->fd))
  ------------------
  |  |  148|   117k|#define IS_INVALID_FD(a)    ((a) == -1)
  |  |  ------------------
  |  |  |  Branch (148:29): [True: 0, False: 117k]
  |  |  ------------------
  ------------------
 1017|      0|    {
 1018|      0|      _gpgrt_yield ();
 1019|      0|      bytes_read = 0;
 1020|      0|    }
 1021|   117k|  else
 1022|   117k|    {
 1023|   117k|      _gpgrt_pre_syscall ();
 1024|   117k|      do
 1025|   117k|        {
 1026|   117k|          bytes_read = read (file_cookie->fd, buffer, size);
 1027|   117k|        }
 1028|   117k|      while (bytes_read == -1 && errno == EINTR);
  ------------------
  |  Branch (1028:14): [True: 0, False: 117k]
  |  Branch (1028:34): [True: 0, False: 0]
  ------------------
 1029|   117k|      _gpgrt_post_syscall ();
 1030|   117k|    }
 1031|       |
 1032|   117k|  trace_errno (bytes_read == -1, ("leave: bytes_read=%d", (int)bytes_read));
  ------------------
  |  |  190|   117k|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1033|   117k|  return bytes_read;
 1034|   117k|}
estream.c:func_fd_write:
 1042|  29.5M|{
 1043|  29.5M|  estream_cookie_fd_t file_cookie = cookie;
 1044|  29.5M|  gpgrt_ssize_t bytes_written;
 1045|       |
 1046|  29.5M|  trace (("enter: cookie=%p buffer=%p size=%d", cookie, buffer, (int)size));
  ------------------
  |  |  189|  29.5M|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1047|       |
 1048|  29.5M|  if (IS_INVALID_FD (file_cookie->fd))
  ------------------
  |  |  148|  29.5M|#define IS_INVALID_FD(a)    ((a) == -1)
  |  |  ------------------
  |  |  |  Branch (148:29): [True: 0, False: 29.5M]
  |  |  ------------------
  ------------------
 1049|      0|    {
 1050|      0|      _gpgrt_yield ();
 1051|      0|      bytes_written = size; /* Yeah:  Success writing to the bit bucket.  */
 1052|      0|    }
 1053|  29.5M|  else if (buffer)
  ------------------
  |  Branch (1053:12): [True: 19.6M, False: 9.91M]
  ------------------
 1054|  19.6M|    {
 1055|  19.6M|      _gpgrt_pre_syscall ();
 1056|  19.6M|      do
 1057|  19.6M|        {
 1058|  19.6M|          bytes_written = write (file_cookie->fd, buffer, size);
 1059|  19.6M|        }
 1060|  19.6M|      while (bytes_written == -1 && errno == EINTR);
  ------------------
  |  Branch (1060:14): [True: 0, False: 19.6M]
  |  Branch (1060:37): [True: 0, False: 0]
  ------------------
 1061|  19.6M|      _gpgrt_post_syscall ();
 1062|  19.6M|    }
 1063|  9.91M|  else
 1064|  9.91M|    bytes_written = size; /* Note that for a flush SIZE should be 0.  */
 1065|       |
 1066|  29.5M|  trace_errno (bytes_written == -1,
  ------------------
  |  |  190|  29.5M|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1067|  29.5M|               ("leave: bytes_written=%d", (int)bytes_written));
 1068|  29.5M|  return bytes_written;
 1069|  29.5M|}
estream.c:func_fd_seek:
 1077|  6.86M|{
 1078|  6.86M|  estream_cookie_fd_t file_cookie = cookie;
 1079|  6.86M|  gpgrt_off_t offset_new;
 1080|  6.86M|  int err;
 1081|       |
 1082|  6.86M|  if (IS_INVALID_FD (file_cookie->fd))
  ------------------
  |  |  148|  6.86M|#define IS_INVALID_FD(a)    ((a) == -1)
  |  |  ------------------
  |  |  |  Branch (148:29): [True: 0, False: 6.86M]
  |  |  ------------------
  ------------------
 1083|      0|    {
 1084|      0|      _set_errno (ESPIPE);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1085|      0|      err = -1;
 1086|      0|    }
 1087|  6.86M|  else
 1088|  6.86M|    {
 1089|  6.86M|      _gpgrt_pre_syscall ();
 1090|  6.86M|      offset_new = lseek (file_cookie->fd, *offset, whence);
 1091|  6.86M|      _gpgrt_post_syscall ();
 1092|  6.86M|      if (offset_new == -1)
  ------------------
  |  Branch (1092:11): [True: 0, False: 6.86M]
  ------------------
 1093|      0|        err = -1;
 1094|  6.86M|      else
 1095|  6.86M|        {
 1096|  6.86M|          *offset = offset_new;
 1097|  6.86M|          err = 0;
 1098|  6.86M|        }
 1099|  6.86M|    }
 1100|       |
 1101|  6.86M|  return err;
 1102|  6.86M|}
estream.c:func_file_create:
 1890|  58.8k|{
 1891|  58.8k|  estream_cookie_fd_t file_cookie;
 1892|  58.8k|  int err;
 1893|  58.8k|  int fd;
 1894|       |
 1895|  58.8k|  err = 0;
 1896|       |
 1897|  58.8k|  file_cookie = mem_alloc (sizeof (*file_cookie));
 1898|  58.8k|  if (! file_cookie)
  ------------------
  |  Branch (1898:7): [True: 0, False: 58.8k]
  ------------------
 1899|      0|    {
 1900|      0|      err = -1;
 1901|      0|      goto out;
 1902|      0|    }
 1903|       |
 1904|       |#ifdef HAVE_W32_SYSTEM
 1905|       |  if (any8bitchar (path))
 1906|       |    {
 1907|       |      wchar_t *wpath;
 1908|       |
 1909|       |      wpath = _gpgrt_utf8_to_wchar (path);
 1910|       |      if (!wpath)
 1911|       |        fd = -1;
 1912|       |      else
 1913|       |        {
 1914|       |          fd = _wopen (wpath, modeflags, cmode);
 1915|       |          _gpgrt_free_wchar (wpath);
 1916|       |        }
 1917|       |    }
 1918|       |  else  /* Avoid unnecessary conversion.  */
 1919|       |    fd = open (path, modeflags, cmode);
 1920|       |#else
 1921|  58.8k|  fd = open (path, modeflags, cmode);
 1922|  58.8k|#endif
 1923|  58.8k|  if (fd == -1)
  ------------------
  |  Branch (1923:7): [True: 2, False: 58.8k]
  ------------------
 1924|      2|    {
 1925|      2|      err = -1;
 1926|      2|      goto out;
 1927|      2|    }
 1928|       |#ifdef HAVE_DOSISH_SYSTEM
 1929|       |  /* Make sure it is in binary mode if requested.  */
 1930|       |  if ( (modeflags & O_BINARY) )
 1931|       |    setmode (fd, O_BINARY);
 1932|       |#endif
 1933|       |
 1934|  58.8k|  file_cookie->fd = fd;
 1935|  58.8k|  file_cookie->no_close = 0;
 1936|  58.8k|  *cookie = file_cookie;
 1937|  58.8k|  *filedes = fd;
 1938|       |
 1939|  58.8k| out:
 1940|       |
 1941|  58.8k|  if (err)
  ------------------
  |  Branch (1941:7): [True: 2, False: 58.8k]
  ------------------
 1942|      2|    mem_free (file_cookie);
 1943|       |
 1944|  58.8k|  return err;
 1945|  58.8k|}
estream.c:create_stream:
 2490|  58.8k|{
 2491|  58.8k|  estream_internal_t stream_internal_new;
 2492|  58.8k|  estream_t stream_new;
 2493|  58.8k|  int err;
 2494|       |#if HAVE_W32_SYSTEM
 2495|       |  void *old_cookie = NULL;
 2496|       |#endif
 2497|       |
 2498|  58.8k|  stream_new = NULL;
 2499|  58.8k|  stream_internal_new = NULL;
 2500|       |
 2501|       |#if HAVE_W32_SYSTEM
 2502|       |  if ((xmode & X_POLLABLE) && kind != BACKEND_W32)
 2503|       |    {
 2504|       |      /* We require the W32 backend, because only that allows us to
 2505|       |       * write directly using the native W32 API and to disable the
 2506|       |       * system clamp.  Note that func_w32_create has already been
 2507|       |       * called with the flag to disable the system call clamp.  */
 2508|       |      _set_errno (EINVAL);
 2509|       |      err = -1;
 2510|       |      goto out;
 2511|       |    }
 2512|       |#endif /*HAVE_W32_SYSTEM*/
 2513|       |
 2514|  58.8k|  stream_new = mem_alloc (sizeof (*stream_new));
 2515|  58.8k|  if (! stream_new)
  ------------------
  |  Branch (2515:7): [True: 0, False: 58.8k]
  ------------------
 2516|      0|    {
 2517|      0|      err = -1;
 2518|      0|      goto out;
 2519|      0|    }
 2520|       |
 2521|  58.8k|  stream_internal_new = mem_alloc (sizeof (*stream_internal_new));
 2522|  58.8k|  if (! stream_internal_new)
  ------------------
  |  Branch (2522:7): [True: 0, False: 58.8k]
  ------------------
 2523|      0|    {
 2524|      0|      err = -1;
 2525|      0|      goto out;
 2526|      0|    }
 2527|       |
 2528|  58.8k|  stream_new->buffer = stream_internal_new->buffer;
 2529|  58.8k|  stream_new->buffer_size = sizeof (stream_internal_new->buffer);
 2530|  58.8k|  stream_new->unread_buffer = stream_internal_new->unread_buffer;
 2531|  58.8k|  stream_new->unread_buffer_size = sizeof (stream_internal_new->unread_buffer);
 2532|  58.8k|  stream_new->intern = stream_internal_new;
 2533|       |
 2534|       |#if HAVE_W32_SYSTEM
 2535|       |  if ((xmode & X_POLLABLE))
 2536|       |    {
 2537|       |      void *new_cookie;
 2538|       |
 2539|       |      err = _gpgrt_w32_pollable_create (&new_cookie, modeflags,
 2540|       |                                        functions, cookie);
 2541|       |      if (err)
 2542|       |        goto out;
 2543|       |
 2544|       |      modeflags &= ~O_NONBLOCK;
 2545|       |      old_cookie = cookie;
 2546|       |      cookie = new_cookie;
 2547|       |      kind = BACKEND_W32_POLLABLE;
 2548|       |      functions = _gpgrt_functions_w32_pollable;
 2549|       |    }
 2550|       |#endif /*HAVE_W32_SYSTEM*/
 2551|       |
 2552|  58.8k|  init_stream_obj (stream_new, cookie, syshd, kind, functions, modeflags,
 2553|  58.8k|                   xmode);
 2554|  58.8k|  init_stream_lock (stream_new);
 2555|       |
 2556|  58.8k|  err = do_list_add (stream_new, with_locked_list);
 2557|  58.8k|  if (err)
  ------------------
  |  Branch (2557:7): [True: 0, False: 58.8k]
  ------------------
 2558|      0|    goto out;
 2559|       |
 2560|  58.8k|  *r_stream = stream_new;
 2561|       |
 2562|  58.8k| out:
 2563|       |
 2564|  58.8k|  if (err)
  ------------------
  |  Branch (2564:7): [True: 0, False: 58.8k]
  ------------------
 2565|      0|    {
 2566|      0|      trace_errno (err, ("leave: err=%d", err));
  ------------------
  |  |  190|      0|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2567|      0|      if (stream_new)
  ------------------
  |  Branch (2567:11): [True: 0, False: 0]
  ------------------
 2568|      0|	{
 2569|      0|	  deinit_stream_obj (stream_new);
 2570|      0|          destroy_stream_lock (stream_new);
 2571|      0|	  mem_free (stream_new->intern);
 2572|      0|	  mem_free (stream_new);
 2573|      0|	}
 2574|      0|    }
 2575|       |#if HAVE_W32_SYSTEM
 2576|       |  else if (old_cookie)
 2577|       |    trace (("leave: success stream=%p cookie=%p,%p",
 2578|       |            *r_stream, old_cookie, cookie));
 2579|       |#endif
 2580|  58.8k|  else
 2581|  58.8k|    trace (("leave: success stream=%p cookie=%p", *r_stream, cookie));
  ------------------
  |  |  189|  58.8k|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2582|       |
 2583|  58.8k|  return err;
 2584|  58.8k|}
estream.c:init_stream_lock:
  399|  58.8k|{
  400|  58.8k|  int rc;
  401|       |
  402|  58.8k|  if (!stream->intern->samethread)
  ------------------
  |  Branch (402:7): [True: 58.8k, False: 0]
  ------------------
  403|  58.8k|    {
  404|  58.8k|      dbg_lock_1 ("enter init_stream_lock for %p\n", stream);
  405|  58.8k|      memset (&stream->intern->lock, 0 , sizeof stream->intern->lock);
  406|  58.8k|      rc = _gpgrt_lock_init (&stream->intern->lock);
  407|  58.8k|      dbg_lock_2 ("leave init_stream_lock for %p: rc=%d\n", stream, rc);
  408|  58.8k|    }
  409|      0|  else
  410|      0|    rc = 0;
  411|  58.8k|  return rc;
  412|  58.8k|}
estream.c:do_list_add:
  510|  58.8k|{
  511|  58.8k|  estream_list_t item;
  512|       |
  513|  58.8k|  if (!with_locked_list)
  ------------------
  |  Branch (513:7): [True: 58.8k, False: 2]
  ------------------
  514|  58.8k|    lock_list ();
  515|       |
  516|   243k|  for (item = estream_list; item && item->stream; item = item->next)
  ------------------
  |  Branch (516:29): [True: 184k, False: 58.8k]
  |  Branch (516:37): [True: 184k, False: 0]
  ------------------
  517|   184k|    ;
  518|  58.8k|  if (!item)
  ------------------
  |  Branch (518:7): [True: 58.8k, False: 0]
  ------------------
  519|  58.8k|    {
  520|  58.8k|      item = mem_alloc (sizeof *item);
  521|  58.8k|      if (item)
  ------------------
  |  Branch (521:11): [True: 58.8k, False: 0]
  ------------------
  522|  58.8k|        {
  523|  58.8k|          item->next = estream_list;
  524|  58.8k|          estream_list = item;
  525|  58.8k|        }
  526|  58.8k|    }
  527|  58.8k|  if (item)
  ------------------
  |  Branch (527:7): [True: 58.8k, False: 0]
  ------------------
  528|  58.8k|    item->stream = stream;
  529|       |
  530|  58.8k|  if (!with_locked_list)
  ------------------
  |  Branch (530:7): [True: 58.8k, False: 2]
  ------------------
  531|  58.8k|    unlock_list ();
  532|       |
  533|  58.8k|  return item? 0 : -1;
  ------------------
  |  Branch (533:10): [True: 58.8k, False: 0]
  ------------------
  534|  58.8k|}
estream.c:destroy_stream_lock:
  417|  58.8k|{
  418|  58.8k|  if (!stream->intern->samethread)
  ------------------
  |  Branch (418:7): [True: 58.8k, False: 0]
  ------------------
  419|  58.8k|    {
  420|  58.8k|      dbg_lock_1 ("enter destroy_stream_lock for %p\n", stream);
  421|  58.8k|      _gpgrt_lock_destroy (&stream->intern->lock);
  422|  58.8k|      dbg_lock_1 ("leave destroy_stream_lock for %p\n", stream);
  423|  58.8k|    }
  424|  58.8k|}
estream.c:mem_free:
  224|   294k|{
  225|   294k|  if (p)
  ------------------
  |  Branch (225:7): [True: 294k, False: 0]
  ------------------
  226|   294k|    _gpgrt_free (p);
  227|   294k|}
estream.c:es_writen:
 3145|  69.0M|{
 3146|  69.0M|  size_t data_written;
 3147|  69.0M|  int err;
 3148|       |
 3149|  69.0M|  data_written = 0;
 3150|  69.0M|  err = 0;
 3151|       |
 3152|  69.0M|  if (!stream->flags.writing)
  ------------------
  |  Branch (3152:7): [True: 0, False: 69.0M]
  ------------------
 3153|      0|    {
 3154|       |      /* Switching to writing mode -> discard input data and seek to
 3155|       |	 position at which reading has stopped.  We can do this only
 3156|       |	 if a seek function has been registered. */
 3157|      0|      if (stream->intern->func_seek)
  ------------------
  |  Branch (3157:11): [True: 0, False: 0]
  ------------------
 3158|      0|        {
 3159|      0|          err = es_seek (stream, 0, SEEK_CUR, NULL);
 3160|      0|          if (err)
  ------------------
  |  Branch (3160:15): [True: 0, False: 0]
  ------------------
 3161|      0|            {
 3162|      0|              if (errno == ESPIPE)
  ------------------
  |  Branch (3162:19): [True: 0, False: 0]
  ------------------
 3163|      0|                err = 0;
 3164|      0|              else
 3165|      0|                goto out;
 3166|      0|            }
 3167|      0|          stream->flags.writing = 1;
 3168|      0|        }
 3169|      0|    }
 3170|       |
 3171|  69.0M|  switch (stream->intern->strategy)
  ------------------
  |  Branch (3171:11): [True: 0, False: 69.0M]
  ------------------
 3172|  69.0M|    {
 3173|      0|    case _IONBF:
  ------------------
  |  Branch (3173:5): [True: 0, False: 69.0M]
  ------------------
 3174|      0|      err = es_write_nbf (stream, buffer, bytes_to_write, &data_written);
 3175|      0|      break;
 3176|       |
 3177|  47.9M|    case _IOLBF:
  ------------------
  |  Branch (3177:5): [True: 47.9M, False: 21.1M]
  ------------------
 3178|  47.9M|      err = es_write_lbf (stream, buffer, bytes_to_write, &data_written);
 3179|  47.9M|      break;
 3180|       |
 3181|  21.1M|    case _IOFBF:
  ------------------
  |  Branch (3181:5): [True: 21.1M, False: 47.9M]
  ------------------
 3182|  21.1M|      err = es_write_fbf (stream, buffer, bytes_to_write, &data_written);
 3183|  21.1M|      break;
 3184|  69.0M|    }
 3185|       |
 3186|  69.0M| out:
 3187|       |
 3188|  69.0M|  if (bytes_written)
  ------------------
  |  Branch (3188:7): [True: 68.7M, False: 308k]
  ------------------
 3189|  68.7M|    *bytes_written = data_written;
 3190|       |
 3191|  69.0M|  return err;
 3192|  69.0M|}
estream.c:es_write_nbf:
 3015|  9.91M|{
 3016|  9.91M|  gpgrt_cookie_write_function_t func_write = stream->intern->func_write;
 3017|  9.91M|  size_t data_written;
 3018|  9.91M|  gpgrt_ssize_t ret;
 3019|  9.91M|  int err;
 3020|       |
 3021|  9.91M|  if (bytes_to_write && (! func_write))
  ------------------
  |  Branch (3021:7): [True: 9.91M, False: 0]
  |  Branch (3021:25): [True: 0, False: 9.91M]
  ------------------
 3022|      0|    {
 3023|      0|      _set_errno (EOPNOTSUPP);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3024|      0|      err = -1;
 3025|      0|      goto out;
 3026|      0|    }
 3027|       |
 3028|  9.91M|  data_written = 0;
 3029|  9.91M|  err = 0;
 3030|       |
 3031|  19.8M|  while (bytes_to_write - data_written)
  ------------------
  |  Branch (3031:10): [True: 9.91M, False: 9.91M]
  ------------------
 3032|  9.91M|    {
 3033|  9.91M|      ret = (*func_write) (stream->intern->cookie,
 3034|  9.91M|			   buffer + data_written,
 3035|  9.91M|			   bytes_to_write - data_written);
 3036|  9.91M|      if (ret == -1)
  ------------------
  |  Branch (3036:11): [True: 0, False: 9.91M]
  ------------------
 3037|      0|	{
 3038|      0|	  err = -1;
 3039|       |#if EWOULDBLOCK != EAGAIN
 3040|       |          if (errno == EWOULDBLOCK)
 3041|       |            _set_errno (EAGAIN);
 3042|       |#endif
 3043|      0|	  break;
 3044|      0|	}
 3045|  9.91M|      else
 3046|  9.91M|	data_written += ret;
 3047|  9.91M|    }
 3048|       |
 3049|  9.91M|  stream->intern->offset += data_written;
 3050|  9.91M|  *bytes_written = data_written;
 3051|       |
 3052|  9.91M| out:
 3053|       |
 3054|  9.91M|  return err;
 3055|  9.91M|}
estream.c:es_write_lbf:
 3111|  47.9M|{
 3112|  47.9M|  size_t data_flushed = 0;
 3113|  47.9M|  size_t data_buffered = 0;
 3114|  47.9M|  unsigned char *nlp;
 3115|  47.9M|  int err = 0;
 3116|       |
 3117|  47.9M|  nlp = memrchr (buffer, '\n', bytes_to_write);
 3118|  47.9M|  if (nlp)
  ------------------
  |  Branch (3118:7): [True: 9.91M, False: 38.0M]
  ------------------
 3119|  9.91M|    {
 3120|       |      /* Found a newline, directly write up to (including) this
 3121|       |	 character.  */
 3122|  9.91M|      err = flush_stream (stream);
 3123|  9.91M|      if (!err)
  ------------------
  |  Branch (3123:11): [True: 9.91M, False: 0]
  ------------------
 3124|  9.91M|	err = es_write_nbf (stream, buffer, nlp - buffer + 1, &data_flushed);
 3125|  9.91M|    }
 3126|       |
 3127|  47.9M|  if (!err)
  ------------------
  |  Branch (3127:7): [True: 47.9M, False: 0]
  ------------------
 3128|  47.9M|    {
 3129|       |      /* Write remaining data fully buffered.  */
 3130|  47.9M|      err = es_write_fbf (stream, buffer + data_flushed,
 3131|  47.9M|			  bytes_to_write - data_flushed, &data_buffered);
 3132|  47.9M|    }
 3133|       |
 3134|  47.9M|  *bytes_written = data_flushed + data_buffered;
 3135|  47.9M|  return err;
 3136|  47.9M|}
estream.c:es_write_fbf:
 3067|  69.0M|{
 3068|  69.0M|  size_t space_available;
 3069|  69.0M|  size_t data_to_write;
 3070|  69.0M|  size_t data_written;
 3071|  69.0M|  int err;
 3072|       |
 3073|  69.0M|  data_written = 0;
 3074|  69.0M|  err = 0;
 3075|       |
 3076|   127M|  while ((bytes_to_write - data_written) && (! err))
  ------------------
  |  Branch (3076:10): [True: 58.3M, False: 69.0M]
  |  Branch (3076:45): [True: 58.3M, False: 0]
  ------------------
 3077|  58.3M|    {
 3078|  58.3M|      if (stream->data_offset == stream->buffer_size)
  ------------------
  |  Branch (3078:11): [True: 9.21k, False: 58.3M]
  ------------------
 3079|       |	/* Container full, flush buffer.  */
 3080|  9.21k|	err = flush_stream (stream);
 3081|       |
 3082|  58.3M|      if (! err)
  ------------------
  |  Branch (3082:11): [True: 58.3M, False: 0]
  ------------------
 3083|  58.3M|	{
 3084|       |	  /* Flushing resulted in empty container.  */
 3085|       |
 3086|  58.3M|	  data_to_write = bytes_to_write - data_written;
 3087|  58.3M|	  space_available = stream->buffer_size - stream->data_offset;
 3088|  58.3M|	  if (data_to_write > space_available)
  ------------------
  |  Branch (3088:8): [True: 6.39k, False: 58.3M]
  ------------------
 3089|  6.39k|	    data_to_write = space_available;
 3090|       |
 3091|  58.3M|	  memcpy (stream->buffer + stream->data_offset,
 3092|  58.3M|		  buffer + data_written, data_to_write);
 3093|  58.3M|	  stream->data_offset += data_to_write;
 3094|  58.3M|	  data_written += data_to_write;
 3095|  58.3M|	}
 3096|  58.3M|    }
 3097|       |
 3098|  69.0M|  *bytes_written = data_written;
 3099|       |
 3100|  69.0M|  return err;
 3101|  69.0M|}
estream.c:es_seek:
 2944|  6.86M|{
 2945|  6.86M|  gpgrt_cookie_seek_function_t func_seek = stream->intern->func_seek;
 2946|  6.86M|  int err, ret;
 2947|  6.86M|  gpgrt_off_t off;
 2948|       |
 2949|  6.86M|  if (! func_seek)
  ------------------
  |  Branch (2949:7): [True: 0, False: 6.86M]
  ------------------
 2950|      0|    {
 2951|      0|      _set_errno (EOPNOTSUPP);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2952|      0|      err = -1;
 2953|      0|      goto out;
 2954|      0|    }
 2955|       |
 2956|  6.86M|  if (stream->flags.writing)
  ------------------
  |  Branch (2956:7): [True: 0, False: 6.86M]
  ------------------
 2957|      0|    {
 2958|       |      /* Flush data first in order to prevent flushing it to the wrong
 2959|       |	 offset.  */
 2960|      0|      err = flush_stream (stream);
 2961|      0|      if (err)
  ------------------
  |  Branch (2961:11): [True: 0, False: 0]
  ------------------
 2962|      0|	goto out;
 2963|      0|      stream->flags.writing = 0;
 2964|      0|    }
 2965|       |
 2966|  6.86M|  off = offset;
 2967|  6.86M|  if (whence == SEEK_CUR)
  ------------------
  |  Branch (2967:7): [True: 0, False: 6.86M]
  ------------------
 2968|      0|    {
 2969|      0|      off = off - stream->data_len + stream->data_offset;
 2970|      0|      off -= stream->unread_data_len;
 2971|      0|    }
 2972|       |
 2973|  6.86M|  ret = (*func_seek) (stream->intern->cookie, &off, whence);
 2974|  6.86M|  if (ret == -1)
  ------------------
  |  Branch (2974:7): [True: 0, False: 6.86M]
  ------------------
 2975|      0|    {
 2976|      0|      err = -1;
 2977|       |#if EWOULDBLOCK != EAGAIN
 2978|       |      if (errno == EWOULDBLOCK)
 2979|       |        _set_errno (EAGAIN);
 2980|       |#endif
 2981|      0|      goto out;
 2982|      0|    }
 2983|       |
 2984|  6.86M|  err = 0;
 2985|  6.86M|  es_empty (stream);
 2986|       |
 2987|  6.86M|  if (offset_new)
  ------------------
  |  Branch (2987:7): [True: 0, False: 6.86M]
  ------------------
 2988|      0|    *offset_new = off;
 2989|       |
 2990|  6.86M|  stream->intern->indicators.eof = 0;
 2991|  6.86M|  stream->intern->offset = off;
 2992|       |
 2993|  6.86M| out:
 2994|       |
 2995|  6.86M|  if (err)
  ------------------
  |  Branch (2995:7): [True: 0, False: 6.86M]
  ------------------
 2996|      0|    {
 2997|      0|      if (errno == EPIPE)
  ------------------
  |  Branch (2997:11): [True: 0, False: 0]
  ------------------
 2998|      0|        stream->intern->indicators.hup = 1;
 2999|      0|      stream->intern->indicators.err = 1;
 3000|      0|    }
 3001|       |
 3002|  6.86M|  return err;
 3003|  6.86M|}
estream.c:es_empty:
 2380|  6.86M|{
 2381|  6.86M|  gpgrt_assert (!stream->flags.writing);
  ------------------
  |  |  577|  6.86M|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 6.86M, False: 0]
  |  |  ------------------
  |  |  578|  6.86M|   ? (void) 0                                                   \
  |  |  579|  6.86M|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 2382|      0|  stream->data_len = 0;
 2383|  6.86M|  stream->data_offset = 0;
 2384|  6.86M|  stream->unread_data_len = 0;
 2385|  6.86M|}
estream.c:do_fpopen:
 3777|      2|{
 3778|      2|  unsigned int modeflags, cmode, xmode;
 3779|      2|  int create_called = 0;
 3780|      2|  estream_t stream = NULL;
 3781|      2|  void *cookie = NULL;
 3782|      2|  int err;
 3783|      2|  es_syshd_t syshd;
 3784|       |
 3785|      2|  err = parse_mode (mode, &modeflags, &xmode, &cmode);
 3786|      2|  if (err)
  ------------------
  |  Branch (3786:7): [True: 0, False: 2]
  ------------------
 3787|      0|    goto out;
 3788|      2|  if ((xmode & X_SYSOPEN))
  ------------------
  |  | 2045|      2|#define X_SYSOPEN	(1 << 1)
  ------------------
  |  Branch (3788:7): [True: 0, False: 2]
  ------------------
 3789|      0|    {
 3790|       |      /* Not allowed for fpopen.  */
 3791|      0|      _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3792|      0|      err = -1;
 3793|      0|      goto out;
 3794|      0|    }
 3795|       |
 3796|      2|  if (fp)
  ------------------
  |  Branch (3796:7): [True: 2, False: 0]
  ------------------
 3797|      2|    fflush (fp);
 3798|      2|  err = func_fp_create (&cookie, fp, modeflags, no_close);
 3799|      2|  if (err)
  ------------------
  |  Branch (3799:7): [True: 0, False: 2]
  ------------------
 3800|      0|    goto out;
 3801|       |
 3802|      2|  syshd.type = ES_SYSHD_FD;
  ------------------
  |  | 1255|      2|#define ES_SYSHD_FD     GPGRT_SYSHD_FD
  ------------------
 3803|      2|  syshd.u.fd = fp? fileno (fp): -1;
  ------------------
  |  Branch (3803:16): [True: 2, False: 0]
  ------------------
 3804|      2|  create_called = 1;
 3805|      2|  err = create_stream (&stream, cookie, &syshd,
 3806|      2|                       BACKEND_FP, estream_functions_fp,
 3807|      2|                       modeflags, xmode, with_locked_list);
 3808|       |
 3809|      2| out:
 3810|      2|  if (err && create_called)
  ------------------
  |  Branch (3810:7): [True: 0, False: 2]
  |  Branch (3810:14): [True: 0, False: 0]
  ------------------
 3811|      0|    (*estream_functions_fp.public.func_close) (cookie);
 3812|       |
 3813|      2|  return stream;
 3814|      2|}
estream.c:func_fp_create:
 1681|      2|{
 1682|      2|  estream_cookie_fp_t fp_cookie;
 1683|      2|  int err;
 1684|       |
 1685|      2|  fp_cookie = mem_alloc (sizeof *fp_cookie);
 1686|      2|  if (!fp_cookie)
  ------------------
  |  Branch (1686:7): [True: 0, False: 2]
  ------------------
 1687|      0|    err = -1;
 1688|      2|  else
 1689|      2|    {
 1690|       |#ifdef HAVE_DOSISH_SYSTEM
 1691|       |      /* Make sure it is in binary mode if requested.  */
 1692|       |      if ( (modeflags & O_BINARY) )
 1693|       |        setmode (fileno (fp), O_BINARY);
 1694|       |#else
 1695|      2|      (void)modeflags;
 1696|      2|#endif
 1697|      2|      fp_cookie->fp = fp;
 1698|      2|      fp_cookie->no_close = no_close;
 1699|      2|      *cookie = fp_cookie;
 1700|      2|      err = 0;
 1701|      2|    }
 1702|       |
 1703|      2|  return err;
 1704|      2|}
estream.c:func_fp_write:
 1739|  17.9k|{
 1740|  17.9k|  estream_cookie_fp_t file_cookie = cookie;
 1741|  17.9k|  size_t bytes_written;
 1742|       |
 1743|  17.9k|  if (file_cookie->fp)
  ------------------
  |  Branch (1743:7): [True: 17.9k, False: 0]
  ------------------
 1744|  17.9k|    {
 1745|  17.9k|      _gpgrt_pre_syscall ();
 1746|  17.9k|      if (buffer)
  ------------------
  |  Branch (1746:11): [True: 8.96k, False: 8.96k]
  ------------------
 1747|  8.96k|        {
 1748|       |#ifdef HAVE_W32_SYSTEM
 1749|       |          /* Using an fwrite to stdout connected to the console fails
 1750|       |             with the error "Not enough space" for an fwrite size of
 1751|       |             >= 52KB (tested on Windows XP SP2).  To solve this we
 1752|       |             always chunk the writes up into smaller blocks.  */
 1753|       |          bytes_written = 0;
 1754|       |          while (bytes_written < size)
 1755|       |            {
 1756|       |              size_t cnt = size - bytes_written;
 1757|       |
 1758|       |              if (cnt > 32*1024)
 1759|       |                cnt = 32*1024;
 1760|       |              if (fwrite ((const char*)buffer + bytes_written,
 1761|       |                          cnt, 1, file_cookie->fp) != 1)
 1762|       |                break; /* Write error.  */
 1763|       |              bytes_written += cnt;
 1764|       |            }
 1765|       |#else
 1766|  8.96k|          bytes_written = fwrite (buffer, 1, size, file_cookie->fp);
 1767|  8.96k|#endif
 1768|  8.96k|        }
 1769|  8.96k|      else /* Only flush requested.  */
 1770|  8.96k|        bytes_written = size;
 1771|       |
 1772|  17.9k|      fflush (file_cookie->fp);
 1773|  17.9k|      _gpgrt_post_syscall ();
 1774|  17.9k|    }
 1775|      0|  else
 1776|      0|    bytes_written = size; /* Successfully written to the bit bucket.  */
 1777|       |
 1778|  17.9k|  if (bytes_written != size)
  ------------------
  |  Branch (1778:7): [True: 0, False: 17.9k]
  ------------------
 1779|      0|    return -1;
 1780|  17.9k|  return bytes_written;
 1781|  17.9k|}
estream.c:lock_list:
  470|   117k|{
  471|   117k|  dbg_lock_0 ("enter lock_list\n");
  472|   117k|  _gpgrt_lock_lock (&estream_list_lock);
  473|   117k|  dbg_lock_0 ("leave lock_list\n");
  474|   117k|}
estream.c:unlock_list:
  479|   117k|{
  480|   117k|  dbg_lock_0 ("enter unlock_list\n");
  481|   117k|  _gpgrt_lock_unlock (&estream_list_lock);
  482|   117k|  dbg_lock_0 ("leave unlock_list\n");
  483|   117k|}
estream.c:es_set_buffering:
 3419|      3|{
 3420|      3|  int err;
 3421|       |
 3422|       |  /* Flush or empty buffer depending on mode.  */
 3423|      3|  if (stream->flags.writing)
  ------------------
  |  Branch (3423:7): [True: 3, False: 0]
  ------------------
 3424|      3|    {
 3425|      3|      err = flush_stream (stream);
 3426|      3|      if (err)
  ------------------
  |  Branch (3426:11): [True: 0, False: 3]
  ------------------
 3427|      0|	goto out;
 3428|      3|    }
 3429|      0|  else
 3430|      0|    es_empty (stream);
 3431|       |
 3432|      3|  stream->intern->indicators.eof = 0;
 3433|       |
 3434|       |  /* Free old buffer in case that was allocated by this function.  */
 3435|      3|  if (stream->intern->deallocate_buffer)
  ------------------
  |  Branch (3435:7): [True: 1, False: 2]
  ------------------
 3436|      1|    {
 3437|      1|      stream->intern->deallocate_buffer = 0;
 3438|      1|      mem_free (stream->buffer);
 3439|      1|      stream->buffer = NULL;
 3440|      1|    }
 3441|       |
 3442|      3|  if (mode == _IONBF)
  ------------------
  |  Branch (3442:7): [True: 0, False: 3]
  ------------------
 3443|      0|    stream->buffer_size = 0;
 3444|      3|  else
 3445|      3|    {
 3446|      3|      void *buffer_new;
 3447|       |
 3448|      3|      if (buffer)
  ------------------
  |  Branch (3448:11): [True: 0, False: 3]
  ------------------
 3449|      0|	buffer_new = buffer;
 3450|      3|      else
 3451|      3|	{
 3452|      3|          if (!size)
  ------------------
  |  Branch (3452:15): [True: 3, False: 0]
  ------------------
 3453|      3|            size = BUFSIZ;
 3454|      3|	  buffer_new = mem_alloc (size);
 3455|      3|	  if (! buffer_new)
  ------------------
  |  Branch (3455:8): [True: 0, False: 3]
  ------------------
 3456|      0|	    {
 3457|      0|	      err = -1;
 3458|      0|	      goto out;
 3459|      0|	    }
 3460|      3|	}
 3461|       |
 3462|      3|      stream->buffer = buffer_new;
 3463|      3|      stream->buffer_size = size;
 3464|      3|      if (! buffer)
  ------------------
  |  Branch (3464:11): [True: 3, False: 0]
  ------------------
 3465|      3|	stream->intern->deallocate_buffer = 1;
 3466|      3|    }
 3467|      3|  stream->intern->strategy = mode;
 3468|      3|  err = 0;
 3469|       |
 3470|      3| out:
 3471|       |
 3472|      3|  return err;
 3473|      3|}
estream.c:lock_stream:
  429|  23.7M|{
  430|  23.7M|  if (!stream->intern->samethread)
  ------------------
  |  Branch (430:7): [True: 23.7M, False: 0]
  ------------------
  431|  23.7M|    {
  432|  23.7M|      dbg_lock_1 ("enter lock_stream for %p\n", stream);
  433|  23.7M|      _gpgrt_lock_lock (&stream->intern->lock);
  434|  23.7M|      dbg_lock_1 ("leave lock_stream for %p\n", stream);
  435|  23.7M|    }
  436|  23.7M|}
estream.c:deinit_stream_obj:
 2443|  58.8k|{
 2444|  58.8k|  gpgrt_cookie_close_function_t func_close;
 2445|  58.8k|  int err, tmp_err;
 2446|       |
 2447|  58.8k|  trace (("enter: stream %p", stream));
  ------------------
  |  |  189|  58.8k|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2448|  58.8k|  func_close = stream->intern->func_close;
 2449|       |
 2450|  58.8k|  err = 0;
 2451|  58.8k|  if (stream->flags.writing)
  ------------------
  |  Branch (2451:7): [True: 2, False: 58.8k]
  ------------------
 2452|      2|    {
 2453|      2|      tmp_err = flush_stream (stream);
 2454|      2|      if (!err)
  ------------------
  |  Branch (2454:11): [True: 2, False: 0]
  ------------------
 2455|      2|        err = tmp_err;
 2456|      2|    }
 2457|  58.8k|  if (func_close)
  ------------------
  |  Branch (2457:7): [True: 58.8k, False: 0]
  ------------------
 2458|  58.8k|    {
 2459|  58.8k|      trace (("stream %p calling func_close", stream));
  ------------------
  |  |  189|  58.8k|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2460|  58.8k|      tmp_err = func_close (stream->intern->cookie);
 2461|  58.8k|      if (!err)
  ------------------
  |  Branch (2461:11): [True: 58.8k, False: 0]
  ------------------
 2462|  58.8k|        err = tmp_err;
 2463|  58.8k|    }
 2464|       |
 2465|  58.8k|  mem_free (stream->intern->printable_fname);
 2466|  58.8k|  stream->intern->printable_fname = NULL;
 2467|  58.8k|  stream->intern->printable_fname_inuse = 0;
 2468|  58.8k|  while (stream->intern->onclose)
  ------------------
  |  Branch (2468:10): [True: 0, False: 58.8k]
  ------------------
 2469|      0|    {
 2470|      0|      notify_list_t tmp = stream->intern->onclose->next;
 2471|      0|      mem_free (stream->intern->onclose);
 2472|      0|      stream->intern->onclose = tmp;
 2473|      0|    }
 2474|       |
 2475|  58.8k|  trace_errno (err, ("leave: stream %p err=%d", stream, err));
  ------------------
  |  |  190|  58.8k|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2476|  58.8k|  return err;
 2477|  58.8k|}
estream.c:init_stream_obj:
 2397|  58.8k|{
 2398|  58.8k|  stream->intern->kind = kind;
 2399|  58.8k|  stream->intern->cookie = cookie;
 2400|  58.8k|  stream->intern->opaque = NULL;
 2401|  58.8k|  stream->intern->offset = 0;
 2402|  58.8k|  stream->intern->func_read = functions.public.func_read;
 2403|  58.8k|  stream->intern->func_write = functions.public.func_write;
 2404|  58.8k|  stream->intern->func_seek = functions.public.func_seek;
 2405|  58.8k|  stream->intern->func_ioctl = functions.func_ioctl;
 2406|  58.8k|  stream->intern->func_close = functions.public.func_close;
 2407|  58.8k|  stream->intern->strategy = _IOFBF;
 2408|  58.8k|  stream->intern->syshd = *syshd;
 2409|  58.8k|  stream->intern->print_ntotal = 0;
 2410|  58.8k|  stream->intern->indicators.err = 0;
 2411|  58.8k|  stream->intern->indicators.eof = 0;
 2412|  58.8k|  stream->intern->indicators.hup = 0;
 2413|  58.8k|  stream->intern->is_stdstream = 0;
 2414|  58.8k|  stream->intern->stdstream_fd = 0;
 2415|  58.8k|  stream->intern->deallocate_buffer = 0;
 2416|  58.8k|  stream->intern->printable_fname = NULL;
 2417|  58.8k|  stream->intern->printable_fname_inuse = 0;
 2418|  58.8k|  stream->intern->samethread = !! (xmode & X_SAMETHREAD);
  ------------------
  |  | 2044|  58.8k|#define X_SAMETHREAD	(1 << 0)
  ------------------
 2419|  58.8k|  stream->intern->onclose = NULL;
 2420|       |
 2421|  58.8k|  stream->data_len = 0;
 2422|  58.8k|  stream->data_offset = 0;
 2423|  58.8k|  stream->data_flushed = 0;
 2424|  58.8k|  stream->unread_data_len = 0;
 2425|       |  /* Depending on the modeflags we set whether we start in writing or
 2426|       |     reading mode.  This is required in case we are working on a
 2427|       |     stream which is not seeekable (like stdout).  Without this
 2428|       |     pre-initialization we would do a seek at the first write call and
 2429|       |     as this will fail no output will be delivered. */
 2430|  58.8k|  if ((modeflags & O_WRONLY) || (modeflags & O_RDWR) )
  ------------------
  |  Branch (2430:7): [True: 5, False: 58.8k]
  |  Branch (2430:33): [True: 0, False: 58.8k]
  ------------------
 2431|      5|    stream->flags.writing = 1;
 2432|  58.8k|  else
 2433|  58.8k|    stream->flags.writing = 0;
 2434|  58.8k|}
estream.c:func_fd_destroy:
 1153|  58.8k|{
 1154|  58.8k|  estream_cookie_fd_t fd_cookie = cookie;
 1155|  58.8k|  int err;
 1156|       |
 1157|  58.8k|  trace (("enter: cookie=%p", cookie));
  ------------------
  |  |  189|  58.8k|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1158|       |
 1159|  58.8k|  if (fd_cookie)
  ------------------
  |  Branch (1159:7): [True: 58.8k, False: 0]
  ------------------
 1160|  58.8k|    {
 1161|  58.8k|      if (IS_INVALID_FD (fd_cookie->fd))
  ------------------
  |  |  148|  58.8k|#define IS_INVALID_FD(a)    ((a) == -1)
  |  |  ------------------
  |  |  |  Branch (148:29): [True: 0, False: 58.8k]
  |  |  ------------------
  ------------------
 1162|      0|        err = 0;
 1163|  58.8k|      else
 1164|  58.8k|        err = fd_cookie->no_close? 0 : close (fd_cookie->fd);
  ------------------
  |  Branch (1164:15): [True: 0, False: 58.8k]
  ------------------
 1165|  58.8k|      mem_free (fd_cookie);
 1166|  58.8k|    }
 1167|      0|  else
 1168|      0|    err = 0;
 1169|       |
 1170|  58.8k|  trace_errno (err,("leave: err=%d", err));
  ------------------
  |  |  190|  58.8k|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1171|  58.8k|  return err;
 1172|  58.8k|}
estream.c:do_close:
 2593|  58.8k|{
 2594|  58.8k|  int err;
 2595|       |
 2596|  58.8k|  trace (("stream %p %s", stream, with_locked_list? "(with locked list)":""));
  ------------------
  |  |  189|  58.8k|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2597|       |
 2598|  58.8k|  if (stream)
  ------------------
  |  Branch (2598:7): [True: 58.8k, False: 0]
  ------------------
 2599|  58.8k|    {
 2600|  58.8k|      do_list_remove (stream, with_locked_list);
 2601|  58.8k|      if (cancel_mode)
  ------------------
  |  Branch (2601:11): [True: 0, False: 58.8k]
  ------------------
 2602|      0|        {
 2603|      0|          stream->flags.writing = 0;
 2604|      0|          es_empty (stream);
 2605|      0|        }
 2606|  58.8k|      while (stream->intern->onclose)
  ------------------
  |  Branch (2606:14): [True: 0, False: 58.8k]
  ------------------
 2607|      0|        {
 2608|      0|          notify_list_t tmp = stream->intern->onclose->next;
 2609|       |
 2610|      0|          if (stream->intern->onclose->fnc)
  ------------------
  |  Branch (2610:15): [True: 0, False: 0]
  ------------------
 2611|      0|            stream->intern->onclose->fnc (stream,
 2612|      0|                                          stream->intern->onclose->fnc_value);
 2613|      0|          mem_free (stream->intern->onclose);
 2614|      0|          stream->intern->onclose = tmp;
 2615|      0|        }
 2616|  58.8k|      err = deinit_stream_obj (stream);
 2617|  58.8k|      destroy_stream_lock (stream);
 2618|  58.8k|      if (stream->intern->deallocate_buffer)
  ------------------
  |  Branch (2618:11): [True: 0, False: 58.8k]
  ------------------
 2619|      0|        mem_free (stream->buffer);
 2620|  58.8k|      mem_free (stream->intern);
 2621|  58.8k|      mem_free (stream);
 2622|  58.8k|    }
 2623|      0|  else
 2624|      0|    err = 0;
 2625|       |
 2626|  58.8k|  trace_errno (err, ("stream %p err=%d", stream, err));
  ------------------
  |  |  190|  58.8k|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2627|  58.8k|  return err;
 2628|  58.8k|}
estream.c:do_list_remove:
  541|  58.8k|{
  542|  58.8k|  estream_list_t item, item_prev = NULL;
  543|       |
  544|  58.8k|  if (!with_locked_list)
  ------------------
  |  Branch (544:7): [True: 58.8k, False: 0]
  ------------------
  545|  58.8k|    lock_list ();
  546|       |
  547|  58.8k|  for (item = estream_list; item; item = item->next)
  ------------------
  |  Branch (547:29): [True: 58.8k, False: 0]
  ------------------
  548|  58.8k|    if (item->stream == stream)
  ------------------
  |  Branch (548:9): [True: 58.8k, False: 0]
  ------------------
  549|  58.8k|      break;
  550|      0|    else
  551|      0|      item_prev = item;
  552|       |
  553|  58.8k|  if (item)
  ------------------
  |  Branch (553:7): [True: 58.8k, False: 0]
  ------------------
  554|  58.8k|    {
  555|  58.8k|      if (item_prev)
  ------------------
  |  Branch (555:11): [True: 0, False: 58.8k]
  ------------------
  556|      0|        item_prev->next = item->next;
  557|  58.8k|      else
  558|  58.8k|        estream_list = item->next;
  559|  58.8k|      mem_free (item);
  560|  58.8k|    }
  561|       |
  562|  58.8k|  if (!with_locked_list)
  ------------------
  |  Branch (562:7): [True: 58.8k, False: 0]
  ------------------
  563|  58.8k|    unlock_list ();
  564|  58.8k|}
estream.c:unlock_stream:
  458|  23.7M|{
  459|  23.7M|  if (!stream->intern->samethread)
  ------------------
  |  Branch (459:7): [True: 23.7M, False: 0]
  ------------------
  460|  23.7M|    {
  461|  23.7M|      dbg_lock_1 ("enter unlock_stream for %p\n", stream);
  462|  23.7M|      _gpgrt_lock_unlock (&stream->intern->lock);
  463|  23.7M|      dbg_lock_1 ("leave unlock_stream for %p\n", stream);
  464|  23.7M|    }
  465|  23.7M|}
estream.c:flush_stream:
 2296|  9.92M|{
 2297|  9.92M|  gpgrt_cookie_write_function_t func_write = stream->intern->func_write;
 2298|  9.92M|  int err;
 2299|       |
 2300|  9.92M|  gpgrt_assert (stream->flags.writing);
  ------------------
  |  |  577|  9.92M|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 9.92M, False: 0]
  |  |  ------------------
  |  |  578|  9.92M|   ? (void) 0                                                   \
  |  |  579|  9.92M|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 2301|       |
 2302|  9.92M|  if (stream->data_offset)
  ------------------
  |  Branch (2302:7): [True: 9.76M, False: 155k]
  ------------------
 2303|  9.76M|    {
 2304|  9.76M|      size_t bytes_written;
 2305|  9.76M|      size_t data_flushed;
 2306|  9.76M|      gpgrt_ssize_t ret;
 2307|       |
 2308|  9.76M|      if (! func_write)
  ------------------
  |  Branch (2308:11): [True: 0, False: 9.76M]
  ------------------
 2309|      0|	{
 2310|      0|          _set_errno (EOPNOTSUPP);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2311|      0|          err = -1;
 2312|      0|	  goto out;
 2313|      0|	}
 2314|       |
 2315|       |      /* Note: to prevent an endless loop caused by user-provided
 2316|       |	 write-functions that pretend to have written more bytes than
 2317|       |	 they were asked to write, we have to check for
 2318|       |	 "(stream->data_offset - data_flushed) > 0" instead of
 2319|       |	 "stream->data_offset - data_flushed".  */
 2320|       |
 2321|  9.76M|      data_flushed = 0;
 2322|  9.76M|      err = 0;
 2323|       |
 2324|  19.5M|      while ((((gpgrt_ssize_t) (stream->data_offset - data_flushed)) > 0)
  ------------------
  |  Branch (2324:14): [True: 9.76M, False: 9.76M]
  ------------------
 2325|  19.5M|             && !err)
  ------------------
  |  Branch (2325:17): [True: 9.76M, False: 0]
  ------------------
 2326|  9.76M|	{
 2327|  9.76M|	  ret = (*func_write) (stream->intern->cookie,
 2328|  9.76M|			       stream->buffer + data_flushed,
 2329|  9.76M|			       stream->data_offset - data_flushed);
 2330|  9.76M|	  if (ret == -1)
  ------------------
  |  Branch (2330:8): [True: 0, False: 9.76M]
  ------------------
 2331|      0|	    {
 2332|      0|	      bytes_written = 0;
 2333|      0|	      err = -1;
 2334|       |#if EWOULDBLOCK != EAGAIN
 2335|       |              if (errno == EWOULDBLOCK)
 2336|       |                _set_errno (EAGAIN);
 2337|       |#endif
 2338|      0|	    }
 2339|  9.76M|	  else
 2340|  9.76M|	    bytes_written = ret;
 2341|       |
 2342|  9.76M|	  data_flushed += bytes_written;
 2343|  9.76M|	  if (err)
  ------------------
  |  Branch (2343:8): [True: 0, False: 9.76M]
  ------------------
 2344|      0|	    break;
 2345|  9.76M|	}
 2346|       |
 2347|  9.76M|      stream->data_flushed += data_flushed;
 2348|  9.76M|      if (stream->data_offset == data_flushed)
  ------------------
  |  Branch (2348:11): [True: 9.76M, False: 0]
  ------------------
 2349|  9.76M|	{
 2350|  9.76M|	  stream->intern->offset += stream->data_offset;
 2351|  9.76M|	  stream->data_offset = 0;
 2352|  9.76M|	  stream->data_flushed = 0;
 2353|  9.76M|	}
 2354|  9.76M|    }
 2355|   155k|  else
 2356|   155k|    err = 0;
 2357|       |
 2358|       |  /* Always propagate flush event in case gpgrt_fflush was called
 2359|       |   * explictly to do flush buffers in caller's cookie functions.  */
 2360|  9.92M|  (*func_write) (stream->intern->cookie, NULL, 0);
 2361|       |
 2362|  9.92M| out:
 2363|       |
 2364|  9.92M|  if (err && errno != EAGAIN)
  ------------------
  |  Branch (2364:7): [True: 0, False: 9.92M]
  |  Branch (2364:14): [True: 0, False: 0]
  ------------------
 2365|      0|    {
 2366|      0|      if (errno == EPIPE)
  ------------------
  |  Branch (2366:11): [True: 0, False: 0]
  ------------------
 2367|      0|        stream->intern->indicators.hup = 1;
 2368|      0|      stream->intern->indicators.err = 1;
 2369|      0|    }
 2370|       |
 2371|  9.92M|  return err;
 2372|  9.92M|}
estream.c:es_offset_calculate:
 3478|   117k|{
 3479|   117k|  gpgrt_off_t offset;
 3480|       |
 3481|   117k|  offset = stream->intern->offset + stream->data_offset;
 3482|   117k|  if (offset < stream->unread_data_len)
  ------------------
  |  Branch (3482:7): [True: 0, False: 117k]
  ------------------
 3483|       |    /* Offset undefined.  */
 3484|      0|    offset = 0;
 3485|   117k|  else
 3486|   117k|    offset -= stream->unread_data_len;
 3487|       |
 3488|   117k|  return offset;
 3489|   117k|}
estream.c:es_readn:
 2819|   176k|{
 2820|   176k|  unsigned char *buffer = (unsigned char *)buffer_arg;
 2821|   176k|  size_t data_read_unread, data_read;
 2822|   176k|  int err;
 2823|       |
 2824|   176k|  data_read_unread = 0;
 2825|   176k|  data_read = 0;
 2826|   176k|  err = 0;
 2827|       |
 2828|   176k|  if (stream->flags.writing)
  ------------------
  |  Branch (2828:7): [True: 0, False: 176k]
  ------------------
 2829|      0|    {
 2830|       |      /* Switching to reading mode -> flush output.  */
 2831|      0|      err = flush_stream (stream);
 2832|      0|      if (err)
  ------------------
  |  Branch (2832:11): [True: 0, False: 0]
  ------------------
 2833|      0|	goto out;
 2834|      0|      stream->flags.writing = 0;
 2835|      0|    }
 2836|       |
 2837|       |  /* Read unread data first.  */
 2838|   176k|  while ((bytes_to_read - data_read_unread) && stream->unread_data_len)
  ------------------
  |  Branch (2838:10): [True: 176k, False: 0]
  |  Branch (2838:48): [True: 0, False: 176k]
  ------------------
 2839|      0|    {
 2840|      0|      buffer[data_read_unread]
 2841|      0|	= stream->unread_buffer[stream->unread_data_len - 1];
 2842|      0|      stream->unread_data_len--;
 2843|      0|      data_read_unread++;
 2844|      0|    }
 2845|       |
 2846|   176k|  switch (stream->intern->strategy)
  ------------------
  |  Branch (2846:11): [True: 0, False: 176k]
  ------------------
 2847|   176k|    {
 2848|      0|    case _IONBF:
  ------------------
  |  Branch (2848:5): [True: 0, False: 176k]
  ------------------
 2849|      0|      err = do_read_nbf (stream,
 2850|      0|			 buffer + data_read_unread,
 2851|      0|			 bytes_to_read - data_read_unread, &data_read);
 2852|      0|      break;
 2853|      0|    case _IOLBF:
  ------------------
  |  Branch (2853:5): [True: 0, False: 176k]
  ------------------
 2854|      0|      err = do_read_lbf (stream,
 2855|      0|			 buffer + data_read_unread,
 2856|      0|			 bytes_to_read - data_read_unread, &data_read);
 2857|      0|      break;
 2858|   176k|    case _IOFBF:
  ------------------
  |  Branch (2858:5): [True: 176k, False: 0]
  ------------------
 2859|   176k|      err = do_read_fbf (stream,
 2860|   176k|			 buffer + data_read_unread,
 2861|   176k|			 bytes_to_read - data_read_unread, &data_read);
 2862|   176k|      break;
 2863|   176k|    }
 2864|       |
 2865|   176k| out:
 2866|       |
 2867|   176k|  if (bytes_read)
  ------------------
  |  Branch (2867:7): [True: 176k, False: 0]
  ------------------
 2868|   176k|    *bytes_read = data_read_unread + data_read;
 2869|       |
 2870|   176k|  return err;
 2871|   176k|}
estream.c:do_read_fbf:
 2728|   176k|{
 2729|   176k|  size_t data_available;
 2730|   176k|  size_t data_to_read;
 2731|   176k|  size_t data_read;
 2732|   176k|  int err;
 2733|       |
 2734|   176k|  data_read = 0;
 2735|   176k|  err = 0;
 2736|       |
 2737|   294k|  while ((bytes_to_read - data_read) && (! err))
  ------------------
  |  Branch (2737:10): [True: 176k, False: 117k]
  |  Branch (2737:41): [True: 176k, False: 0]
  ------------------
 2738|   176k|    {
 2739|   176k|      if (stream->data_offset == stream->data_len)
  ------------------
  |  Branch (2739:11): [True: 117k, False: 58.9k]
  ------------------
 2740|   117k|	{
 2741|       |	  /* Nothing more to read in current container, try to
 2742|       |	     fill container with new data.  */
 2743|   117k|	  err = fill_stream (stream);
 2744|   117k|	  if (! err)
  ------------------
  |  Branch (2744:8): [True: 117k, False: 0]
  ------------------
 2745|   117k|	    if (! stream->data_len)
  ------------------
  |  Branch (2745:10): [True: 58.9k, False: 58.9k]
  ------------------
 2746|       |	      /* Filling did not result in any data read.  */
 2747|  58.9k|	      break;
 2748|   117k|	}
 2749|       |
 2750|   117k|      if (! err)
  ------------------
  |  Branch (2750:11): [True: 117k, False: 0]
  ------------------
 2751|   117k|	{
 2752|       |	  /* Filling resulted in some new data.  */
 2753|       |
 2754|   117k|	  data_to_read = bytes_to_read - data_read;
 2755|   117k|	  data_available = stream->data_len - stream->data_offset;
 2756|   117k|	  if (data_to_read > data_available)
  ------------------
  |  Branch (2756:8): [True: 0, False: 117k]
  ------------------
 2757|      0|	    data_to_read = data_available;
 2758|       |
 2759|   117k|	  memcpy (buffer + data_read,
 2760|   117k|		  stream->buffer + stream->data_offset, data_to_read);
 2761|   117k|	  stream->data_offset += data_to_read;
 2762|   117k|	  data_read += data_to_read;
 2763|   117k|	}
 2764|   117k|    }
 2765|       |
 2766|   176k|  *bytes_read = data_read;
 2767|       |
 2768|   176k|  return err;
 2769|   176k|}
estream.c:fill_stream:
 2241|   117k|{
 2242|   117k|  size_t bytes_read = 0;
 2243|   117k|  int err;
 2244|       |
 2245|   117k|  if (!stream->intern->func_read)
  ------------------
  |  Branch (2245:7): [True: 0, False: 117k]
  ------------------
 2246|      0|    {
 2247|      0|      _set_errno (EOPNOTSUPP);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2248|      0|      err = -1;
 2249|      0|    }
 2250|   117k|  else if (!stream->buffer_size)
  ------------------
  |  Branch (2250:12): [True: 0, False: 117k]
  ------------------
 2251|      0|    err = 0;
 2252|   117k|  else
 2253|   117k|    {
 2254|   117k|      gpgrt_cookie_read_function_t func_read = stream->intern->func_read;
 2255|   117k|      gpgrt_ssize_t ret;
 2256|       |
 2257|   117k|      ret = (*func_read) (stream->intern->cookie,
 2258|   117k|			  stream->buffer, stream->buffer_size);
 2259|   117k|      if (ret == -1)
  ------------------
  |  Branch (2259:11): [True: 0, False: 117k]
  ------------------
 2260|      0|	{
 2261|      0|	  bytes_read = 0;
 2262|      0|	  err = -1;
 2263|       |#if EWOULDBLOCK != EAGAIN
 2264|       |          if (errno == EWOULDBLOCK)
 2265|       |            _set_errno (EAGAIN);
 2266|       |#endif
 2267|      0|	}
 2268|   117k|      else
 2269|   117k|	{
 2270|   117k|	  bytes_read = ret;
 2271|   117k|	  err = 0;
 2272|   117k|	}
 2273|   117k|    }
 2274|       |
 2275|   117k|  if (err)
  ------------------
  |  Branch (2275:7): [True: 0, False: 117k]
  ------------------
 2276|      0|    {
 2277|      0|      if (errno != EAGAIN)
  ------------------
  |  Branch (2277:11): [True: 0, False: 0]
  ------------------
 2278|      0|        {
 2279|      0|          if (errno == EPIPE)
  ------------------
  |  Branch (2279:15): [True: 0, False: 0]
  ------------------
 2280|      0|            stream->intern->indicators.hup = 1;
 2281|      0|          stream->intern->indicators.err = 1;
 2282|      0|        }
 2283|      0|    }
 2284|   117k|  else if (!bytes_read)
  ------------------
  |  Branch (2284:12): [True: 58.9k, False: 58.9k]
  ------------------
 2285|  58.9k|    stream->intern->indicators.eof = 1;
 2286|       |
 2287|   117k|  stream->intern->offset += stream->data_len;
 2288|   117k|  stream->data_len = bytes_read;
 2289|   117k|  stream->data_offset = 0;
 2290|       |
 2291|   117k|  return err;
 2292|   117k|}
estream.c:mem_alloc:
  212|   294k|{
  213|   294k|  return _gpgrt_malloc (n);
  214|   294k|}
estream.c:do_print_stream:
 3405|  15.9M|{
 3406|  15.9M|  int rc;
 3407|       |
 3408|  15.9M|  stream->intern->print_ntotal = 0;
 3409|  15.9M|  rc = _gpgrt_estream_format (print_writer, stream, sf, sfvalue, format, ap);
 3410|  15.9M|  if (rc)
  ------------------
  |  Branch (3410:7): [True: 0, False: 15.9M]
  ------------------
 3411|      0|    return -1;
 3412|  15.9M|  return (int)stream->intern->print_ntotal;
 3413|  15.9M|}
estream.c:print_writer:
 3388|  68.7M|{
 3389|  68.7M|  estream_t stream = outfncarg;
 3390|  68.7M|  size_t nwritten;
 3391|  68.7M|  int rc;
 3392|       |
 3393|  68.7M|  nwritten = 0;
 3394|  68.7M|  rc = es_writen (stream, buf, buflen, &nwritten);
 3395|  68.7M|  stream->intern->print_ntotal += nwritten;
 3396|  68.7M|  return rc;
 3397|  68.7M|}
estream.c:fname_set_internal:
 5598|  58.8k|{
 5599|  58.8k|  if (stream->intern->printable_fname
  ------------------
  |  Branch (5599:7): [True: 0, False: 58.8k]
  ------------------
 5600|  58.8k|      && !stream->intern->printable_fname_inuse)
  ------------------
  |  Branch (5600:10): [True: 0, False: 0]
  ------------------
 5601|      0|    {
 5602|      0|      mem_free (stream->intern->printable_fname);
 5603|      0|      stream->intern->printable_fname = NULL;
 5604|      0|    }
 5605|  58.8k|  if (stream->intern->printable_fname)
  ------------------
  |  Branch (5605:7): [True: 0, False: 58.8k]
  ------------------
 5606|      0|    return; /* Can't change because it is in use.  */
 5607|       |
 5608|  58.8k|  if (*fname != '[')
  ------------------
  |  Branch (5608:7): [True: 58.8k, False: 2]
  ------------------
 5609|  58.8k|    quote = 0;
 5610|      2|  else
 5611|      2|    quote = !!quote;
 5612|       |
 5613|  58.8k|  stream->intern->printable_fname = mem_alloc (strlen (fname) + quote + 1);
 5614|  58.8k|  if (quote)
  ------------------
  |  Branch (5614:7): [True: 0, False: 58.8k]
  ------------------
 5615|      0|    stream->intern->printable_fname[0] = '\\';
 5616|  58.8k|  strcpy (stream->intern->printable_fname+quote, fname);
 5617|  58.8k|}

strsource.c:gpg_err_source:
  977|   176k|{
  978|   176k|  return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
  ------------------
  |  |  748|   176k|#define GPG_ERR_SOURCE_SHIFT	24
  ------------------
  979|   176k|			     & GPG_ERR_SOURCE_MASK);
  ------------------
  |  |  747|   176k|#define GPG_ERR_SOURCE_MASK	(GPG_ERR_SOURCE_DIM - 1)
  ------------------
  980|   176k|}
strerror.c:gpg_err_code:
  969|   307k|{
  970|   307k|  return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
  ------------------
  |  |  742|   307k|#define GPG_ERR_CODE_MASK	(GPG_ERR_CODE_DIM - 1)
  ------------------
  971|   307k|}

_gpg_err_init:
   92|      2|{
   93|       |#ifdef HAVE_W32_SYSTEM
   94|       |# ifdef DLL_EXPORT
   95|       |  /* We always have a constructor and thus this function is called
   96|       |     automatically.  Due to the way the C init code of mingw works,
   97|       |     the constructors are called before our DllMain function is
   98|       |     called.  The problem with that is that the TLS has not been setup
   99|       |     and w32-gettext.c requires TLS.  To solve this we do nothing here
  100|       |     but call the actual init code from our DllMain.  */
  101|       |# else /*!DLL_EXPORT*/
  102|       |  /* Note that if the TLS is actually used, we can't release the TLS
  103|       |     as there is no way to know when a thread terminates (i.e. no
  104|       |     thread-specific-atexit).  You are really better off to use the
  105|       |     DLL! */
  106|       |  if (tls_index == TLS_OUT_OF_INDEXES)
  107|       |    {
  108|       |      tls_index = TlsAlloc ();
  109|       |      if (tls_index == TLS_OUT_OF_INDEXES)
  110|       |        {
  111|       |          /* No way to continue - commit suicide.  */
  112|       |          _gpgrt_abort ();
  113|       |        }
  114|       |      _gpg_w32__init_gettext_module ();
  115|       |      real_init ();
  116|       |    }
  117|       |# endif /*!DLL_EXPORT*/
  118|       |#else
  119|      2|  real_init ();
  120|      2|#endif
  121|      2|  return 0;
  122|      2|}
_gpgrt_realloc:
  234|   588k|{
  235|   588k|  if (custom_realloc)
  ------------------
  |  Branch (235:7): [True: 0, False: 588k]
  ------------------
  236|      0|    return custom_realloc (a, n);
  237|       |
  238|   588k|  if (!n)
  ------------------
  |  Branch (238:7): [True: 294k, False: 294k]
  ------------------
  239|   294k|    {
  240|   294k|      free (a);
  241|   294k|      return NULL;
  242|   294k|    }
  243|       |
  244|   294k|  if (!a)
  ------------------
  |  Branch (244:7): [True: 294k, False: 0]
  ------------------
  245|   294k|    return malloc (n);
  246|       |
  247|      0|  return realloc (a, n);
  248|   294k|}
_gpgrt_malloc:
  303|   294k|{
  304|   294k|  if (!n)
  ------------------
  |  Branch (304:7): [True: 0, False: 294k]
  ------------------
  305|      0|    n++;
  306|   294k|  return _gpgrt_realloc (NULL, n);
  307|   294k|}
_gpgrt_free:
  398|   294k|{
  399|   294k|  int save_errno;
  400|       |
  401|   294k|  if (!a)
  ------------------
  |  Branch (401:7): [True: 0, False: 294k]
  ------------------
  402|      0|    return;  /* Shortcut */
  403|       |
  404|       |  /* In case ERRNO is set we better save it so that the free machinery
  405|       |   * may not accidentally change ERRNO.  We restore it only if it was
  406|       |   * already set to comply with the usual C semantic for ERRNO.
  407|       |   * See also https://dev.gnupg.org/T5393#146261  */
  408|   294k|  save_errno = errno;
  409|   294k|  _gpgrt_realloc (a, 0);
  410|   294k|  if (save_errno && save_errno != errno)
  ------------------
  |  Branch (410:7): [True: 294k, False: 5]
  |  Branch (410:21): [True: 0, False: 294k]
  ------------------
  411|      0|    _gpg_err_set_errno (save_errno);
  412|   294k|}
_gpg_err_set_errno:
  417|  10.3k|{
  418|  10.3k|  errno = err;
  419|  10.3k|}
init.c:real_init:
   74|      2|{
   75|      2|#ifdef ENABLE_NLS
   76|      2|  char *locale_dir;
   77|       |
   78|       |  /* We only have to bind our locale directory to our text domain.  */
   79|      2|  locale_dir = get_locale_dir ();
  ------------------
  |  |   47|      2|#define get_locale_dir() LOCALEDIR
  ------------------
   80|      2|  if (locale_dir)
  ------------------
  |  Branch (80:7): [True: 2, False: 0]
  ------------------
   81|      2|    {
   82|      2|      bindtextdomain (PACKAGE, locale_dir);
  ------------------
  |  |  210|      2|#define PACKAGE "libgpg-error"
  ------------------
   83|      2|      drop_locale_dir (locale_dir);
   84|      2|    }
   85|      2|#endif
   86|      2|  _gpgrt_estream_init ();
   87|      2|}

_gpgrt_inc_errorcount:
  128|  2.62M|{
  129|       |  /* Protect against counter overflow.  */
  130|  2.62M|  if (errorcount < 30000)
  ------------------
  |  Branch (130:7): [True: 30.0k, False: 2.59M]
  ------------------
  131|  30.0k|    errorcount++;
  132|  2.62M|}
_gpgrt_log_set_sink:
  538|      2|{
  539|      2|  if (name && !stream && fd == -1)
  ------------------
  |  Branch (539:7): [True: 1, False: 1]
  |  Branch (539:15): [True: 1, False: 0]
  |  Branch (539:26): [True: 1, False: 0]
  ------------------
  540|      1|    set_file_fd (name, -1, NULL);
  541|      1|  else if (!name && !stream && fd != -1)
  ------------------
  |  Branch (541:12): [True: 1, False: 0]
  |  Branch (541:21): [True: 1, False: 0]
  |  Branch (541:32): [True: 0, False: 1]
  ------------------
  542|      0|    {
  543|      0|      if (!_gpgrt_fd_valid_p (fd))
  ------------------
  |  Branch (543:11): [True: 0, False: 0]
  ------------------
  544|      0|        _gpgrt_log_fatal ("gpgrt_log_set_sink: fd is invalid: %s\n",
  545|      0|                     strerror (errno));
  546|      0|      set_file_fd (NULL, fd, NULL);
  547|      0|    }
  548|      1|  else if (!name && stream && fd == -1)
  ------------------
  |  Branch (548:12): [True: 1, False: 0]
  |  Branch (548:21): [True: 0, False: 1]
  |  Branch (548:31): [True: 0, False: 0]
  ------------------
  549|      0|    {
  550|      0|      set_file_fd (NULL, -1, stream);
  551|      0|    }
  552|      1|  else /* default */
  553|      1|    set_file_fd ("-", -1, NULL);
  554|      2|}
_gpgrt_log_get_stream:
  643|  19.7k|{
  644|  19.7k|  if (!logstream)
  ------------------
  |  Branch (644:7): [True: 0, False: 19.7k]
  ------------------
  645|      0|    {
  646|       |      /* Make sure a log stream has been set.  */
  647|      0|      _gpgrt_log_set_sink (NULL, NULL, -1);
  648|      0|      if (!logstream)
  ------------------
  |  Branch (648:11): [True: 0, False: 0]
  ------------------
  649|      0|        {
  650|      0|          fputs ("gpgrt fatal: failed to init log stream\n", stderr);
  651|      0|          _gpgrt_abort ();
  652|      0|        }
  653|      0|    }
  654|  19.7k|  return logstream;
  655|  19.7k|}
_gpgrt_logv_internal:
  844|  9.93M|{
  845|  9.93M|  int leading_backspace = (fmt && *fmt == '\b');
  ------------------
  |  Branch (845:28): [True: 9.93M, False: 0]
  |  Branch (845:35): [True: 0, False: 9.93M]
  ------------------
  846|  9.93M|  int length;
  847|  9.93M|  int rc;
  848|       |
  849|  9.93M|  if (!logstream)
  ------------------
  |  Branch (849:7): [True: 1, False: 9.93M]
  ------------------
  850|      1|    {
  851|       |#ifdef HAVE_W32_SYSTEM
  852|       |      char *tmp;
  853|       |
  854|       |      tmp = (no_registry
  855|       |             ? NULL
  856|       |             : _gpgrt_w32_reg_query_string (NULL, "Software\\\\GNU\\\\GnuPG",
  857|       |                                            "DefaultLogFile"));
  858|       |      _gpgrt_log_set_sink (tmp && *tmp? tmp : NULL, NULL, -1);
  859|       |      _gpgrt_free (tmp);
  860|       |#else
  861|       |      /* Make sure a log stream has been set.  */
  862|      1|      _gpgrt_log_set_sink (NULL, NULL, -1);
  863|      1|#endif
  864|      1|      if (!logstream)
  ------------------
  |  Branch (864:11): [True: 0, False: 1]
  ------------------
  865|      0|        {
  866|      0|          fputs ("gpgrt fatal: failed to init log stream\n", stderr);
  867|      0|          _gpgrt_abort ();
  868|      0|        }
  869|      1|    }
  870|       |
  871|  9.93M|  _gpgrt_flockfile (logstream);
  872|  9.93M|  if (missing_lf && level != GPGRT_LOGLVL_CONT)
  ------------------
  |  Branch (872:7): [True: 19.7k, False: 9.91M]
  |  Branch (872:21): [True: 0, False: 19.7k]
  ------------------
  873|      0|    _gpgrt_putc_unlocked ('\n', logstream );
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  874|  9.93M|  missing_lf = 0;
  875|       |
  876|  9.93M|  length = print_prefix (level, leading_backspace);
  877|  9.93M|  if (leading_backspace)
  ------------------
  |  Branch (877:7): [True: 0, False: 9.93M]
  ------------------
  878|      0|    fmt++;
  879|       |
  880|  9.93M|  if (fmt)
  ------------------
  |  Branch (880:7): [True: 9.93M, False: 0]
  ------------------
  881|  9.93M|    {
  882|  9.93M|      if (prefmt)
  ------------------
  |  Branch (882:11): [True: 0, False: 9.93M]
  ------------------
  883|      0|        {
  884|      0|          _gpgrt_fputs_unlocked (prefmt, logstream);
  885|      0|          length += strlen (prefmt);
  886|      0|        }
  887|       |
  888|  9.93M|      if (ignore_arg_ptr)
  ------------------
  |  Branch (888:11): [True: 0, False: 9.93M]
  ------------------
  889|      0|        { /* This is used by log_string and comes with the extra
  890|       |           * feature that after a LF the next line is indent at the
  891|       |           * length of the prefix.  Note that we do not yet include
  892|       |           * the length of the timestamp and pid in the indent
  893|       |           * computation.  */
  894|      0|          const char *p, *pend;
  895|       |
  896|      0|          for (p = fmt; (pend = strchr (p, '\n')); p = pend+1)
  ------------------
  |  Branch (896:25): [True: 0, False: 0]
  ------------------
  897|      0|            {
  898|      0|              rc = _gpgrt_fprintf_unlocked (logstream, "%*s%.*s",
  899|      0|                                 (int)((p != fmt
  ------------------
  |  Branch (899:41): [True: 0, False: 0]
  ------------------
  900|      0|                                        && (with_prefix || force_prefixes))
  ------------------
  |  Branch (900:45): [True: 0, False: 0]
  |  Branch (900:60): [True: 0, False: 0]
  ------------------
  901|      0|                                       ?strlen (prefix_buffer)+2:0), "",
  902|      0|                                 (int)(pend - p)+1, p);
  903|      0|              if (rc > 0)
  ------------------
  |  Branch (903:19): [True: 0, False: 0]
  ------------------
  904|      0|                length += rc;
  905|      0|            }
  906|      0|          _gpgrt_fputs_unlocked (p, logstream);
  907|      0|          length += strlen (p);
  908|      0|        }
  909|  9.93M|      else
  910|  9.93M|        {
  911|  9.93M|          struct fmt_string_filter_s sf = {NULL};
  912|       |
  913|  9.93M|          rc = _gpgrt_vfprintf_unlocked (logstream, fmt_string_filter, &sf,
  914|  9.93M|                                         fmt, arg_ptr);
  915|  9.93M|          if (rc > 0)
  ------------------
  |  Branch (915:15): [True: 9.93M, False: 0]
  ------------------
  916|  9.93M|            length += rc;
  917|  9.93M|        }
  918|       |
  919|  9.93M|      if (*fmt && fmt[strlen(fmt)-1] != '\n')
  ------------------
  |  Branch (919:11): [True: 9.93M, False: 0]
  |  Branch (919:19): [True: 19.7k, False: 9.91M]
  ------------------
  920|  19.7k|        missing_lf = 1;
  921|  9.93M|    }
  922|       |
  923|       |  /* If we have an EXTRASTRING print it now while we still hold the
  924|       |   * lock on the logstream.  */
  925|  9.93M|  if (extrastring)
  ------------------
  |  Branch (925:7): [True: 0, False: 9.93M]
  ------------------
  926|      0|    {
  927|      0|      int c;
  928|       |
  929|      0|      if (missing_lf)
  ------------------
  |  Branch (929:11): [True: 0, False: 0]
  ------------------
  930|      0|        {
  931|      0|          _gpgrt_putc_unlocked ('\n', logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  932|      0|          missing_lf = 0;
  933|      0|          length = 0;
  934|      0|        }
  935|      0|      length += print_prefix (level, leading_backspace);
  936|      0|      _gpgrt_fputs_unlocked (">> ", logstream);
  937|      0|      length += 3;
  938|      0|      missing_lf = 1;
  939|      0|      while ((c = *extrastring++))
  ------------------
  |  Branch (939:14): [True: 0, False: 0]
  ------------------
  940|      0|        {
  941|      0|          missing_lf = 1;
  942|      0|          if (c == '\\')
  ------------------
  |  Branch (942:15): [True: 0, False: 0]
  ------------------
  943|      0|            {
  944|      0|              _gpgrt_fputs_unlocked ("\\\\", logstream);
  945|      0|              length += 2;
  946|      0|            }
  947|      0|          else if (c == '\r')
  ------------------
  |  Branch (947:20): [True: 0, False: 0]
  ------------------
  948|      0|            {
  949|      0|              _gpgrt_fputs_unlocked ("\\r", logstream);
  950|      0|              length += 2;
  951|      0|            }
  952|      0|          else if (c == '\n')
  ------------------
  |  Branch (952:20): [True: 0, False: 0]
  ------------------
  953|      0|            {
  954|      0|              _gpgrt_fputs_unlocked ("\\n\n", logstream);
  955|      0|              length = 0;
  956|      0|              if (*extrastring)
  ------------------
  |  Branch (956:19): [True: 0, False: 0]
  ------------------
  957|      0|                {
  958|      0|                  length += print_prefix (level, leading_backspace);
  959|      0|                  _gpgrt_fputs_unlocked (">> ", logstream);
  960|      0|                  length += 3;
  961|      0|                }
  962|      0|              else
  963|      0|                missing_lf = 0;
  964|      0|            }
  965|      0|          else
  966|      0|            {
  967|      0|              _gpgrt_putc_unlocked (c, logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  968|      0|              length++;
  969|      0|            }
  970|      0|        }
  971|      0|      if (missing_lf)
  ------------------
  |  Branch (971:11): [True: 0, False: 0]
  ------------------
  972|      0|        {
  973|      0|          _gpgrt_putc_unlocked ('\n', logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  974|      0|          length = 0;
  975|      0|          missing_lf = 0;
  976|      0|        }
  977|      0|    }
  978|       |
  979|  9.93M|  if (level == GPGRT_LOGLVL_FATAL)
  ------------------
  |  Branch (979:7): [True: 0, False: 9.93M]
  ------------------
  980|      0|    {
  981|      0|      if (missing_lf)
  ------------------
  |  Branch (981:11): [True: 0, False: 0]
  ------------------
  982|      0|        _gpgrt_putc_unlocked ('\n', logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  983|      0|      _gpgrt_funlockfile (logstream);
  984|      0|      exit (2);
  985|      0|    }
  986|  9.93M|  else if (level == GPGRT_LOGLVL_BUG)
  ------------------
  |  Branch (986:12): [True: 0, False: 9.93M]
  ------------------
  987|      0|    {
  988|      0|      if (missing_lf)
  ------------------
  |  Branch (988:11): [True: 0, False: 0]
  ------------------
  989|      0|        _gpgrt_putc_unlocked ('\n', logstream );
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  990|      0|      _gpgrt_funlockfile (logstream);
  991|       |      /* Using backtrace requires a configure test and to pass
  992|       |       * -rdynamic to gcc.  Thus we do not enable it now.  */
  993|       |      /* { */
  994|       |      /*   void *btbuf[20]; */
  995|       |      /*   int btidx, btlen; */
  996|       |      /*   char **btstr; */
  997|       |
  998|       |      /*   btlen = backtrace (btbuf, DIM (btbuf)); */
  999|       |      /*   btstr = backtrace_symbols (btbuf, btlen); */
 1000|       |      /*   if (btstr) */
 1001|       |      /*     for (btidx=0; btidx < btlen; btidx++) */
 1002|       |      /*       log_debug ("[%d] %s\n", btidx, btstr[btidx]); */
 1003|       |      /* } */
 1004|      0|      _gpgrt_abort ();
 1005|      0|    }
 1006|  9.93M|  else
 1007|  9.93M|    _gpgrt_funlockfile (logstream);
 1008|       |
 1009|       |  /* Bumb the error counter for log_error.  */
 1010|  9.93M|  if (level == GPGRT_LOGLVL_ERROR)
  ------------------
  |  Branch (1010:7): [True: 2.62M, False: 7.30M]
  ------------------
 1011|  2.62M|    _gpgrt_inc_errorcount ();
 1012|       |
 1013|  9.93M|  return length;
 1014|  9.93M|}
_gpgrt_logv:
 1030|  9.93M|{
 1031|  9.93M|  _gpgrt_logv_internal (level, 0, NULL, NULL, fmt, arg_ptr);
 1032|  9.93M|}
logging.c:set_file_fd:
  450|      2|{
  451|      2|  estream_t fp;
  452|      2|  int want_socket = 0;
  453|      2|  struct fun_cookie_s *cookie;
  454|       |
  455|       |  /* Close an open log stream.  */
  456|      2|  if (logstream)
  ------------------
  |  Branch (456:7): [True: 1, False: 1]
  ------------------
  457|      1|    {
  458|      1|      if (logstream != es_stderr)
  ------------------
  |  |  363|      1|#define es_stderr _gpgrt__get_std_stream (2)
  ------------------
  |  Branch (458:11): [True: 0, False: 1]
  ------------------
  459|      0|        _gpgrt_fclose (logstream);
  460|      1|      logstream = NULL;
  461|      1|    }
  462|       |
  463|      2|  if (stream)
  ------------------
  |  Branch (463:7): [True: 0, False: 2]
  ------------------
  464|      0|    {
  465|       |      /* We don't use a cookie to log directly to a stream.  */
  466|      0|      fp = stream;
  467|      0|      goto leave;
  468|      0|    }
  469|       |
  470|       |  /* Figure out what kind of logging we want.  */
  471|      2|  if (name && !strcmp (name, "-"))
  ------------------
  |  Branch (471:7): [True: 2, False: 0]
  |  Branch (471:15): [True: 1, False: 1]
  ------------------
  472|      1|    {
  473|      1|      fp = es_stderr;
  ------------------
  |  |  363|      1|#define es_stderr _gpgrt__get_std_stream (2)
  ------------------
  474|      1|      goto leave;
  475|      1|    }
  476|      1|  else if (name && !strncmp (name, "tcp://", 6) && name[6])
  ------------------
  |  Branch (476:12): [True: 1, False: 0]
  |  Branch (476:20): [True: 0, False: 1]
  |  Branch (476:52): [True: 0, False: 0]
  ------------------
  477|      0|    want_socket = 1;
  478|      1|#ifndef HAVE_W32_SYSTEM
  479|      1|  else if (name && !strncmp (name, "socket://", 9))
  ------------------
  |  Branch (479:12): [True: 1, False: 0]
  |  Branch (479:20): [True: 0, False: 1]
  ------------------
  480|      0|    want_socket = 2;
  481|      1|#endif /*HAVE_W32_SYSTEM*/
  482|       |
  483|       |  /* Setup a new stream.  */
  484|       |
  485|      1|  if (!name)
  ------------------
  |  Branch (485:7): [True: 0, False: 1]
  ------------------
  486|      0|    fp = _gpgrt_fdopen (fd, "w");
  487|      1|  else if (!want_socket)
  ------------------
  |  Branch (487:12): [True: 1, False: 0]
  ------------------
  488|      1|    fp = _gpgrt_fopen (name, "a");
  489|      0|  else
  490|      0|    {
  491|      0|      es_cookie_io_functions_t io = { NULL };
  492|       |
  493|      0|      cookie = _gpgrt_malloc (sizeof *cookie + (name? strlen (name):0));
  ------------------
  |  Branch (493:49): [True: 0, False: 0]
  ------------------
  494|      0|      if (!cookie)
  ------------------
  |  Branch (494:11): [True: 0, False: 0]
  ------------------
  495|      0|        return; /* oops */
  496|      0|      strcpy (cookie->name, name? name:"");
  ------------------
  |  Branch (496:29): [True: 0, False: 0]
  ------------------
  497|      0|      cookie->quiet = 0;
  498|      0|      cookie->is_socket = 0;
  499|      0|      cookie->want_socket = want_socket;
  500|      0|      cookie->fd = -1;
  501|      0|      log_socket = cookie->fd;
  502|       |
  503|      0|      io.func_write = fun_writer;
  504|      0|      io.func_close = fun_closer;
  505|       |
  506|      0|      fp = _gpgrt_fopencookie (cookie, "w", io);
  507|      0|    }
  508|       |
  509|       |  /* On error default to a stderr based estream.  */
  510|      1|  if (!fp)
  ------------------
  |  Branch (510:7): [True: 0, False: 1]
  ------------------
  511|      0|    fp = es_stderr;
  ------------------
  |  |  363|      0|#define es_stderr _gpgrt__get_std_stream (2)
  ------------------
  512|       |
  513|      2| leave:
  514|      2|  _gpgrt_setvbuf (fp, NULL, _IOLBF, 0);
  515|       |
  516|      2|  logstream = fp;
  517|       |
  518|       |  /* We always need to print the prefix and the pid for socket mode,
  519|       |     so that the server reading the socket can do something
  520|       |     meaningful. */
  521|      2|  force_prefixes = want_socket;
  522|       |
  523|      2|  missing_lf = 0;
  524|      2|}
logging.c:print_prefix:
  752|  9.93M|{
  753|  9.93M|  int rc;
  754|  9.93M|  int length = 0;
  755|       |
  756|  9.93M|  if (level != GPGRT_LOGLVL_CONT)
  ------------------
  |  Branch (756:7): [True: 9.91M, False: 19.7k]
  ------------------
  757|  9.91M|    { /* Note this does not work for multiple line logging as we would
  758|       |       * need to print to a buffer first */
  759|  9.91M|      if (with_time && !force_prefixes)
  ------------------
  |  Branch (759:11): [True: 0, False: 9.91M]
  |  Branch (759:24): [True: 0, False: 0]
  ------------------
  760|      0|        {
  761|      0|          struct tm *tp;
  762|      0|          time_t atime = time (NULL);
  763|       |
  764|      0|          tp = localtime (&atime);
  765|      0|          rc = _gpgrt_fprintf_unlocked (logstream,
  766|      0|                                        "%04d-%02d-%02d %02d:%02d:%02d ",
  767|      0|                               1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday,
  768|      0|                               tp->tm_hour, tp->tm_min, tp->tm_sec );
  769|      0|          if (rc > 0)
  ------------------
  |  Branch (769:15): [True: 0, False: 0]
  ------------------
  770|      0|            length += rc;
  771|      0|        }
  772|  9.91M|      if (with_prefix || force_prefixes)
  ------------------
  |  Branch (772:11): [True: 0, False: 9.91M]
  |  Branch (772:26): [True: 0, False: 9.91M]
  ------------------
  773|      0|        {
  774|      0|          _gpgrt_fputs_unlocked (prefix_buffer, logstream);
  775|      0|          length += strlen (prefix_buffer);
  776|      0|        }
  777|  9.91M|      if (with_pid || force_prefixes)
  ------------------
  |  Branch (777:11): [True: 0, False: 9.91M]
  |  Branch (777:23): [True: 0, False: 9.91M]
  ------------------
  778|      0|        {
  779|      0|          unsigned long pidsuf;
  780|      0|          int pidfmt;
  781|       |
  782|      0|          if (get_pid_suffix_cb && (pidfmt=get_pid_suffix_cb (&pidsuf)))
  ------------------
  |  Branch (782:15): [True: 0, False: 0]
  |  Branch (782:36): [True: 0, False: 0]
  ------------------
  783|      0|            rc = _gpgrt_fprintf_unlocked (logstream,
  784|      0|                                          pidfmt == 1? "[%u.%lu]":"[%u.%lx]",
  ------------------
  |  Branch (784:43): [True: 0, False: 0]
  ------------------
  785|      0|                                          (unsigned int)getpid (), pidsuf);
  786|      0|          else
  787|      0|            rc = _gpgrt_fprintf_unlocked (logstream, "[%u]",
  788|      0|                                          (unsigned int)getpid ());
  789|      0|          if (rc > 0)
  ------------------
  |  Branch (789:15): [True: 0, False: 0]
  ------------------
  790|      0|            length += rc;
  791|      0|        }
  792|  9.91M|      if ((!with_time && (with_prefix || with_pid)) || force_prefixes)
  ------------------
  |  Branch (792:12): [True: 9.91M, False: 0]
  |  Branch (792:27): [True: 0, False: 9.91M]
  |  Branch (792:42): [True: 0, False: 9.91M]
  |  Branch (792:56): [True: 0, False: 9.91M]
  ------------------
  793|      0|        {
  794|      0|          _gpgrt_putc_unlocked (':', logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  795|      0|          length++;
  796|      0|        }
  797|       |      /* A leading backspace suppresses the extra space so that we can
  798|       |         correctly output, programname, filename and linenumber. */
  799|  9.91M|      if (!leading_backspace
  ------------------
  |  Branch (799:11): [True: 9.91M, False: 0]
  ------------------
  800|  9.91M|          && (with_time || with_prefix || with_pid || force_prefixes))
  ------------------
  |  Branch (800:15): [True: 0, False: 9.91M]
  |  Branch (800:28): [True: 0, False: 9.91M]
  |  Branch (800:43): [True: 0, False: 9.91M]
  |  Branch (800:55): [True: 0, False: 9.91M]
  ------------------
  801|      0|        {
  802|      0|          _gpgrt_putc_unlocked (' ', logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  803|      0|          length++;
  804|      0|        }
  805|  9.91M|    }
  806|       |
  807|  9.93M|  switch (level)
  808|  9.93M|    {
  809|      0|    case GPGRT_LOGLVL_BEGIN: break;
  ------------------
  |  Branch (809:5): [True: 0, False: 9.93M]
  ------------------
  810|  19.7k|    case GPGRT_LOGLVL_CONT: break;
  ------------------
  |  Branch (810:5): [True: 19.7k, False: 9.91M]
  ------------------
  811|  7.28M|    case GPGRT_LOGLVL_INFO: break;
  ------------------
  |  Branch (811:5): [True: 7.28M, False: 2.64M]
  ------------------
  812|      0|    case GPGRT_LOGLVL_WARN: break;
  ------------------
  |  Branch (812:5): [True: 0, False: 9.93M]
  ------------------
  813|  2.62M|    case GPGRT_LOGLVL_ERROR: break;
  ------------------
  |  Branch (813:5): [True: 2.62M, False: 7.30M]
  ------------------
  814|      0|    case GPGRT_LOGLVL_FATAL:
  ------------------
  |  Branch (814:5): [True: 0, False: 9.93M]
  ------------------
  815|      0|      _gpgrt_fputs_unlocked ("Fatal: ", logstream);
  816|      0|      length += 7;
  817|      0|      break;
  818|      0|    case GPGRT_LOGLVL_BUG:
  ------------------
  |  Branch (818:5): [True: 0, False: 9.93M]
  ------------------
  819|      0|      _gpgrt_fputs_unlocked ("Ohhhh jeeee: ", logstream);
  820|      0|      length += 13;
  821|      0|      break;
  822|      0|    case GPGRT_LOGLVL_DEBUG:
  ------------------
  |  Branch (822:5): [True: 0, False: 9.93M]
  ------------------
  823|      0|      _gpgrt_fputs_unlocked ("DBG: ", logstream);
  824|      0|      length += 5;
  825|      0|      break;
  826|      0|    default:
  ------------------
  |  Branch (826:5): [True: 0, False: 9.93M]
  ------------------
  827|      0|      rc = _gpgrt_fprintf_unlocked (logstream,
  828|      0|                                    "[Unknown log level %d]: ", level);
  829|      0|      if (rc > 0)
  ------------------
  |  Branch (829:11): [True: 0, False: 0]
  ------------------
  830|      0|        length += rc;
  831|      0|      break;
  832|  9.93M|    }
  833|       |
  834|  9.93M|  return length;
  835|  9.93M|}
logging.c:fmt_string_filter:
  662|  32.5M|{
  663|  32.5M|  struct fmt_string_filter_s *state = opaque;
  664|  32.5M|  const unsigned char *p;
  665|  32.5M|  size_t buflen;
  666|  32.5M|  char *d;
  667|  32.5M|  int any;
  668|       |
  669|  32.5M|  if (no == -1)
  ------------------
  |  Branch (669:7): [True: 16.2M, False: 16.2M]
  ------------------
  670|  16.2M|    {
  671|       |      /* The printf engine asked us to release resources.  */
  672|  16.2M|      if (state->last_result)
  ------------------
  |  Branch (672:11): [True: 0, False: 16.2M]
  ------------------
  673|      0|        {
  674|      0|          _gpgrt_free (state->last_result);
  675|      0|          state->last_result = NULL;
  676|      0|        }
  677|  16.2M|      return NULL;
  678|  16.2M|    }
  679|       |
  680|  16.2M|  if (!string)
  ------------------
  |  Branch (680:7): [True: 0, False: 16.2M]
  ------------------
  681|      0|    return NULL; /* Nothing to filter - printf handles NULL nicely.  */
  682|       |
  683|       |  /* Check whether escaping is needed and count needed length. */
  684|  16.2M|  any = 0;
  685|  16.2M|  buflen = 1;
  686|   163M|  for (p = (const unsigned char *)string; *p; p++)
  ------------------
  |  Branch (686:43): [True: 146M, False: 16.2M]
  ------------------
  687|   146M|    {
  688|   146M|      switch (*p)
  689|   146M|        {
  690|      0|        case '\n':
  ------------------
  |  Branch (690:9): [True: 0, False: 146M]
  ------------------
  691|      0|        case '\r':
  ------------------
  |  Branch (691:9): [True: 0, False: 146M]
  ------------------
  692|      0|        case '\f':
  ------------------
  |  Branch (692:9): [True: 0, False: 146M]
  ------------------
  693|      0|        case '\v':
  ------------------
  |  Branch (693:9): [True: 0, False: 146M]
  ------------------
  694|      0|        case '\b':
  ------------------
  |  Branch (694:9): [True: 0, False: 146M]
  ------------------
  695|      0|        case '\t':
  ------------------
  |  Branch (695:9): [True: 0, False: 146M]
  ------------------
  696|      0|        case '\a':
  ------------------
  |  Branch (696:9): [True: 0, False: 146M]
  ------------------
  697|      0|        case '\\':
  ------------------
  |  Branch (697:9): [True: 0, False: 146M]
  ------------------
  698|      0|          buflen += 2;
  699|      0|          any = 1;
  700|      0|          break;
  701|   146M|        default:
  ------------------
  |  Branch (701:9): [True: 146M, False: 0]
  ------------------
  702|   146M|          if (*p < 0x20 || *p == 0x7f)
  ------------------
  |  Branch (702:15): [True: 0, False: 146M]
  |  Branch (702:28): [True: 0, False: 146M]
  ------------------
  703|      0|            {
  704|      0|              buflen += 5;
  705|      0|              any = 1;
  706|      0|            }
  707|   146M|          else
  708|   146M|            buflen++;
  709|   146M|        }
  710|   146M|    }
  711|  16.2M|  if (!any)
  ------------------
  |  Branch (711:7): [True: 16.2M, False: 0]
  ------------------
  712|  16.2M|    return (char*)string;  /* Nothing to escape.  */
  713|       |
  714|       |  /* Create a buffer and escape the input.  */
  715|      0|  _gpgrt_free (state->last_result);
  716|      0|  state->last_result = _gpgrt_malloc (buflen);
  717|      0|  if (!state->last_result)
  ------------------
  |  Branch (717:7): [True: 0, False: 0]
  ------------------
  718|      0|    return "[out_of_core_in_format_string_filter]";
  719|       |
  720|      0|  d = state->last_result;
  721|      0|  for (p = (const unsigned char *)string; *p; p++)
  ------------------
  |  Branch (721:43): [True: 0, False: 0]
  ------------------
  722|      0|    {
  723|      0|      switch (*p)
  724|      0|        {
  725|      0|        case '\n': *d++ = '\\'; *d++ = 'n'; break;
  ------------------
  |  Branch (725:9): [True: 0, False: 0]
  ------------------
  726|      0|        case '\r': *d++ = '\\'; *d++ = 'r'; break;
  ------------------
  |  Branch (726:9): [True: 0, False: 0]
  ------------------
  727|      0|        case '\f': *d++ = '\\'; *d++ = 'f'; break;
  ------------------
  |  Branch (727:9): [True: 0, False: 0]
  ------------------
  728|      0|        case '\v': *d++ = '\\'; *d++ = 'v'; break;
  ------------------
  |  Branch (728:9): [True: 0, False: 0]
  ------------------
  729|      0|        case '\b': *d++ = '\\'; *d++ = 'b'; break;
  ------------------
  |  Branch (729:9): [True: 0, False: 0]
  ------------------
  730|      0|        case '\t': *d++ = '\\'; *d++ = 't'; break;
  ------------------
  |  Branch (730:9): [True: 0, False: 0]
  ------------------
  731|      0|        case '\a': *d++ = '\\'; *d++ = 'a'; break;
  ------------------
  |  Branch (731:9): [True: 0, False: 0]
  ------------------
  732|      0|        case '\\': *d++ = '\\'; *d++ = '\\'; break;
  ------------------
  |  Branch (732:9): [True: 0, False: 0]
  ------------------
  733|       |
  734|      0|        default:
  ------------------
  |  Branch (734:9): [True: 0, False: 0]
  ------------------
  735|      0|          if (*p < 0x20 || *p == 0x7f)
  ------------------
  |  Branch (735:15): [True: 0, False: 0]
  |  Branch (735:28): [True: 0, False: 0]
  ------------------
  736|      0|            {
  737|      0|              snprintf (d, 5, "\\x%02x", *p);
  ------------------
  |  |  483|      0|#define snprintf _gpgrt_estream_snprintf
  ------------------
  738|      0|              d += 4;
  739|      0|            }
  740|      0|          else
  741|      0|            *d++ = *p;
  742|      0|        }
  743|      0|    }
  744|      0|  *d = 0;
  745|      0|  return state->last_result;
  746|      0|}

_gpgrt_lock_init:
  165|  58.8k|{
  166|  58.8k|  _gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd;
  167|  58.8k|  int rc;
  168|       |
  169|       |  /* If VERS is zero we assume that no static initialization has been
  170|       |     done, so we setup our ABI version right here.  The caller might
  171|       |     have called us to test whether lock support is at all available. */
  172|  58.8k|  if (!lock->vers)
  ------------------
  |  Branch (172:7): [True: 58.8k, False: 0]
  ------------------
  173|  58.8k|    {
  174|  58.8k|      if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t))
  ------------------
  |  Branch (174:11): [Folded - Ignored]
  ------------------
  175|      0|        {
  176|      0|          fputs ("gpgrt fatal: sizeof lock obj\n", stderr);
  177|      0|          _gpgrt_abort ();
  178|      0|        }
  179|  58.8k|      lock->vers = LOCK_ABI_VERSION;
  ------------------
  |  |   25|  58.8k|# define LOCK_ABI_VERSION 1
  ------------------
  180|  58.8k|    }
  181|      0|  else /* Run the usual check.  */
  182|      0|    lock = get_lock_object (lockhd);
  183|       |
  184|  58.8k|#if USE_POSIX_THREADS
  185|  58.8k|  if (use_pthread_p())
  ------------------
  |  |   62|  58.8k|#   define use_pthread_p() (!!pthread_cancel)
  |  |  ------------------
  |  |  |  Branch (62:28): [True: 58.8k, False: 0]
  |  |  ------------------
  ------------------
  186|  58.8k|    {
  187|  58.8k|      rc = pthread_mutex_init (&lock->u.mtx, NULL);
  188|  58.8k|      if (rc)
  ------------------
  |  Branch (188:11): [True: 0, False: 58.8k]
  ------------------
  189|      0|        rc = _gpg_err_code_from_errno (rc);
  190|  58.8k|    }
  191|      0|  else
  192|      0|    rc = 0; /* Threads are not used.  */
  193|       |#else /* Unknown thread system.  */
  194|       |  rc = lock->vers == LOCK_ABI_NOT_AVAILABLE? 0 : GPG_ERR_NOT_IMPLEMENTED;
  195|       |#endif /* Unknown thread system.  */
  196|       |
  197|  58.8k|  return rc;
  198|  58.8k|}
_gpgrt_lock_lock:
  203|  23.9M|{
  204|  23.9M|  _gpgrt_lock_t *lock = get_lock_object (lockhd);
  205|  23.9M|  int rc;
  206|       |
  207|  23.9M|#if USE_POSIX_THREADS
  208|  23.9M|  if (use_pthread_p())
  ------------------
  |  |   62|  23.9M|#   define use_pthread_p() (!!pthread_cancel)
  |  |  ------------------
  |  |  |  Branch (62:28): [True: 23.9M, False: 0]
  |  |  ------------------
  ------------------
  209|  23.9M|    {
  210|  23.9M|      _gpgrt_pre_syscall ();
  211|  23.9M|      rc = pthread_mutex_lock (&lock->u.mtx);
  212|  23.9M|      if (rc)
  ------------------
  |  Branch (212:11): [True: 0, False: 23.9M]
  ------------------
  213|      0|        rc = _gpg_err_code_from_errno (rc);
  214|  23.9M|      _gpgrt_post_syscall ();
  215|  23.9M|    }
  216|      0|  else
  217|      0|    rc = 0; /* Threads are not used.  */
  218|       |#else /* Unknown thread system.  */
  219|       |  rc = lock->vers == LOCK_ABI_NOT_AVAILABLE? 0 : GPG_ERR_NOT_IMPLEMENTED;
  220|       |#endif /* Unknown thread system.  */
  221|       |
  222|  23.9M|  return rc;
  223|  23.9M|}
_gpgrt_lock_unlock:
  251|  23.9M|{
  252|  23.9M|  _gpgrt_lock_t *lock = get_lock_object (lockhd);
  253|  23.9M|  int rc;
  254|       |
  255|  23.9M|#if USE_POSIX_THREADS
  256|  23.9M|  if (use_pthread_p())
  ------------------
  |  |   62|  23.9M|#   define use_pthread_p() (!!pthread_cancel)
  |  |  ------------------
  |  |  |  Branch (62:28): [True: 23.9M, False: 0]
  |  |  ------------------
  ------------------
  257|  23.9M|    {
  258|  23.9M|      rc = pthread_mutex_unlock (&lock->u.mtx);
  259|  23.9M|      if (rc)
  ------------------
  |  Branch (259:11): [True: 0, False: 23.9M]
  ------------------
  260|      0|        rc = _gpg_err_code_from_errno (rc);
  261|  23.9M|    }
  262|      0|  else
  263|      0|    rc = 0; /* Threads are not used.  */
  264|       |#else /* Unknown thread system.  */
  265|       |  rc = lock->vers == LOCK_ABI_NOT_AVAILABLE? 0 : GPG_ERR_NOT_IMPLEMENTED;
  266|       |#endif /* Unknown thread system.  */
  267|       |
  268|  23.9M|  return rc;
  269|  23.9M|}
_gpgrt_lock_destroy:
  276|  58.8k|{
  277|  58.8k|  _gpgrt_lock_t *lock = get_lock_object (lockhd);
  278|  58.8k|  int rc;
  279|       |
  280|  58.8k|#if USE_POSIX_THREADS
  281|  58.8k|  if (use_pthread_p())
  ------------------
  |  |   62|  58.8k|#   define use_pthread_p() (!!pthread_cancel)
  |  |  ------------------
  |  |  |  Branch (62:28): [True: 58.8k, False: 0]
  |  |  ------------------
  ------------------
  282|  58.8k|    {
  283|  58.8k|      rc = pthread_mutex_destroy (&lock->u.mtx);
  284|  58.8k|      if (rc)
  ------------------
  |  Branch (284:11): [True: 0, False: 58.8k]
  ------------------
  285|      0|        rc = _gpg_err_code_from_errno (rc);
  286|  58.8k|      else
  287|  58.8k|        {
  288|       |          /* Re-init the mutex so that it can be re-used.  */
  289|  58.8k|          gpgrt_lock_t tmp = GPGRT_LOCK_INITIALIZER;
  ------------------
  |  | 1126|  58.8k|#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \
  |  | 1127|  58.8k|                                    0,0,0,0,0,0,0,0, \
  |  | 1128|  58.8k|                                    0,0,0,0,0,0,0,0, \
  |  | 1129|  58.8k|                                    0,0,0,0,0,0,0,0, \
  |  | 1130|  58.8k|                                    0,0,0,0,0,0,0,0}}}
  ------------------
  290|  58.8k|          memcpy (lockhd, &tmp, sizeof tmp);
  291|  58.8k|        }
  292|  58.8k|    }
  293|      0|  else
  294|      0|    rc = 0; /* Threads are not used.  */
  295|       |#else /* Unknown thread system.  */
  296|       |  rc = lock->vers == LOCK_ABI_NOT_AVAILABLE? 0 : GPG_ERR_NOT_IMPLEMENTED;
  297|       |#endif /* Unknown thread system.  */
  298|       |
  299|  58.8k|  return rc;
  300|  58.8k|}
posix-lock.c:get_lock_object:
  145|  48.0M|{
  146|  48.0M|  _gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd;
  147|       |
  148|  48.0M|  if (lock->vers != LOCK_ABI_VERSION)
  ------------------
  |  |   25|  48.0M|# define LOCK_ABI_VERSION 1
  ------------------
  |  Branch (148:7): [True: 0, False: 48.0M]
  ------------------
  149|      0|    {
  150|      0|      fputs ("gpgrt fatal: lock ABI version mismatch\n", stderr);
  151|      0|      _gpgrt_abort ();
  152|      0|    }
  153|  48.0M|  if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t))
  ------------------
  |  Branch (153:7): [Folded - Ignored]
  ------------------
  154|      0|    {
  155|      0|      fputs ("gpgrt fatal: sizeof lock obj\n", stderr);
  156|      0|      _gpgrt_abort ();
  157|      0|    }
  158|       |
  159|  48.0M|  return lock;
  160|  48.0M|}

_gpg_strerror:
   43|   307k|{
   44|   307k|  gpg_err_code_t code = gpg_err_code (err);
   45|       |
   46|   307k|  if (code & GPG_ERR_SYSTEM_ERROR)
  ------------------
  |  |  584|   307k|#define GPG_ERR_SYSTEM_ERROR	(1 << 15)
  ------------------
  |  Branch (46:7): [True: 10.4k, False: 297k]
  ------------------
   47|  10.4k|    {
   48|  10.4k|      int no = gpg_err_code_to_errno (code);
   49|  10.4k|      if (no)
  ------------------
  |  Branch (49:11): [True: 10.3k, False: 117]
  ------------------
   50|  10.3k|	return strerror (no);
   51|    117|      else
   52|    117|	code = GPG_ERR_UNKNOWN_ERRNO;
   53|  10.4k|    }
   54|   297k|  return dgettext (PACKAGE, msgstr + msgidx[msgidxof (code)]);
   55|   307k|}

_gpg_strsource:
   34|   176k|{
   35|   176k|  gpg_err_source_t source = gpg_err_source (err);
   36|   176k|  return dgettext (PACKAGE, msgstr + msgidx[msgidxof (source)]);
   37|   176k|}

_gpgrt_get_syscall_clamp:
   59|      2|{
   60|      2|  *r_pre  = pre_syscall_func;
   61|      2|  *r_post = post_syscall_func;
   62|      2|}
_gpgrt_pre_syscall:
   68|  50.6M|{
   69|  50.6M|  if (pre_syscall_func)
  ------------------
  |  Branch (69:7): [True: 0, False: 50.6M]
  ------------------
   70|      0|    pre_syscall_func ();
   71|  50.6M|}
_gpgrt_post_syscall:
   77|  50.6M|{
   78|  50.6M|  if (post_syscall_func)
  ------------------
  |  Branch (78:7): [True: 0, False: 50.6M]
  ------------------
   79|      0|    post_syscall_func ();
   80|  50.6M|}

_gpgrt_access:
  492|      9|{
  493|      9|  gpg_err_code_t ec;
  494|       |
  495|       |#ifdef HAVE_W32_SYSTEM
  496|       |  wchar_t *wfname;
  497|       |  DWORD attribs;
  498|       |
  499|       |  wfname = _gpgrt_fname_to_wchar (fname);
  500|       |  if (!wfname)
  501|       |    return _gpg_err_code_from_syserror ();
  502|       |
  503|       |  attribs = GetFileAttributesW (wfname);
  504|       |  if (attribs == (DWORD)(-1))
  505|       |    ec = _gpgrt_w32_get_last_err_code ();
  506|       |  else
  507|       |    {
  508|       |      if ((mode & W_OK) && (attribs & FILE_ATTRIBUTE_READONLY))
  509|       |        {
  510|       |          _gpg_err_set_errno (EACCES);
  511|       |          ec = _gpg_err_code_from_syserror ();
  512|       |        }
  513|       |      else
  514|       |        ec = 0;
  515|       |    }
  516|       |  _gpgrt_free_wchar (wfname);
  517|       |#else /* Unix */
  518|      9|  ec = access (fname, mode)? _gpg_err_code_from_syserror () : 0;
  ------------------
  |  Branch (518:8): [True: 4, False: 5]
  ------------------
  519|      9|#endif /* Unix */
  520|       |
  521|      9|  return ec;
  522|      9|}

gpg_strerror:
   30|   307k|{
   31|   307k|  return _gpg_strerror (err);
   32|   307k|}
gpg_strsource:
   42|   176k|{
   43|   176k|  return _gpg_strsource (err);
   44|   176k|}
gpg_err_code_from_errno:
   48|  10.3k|{
   49|  10.3k|  return _gpg_err_code_from_errno (err);
   50|  10.3k|}
gpg_err_code_to_errno:
   54|  10.4k|{
   55|  10.4k|  return _gpg_err_code_to_errno (code);
   56|  10.4k|}
gpg_err_code_from_syserror:
   60|  10.3k|{
   61|  10.3k|  return _gpg_err_code_from_syserror ();
   62|  10.3k|}
gpg_err_set_errno:
   66|  10.3k|{
   67|  10.3k|  _gpg_err_set_errno (err);
   68|  10.3k|}
gpg_err_init:
   73|      2|{
   74|      2|  return _gpg_err_init ();
   75|      2|}
gpgrt_get_syscall_clamp:
  115|      2|{
  116|      2|  _gpgrt_get_syscall_clamp (r_pre, r_post);
  117|      2|}
gpgrt_lock_lock:
  134|   166k|{
  135|   166k|  return _gpgrt_lock_lock (lockhd);
  136|   166k|}
gpgrt_lock_unlock:
  146|   166k|{
  147|   166k|  return _gpgrt_lock_unlock (lockhd);
  148|   166k|}
gpgrt_fopen:
  167|  58.8k|{
  168|  58.8k|  return _gpgrt_fopen (path, mode);
  169|  58.8k|}
gpgrt_fclose:
  249|  58.8k|{
  250|  58.8k|  return _gpgrt_fclose (stream);
  251|  58.8k|}
_gpgrt_get_std_stream:
  304|      1|{
  305|      1|  return _gpgrt__get_std_stream (fd);  /* (double dash in name) */
  306|      1|}
gpgrt_ferror:
  352|  58.9k|{
  353|  58.9k|  return _gpgrt_ferror (stream);
  354|  58.9k|}
gpgrt_fseeko:
  388|  6.86M|{
  389|  6.86M|  return _gpgrt_fseeko (stream, offset, whence);
  390|  6.86M|}
gpgrt_ftello:
  400|   117k|{
  401|   117k|  return _gpgrt_ftello (stream);
  402|   117k|}
gpgrt_fgetc:
  418|   353k|{
  419|   353k|  return _gpgrt_fgetc (stream);
  420|   353k|}
gpgrt_fputc:
  430|   700k|{
  431|   700k|  return _gpgrt_fputc (c, stream);
  432|   700k|}
gpgrt_write_sanitized:
  467|  22.9k|{
  468|  22.9k|  return _gpgrt_write_sanitized (stream, buffer, length, delimiters,
  469|  22.9k|                                 bytes_written);
  470|  22.9k|}
gpgrt_write_hexstring:
  476|  36.3k|{
  477|  36.3k|  return _gpgrt_write_hexstring (stream, buffer, length, reserved,
  478|  36.3k|                                 bytes_written);
  479|  36.3k|}
gpgrt_fread:
  484|  58.9k|{
  485|  58.9k|  return _gpgrt_fread (ptr, size, nitems, stream);
  486|  58.9k|}
gpgrt_fwrite:
  491|      1|{
  492|      1|  return _gpgrt_fwrite (ptr, size, nitems, stream);
  493|      1|}
gpgrt_fputs:
  504|   124k|{
  505|   124k|  return _gpgrt_fputs (s, stream);
  506|   124k|}
gpgrt_fprintf:
  576|  5.43M|{
  577|  5.43M|  va_list ap;
  578|  5.43M|  int rc;
  579|       |
  580|  5.43M|  va_start (ap, format);
  581|  5.43M|  rc = _gpgrt_vfprintf (stream, NULL, NULL, format, ap);
  582|  5.43M|  va_end (ap);
  583|       |
  584|  5.43M|  return rc;
  585|  5.43M|}
gpgrt_snprintf:
  746|  6.92M|{
  747|  6.92M|  int rc;
  748|  6.92M|  va_list arg_ptr;
  749|       |
  750|  6.92M|  va_start (arg_ptr, format);
  751|  6.92M|  rc = _gpgrt_estream_vsnprintf (buf, bufsize, format, arg_ptr);
  752|  6.92M|  va_end (arg_ptr);
  753|       |
  754|  6.92M|  return rc;
  755|  6.92M|}
gpgrt_access:
  852|      9|{
  853|      9|  return _gpgrt_access (fname, mode);
  854|      9|}
gpgrt_inc_errorcount:
  905|    186|{
  906|    186|  _gpgrt_inc_errorcount ();
  907|    186|}
gpgrt_log_set_sink:
  911|      1|{
  912|      1|  _gpgrt_log_set_sink (name, stream, fd);
  913|      1|}
gpgrt_log_get_stream:
  953|  19.7k|{
  954|  19.7k|  return _gpgrt_log_get_stream ();
  955|  19.7k|}
gpgrt_log_info:
  988|  7.28M|{
  989|  7.28M|  va_list arg_ptr;
  990|       |
  991|  7.28M|  va_start (arg_ptr, fmt);
  992|  7.28M|  _gpgrt_logv (GPGRT_LOGLVL_INFO, fmt, arg_ptr);
  993|  7.28M|  va_end (arg_ptr);
  994|  7.28M|}
gpgrt_log_error:
  998|  2.62M|{
  999|  2.62M|  va_list arg_ptr;
 1000|       |
 1001|  2.62M|  va_start (arg_ptr, fmt);
 1002|  2.62M|  _gpgrt_logv (GPGRT_LOGLVL_ERROR, fmt, arg_ptr);
 1003|  2.62M|  va_end (arg_ptr);
 1004|  2.62M|}
gpgrt_log_printf:
 1050|  19.7k|{
 1051|  19.7k|  va_list arg_ptr;
 1052|       |
 1053|  19.7k|  va_start (arg_ptr, fmt);
 1054|  19.7k|  _gpgrt_logv (fmt ? GPGRT_LOGLVL_CONT : GPGRT_LOGLVL_BEGIN, fmt, arg_ptr);
  ------------------
  |  Branch (1054:16): [True: 19.7k, False: 0]
  ------------------
 1055|  19.7k|  va_end (arg_ptr);
 1056|  19.7k|}

