ssh_bind_new:
  136|    408|{
  137|    408|    ssh_bind ptr = NULL;
  138|       |
  139|    408|    ptr = calloc(1, sizeof(struct ssh_bind_struct));
  140|    408|    if (ptr == NULL) {
  ------------------
  |  Branch (140:9): [True: 0, False: 408]
  ------------------
  141|      0|        return NULL;
  142|      0|    }
  143|    408|    ptr->bindfd = SSH_INVALID_SOCKET;
  ------------------
  |  |  124|    408|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  144|    408|    ptr->bindport = 22;
  145|    408|    ptr->common.log_verbosity = 0;
  146|       |
  147|    408|    return ptr;
  148|    408|}
ssh_bind_free:
  372|    408|void ssh_bind_free(ssh_bind sshbind){
  373|    408|  int i;
  374|       |
  375|    408|  if (sshbind == NULL) {
  ------------------
  |  Branch (375:7): [True: 0, False: 408]
  ------------------
  376|      0|    return;
  377|      0|  }
  378|       |
  379|    408|  if (sshbind->bindfd >= 0) {
  ------------------
  |  Branch (379:7): [True: 0, False: 408]
  ------------------
  380|      0|      CLOSE_SOCKET(sshbind->bindfd);
  ------------------
  |  |  472|      0|#define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  124|      0|#define SSH_INVALID_SOCKET ((socket_t) -1)
  |  |  ------------------
  |  |               #define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  199|      0|#define _XCLOSESOCKET close
  |  |  ------------------
  |  |               #define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  124|      0|#define SSH_INVALID_SOCKET ((socket_t) -1)
  |  |  ------------------
  |  |  |  Branch (472:34): [True: 0, False: 0]
  |  |  |  Branch (472:116): [Folded, False: 0]
  |  |  ------------------
  ------------------
  381|      0|  }
  382|    408|  sshbind->bindfd = SSH_INVALID_SOCKET;
  ------------------
  |  |  124|    408|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  383|       |
  384|       |  /* options */
  385|    408|  SAFE_FREE(sshbind->banner);
  ------------------
  |  |  373|    408|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 408]
  |  |  |  Branch (373:71): [Folded, False: 408]
  |  |  ------------------
  ------------------
  386|    408|  SAFE_FREE(sshbind->moduli_file);
  ------------------
  |  |  373|    408|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 408]
  |  |  |  Branch (373:71): [Folded, False: 408]
  |  |  ------------------
  ------------------
  387|    408|  SAFE_FREE(sshbind->bindaddr);
  ------------------
  |  |  373|    408|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 408]
  |  |  |  Branch (373:71): [Folded, False: 408]
  |  |  ------------------
  ------------------
  388|    408|  SAFE_FREE(sshbind->config_dir);
  ------------------
  |  |  373|    408|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 408]
  |  |  |  Branch (373:71): [Folded, False: 408]
  |  |  ------------------
  ------------------
  389|    408|  SAFE_FREE(sshbind->pubkey_accepted_key_types);
  ------------------
  |  |  373|    408|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 11, False: 397]
  |  |  |  Branch (373:71): [Folded, False: 408]
  |  |  ------------------
  ------------------
  390|       |
  391|    408|  SAFE_FREE(sshbind->rsakey);
  ------------------
  |  |  373|    408|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 408]
  |  |  |  Branch (373:71): [Folded, False: 408]
  |  |  ------------------
  ------------------
  392|    408|  SAFE_FREE(sshbind->ecdsakey);
  ------------------
  |  |  373|    408|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 408]
  |  |  |  Branch (373:71): [Folded, False: 408]
  |  |  ------------------
  ------------------
  393|    408|  SAFE_FREE(sshbind->ed25519key);
  ------------------
  |  |  373|    408|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 408]
  |  |  |  Branch (373:71): [Folded, False: 408]
  |  |  ------------------
  ------------------
  394|    408|  SAFE_FREE(sshbind->gssapi_key_exchange_algs);
  ------------------
  |  |  373|    408|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 408]
  |  |  |  Branch (373:71): [Folded, False: 408]
  |  |  ------------------
  ------------------
  395|       |
  396|    408|  ssh_key_free(sshbind->rsa);
  397|    408|  sshbind->rsa = NULL;
  398|    408|  ssh_key_free(sshbind->ecdsa);
  399|    408|  sshbind->ecdsa = NULL;
  400|    408|  ssh_key_free(sshbind->ed25519);
  401|    408|  sshbind->ed25519 = NULL;
  402|       |
  403|  4.48k|  for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  4.48k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (403:15): [True: 4.08k, False: 408]
  ------------------
  404|  4.08k|    if (sshbind->wanted_methods[i]) {
  ------------------
  |  Branch (404:9): [True: 277, False: 3.80k]
  ------------------
  405|    277|      SAFE_FREE(sshbind->wanted_methods[i]);
  ------------------
  |  |  373|    277|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 277, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 277]
  |  |  ------------------
  ------------------
  406|    277|    }
  407|  4.08k|  }
  408|       |
  409|       |  SAFE_FREE(sshbind);
  ------------------
  |  |  373|    408|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 408, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 408]
  |  |  ------------------
  ------------------
  410|    408|}

ssh_bind_config_parse_string:
  697|    408|{
  698|    408|    char line[MAX_LINE_SIZE] = {0};
  699|    408|    const char *c = input, *line_start = input;
  700|    408|    unsigned int line_num = 0;
  701|    408|    size_t line_len;
  702|    408|    uint32_t parser_flags;
  703|    408|    int rv;
  704|       |
  705|       |    /* This local table is used during the parsing of the current file (and
  706|       |     * files included recursively in this file) to prevent an option to be
  707|       |     * redefined, i.e. the first value set is kept. But this DO NOT prevent the
  708|       |     * option to be redefined later by another file. */
  709|    408|    uint8_t seen[BIND_CFG_MAX] = {0};
  710|       |
  711|    408|    SSH_LOG(SSH_LOG_DEBUG, "Reading bind configuration data from string:");
  ------------------
  |  |  281|    408|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  712|    408|    SSH_LOG(SSH_LOG_DEBUG, "START\n%s\nEND", input);
  ------------------
  |  |  281|    408|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  713|       |
  714|    408|    parser_flags = PARSING;
  ------------------
  |  |   48|    408|#define PARSING     1
  ------------------
  715|  21.1k|    while (1) {
  ------------------
  |  Branch (715:12): [True: 21.1k, Folded]
  ------------------
  716|  21.1k|        line_num++;
  717|  21.1k|        line_start = c;
  718|  21.1k|        c = strchr(line_start, '\n');
  719|  21.1k|        if (c == NULL) {
  ------------------
  |  Branch (719:13): [True: 406, False: 20.7k]
  ------------------
  720|       |            /* if there is no newline at the end of the string */
  721|    406|            c = strchr(line_start, '\0');
  722|    406|        }
  723|  21.1k|        if (c == NULL) {
  ------------------
  |  Branch (723:13): [True: 0, False: 21.1k]
  ------------------
  724|       |            /* should not happen, would mean a string without trailing '\0' */
  725|      0|            ssh_set_error(bind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  726|      0|                          SSH_FATAL,
  727|      0|                          "No trailing '\\0' in config string");
  728|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  729|      0|        }
  730|  21.1k|        line_len = c - line_start;
  731|  21.1k|        if (line_len > MAX_LINE_SIZE - 1) {
  ------------------
  |  |   44|  21.1k|#define MAX_LINE_SIZE 1024
  ------------------
  |  Branch (731:13): [True: 8, False: 21.1k]
  ------------------
  732|      8|            ssh_set_error(bind,
  ------------------
  |  |  311|      8|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  733|      8|                          SSH_FATAL,
  734|      8|                          "Line %u too long: %zu characters",
  735|      8|                          line_num,
  736|      8|                          line_len);
  737|      8|            return SSH_ERROR;
  ------------------
  |  |  317|      8|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  738|      8|        }
  739|  21.1k|        memcpy(line, line_start, line_len);
  740|  21.1k|        line[line_len] = '\0';
  741|  21.1k|        SSH_LOG(SSH_LOG_DEBUG, "Line %u: %s", line_num, line);
  ------------------
  |  |  281|  21.1k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  742|  21.1k|        rv = ssh_bind_config_parse_line(bind,
  743|  21.1k|                                        line,
  744|  21.1k|                                        line_num,
  745|  21.1k|                                        &parser_flags,
  746|  21.1k|                                        seen,
  747|  21.1k|                                        0);
  748|  21.1k|        if (rv < 0) {
  ------------------
  |  Branch (748:13): [True: 22, False: 21.1k]
  ------------------
  749|     22|            return SSH_ERROR;
  ------------------
  |  |  317|     22|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  750|     22|        }
  751|  21.1k|        if (*c == '\0') {
  ------------------
  |  Branch (751:13): [True: 378, False: 20.7k]
  ------------------
  752|    378|            break;
  753|    378|        }
  754|  20.7k|        c++;
  755|  20.7k|    }
  756|       |
  757|    378|    return SSH_OK;
  ------------------
  |  |  316|    378|#define SSH_OK 0     /* No error */
  ------------------
  758|    408|}
bind_config.c:ssh_bind_config_parse_line:
  296|  2.97M|{
  297|  2.97M|    enum ssh_bind_config_opcode_e opcode;
  298|  2.97M|    const char *p = NULL;
  299|  2.97M|    char *s = NULL, *x = NULL;
  300|  2.97M|    char *keyword = NULL;
  301|  2.97M|    long l;
  302|  2.97M|    size_t len;
  303|       |
  304|  2.97M|    int rc = 0;
  305|       |
  306|  2.97M|    if (bind == NULL) {
  ------------------
  |  Branch (306:9): [True: 0, False: 2.97M]
  ------------------
  307|      0|        return -1;
  308|      0|    }
  309|       |
  310|       |    /* Ignore empty lines */
  311|  2.97M|    if (line == NULL || *line == '\0') {
  ------------------
  |  Branch (311:9): [True: 0, False: 2.97M]
  |  Branch (311:25): [True: 566k, False: 2.40M]
  ------------------
  312|   566k|        return 0;
  313|   566k|    }
  314|       |
  315|  2.40M|    if (parser_flags == NULL) {
  ------------------
  |  Branch (315:9): [True: 0, False: 2.40M]
  ------------------
  316|      0|        ssh_set_error_invalid(bind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  317|      0|        return -1;
  318|      0|    }
  319|       |
  320|  2.40M|    x = s = strdup(line);
  321|  2.40M|    if (s == NULL) {
  ------------------
  |  Branch (321:9): [True: 0, False: 2.40M]
  ------------------
  322|      0|        ssh_set_error_oom(bind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  323|      0|        return -1;
  324|      0|    }
  325|       |
  326|       |    /* Remove trailing spaces */
  327|  3.82M|    for (len = strlen(s) - 1; len > 0; len--) {
  ------------------
  |  Branch (327:31): [True: 3.39M, False: 430k]
  ------------------
  328|  3.39M|        if (! isspace(s[len])) {
  ------------------
  |  Branch (328:13): [True: 1.97M, False: 1.42M]
  ------------------
  329|  1.97M|            break;
  330|  1.97M|        }
  331|  1.42M|        s[len] = '\0';
  332|  1.42M|    }
  333|       |
  334|  2.40M|    keyword = ssh_config_get_token(&s);
  335|  2.40M|    if (keyword == NULL || *keyword == '#' ||
  ------------------
  |  Branch (335:9): [True: 0, False: 2.40M]
  |  Branch (335:28): [True: 175k, False: 2.23M]
  ------------------
  336|  2.23M|            *keyword == '\0' || *keyword == '\n') {
  ------------------
  |  Branch (336:13): [True: 276k, False: 1.95M]
  |  Branch (336:33): [True: 0, False: 1.95M]
  ------------------
  337|   451k|        SAFE_FREE(x);
  ------------------
  |  |  373|   451k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 451k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 451k]
  |  |  ------------------
  ------------------
  338|   451k|        return 0;
  339|   451k|    }
  340|       |
  341|  1.95M|    opcode = ssh_bind_config_get_opcode(keyword, parser_flags);
  342|  1.95M|    if ((*parser_flags & PARSING) &&
  ------------------
  |  |   48|  1.95M|#define PARSING     1
  ------------------
  |  Branch (342:9): [True: 1.80M, False: 146k]
  ------------------
  343|  1.80M|            opcode != BIND_CFG_HOSTKEY &&
  ------------------
  |  Branch (343:13): [True: 1.80M, False: 159]
  ------------------
  344|  1.80M|            opcode != BIND_CFG_INCLUDE &&
  ------------------
  |  Branch (344:13): [True: 1.80M, False: 1.34k]
  ------------------
  345|  1.80M|            opcode != BIND_CFG_MATCH &&
  ------------------
  |  Branch (345:13): [True: 1.80M, False: 51]
  ------------------
  346|  1.80M|            opcode > BIND_CFG_UNSUPPORTED) { /* Ignore all unknown types here */
  ------------------
  |  Branch (346:13): [True: 571, False: 1.80M]
  ------------------
  347|       |        /* Skip all the options that were already applied */
  348|    571|        if (seen[opcode] != 0) {
  ------------------
  |  Branch (348:13): [True: 222, False: 349]
  ------------------
  349|    222|            SAFE_FREE(x);
  ------------------
  |  |  373|    222|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 222, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 222]
  |  |  ------------------
  ------------------
  350|    222|            return 0;
  351|    222|        }
  352|    349|        seen[opcode] = 1;
  353|    349|    }
  354|       |
  355|  1.95M|    switch (opcode) {
  356|  1.34k|    case BIND_CFG_INCLUDE:
  ------------------
  |  Branch (356:5): [True: 1.34k, False: 1.95M]
  ------------------
  357|  1.34k|        p = ssh_config_get_str_tok(&s, NULL);
  358|  1.34k|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|    481|#define PARSING     1
  ------------------
  |  Branch (358:13): [True: 481, False: 859]
  |  Branch (358:18): [True: 481, False: 0]
  ------------------
  359|    481|#if defined(HAVE_GLOB) && defined(HAVE_GLOB_GL_FLAGS_MEMBER)
  360|    481|            local_parse_glob(bind, p, parser_flags, seen, depth + 1);
  361|       |#else
  362|       |            local_parse_file(bind, p, parser_flags, seen, depth + 1);
  363|       |#endif /* HAVE_GLOB */
  364|    481|        }
  365|  1.34k|        break;
  366|       |
  367|    159|    case BIND_CFG_HOSTKEY:
  ------------------
  |  Branch (367:5): [True: 159, False: 1.95M]
  ------------------
  368|    159|        p = ssh_config_get_str_tok(&s, NULL);
  369|    159|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      0|#define PARSING     1
  ------------------
  |  Branch (369:13): [True: 0, False: 159]
  |  Branch (369:18): [True: 0, False: 0]
  ------------------
  370|      0|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HOSTKEY, p);
  371|      0|            if (rc != 0) {
  ------------------
  |  Branch (371:17): [True: 0, False: 0]
  ------------------
  372|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  373|      0|                        "line %d: Failed to set Hostkey value '%s'",
  374|      0|                        count, p);
  375|      0|            }
  376|      0|        }
  377|    159|        break;
  378|      0|    case BIND_CFG_LISTENADDRESS:
  ------------------
  |  Branch (378:5): [True: 0, False: 1.95M]
  ------------------
  379|      0|        p = ssh_config_get_str_tok(&s, NULL);
  380|      0|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      0|#define PARSING     1
  ------------------
  |  Branch (380:13): [True: 0, False: 0]
  |  Branch (380:18): [True: 0, False: 0]
  ------------------
  381|      0|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_BINDADDR, p);
  382|      0|            if (rc != 0) {
  ------------------
  |  Branch (382:17): [True: 0, False: 0]
  ------------------
  383|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  384|      0|                        "line %d: Failed to set ListenAddress value '%s'",
  385|      0|                        count, p);
  386|      0|            }
  387|      0|        }
  388|      0|        break;
  389|      2|    case BIND_CFG_PORT:
  ------------------
  |  Branch (389:5): [True: 2, False: 1.95M]
  ------------------
  390|      2|        p = ssh_config_get_str_tok(&s, NULL);
  391|      2|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      0|#define PARSING     1
  ------------------
  |  Branch (391:13): [True: 0, False: 2]
  |  Branch (391:18): [True: 0, False: 0]
  ------------------
  392|      0|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_BINDPORT_STR, p);
  393|      0|            if (rc != 0) {
  ------------------
  |  Branch (393:17): [True: 0, False: 0]
  ------------------
  394|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  395|      0|                        "line %d: Failed to set Port value '%s'",
  396|      0|                        count, p);
  397|      0|            }
  398|      0|        }
  399|      2|        break;
  400|     38|    case BIND_CFG_CIPHERS:
  ------------------
  |  Branch (400:5): [True: 38, False: 1.95M]
  ------------------
  401|     38|        p = ssh_config_get_str_tok(&s, NULL);
  402|     38|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     38|#define PARSING     1
  ------------------
  |  Branch (402:13): [True: 38, False: 0]
  |  Branch (402:18): [True: 38, False: 0]
  ------------------
  403|     38|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_CIPHERS_C_S, p);
  404|     38|            if (rc != 0) {
  ------------------
  |  Branch (404:17): [True: 1, False: 37]
  ------------------
  405|      1|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      1|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  406|      1|                        "line %d: Failed to set C->S Ciphers value '%s'",
  407|      1|                        count, p);
  408|      1|                break;
  409|      1|            }
  410|       |
  411|     37|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_CIPHERS_S_C, p);
  412|     37|            if (rc != 0) {
  ------------------
  |  Branch (412:17): [True: 0, False: 37]
  ------------------
  413|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  414|      0|                        "line %d: Failed to set S->C Ciphers value '%s'",
  415|      0|                        count, p);
  416|      0|            }
  417|     37|        }
  418|     37|        break;
  419|     81|    case BIND_CFG_MACS:
  ------------------
  |  Branch (419:5): [True: 81, False: 1.95M]
  ------------------
  420|     81|        p = ssh_config_get_str_tok(&s, NULL);
  421|     81|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     81|#define PARSING     1
  ------------------
  |  Branch (421:13): [True: 81, False: 0]
  |  Branch (421:18): [True: 81, False: 0]
  ------------------
  422|     81|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HMAC_C_S, p);
  423|     81|            if (rc != 0) {
  ------------------
  |  Branch (423:17): [True: 5, False: 76]
  ------------------
  424|      5|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      5|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  425|      5|                        "line %d: Failed to set C->S MAC value '%s'",
  426|      5|                        count, p);
  427|      5|                break;
  428|      5|            }
  429|       |
  430|     76|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HMAC_S_C, p);
  431|     76|            if (rc != 0) {
  ------------------
  |  Branch (431:17): [True: 0, False: 76]
  ------------------
  432|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  433|      0|                        "line %d: Failed to set S->C MAC value '%s'",
  434|      0|                        count, p);
  435|      0|            }
  436|     76|        }
  437|     76|        break;
  438|     87|    case BIND_CFG_LOGLEVEL:
  ------------------
  |  Branch (438:5): [True: 87, False: 1.95M]
  ------------------
  439|     87|        p = ssh_config_get_str_tok(&s, NULL);
  440|     87|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     80|#define PARSING     1
  ------------------
  |  Branch (440:13): [True: 80, False: 7]
  |  Branch (440:18): [True: 25, False: 55]
  ------------------
  441|     25|            int value = -1;
  442|       |
  443|     25|            if (strcasecmp(p, "quiet") == 0) {
  ------------------
  |  Branch (443:17): [True: 2, False: 23]
  ------------------
  444|      2|                value = SSH_LOG_NONE;
  ------------------
  |  |  355|      2|#define SSH_LOG_NONE 0
  ------------------
  445|     23|            } else if (strcasecmp(p, "fatal") == 0 ||
  ------------------
  |  Branch (445:24): [True: 2, False: 21]
  ------------------
  446|     21|                    strcasecmp(p, "error")== 0) {
  ------------------
  |  Branch (446:21): [True: 0, False: 21]
  ------------------
  447|      2|                value = SSH_LOG_WARN;
  ------------------
  |  |  357|      2|#define SSH_LOG_WARN 1
  ------------------
  448|     21|            } else if (strcasecmp(p, "verbose") == 0 ||
  ------------------
  |  Branch (448:24): [True: 2, False: 19]
  ------------------
  449|     19|                    strcasecmp(p, "info") == 0) {
  ------------------
  |  Branch (449:21): [True: 2, False: 17]
  ------------------
  450|      4|                value = SSH_LOG_INFO;
  ------------------
  |  |  359|      4|#define SSH_LOG_INFO 2
  ------------------
  451|     17|            } else if (strcasecmp(p, "DEBUG") == 0 ||
  ------------------
  |  Branch (451:24): [True: 4, False: 13]
  ------------------
  452|     13|                    strcasecmp(p, "DEBUG1") == 0) {
  ------------------
  |  Branch (452:21): [True: 0, False: 13]
  ------------------
  453|      4|                value = SSH_LOG_DEBUG;
  ------------------
  |  |  361|      4|#define SSH_LOG_DEBUG 3
  ------------------
  454|     13|            } else if (strcasecmp(p, "DEBUG2") == 0 ||
  ------------------
  |  Branch (454:24): [True: 2, False: 11]
  ------------------
  455|     11|                    strcasecmp(p, "DEBUG3") == 0) {
  ------------------
  |  Branch (455:21): [True: 0, False: 11]
  ------------------
  456|      2|                value = SSH_LOG_TRACE;
  ------------------
  |  |  363|      2|#define SSH_LOG_TRACE 4
  ------------------
  457|      2|            }
  458|     25|            if (value != -1) {
  ------------------
  |  Branch (458:17): [True: 14, False: 11]
  ------------------
  459|     14|                rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_LOG_VERBOSITY,
  460|     14|                        &value);
  461|     14|                if (rc != 0) {
  ------------------
  |  Branch (461:21): [True: 0, False: 14]
  ------------------
  462|      0|                    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  463|      0|                            "line %d: Failed to set LogLevel value '%s'",
  464|      0|                            count, p);
  465|      0|                }
  466|     14|            }
  467|     25|        }
  468|     87|        break;
  469|      4|    case BIND_CFG_KEXALGORITHMS:
  ------------------
  |  Branch (469:5): [True: 4, False: 1.95M]
  ------------------
  470|      4|        p = ssh_config_get_str_tok(&s, NULL);
  471|      4|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      4|#define PARSING     1
  ------------------
  |  Branch (471:13): [True: 4, False: 0]
  |  Branch (471:18): [True: 4, False: 0]
  ------------------
  472|      4|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_KEY_EXCHANGE, p);
  473|      4|            if (rc != 0) {
  ------------------
  |  Branch (473:17): [True: 0, False: 4]
  ------------------
  474|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  475|      0|                        "line %d: Failed to set KexAlgorithms value '%s'",
  476|      0|                        count, p);
  477|      0|            }
  478|      4|        }
  479|      4|        break;
  480|    221|    case BIND_CFG_MATCH: {
  ------------------
  |  Branch (480:5): [True: 221, False: 1.95M]
  ------------------
  481|    221|        bool negate;
  482|    221|        int result = PARSING;
  ------------------
  |  |   48|    221|#define PARSING     1
  ------------------
  483|    221|        size_t args = 0;
  484|    221|        enum ssh_bind_config_match_e opt;
  485|    221|        const char *p2 = NULL;
  486|       |
  487|       |        /* The options set in Match blocks should be applied when a connection
  488|       |         * is accepted, and not right away when parsing the file (as it is
  489|       |         * currently done). This means the configuration files should be parsed
  490|       |         * again or the options set in the Match blocks should be stored and
  491|       |         * applied as necessary. */
  492|       |
  493|       |        /* If this is the first Match block, erase the seen table to allow
  494|       |         * options to be overridden. Erasing the seen table was the easiest way
  495|       |         * to allow overriding an option, but only for the first occurrence of
  496|       |         * an option in a Match block. This is sufficient for the current
  497|       |         * implementation which supports only the 'All' criterion, meaning the
  498|       |         * options can be applied right away. */
  499|    221|        if (!(*parser_flags & IN_MATCH)) {
  ------------------
  |  |   49|    221|#define IN_MATCH    (1<<1)
  ------------------
  |  Branch (499:13): [True: 38, False: 183]
  ------------------
  500|     38|            memset(seen, 0x00, BIND_CFG_MAX * sizeof(uint8_t));
  501|     38|        }
  502|       |
  503|       |        /* In this line the PARSING bit is cleared from the flags */
  504|    221|        *parser_flags = IN_MATCH;
  ------------------
  |  |   49|    221|#define IN_MATCH    (1<<1)
  ------------------
  505|    392|        do {
  506|    392|            p = p2 = ssh_config_get_str_tok(&s, NULL);
  507|    392|            if (p == NULL || p[0] == '\0') {
  ------------------
  |  Branch (507:17): [True: 124, False: 268]
  |  Branch (507:30): [True: 0, False: 268]
  ------------------
  508|    124|                break;
  509|    124|            }
  510|    268|            args++;
  511|    268|            SSH_LOG(SSH_LOG_TRACE, "line %d: Processing Match keyword '%s'",
  ------------------
  |  |  281|    268|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  512|    268|                    count, p);
  513|       |
  514|       |            /* If the option is prefixed with ! the result should be negated */
  515|    268|            negate = false;
  516|    268|            if (p[0] == '!') {
  ------------------
  |  Branch (516:17): [True: 26, False: 242]
  ------------------
  517|     26|                negate = true;
  518|     26|                p++;
  519|     26|            }
  520|       |
  521|    268|            opt = ssh_bind_config_get_match_opcode(p);
  522|    268|            switch (opt) {
  523|     49|            case BIND_MATCH_ALL:
  ------------------
  |  Branch (523:13): [True: 49, False: 219]
  ------------------
  524|     49|                p = ssh_config_get_str_tok(&s, NULL);
  525|     49|                if ((args == 1) && (p == NULL || p[0] == '\0')) {
  ------------------
  |  Branch (525:21): [True: 49, False: 0]
  |  Branch (525:37): [True: 46, False: 3]
  |  Branch (525:50): [True: 0, False: 3]
  ------------------
  526|       |                    /* The "all" keyword does not accept arguments or modifiers
  527|       |                     */
  528|     46|                    if (negate == true) {
  ------------------
  |  Branch (528:25): [True: 18, False: 28]
  ------------------
  529|     18|                        result = 0;
  530|     18|                    }
  531|     46|                    break;
  532|     46|                }
  533|      3|                ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  311|      3|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  534|      3|                              "line %d: ERROR - Match all cannot be combined with "
  535|      3|                              "other Match attributes", count);
  536|      3|                SAFE_FREE(x);
  ------------------
  |  |  373|      3|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 3, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 3]
  |  |  ------------------
  ------------------
  537|      3|                return -1;
  538|      9|            case BIND_MATCH_USER:
  ------------------
  |  Branch (538:13): [True: 9, False: 259]
  ------------------
  539|     40|            case BIND_MATCH_GROUP:
  ------------------
  |  Branch (539:13): [True: 31, False: 237]
  ------------------
  540|    108|            case BIND_MATCH_HOST:
  ------------------
  |  Branch (540:13): [True: 68, False: 200]
  ------------------
  541|    147|            case BIND_MATCH_LOCALADDRESS:
  ------------------
  |  Branch (541:13): [True: 39, False: 229]
  ------------------
  542|    153|            case BIND_MATCH_LOCALPORT:
  ------------------
  |  Branch (542:13): [True: 6, False: 262]
  ------------------
  543|    165|            case BIND_MATCH_RDOMAIN:
  ------------------
  |  Branch (543:13): [True: 12, False: 256]
  ------------------
  544|    174|            case BIND_MATCH_ADDRESS:
  ------------------
  |  Branch (544:13): [True: 9, False: 259]
  ------------------
  545|       |                /* Only "All" is supported for now */
  546|       |                /* Skip one argument */
  547|    174|                p = ssh_config_get_str_tok(&s, NULL);
  548|    174|                if (p == NULL || p[0] == '\0') {
  ------------------
  |  Branch (548:21): [True: 3, False: 171]
  |  Branch (548:34): [True: 0, False: 171]
  ------------------
  549|      3|                    SSH_LOG(SSH_LOG_TRACE, "line %d: Match keyword "
  ------------------
  |  |  281|      3|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  550|      3|                            "'%s' requires argument\n", count, p2);
  551|      3|                    SAFE_FREE(x);
  ------------------
  |  |  373|      3|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 3, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 3]
  |  |  ------------------
  ------------------
  552|      3|                    return -1;
  553|      3|                }
  554|    171|                args++;
  555|    171|                SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|    171|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  556|    171|                        "line %d: Unsupported Match keyword '%s', ignoring\n",
  557|    171|                        count,
  558|    171|                        p2);
  559|    171|                result = 0;
  560|    171|                break;
  561|     45|            case BIND_MATCH_UNKNOWN:
  ------------------
  |  Branch (561:13): [True: 45, False: 223]
  ------------------
  562|     45|            default:
  ------------------
  |  Branch (562:13): [True: 0, False: 268]
  ------------------
  563|     45|                ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  311|     45|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  564|     45|                              "ERROR - Unknown argument '%s' for Match keyword", p);
  565|     45|                SAFE_FREE(x);
  ------------------
  |  |  373|     45|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 45, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 45]
  |  |  ------------------
  ------------------
  566|     45|                return -1;
  567|    268|            }
  568|    268|        } while (p != NULL && p[0] != '\0');
  ------------------
  |  Branch (568:18): [True: 171, False: 46]
  |  Branch (568:31): [True: 171, False: 0]
  ------------------
  569|    170|        if (args == 0) {
  ------------------
  |  Branch (569:13): [True: 1, False: 169]
  ------------------
  570|      1|            ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  311|      1|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  571|      1|                          "ERROR - Match keyword requires an argument");
  572|      1|            SAFE_FREE(x);
  ------------------
  |  |  373|      1|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 1, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 1]
  |  |  ------------------
  ------------------
  573|      1|            return -1;
  574|      1|        }
  575|       |        /* This line only sets the PARSING flag if all checks passed */
  576|    169|        *parser_flags |= result;
  577|    169|        break;
  578|    170|    }
  579|     75|    case BIND_CFG_PUBKEY_ACCEPTED_KEY_TYPES:
  ------------------
  |  Branch (579:5): [True: 75, False: 1.95M]
  ------------------
  580|     75|        p = ssh_config_get_str_tok(&s, NULL);
  581|     75|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     23|#define PARSING     1
  ------------------
  |  Branch (581:13): [True: 23, False: 52]
  |  Branch (581:18): [True: 19, False: 4]
  ------------------
  582|     19|            rc = ssh_bind_options_set(bind,
  583|     19|                                 SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES, p);
  584|     19|            if (rc != 0) {
  ------------------
  |  Branch (584:17): [True: 5, False: 14]
  ------------------
  585|      5|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      5|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  586|      5|                        "line %d: Failed to set PubKeyAcceptedKeyTypes value '%s'",
  587|      5|                        count, p);
  588|      5|            }
  589|     19|        }
  590|     75|        break;
  591|    120|    case BIND_CFG_HOSTKEY_ALGORITHMS:
  ------------------
  |  Branch (591:5): [True: 120, False: 1.95M]
  ------------------
  592|    120|        p = ssh_config_get_str_tok(&s, NULL);
  593|    120|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|    109|#define PARSING     1
  ------------------
  |  Branch (593:13): [True: 109, False: 11]
  |  Branch (593:18): [True: 56, False: 53]
  ------------------
  594|     56|            rc = ssh_bind_options_set(bind,
  595|     56|                                 SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS, p);
  596|     56|            if (rc != 0) {
  ------------------
  |  Branch (596:17): [True: 5, False: 51]
  ------------------
  597|      5|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      5|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  598|      5|                        "line %d: Failed to set HostkeyAlgorithms value '%s'",
  599|      5|                        count, p);
  600|      5|            }
  601|     56|        }
  602|    120|        break;
  603|    395|    case BIND_CFG_REQUIRED_RSA_SIZE:
  ------------------
  |  Branch (603:5): [True: 395, False: 1.95M]
  ------------------
  604|    395|        l = ssh_config_get_long(&s, -1);
  605|    395|        if (l >= 0 && l <= INT_MAX && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     43|#define PARSING     1
  ------------------
  |  Branch (605:13): [True: 61, False: 334]
  |  Branch (605:23): [True: 43, False: 18]
  |  Branch (605:39): [True: 30, False: 13]
  ------------------
  606|     30|            int i = (int)l;
  607|     30|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_RSA_MIN_SIZE, &i);
  608|     30|            if (rc != 0) {
  ------------------
  |  Branch (608:17): [True: 0, False: 30]
  ------------------
  609|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  610|      0|                        "line %d: Failed to set RequiredRSASize value '%ld'",
  611|      0|                        count,
  612|      0|                        l);
  613|      0|            }
  614|     30|        }
  615|    395|        break;
  616|  1.08k|    case BIND_CFG_NOT_ALLOWED_IN_MATCH:
  ------------------
  |  Branch (616:5): [True: 1.08k, False: 1.95M]
  ------------------
  617|  1.08k|        SSH_LOG(SSH_LOG_DEBUG, "Option not allowed in Match block: %s, line: %d",
  ------------------
  |  |  281|  1.08k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  618|  1.08k|                keyword, count);
  619|  1.08k|        break;
  620|  1.95M|    case BIND_CFG_UNKNOWN:
  ------------------
  |  Branch (620:5): [True: 1.95M, False: 3.60k]
  ------------------
  621|  1.95M|        SSH_LOG(SSH_LOG_TRACE, "Unknown option: %s, line: %d",
  ------------------
  |  |  281|  1.95M|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  622|  1.95M|                keyword, count);
  623|  1.95M|        break;
  624|      0|    case BIND_CFG_UNSUPPORTED:
  ------------------
  |  Branch (624:5): [True: 0, False: 1.95M]
  ------------------
  625|      0|        SSH_LOG(SSH_LOG_TRACE, "Unsupported option: %s, line: %d",
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  626|      0|                keyword, count);
  627|      0|        break;
  628|      0|    case BIND_CFG_NA:
  ------------------
  |  Branch (628:5): [True: 0, False: 1.95M]
  ------------------
  629|      0|        SSH_LOG(SSH_LOG_TRACE, "Option not applicable: %s, line: %d",
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  630|      0|                keyword, count);
  631|      0|        break;
  632|      0|    default:
  ------------------
  |  Branch (632:5): [True: 0, False: 1.95M]
  ------------------
  633|      0|        ssh_set_error(bind, SSH_FATAL, "ERROR - unimplemented opcode: %d",
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  634|      0|                opcode);
  635|      0|        SAFE_FREE(x);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  636|      0|        return -1;
  637|      0|        break;
  638|  1.95M|    }
  639|       |
  640|  1.95M|    SAFE_FREE(x);
  ------------------
  |  |  373|  1.95M|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 1.95M, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 1.95M]
  |  |  ------------------
  ------------------
  641|  1.95M|    return rc;
  642|  1.95M|}
bind_config.c:ssh_bind_config_get_opcode:
  175|  1.95M|{
  176|  1.95M|    int i;
  177|       |
  178|  25.3M|    for (i = 0; ssh_bind_config_keyword_table[i].name != NULL; i++) {
  ------------------
  |  Branch (178:17): [True: 23.4M, False: 1.95M]
  ------------------
  179|  23.4M|        if (strcasecmp(keyword, ssh_bind_config_keyword_table[i].name) == 0) {
  ------------------
  |  Branch (179:13): [True: 3.83k, False: 23.4M]
  ------------------
  180|  3.83k|            if ((*parser_flags & IN_MATCH) &&
  ------------------
  |  |   49|  3.83k|#define IN_MATCH    (1<<1)
  ------------------
  |  Branch (180:17): [True: 1.76k, False: 2.07k]
  ------------------
  181|  1.76k|                !(ssh_bind_config_keyword_table[i].allowed_in_match))
  ------------------
  |  Branch (181:17): [True: 1.08k, False: 673]
  ------------------
  182|  1.08k|            {
  183|  1.08k|                return BIND_CFG_NOT_ALLOWED_IN_MATCH;
  184|  1.08k|            }
  185|  2.74k|            return ssh_bind_config_keyword_table[i].opcode;
  186|  3.83k|        }
  187|  23.4M|    }
  188|       |
  189|  1.95M|    return BIND_CFG_UNKNOWN;
  190|  1.95M|}
bind_config.c:local_parse_glob:
  249|    481|{
  250|    481|    glob_t globbuf = {
  251|    481|        .gl_flags = 0,
  252|    481|    };
  253|    481|    int rt;
  254|    481|    u_int i;
  255|       |
  256|    481|    rt = glob(fileglob, GLOB_TILDE, NULL, &globbuf);
  257|    481|    if (rt == GLOB_NOMATCH) {
  ------------------
  |  Branch (257:9): [True: 172, False: 309]
  ------------------
  258|    172|        globfree(&globbuf);
  259|    172|        return;
  260|    309|    } else if (rt != 0) {
  ------------------
  |  Branch (260:16): [True: 0, False: 309]
  ------------------
  261|      0|        SSH_LOG(SSH_LOG_RARE, "Glob error: %s",
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  262|      0|                fileglob);
  263|      0|        globfree(&globbuf);
  264|      0|        return;
  265|      0|    }
  266|       |
  267|  8.92k|    for (i = 0; i < globbuf.gl_pathc; i++) {
  ------------------
  |  Branch (267:17): [True: 8.61k, False: 309]
  ------------------
  268|  8.61k|        local_parse_file(bind, globbuf.gl_pathv[i], parser_flags, seen, depth);
  269|  8.61k|    }
  270|       |
  271|    309|    globfree(&globbuf);
  272|    309|}
bind_config.c:local_parse_file:
  207|  8.61k|{
  208|  8.61k|    FILE *f = NULL;
  209|  8.61k|    char line[MAX_LINE_SIZE] = {0};
  210|  8.61k|    unsigned int count = 0;
  211|  8.61k|    int rv;
  212|       |
  213|  8.61k|    if (depth > LIBSSH_BIND_CONF_MAX_DEPTH) {
  ------------------
  |  |  200|  8.61k|#define LIBSSH_BIND_CONF_MAX_DEPTH 16
  ------------------
  |  Branch (213:9): [True: 0, False: 8.61k]
  ------------------
  214|      0|        ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  215|      0|                      "ERROR - Too many levels of configuration includes "
  216|      0|                      "when processing file '%s'", filename);
  217|      0|        return;
  218|      0|    }
  219|       |
  220|  8.61k|    f = ssh_strict_fopen(filename, SSH_MAX_CONFIG_FILE_SIZE);
  ------------------
  |  |  528|  8.61k|#define SSH_MAX_CONFIG_FILE_SIZE 16 * 1024 * 1024
  ------------------
  221|  8.61k|    if (f == NULL) {
  ------------------
  |  Branch (221:9): [True: 1.65k, False: 6.96k]
  ------------------
  222|  1.65k|        SSH_LOG(SSH_LOG_RARE, "Cannot find file %s to load",
  ------------------
  |  |  281|  1.65k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  223|  1.65k|                filename);
  224|  1.65k|        return;
  225|  1.65k|    }
  226|       |
  227|  6.96k|    SSH_LOG(SSH_LOG_PACKET, "Reading additional configuration data from %s",
  ------------------
  |  |  281|  6.96k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  228|  6.96k|            filename);
  229|       |
  230|  2.95M|    while (fgets(line, sizeof(line), f)) {
  ------------------
  |  Branch (230:12): [True: 2.95M, False: 6.92k]
  ------------------
  231|  2.95M|        count++;
  232|  2.95M|        rv = ssh_bind_config_parse_line(bind, line, count, parser_flags, seen, depth);
  233|  2.95M|        if (rv < 0) {
  ------------------
  |  Branch (233:13): [True: 46, False: 2.95M]
  ------------------
  234|     46|            fclose(f);
  235|     46|            return;
  236|     46|        }
  237|  2.95M|    }
  238|       |
  239|  6.92k|    fclose(f);
  240|  6.92k|    return;
  241|  6.96k|}
bind_config.c:ssh_bind_config_get_match_opcode:
  277|    268|{
  278|    268|    size_t i;
  279|       |
  280|  1.22k|    for (i = 0; ssh_bind_config_match_keyword_table[i].name != NULL; i++) {
  ------------------
  |  Branch (280:17): [True: 1.17k, False: 45]
  ------------------
  281|  1.17k|        if (strcasecmp(keyword, ssh_bind_config_match_keyword_table[i].name) == 0) {
  ------------------
  |  Branch (281:13): [True: 223, False: 956]
  ------------------
  282|    223|            return ssh_bind_config_match_keyword_table[i].opcode;
  283|    223|        }
  284|  1.17k|    }
  285|       |
  286|     45|    return BIND_MATCH_UNKNOWN;
  287|    268|}

ssh_config_get_token_info:
   69|  2.40M|{
   70|  2.40M|    register char *c = NULL;
   71|       |    /* Write cursor for the normalized token. Quotes and selected escape
   72|       |     * characters are dropped while still returning a pointer into the original
   73|       |     * buffer.
   74|       |     */
   75|  2.40M|    char *dst = NULL;
   76|  2.40M|    bool had_equal = false;
   77|  2.40M|    bool found = false;
   78|  2.40M|    bool invalid = false;
   79|  2.40M|    char *r = NULL;
   80|       |
   81|  2.40M|    if (info != NULL) {
  ------------------
  |  Branch (81:9): [True: 0, False: 2.40M]
  ------------------
   82|      0|        info->found = false;
   83|      0|        info->had_equal = false;
   84|      0|        info->invalid = false;
   85|      0|    }
   86|       |
   87|       |    /* Ignore leading spaces */
   88|  5.09M|    for (c = *str; *c; c++) {
  ------------------
  |  Branch (88:20): [True: 5.08M, False: 4.37k]
  ------------------
   89|  5.08M|        if (! isblank(*c)) {
  ------------------
  |  Branch (89:13): [True: 2.40M, False: 2.68M]
  ------------------
   90|  2.40M|            break;
   91|  2.40M|        }
   92|  5.08M|    }
   93|       |
   94|       |    /* End of string or a bare newline means there is no token here, not an
   95|       |     * explicit empty token (""). Keep found=false in both cases; the newline
   96|       |     * branch also consumes the line boundary.
   97|       |     */
   98|  2.40M|    if (*c == '\0') {
  ------------------
  |  Branch (98:9): [True: 4.37k, False: 2.40M]
  ------------------
   99|  4.37k|        r = c;
  100|  4.37k|        goto out;
  101|  4.37k|    }
  102|  2.40M|    if (*c == '\n') {
  ------------------
  |  Branch (102:9): [True: 266k, False: 2.13M]
  ------------------
  103|   266k|        r = c;
  104|   266k|        *c = '\0';
  105|   266k|        c++;
  106|   266k|        goto out;
  107|   266k|    }
  108|       |
  109|  2.13M|    found = true;
  110|       |
  111|       |    /* If we start with quote, return the whole quoted block */
  112|  2.13M|    if (*c == '\"') {
  ------------------
  |  Branch (112:9): [True: 36.3k, False: 2.10M]
  ------------------
  113|  36.3k|        bool closed_quote = false;
  114|       |
  115|  36.3k|        r = dst = ++c;
  116|   481k|        while (*c != '\0' && *c != '\n') {
  ------------------
  |  Branch (116:16): [True: 478k, False: 3.06k]
  |  Branch (116:30): [True: 478k, False: 0]
  ------------------
  117|   478k|            if (*c == '\\' && c[1] == '\"') {
  ------------------
  |  Branch (117:17): [True: 2.14k, False: 476k]
  |  Branch (117:31): [True: 536, False: 1.61k]
  ------------------
  118|    536|                c++;
  119|   477k|            } else if (*c == '\"') {
  ------------------
  |  Branch (119:24): [True: 33.2k, False: 444k]
  ------------------
  120|  33.2k|                *dst = '\0';
  121|  33.2k|                c++;
  122|  33.2k|                closed_quote = true;
  123|  33.2k|                break;
  124|  33.2k|            }
  125|   444k|            *dst++ = *c++;
  126|   444k|        }
  127|  36.3k|        if (!closed_quote) {
  ------------------
  |  Branch (127:13): [True: 3.06k, False: 33.2k]
  ------------------
  128|  3.06k|            invalid = true;
  129|  3.06k|            *dst = '\0';
  130|  3.06k|            if (*c == '\n') {
  ------------------
  |  Branch (130:17): [True: 0, False: 3.06k]
  ------------------
  131|      0|                c++;
  132|      0|            }
  133|  3.06k|        }
  134|  2.10M|    } else {
  135|       |        /* Otherwise terminate on space, equal or newline */
  136|  2.10M|        r = dst = c;
  137|  44.4M|        for (; *c; c++) {
  ------------------
  |  Branch (137:16): [True: 43.2M, False: 1.14M]
  ------------------
  138|       |            /* Treat escaped whitespace outside quotes as part of the current
  139|       |             * token, e.g. "tag\ name". The backslash is dropped as the token
  140|       |             * is compacted in place through dst.
  141|       |             *
  142|       |             * Note: there is no general backslash escape; the quoted branch
  143|       |             * above only recognizes \", and this branch only recognizes
  144|       |             * \<blank>.
  145|       |             */
  146|  43.2M|            if (*c == '\\' && isblank((unsigned char)c[1])) {
  ------------------
  |  Branch (146:17): [True: 149k, False: 43.1M]
  |  Branch (146:31): [True: 80, False: 148k]
  ------------------
  147|     80|                c++;
  148|     80|                *dst++ = *c;
  149|  43.2M|            } else if (isblank((unsigned char)*c) || *c == '=' || *c == '\n') {
  ------------------
  |  Branch (149:24): [True: 916k, False: 42.3M]
  |  Branch (149:54): [True: 37.9k, False: 42.3M]
  |  Branch (149:67): [True: 0, False: 42.3M]
  ------------------
  150|   954k|                had_equal = (*c == '=');
  151|   954k|                *dst = '\0';
  152|   954k|                c++;
  153|   954k|                break;
  154|  42.3M|            } else {
  155|  42.3M|                *dst++ = *c;
  156|  42.3M|            }
  157|  43.2M|        }
  158|  2.10M|        if (*c == '\0') {
  ------------------
  |  Branch (158:13): [True: 1.15M, False: 953k]
  ------------------
  159|  1.15M|            *dst = '\0';
  160|  1.15M|        }
  161|  2.10M|    }
  162|       |
  163|       |    /* Skip any other remaining whitespace */
  164|  2.46M|    while (isblank((unsigned char)*c) || *c == '\n' ||
  ------------------
  |  Branch (164:12): [True: 294k, False: 2.17M]
  |  Branch (164:42): [True: 0, False: 2.17M]
  ------------------
  165|  2.17M|           (!had_equal && *c == '=')) {
  ------------------
  |  Branch (165:13): [True: 2.10M, False: 72.5k]
  |  Branch (165:27): [True: 34.6k, False: 2.06M]
  ------------------
  166|   329k|        if (*c == '=') {
  ------------------
  |  Branch (166:13): [True: 34.6k, False: 294k]
  ------------------
  167|  34.6k|            had_equal = true;
  168|  34.6k|        }
  169|   329k|        c++;
  170|   329k|    }
  171|  2.40M|out:
  172|  2.40M|    *str = c;
  173|  2.40M|    if (info != NULL) {
  ------------------
  |  Branch (173:9): [True: 0, False: 2.40M]
  ------------------
  174|      0|        info->found = found;
  175|      0|        info->had_equal = had_equal;
  176|      0|        info->invalid = invalid;
  177|      0|    }
  178|  2.40M|    return r;
  179|  2.13M|}
ssh_config_get_token:
  182|  2.40M|{
  183|       |    return ssh_config_get_token_info(str, NULL);
  184|  2.40M|}
ssh_config_get_long:
  187|    395|{
  188|    395|    char *p = NULL, *endp = NULL;
  189|    395|    long i;
  190|       |
  191|    395|    p = ssh_config_get_token(str);
  192|    395|    if (p && *p) {
  ------------------
  |  Branch (192:9): [True: 395, False: 0]
  |  Branch (192:14): [True: 193, False: 202]
  ------------------
  193|    193|        i = strtol(p, &endp, 10);
  194|    193|        if (p == endp || *endp != '\0') {
  ------------------
  |  Branch (194:13): [True: 11, False: 182]
  |  Branch (194:26): [True: 104, False: 78]
  ------------------
  195|    115|            return notfound;
  196|    115|        }
  197|     78|        return i;
  198|    193|    }
  199|       |
  200|    202|    return notfound;
  201|    395|}
ssh_config_get_str_tok:
  204|  2.52k|{
  205|  2.52k|    char *p = NULL;
  206|       |
  207|  2.52k|    p = ssh_config_get_token(str);
  208|  2.52k|    if (p && *p) {
  ------------------
  |  Branch (208:9): [True: 2.52k, False: 0]
  |  Branch (208:14): [True: 1.25k, False: 1.26k]
  ------------------
  209|  1.25k|        return p;
  210|  1.25k|    }
  211|       |
  212|  1.26k|    return def;
  213|  2.52k|}

ssh_dh_init:
  235|      2|{
  236|      2|    unsigned long g_int = 2 ;	/* G is defined as 2 by the ssh2 standards */
  237|      2|    int rc;
  238|      2|    if (dh_crypto_initialized) {
  ------------------
  |  Branch (238:9): [True: 0, False: 2]
  ------------------
  239|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  240|      0|    }
  241|      2|    dh_crypto_initialized = 1;
  242|       |
  243|      2|    ssh_dh_generator = bignum_new();
  ------------------
  |  |   70|      2|#define bignum_new() BN_new()
  ------------------
  244|      2|    if (ssh_dh_generator == NULL) {
  ------------------
  |  Branch (244:9): [True: 0, False: 2]
  ------------------
  245|      0|        goto error;
  246|      0|    }
  247|      2|    rc = bignum_set_word(ssh_dh_generator, g_int);
  ------------------
  |  |   77|      2|#define bignum_set_word(bn,n) BN_set_word(bn,n)
  ------------------
  248|      2|    if (rc != 1) {
  ------------------
  |  Branch (248:9): [True: 0, False: 2]
  ------------------
  249|      0|        goto error;
  250|      0|    }
  251|       |
  252|      2|    bignum_bin2bn(p_group1_value, P_GROUP1_LEN, &ssh_dh_group1);
  ------------------
  |  |   79|      2|    do {                                     \
  |  |   80|      2|        (*dest) = BN_new();                  \
  |  |   81|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (81:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   82|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   83|      2|        }                                    \
  |  |   84|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (84:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  253|      2|    if (ssh_dh_group1 == NULL) {
  ------------------
  |  Branch (253:9): [True: 0, False: 2]
  ------------------
  254|      0|        goto error;
  255|      0|    }
  256|      2|    bignum_bin2bn(p_group14_value, P_GROUP14_LEN, &ssh_dh_group14);
  ------------------
  |  |   79|      2|    do {                                     \
  |  |   80|      2|        (*dest) = BN_new();                  \
  |  |   81|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (81:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   82|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   83|      2|        }                                    \
  |  |   84|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (84:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  257|      2|    if (ssh_dh_group14 == NULL) {
  ------------------
  |  Branch (257:9): [True: 0, False: 2]
  ------------------
  258|      0|        goto error;
  259|      0|    }
  260|      2|    bignum_bin2bn(p_group16_value, P_GROUP16_LEN, &ssh_dh_group16);
  ------------------
  |  |   79|      2|    do {                                     \
  |  |   80|      2|        (*dest) = BN_new();                  \
  |  |   81|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (81:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   82|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   83|      2|        }                                    \
  |  |   84|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (84:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  261|      2|    if (ssh_dh_group16 == NULL) {
  ------------------
  |  Branch (261:9): [True: 0, False: 2]
  ------------------
  262|      0|        goto error;
  263|      0|    }
  264|      2|    bignum_bin2bn(p_group18_value, P_GROUP18_LEN, &ssh_dh_group18);
  ------------------
  |  |   79|      2|    do {                                     \
  |  |   80|      2|        (*dest) = BN_new();                  \
  |  |   81|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (81:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   82|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   83|      2|        }                                    \
  |  |   84|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (84:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  265|      2|    if (ssh_dh_group18 == NULL) {
  ------------------
  |  Branch (265:9): [True: 0, False: 2]
  ------------------
  266|      0|        goto error;
  267|      0|    }
  268|       |
  269|      2|    return 0;
  270|      0|error:
  271|      0|    ssh_dh_finalize();
  272|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  273|      2|}

_ssh_set_error:
   55|     73|{
   56|     73|    struct ssh_common_struct *err = error;
   57|     73|    va_list va;
   58|       |
   59|     73|    va_start(va, descr);
   60|     73|    vsnprintf(err->error.error_buffer, ERROR_BUFFERLEN, descr, va);
  ------------------
  |  |  219|     73|#define ERROR_BUFFERLEN 1024
  ------------------
   61|     73|    va_end(va);
   62|       |
   63|     73|    err->error.error_code = code;
   64|     73|    if (ssh_get_log_level() == SSH_LOG_TRACE) {
  ------------------
  |  |  363|     73|#define SSH_LOG_TRACE 4
  ------------------
  |  Branch (64:9): [True: 0, False: 73]
  ------------------
   65|      0|        ssh_log_function(SSH_LOG_TRACE,
  ------------------
  |  |  363|      0|#define SSH_LOG_TRACE 4
  ------------------
   66|      0|                         function,
   67|      0|                         err->error.error_buffer);
   68|      0|    }
   69|     73|}

libssh_constructor:
  114|      2|{
  115|       |
  116|      2|    int rc;
  117|       |
  118|      2|    rc = _ssh_init(1);
  119|       |
  120|      2|    if (rc < 0) {
  ------------------
  |  Branch (120:9): [True: 0, False: 2]
  ------------------
  121|      0|        fprintf(stderr, "Error in auto_init()\n");
  122|      0|    }
  123|       |
  124|      2|    return;
  125|      2|}
ssh_init:
  156|      2|int ssh_init(void) {
  157|      2|    return _ssh_init(0);
  158|      2|}
ssh_finalize:
  241|      2|int ssh_finalize(void) {
  242|      2|    return _ssh_finalize(0);
  243|      2|}
init.c:_ssh_init:
   62|      4|static int _ssh_init(unsigned constructor) {
   63|       |
   64|      4|    int rc = 0;
   65|       |
   66|      4|    if (!constructor) {
  ------------------
  |  Branch (66:9): [True: 2, False: 2]
  ------------------
   67|      2|        ssh_mutex_lock(&ssh_init_mutex);
   68|      2|    }
   69|       |
   70|      4|    _ssh_initialized++;
   71|       |
   72|      4|    if (_ssh_initialized > 1) {
  ------------------
  |  Branch (72:9): [True: 2, False: 2]
  ------------------
   73|      2|        rc = _ssh_init_ret;
   74|      2|        goto _ret;
   75|      2|    }
   76|       |
   77|      2|    rc = ssh_threads_init();
   78|      2|    if (rc) {
  ------------------
  |  Branch (78:9): [True: 0, False: 2]
  ------------------
   79|      0|        goto _ret;
   80|      0|    }
   81|       |
   82|      2|    rc = ssh_crypto_init();
   83|      2|    if (rc) {
  ------------------
  |  Branch (83:9): [True: 0, False: 2]
  ------------------
   84|      0|        goto _ret;
   85|      0|    }
   86|       |
   87|      2|    rc = ssh_dh_init();
   88|      2|    if (rc) {
  ------------------
  |  Branch (88:9): [True: 0, False: 2]
  ------------------
   89|      0|        goto _ret;
   90|      0|    }
   91|       |
   92|      2|    rc = ssh_socket_init();
   93|      2|    if (rc) {
  ------------------
  |  Branch (93:9): [True: 0, False: 2]
  ------------------
   94|      0|        goto _ret;
   95|      0|    }
   96|       |
   97|      4|_ret:
   98|      4|    _ssh_init_ret = rc;
   99|       |
  100|      4|    if (!constructor) {
  ------------------
  |  Branch (100:9): [True: 2, False: 2]
  ------------------
  101|      2|        ssh_mutex_unlock(&ssh_init_mutex);
  102|      2|    }
  103|       |
  104|      4|    return rc;
  105|      2|}
init.c:_ssh_finalize:
  160|      2|static int _ssh_finalize(unsigned destructor) {
  161|       |
  162|      2|    if (!destructor) {
  ------------------
  |  Branch (162:9): [True: 2, False: 0]
  ------------------
  163|      2|        ssh_mutex_lock(&ssh_init_mutex);
  164|       |
  165|      2|        if (_ssh_initialized > 1) {
  ------------------
  |  Branch (165:13): [True: 2, False: 0]
  ------------------
  166|      2|            _ssh_initialized--;
  167|      2|            ssh_mutex_unlock(&ssh_init_mutex);
  168|      2|            return 0;
  169|      2|        }
  170|       |
  171|      0|        if (_ssh_initialized == 1) {
  ------------------
  |  Branch (171:13): [True: 0, False: 0]
  ------------------
  172|      0|            if (_ssh_init_ret < 0) {
  ------------------
  |  Branch (172:17): [True: 0, False: 0]
  ------------------
  173|      0|                ssh_mutex_unlock(&ssh_init_mutex);
  174|      0|                return 0;
  175|      0|            }
  176|      0|        }
  177|      0|    }
  178|       |
  179|       |    /* If the counter reaches zero or it is the destructor calling, finalize */
  180|      0|    ssh_dh_finalize();
  181|      0|    ssh_crypto_finalize();
  182|      0|    ssh_socket_cleanup();
  183|       |    /* It is important to finalize threading after CRYPTO because
  184|       |     * it still depends on it */
  185|      0|    ssh_threads_finalize();
  186|       |
  187|      0|    _ssh_initialized = 0;
  188|       |
  189|      0|    if (!destructor) {
  ------------------
  |  Branch (189:9): [True: 0, False: 0]
  ------------------
  190|      0|        ssh_mutex_unlock(&ssh_init_mutex);
  191|      0|    }
  192|       |
  193|       |#if (defined(_WIN32) && !defined(HAVE_PTHREAD))
  194|       |    if (ssh_init_mutex != NULL) {
  195|       |        DeleteCriticalSection(ssh_init_mutex);
  196|       |        SAFE_FREE(ssh_init_mutex);
  197|       |    }
  198|       |#endif
  199|       |
  200|      0|    return 0;
  201|      2|}

ssh_kex_get_description:
  317|     16|{
  318|     16|    if (type >= SSH_KEX_METHODS) {
  ------------------
  |  |   27|     16|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (318:9): [True: 0, False: 16]
  ------------------
  319|      0|        return NULL;
  320|      0|    }
  321|       |
  322|     16|    return ssh_kex_descriptions[type];
  323|     16|}
ssh_keep_known_algos:
 1324|     28|{
 1325|     28|    if (algo > SSH_LANG_S_C) {
  ------------------
  |  Branch (1325:9): [True: 0, False: 28]
  ------------------
 1326|      0|        return NULL;
 1327|      0|    }
 1328|       |
 1329|     28|    return ssh_find_all_matching(supported_methods[algo], list);
 1330|     28|}
ssh_add_to_default_algos:
 1368|    105|{
 1369|    105|    char *tmp = NULL, *ret = NULL;
 1370|       |
 1371|    105|    if (algo > SSH_LANG_S_C || list == NULL || list[0] == '\0') {
  ------------------
  |  Branch (1371:9): [True: 0, False: 105]
  |  Branch (1371:32): [True: 0, False: 105]
  |  Branch (1371:48): [True: 0, False: 105]
  ------------------
 1372|      0|        return NULL;
 1373|      0|    }
 1374|       |
 1375|    105|    if (ssh_fips_mode()) {
  ------------------
  |  |  115|    105|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 105]
  |  |  ------------------
  ------------------
 1376|      0|        tmp = ssh_append_without_duplicates(fips_methods[algo], list);
 1377|      0|        ret = ssh_find_all_matching(fips_methods[algo], tmp);
 1378|    105|    } else {
 1379|    105|        tmp = ssh_append_without_duplicates(default_methods[algo], list);
 1380|    105|        ret = ssh_find_all_matching(supported_methods[algo], tmp);
 1381|    105|    }
 1382|       |
 1383|    105|    free(tmp);
 1384|    105|    return ret;
 1385|    105|}
ssh_remove_from_default_algos:
 1401|     56|{
 1402|     56|    if (algo > SSH_LANG_S_C) {
  ------------------
  |  Branch (1402:9): [True: 0, False: 56]
  ------------------
 1403|      0|        return NULL;
 1404|      0|    }
 1405|       |
 1406|     56|    if (list == NULL || list[0] == '\0') {
  ------------------
  |  Branch (1406:9): [True: 0, False: 56]
  |  Branch (1406:25): [True: 6, False: 50]
  ------------------
 1407|      6|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|      6|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 6]
  |  |  ------------------
  ------------------
 1408|      0|            return strdup(fips_methods[algo]);
 1409|      6|        } else {
 1410|      6|            return strdup(default_methods[algo]);
 1411|      6|        }
 1412|      6|    }
 1413|       |
 1414|     50|    if (ssh_fips_mode()) {
  ------------------
  |  |  115|     50|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 50]
  |  |  ------------------
  ------------------
 1415|      0|        return ssh_remove_all_matching(fips_methods[algo], list);
 1416|     50|    } else {
 1417|     50|        return ssh_remove_all_matching(default_methods[algo], list);
 1418|     50|    }
 1419|     50|}
ssh_prefix_default_algos:
 1439|    122|{
 1440|    122|    char *ret = NULL, *tmp = NULL;
 1441|       |
 1442|    122|    if (algo > SSH_LANG_S_C || list == NULL || list[0] == '\0') {
  ------------------
  |  Branch (1442:9): [True: 0, False: 122]
  |  Branch (1442:32): [True: 0, False: 122]
  |  Branch (1442:48): [True: 0, False: 122]
  ------------------
 1443|      0|        return NULL;
 1444|      0|    }
 1445|       |
 1446|    122|    if (ssh_fips_mode()) {
  ------------------
  |  |  115|    122|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 122]
  |  |  ------------------
  ------------------
 1447|      0|        tmp = ssh_prefix_without_duplicates(fips_methods[algo], list);
 1448|      0|        ret = ssh_find_all_matching(fips_methods[algo], tmp);
 1449|    122|    } else {
 1450|    122|        tmp = ssh_prefix_without_duplicates(default_methods[algo], list);
 1451|    122|        ret = ssh_find_all_matching(supported_methods[algo], tmp);
 1452|    122|    }
 1453|       |
 1454|    122|    free(tmp);
 1455|    122|    return ret;
 1456|    122|}

ssh_crypto_init:
 1391|      2|{
 1392|       |#ifndef HAVE_OPENSSL_EVP_CHACHA20
 1393|       |    size_t i;
 1394|       |#endif
 1395|       |
 1396|      2|    if (libcrypto_initialized) {
  ------------------
  |  Branch (1396:9): [True: 0, False: 2]
  ------------------
 1397|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 1398|      0|    }
 1399|      2|    if (OpenSSL_version_num() != OPENSSL_VERSION_NUMBER) {
  ------------------
  |  Branch (1399:9): [True: 0, False: 2]
  ------------------
 1400|      0|        SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1401|      0|                "libssh compiled with %s "
 1402|      0|                "headers, currently running with %s.",
 1403|      0|                OPENSSL_VERSION_TEXT,
 1404|      0|                OpenSSL_version(OpenSSL_version_num()));
 1405|      0|    }
 1406|       |#ifdef CAN_DISABLE_AESNI
 1407|       |    /*
 1408|       |     * disable AES-NI when running within Valgrind, because they generate
 1409|       |     * too many "uninitialized memory access" false positives
 1410|       |     */
 1411|       |    if (RUNNING_ON_VALGRIND) {
 1412|       |        SSH_LOG(SSH_LOG_INFO, "Running within Valgrind, disabling AES-NI");
 1413|       |        /* Bit #57 denotes AES-NI instruction set extension */
 1414|       |        OPENSSL_ia32cap &= ~(1LL << 57);
 1415|       |    }
 1416|       |#endif /* CAN_DISABLE_AESNI */
 1417|       |
 1418|       |#ifndef HAVE_OPENSSL_EVP_CHACHA20
 1419|       |    for (i = 0; ssh_ciphertab[i].name != NULL; i++) {
 1420|       |        int cmp;
 1421|       |
 1422|       |        cmp = strcmp(ssh_ciphertab[i].name, "chacha20-poly1305@openssh.com");
 1423|       |        if (cmp == 0) {
 1424|       |            memcpy(&ssh_ciphertab[i],
 1425|       |                   ssh_get_chacha20poly1305_cipher(),
 1426|       |                   sizeof(struct ssh_cipher_struct));
 1427|       |            break;
 1428|       |        }
 1429|       |    }
 1430|       |#endif /* HAVE_OPENSSL_EVP_CHACHA20 */
 1431|       |
 1432|      2|    libcrypto_initialized = 1;
 1433|       |
 1434|      2|    return SSH_OK;
  ------------------
  |  |  316|      2|#define SSH_OK 0     /* No error */
  ------------------
 1435|      2|}

ssh_log_function:
  125|  1.13k|{
  126|  1.13k|    ssh_logging_callback log_fn = ssh_get_log_callback();
  127|       |
  128|  1.13k|    if (log_fn) {
  ------------------
  |  Branch (128:9): [True: 0, False: 1.13k]
  ------------------
  129|      0|        ssh_log_custom(log_fn, verbosity, function, buffer);
  130|      0|        return;
  131|      0|    }
  132|       |
  133|  1.13k|    ssh_log_stderr(verbosity, function, buffer);
  134|  1.13k|}
ssh_vlog:
  149|  1.13k|{
  150|  1.13k|    char buffer[LOG_SIZE];
  151|       |
  152|  1.13k|    vsnprintf(buffer, sizeof(buffer), format, *va);
  153|  1.13k|    ssh_log_function(verbosity, function, buffer);
  154|  1.13k|}
_ssh_log:
  168|  1.98M|{
  169|  1.98M|    va_list va;
  170|       |
  171|  1.98M|    if (verbosity <= ssh_get_log_level()) {
  ------------------
  |  Branch (171:9): [True: 1.13k, False: 1.98M]
  ------------------
  172|  1.13k|        va_start(va, format);
  173|  1.13k|        ssh_vlog(verbosity, function, format, &va);
  174|       |        va_end(va);
  175|  1.13k|    }
  176|  1.98M|}
ssh_set_log_level:
  237|     14|int ssh_set_log_level(int level) {
  238|     14|  if (level < 0) {
  ------------------
  |  Branch (238:7): [True: 0, False: 14]
  ------------------
  239|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  240|      0|  }
  241|       |
  242|     14|  ssh_log_level = level;
  243|       |
  244|     14|  return SSH_OK;
  ------------------
  |  |  316|     14|#define SSH_OK 0     /* No error */
  ------------------
  245|     14|}
ssh_get_log_level:
  252|  1.98M|int ssh_get_log_level(void) {
  253|  1.98M|  return ssh_log_level;
  254|  1.98M|}
ssh_get_log_callback:
  275|  1.13k|ssh_logging_callback ssh_get_log_callback(void) {
  276|  1.13k|  return ssh_log_cb;
  277|  1.13k|}
log.c:ssh_log_stderr:
   87|  1.13k|{
   88|  1.13k|    char date[128] = {0};
   89|  1.13k|    int rc;
   90|       |
   91|  1.13k|    rc = current_timestring(1, date, sizeof(date));
   92|  1.13k|    if (rc == 0) {
  ------------------
  |  Branch (92:9): [True: 1.13k, False: 0]
  ------------------
   93|  1.13k|        fprintf(stderr, "[%s, %d] %s:", date, verbosity, function);
   94|  1.13k|    } else {
   95|      0|        fprintf(stderr, "[%d] %s", verbosity, function);
   96|      0|    }
   97|       |
   98|       |    fprintf(stderr, "  %s\n", buffer);
   99|  1.13k|}
log.c:current_timestring:
   59|  1.13k|{
   60|  1.13k|    char tbuf[64];
   61|  1.13k|    struct timeval tv;
   62|  1.13k|    struct tm tm, *tm_ptr = NULL;
   63|  1.13k|    time_t t;
   64|       |
   65|  1.13k|    gettimeofday(&tv, NULL);
   66|  1.13k|    t = (time_t) tv.tv_sec;
   67|       |
   68|  1.13k|    tm_ptr = localtime_r(&t, &tm);
   69|  1.13k|    if (tm_ptr == NULL) {
  ------------------
  |  Branch (69:9): [True: 0, False: 1.13k]
  ------------------
   70|      0|        return -1;
   71|      0|    }
   72|       |
   73|  1.13k|    if (hires) {
  ------------------
  |  Branch (73:9): [True: 1.13k, False: 0]
  ------------------
   74|  1.13k|        strftime(tbuf, sizeof(tbuf), "%Y/%m/%d %H:%M:%S", &tm);
   75|  1.13k|        snprintf(buf, len, "%s.%06ld", tbuf, (long)tv.tv_usec);
   76|  1.13k|    } else {
   77|      0|        strftime(tbuf, sizeof(tbuf), "%Y/%m/%d %H:%M:%S", &tm);
   78|      0|        snprintf(buf, len, "%s", tbuf);
   79|      0|    }
   80|       |
   81|  1.13k|    return 0;
   82|  1.13k|}

ssh_strerror:
 2396|    236|{
 2397|       |#if ((defined(__linux__) && defined(__GLIBC__)) || defined(__CYGWIN__)) && defined(_GNU_SOURCE)
 2398|       |    /* GNU extension on Linux */
 2399|       |    return strerror_r(err_num, buf, buflen);
 2400|       |#else
 2401|    236|    int rv;
 2402|       |
 2403|       |#if defined(_WIN32)
 2404|       |    rv = strerror_s(buf, buflen, err_num);
 2405|       |#else
 2406|       |    /* POSIX version available for example on FreeBSD or in musl libc */
 2407|    236|    rv = strerror_r(err_num, buf, buflen);
 2408|    236|#endif /* _WIN32 */
 2409|       |
 2410|       |    /* make sure the buffer is initialized and terminated with NULL */
 2411|    236|    if (-rv == ERANGE) {
  ------------------
  |  Branch (2411:9): [True: 0, False: 236]
  ------------------
 2412|      0|        buf[0] = '\0';
 2413|      0|    }
 2414|    236|    return buf;
 2415|    236|#endif /* ((defined(__linux__) && defined(__GLIBC__)) || defined(__CYGWIN__)) && defined(_GNU_SOURCE) */
 2416|    236|}
ssh_strict_fopen:
 2683|  8.61k|{
 2684|  8.61k|    FILE *f = NULL;
 2685|  8.61k|    struct stat sb;
 2686|  8.61k|    int r, fd;
 2687|       |
 2688|       |    /* open first to avoid TOCTOU */
 2689|  8.61k|    fd = open(filename, O_RDONLY);
 2690|  8.61k|    if (fd == -1) {
  ------------------
  |  Branch (2690:9): [True: 236, False: 8.38k]
  ------------------
 2691|    236|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  283|    236|    do {                                                            \
  |  |  284|    236|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|    236|        _ssh_log(priority,                                          \
  |  |  286|    236|                 __func__,                                          \
  |  |  287|    236|                 __VA_ARGS__,                                       \
  |  |  288|    236|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|    236|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|    236|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 236]
  |  |  ------------------
  ------------------
 2692|    236|                         errno,
 2693|    236|                         "Failed to open a file %s for reading: %s",
 2694|    236|                         filename);
 2695|    236|        return NULL;
 2696|    236|    }
 2697|       |
 2698|       |    /* Check the file is sensible for a configuration file */
 2699|  8.38k|    r = fstat(fd, &sb);
 2700|  8.38k|    if (r != 0) {
  ------------------
  |  Branch (2700:9): [True: 0, False: 8.38k]
  ------------------
 2701|      0|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    do {                                                            \
  |  |  284|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|      0|        _ssh_log(priority,                                          \
  |  |  286|      0|                 __func__,                                          \
  |  |  287|      0|                 __VA_ARGS__,                                       \
  |  |  288|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2702|      0|                         errno,
 2703|      0|                         "Failed to stat %s: %s",
 2704|      0|                         filename);
 2705|      0|        close(fd);
 2706|      0|        return NULL;
 2707|      0|    }
 2708|  8.38k|    if ((sb.st_mode & S_IFMT) != S_IFREG) {
  ------------------
  |  Branch (2708:9): [True: 1.41k, False: 6.96k]
  ------------------
 2709|  1.41k|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|  1.41k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2710|  1.41k|                "The file %s is not a regular file: skipping",
 2711|  1.41k|                filename);
 2712|  1.41k|        close(fd);
 2713|  1.41k|        return NULL;
 2714|  1.41k|    }
 2715|       |
 2716|  6.96k|    if ((size_t)sb.st_size > max_file_size) {
  ------------------
  |  Branch (2716:9): [True: 1, False: 6.96k]
  ------------------
 2717|      1|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      1|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2718|      1|                "The file %s is too large (%jd MB > %zu MB): skipping",
 2719|      1|                filename,
 2720|      1|                (intmax_t)sb.st_size / 1024 / 1024,
 2721|      1|                max_file_size / 1024 / 1024);
 2722|      1|        close(fd);
 2723|      1|        return NULL;
 2724|      1|    }
 2725|       |
 2726|  6.96k|    f = fdopen(fd, "r");
 2727|  6.96k|    if (f == NULL) {
  ------------------
  |  Branch (2727:9): [True: 0, False: 6.96k]
  ------------------
 2728|      0|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    do {                                                            \
  |  |  284|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|      0|        _ssh_log(priority,                                          \
  |  |  286|      0|                 __func__,                                          \
  |  |  287|      0|                 __VA_ARGS__,                                       \
  |  |  288|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2729|      0|                         errno,
 2730|      0|                         "Failed to open a file %s for reading: %s",
 2731|      0|                         filename);
 2732|      0|        close(fd);
 2733|      0|        return NULL;
 2734|      0|    }
 2735|       |
 2736|       |    /* the flcose() will close also the underlying fd */
 2737|  6.96k|    return f;
 2738|  6.96k|}
strlcat:
 2765|  8.72k|{
 2766|  8.72k|    size_t dst_len;
 2767|  8.72k|    const char *p = memchr(dst, '\0', size);
 2768|  8.72k|    size_t src_len = strlen(src);
 2769|       |
 2770|  8.72k|    dst_len = (p != NULL) ? (size_t)(p - dst) : size;
  ------------------
  |  Branch (2770:15): [True: 8.72k, False: 0]
  ------------------
 2771|       |
 2772|  8.72k|    if (dst_len < size) {
  ------------------
  |  Branch (2772:9): [True: 8.72k, False: 0]
  ------------------
 2773|  8.72k|        size_t copy_len =
 2774|  8.72k|            (src_len >= size - dst_len) ? size - dst_len - 1 : src_len;
  ------------------
  |  Branch (2774:13): [True: 0, False: 8.72k]
  ------------------
 2775|  8.72k|        memcpy(dst + dst_len, src, copy_len);
 2776|  8.72k|        dst[dst_len + copy_len] = '\0';
 2777|  8.72k|    }
 2778|       |
 2779|  8.72k|    return dst_len + src_len;
 2780|  8.72k|}

ssh_options_set_algo:
  327|    311|{
  328|       |    /* When the list start with +,-,^ the filtration of unknown algorithms
  329|       |     * gets handled inside the helper functions, otherwise the list is taken
  330|       |     * as it is. */
  331|    311|    char *p = (char *)list;
  332|       |
  333|    311|    if (algo < SSH_COMP_C_S) {
  ------------------
  |  Branch (333:9): [True: 311, False: 0]
  ------------------
  334|    311|        if (list[0] == '+') {
  ------------------
  |  Branch (334:13): [True: 105, False: 206]
  ------------------
  335|    105|            p = ssh_add_to_default_algos(algo, list+1);
  336|    206|        } else if (list[0] == '-') {
  ------------------
  |  Branch (336:20): [True: 56, False: 150]
  ------------------
  337|     56|            p = ssh_remove_from_default_algos(algo, list+1);
  338|    150|        } else if (list[0] == '^') {
  ------------------
  |  Branch (338:20): [True: 122, False: 28]
  ------------------
  339|    122|            p = ssh_prefix_default_algos(algo, list+1);
  340|    122|        }
  341|    311|    }
  342|       |
  343|    311|    if (p == list) {
  ------------------
  |  Branch (343:9): [True: 28, False: 283]
  ------------------
  344|     28|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|     28|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 28]
  |  |  ------------------
  ------------------
  345|      0|            p = ssh_keep_fips_algos(algo, list);
  346|     28|        } else {
  347|     28|            p = ssh_keep_known_algos(algo, list);
  348|     28|        }
  349|     28|    }
  350|       |
  351|    311|    if (p == NULL) {
  ------------------
  |  Branch (351:9): [True: 16, False: 295]
  ------------------
  352|     16|        ssh_set_error(session, SSH_REQUEST_DENIED,
  ------------------
  |  |  311|     16|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  353|     16|                "Setting method: no allowed algorithm for method \"%s\" (%s)",
  354|     16|                ssh_kex_get_description(algo), list);
  355|     16|        return -1;
  356|     16|    }
  357|       |
  358|    295|    SAFE_FREE(*place);
  ------------------
  |  |  373|    295|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 7, False: 288]
  |  |  |  Branch (373:71): [Folded, False: 295]
  |  |  ------------------
  ------------------
  359|    295|    *place = p;
  360|       |
  361|    295|    return 0;
  362|    311|}
ssh_bind_options_set:
 2725|    355|{
 2726|    355|    bool allowed;
 2727|    355|    char *p = NULL, *q = NULL;
 2728|    355|    const char *v = NULL;
 2729|    355|    int i, rc;
 2730|    355|    char **wanted_methods = sshbind->wanted_methods;
 2731|       |
 2732|    355|    if (sshbind == NULL) {
  ------------------
  |  Branch (2732:9): [True: 0, False: 355]
  ------------------
 2733|      0|        return -1;
 2734|      0|    }
 2735|       |
 2736|    355|    switch (type) {
 2737|      0|    case SSH_BIND_OPTIONS_RSAKEY:
  ------------------
  |  Branch (2737:5): [True: 0, False: 355]
  ------------------
 2738|      0|    case SSH_BIND_OPTIONS_ECDSAKEY:
  ------------------
  |  Branch (2738:5): [True: 0, False: 355]
  ------------------
 2739|       |        /* deprecated */
 2740|      0|    case SSH_BIND_OPTIONS_HOSTKEY:
  ------------------
  |  Branch (2740:5): [True: 0, False: 355]
  ------------------
 2741|      0|    case SSH_BIND_OPTIONS_IMPORT_KEY:
  ------------------
  |  Branch (2741:5): [True: 0, False: 355]
  ------------------
 2742|      0|    case SSH_BIND_OPTIONS_IMPORT_KEY_STR:
  ------------------
  |  Branch (2742:5): [True: 0, False: 355]
  ------------------
 2743|      0|        if (value == NULL) {
  ------------------
  |  Branch (2743:13): [True: 0, False: 0]
  ------------------
 2744|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2745|      0|            return -1;
 2746|      0|        } else {
 2747|      0|            int key_type;
 2748|      0|            ssh_key *bind_key_loc = NULL;
 2749|      0|            ssh_key key = NULL;
 2750|      0|            char **bind_key_path_loc = NULL;
 2751|       |
 2752|      0|            if (type == SSH_BIND_OPTIONS_IMPORT_KEY_STR) {
  ------------------
  |  Branch (2752:17): [True: 0, False: 0]
  ------------------
 2753|      0|                const char *key_str = (const char *)value;
 2754|      0|                rc = ssh_pki_import_privkey_base64(key_str,
 2755|      0|                                                   NULL,
 2756|      0|                                                   NULL,
 2757|      0|                                                   NULL,
 2758|      0|                                                   &key);
 2759|      0|                if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (2759:21): [True: 0, False: 0]
  ------------------
 2760|      0|                    ssh_set_error(sshbind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2761|      0|                                  SSH_FATAL,
 2762|      0|                                  "Failed to import key from buffer");
 2763|      0|                    return -1;
 2764|      0|                }
 2765|      0|            } else if (type == SSH_BIND_OPTIONS_IMPORT_KEY) {
  ------------------
  |  Branch (2765:24): [True: 0, False: 0]
  ------------------
 2766|      0|                key = (ssh_key)value;
 2767|      0|            } else {
 2768|      0|                rc = ssh_pki_import_privkey_file(value, NULL, NULL, NULL, &key);
 2769|      0|                if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2769:21): [True: 0, False: 0]
  ------------------
 2770|      0|                    return -1;
 2771|      0|                }
 2772|      0|            }
 2773|      0|            allowed = ssh_bind_key_size_allowed(sshbind, key);
 2774|      0|            if (!allowed) {
  ------------------
  |  Branch (2774:17): [True: 0, False: 0]
  ------------------
 2775|      0|                ssh_set_error(sshbind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2776|      0|                              SSH_FATAL,
 2777|      0|                              "The host key size %d is too small.",
 2778|      0|                              ssh_key_size(key));
 2779|      0|                if (type != SSH_BIND_OPTIONS_IMPORT_KEY) {
  ------------------
  |  Branch (2779:21): [True: 0, False: 0]
  ------------------
 2780|      0|                    SSH_KEY_FREE(key);
  ------------------
  |  |  752|      0|    do { if ((x) != NULL) { ssh_key_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (752:14): [True: 0, False: 0]
  |  |  |  Branch (752:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2781|      0|                }
 2782|      0|                return -1;
 2783|      0|            }
 2784|      0|            key_type = ssh_key_type(key);
 2785|      0|            switch (key_type) {
 2786|      0|            case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (2786:13): [True: 0, False: 0]
  ------------------
 2787|      0|            case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (2787:13): [True: 0, False: 0]
  ------------------
 2788|      0|            case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (2788:13): [True: 0, False: 0]
  ------------------
 2789|      0|#ifdef HAVE_ECC
 2790|      0|                bind_key_loc = &sshbind->ecdsa;
 2791|      0|                bind_key_path_loc = &sshbind->ecdsakey;
 2792|       |#else
 2793|       |                ssh_set_error(sshbind,
 2794|       |                              SSH_FATAL,
 2795|       |                              "ECDSA key used and libssh compiled "
 2796|       |                              "without ECDSA support");
 2797|       |#endif
 2798|      0|                break;
 2799|      0|            case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (2799:13): [True: 0, False: 0]
  ------------------
 2800|      0|                bind_key_loc = &sshbind->rsa;
 2801|      0|                bind_key_path_loc = &sshbind->rsakey;
 2802|      0|                break;
 2803|      0|            case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (2803:13): [True: 0, False: 0]
  ------------------
 2804|      0|                bind_key_loc = &sshbind->ed25519;
 2805|      0|                bind_key_path_loc = &sshbind->ed25519key;
 2806|      0|                break;
 2807|      0|            default:
  ------------------
  |  Branch (2807:13): [True: 0, False: 0]
  ------------------
 2808|      0|                ssh_set_error(sshbind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2809|      0|                              SSH_FATAL,
 2810|      0|                              "Unsupported key type %d",
 2811|      0|                              key_type);
 2812|      0|            }
 2813|      0|            if (type == SSH_BIND_OPTIONS_RSAKEY ||
  ------------------
  |  Branch (2813:17): [True: 0, False: 0]
  ------------------
 2814|      0|                type == SSH_BIND_OPTIONS_ECDSAKEY ||
  ------------------
  |  Branch (2814:17): [True: 0, False: 0]
  ------------------
 2815|      0|                type == SSH_BIND_OPTIONS_HOSTKEY) {
  ------------------
  |  Branch (2815:17): [True: 0, False: 0]
  ------------------
 2816|      0|                if (bind_key_loc == NULL) {
  ------------------
  |  Branch (2816:21): [True: 0, False: 0]
  ------------------
 2817|      0|                    ssh_key_free(key);
 2818|      0|                    return -1;
 2819|      0|                }
 2820|       |                /* Set the location of the key on disk even though we don't
 2821|       |                   need it in case some other function wants it */
 2822|      0|                rc = ssh_bind_set_key(sshbind, bind_key_path_loc, value);
 2823|      0|                if (rc < 0) {
  ------------------
  |  Branch (2823:21): [True: 0, False: 0]
  ------------------
 2824|      0|                    ssh_key_free(key);
 2825|      0|                    return -1;
 2826|      0|                }
 2827|      0|            } else if (type == SSH_BIND_OPTIONS_IMPORT_KEY_STR) {
  ------------------
  |  Branch (2827:24): [True: 0, False: 0]
  ------------------
 2828|      0|                if (bind_key_loc == NULL) {
  ------------------
  |  Branch (2828:21): [True: 0, False: 0]
  ------------------
 2829|      0|                    ssh_key_free(key);
 2830|      0|                    return -1;
 2831|      0|                }
 2832|      0|            } else {
 2833|      0|                if (bind_key_loc == NULL) {
  ------------------
  |  Branch (2833:21): [True: 0, False: 0]
  ------------------
 2834|      0|                    return -1;
 2835|      0|                }
 2836|      0|            }
 2837|      0|            ssh_key_free(*bind_key_loc);
 2838|      0|            *bind_key_loc = key;
 2839|      0|        }
 2840|      0|        break;
 2841|      0|    case SSH_BIND_OPTIONS_BINDADDR:
  ------------------
  |  Branch (2841:5): [True: 0, False: 355]
  ------------------
 2842|      0|        if (value == NULL) {
  ------------------
  |  Branch (2842:13): [True: 0, False: 0]
  ------------------
 2843|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2844|      0|            return -1;
 2845|      0|        } else {
 2846|      0|            SAFE_FREE(sshbind->bindaddr);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2847|      0|            sshbind->bindaddr = strdup(value);
 2848|      0|            if (sshbind->bindaddr == NULL) {
  ------------------
  |  Branch (2848:17): [True: 0, False: 0]
  ------------------
 2849|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2850|      0|                return -1;
 2851|      0|            }
 2852|      0|        }
 2853|      0|        break;
 2854|      0|    case SSH_BIND_OPTIONS_BINDPORT:
  ------------------
  |  Branch (2854:5): [True: 0, False: 355]
  ------------------
 2855|      0|        if (value == NULL) {
  ------------------
  |  Branch (2855:13): [True: 0, False: 0]
  ------------------
 2856|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2857|      0|            return -1;
 2858|      0|        } else {
 2859|      0|            int *x = (int *)value;
 2860|      0|            sshbind->bindport = *x & 0xffffU;
 2861|      0|        }
 2862|      0|        break;
 2863|      0|    case SSH_BIND_OPTIONS_BINDPORT_STR:
  ------------------
  |  Branch (2863:5): [True: 0, False: 355]
  ------------------
 2864|      0|        if (value == NULL) {
  ------------------
  |  Branch (2864:13): [True: 0, False: 0]
  ------------------
 2865|      0|            sshbind->bindport = 22 & 0xffffU;
 2866|      0|        } else {
 2867|      0|            q = strdup(value);
 2868|      0|            if (q == NULL) {
  ------------------
  |  Branch (2868:17): [True: 0, False: 0]
  ------------------
 2869|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2870|      0|                return -1;
 2871|      0|            }
 2872|      0|            i = strtol(q, &p, 10);
 2873|      0|            if (q == p) {
  ------------------
  |  Branch (2873:17): [True: 0, False: 0]
  ------------------
 2874|      0|                SSH_LOG(SSH_LOG_DEBUG, "No bind port was parsed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2875|      0|                SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2876|      0|                return -1;
 2877|      0|            }
 2878|      0|            SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2879|       |
 2880|      0|            sshbind->bindport = i & 0xffffU;
 2881|      0|        }
 2882|      0|        break;
 2883|     14|    case SSH_BIND_OPTIONS_LOG_VERBOSITY:
  ------------------
  |  Branch (2883:5): [True: 14, False: 341]
  ------------------
 2884|     14|        if (value == NULL) {
  ------------------
  |  Branch (2884:13): [True: 0, False: 14]
  ------------------
 2885|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2886|      0|            return -1;
 2887|     14|        } else {
 2888|     14|            int *x = (int *)value;
 2889|     14|            ssh_set_log_level(*x & 0xffffU);
 2890|     14|        }
 2891|     14|        break;
 2892|     14|    case SSH_BIND_OPTIONS_LOG_VERBOSITY_STR:
  ------------------
  |  Branch (2892:5): [True: 0, False: 355]
  ------------------
 2893|      0|        if (value == NULL) {
  ------------------
  |  Branch (2893:13): [True: 0, False: 0]
  ------------------
 2894|      0|            ssh_set_log_level(0);
 2895|      0|        } else {
 2896|      0|            q = strdup(value);
 2897|      0|            if (q == NULL) {
  ------------------
  |  Branch (2897:17): [True: 0, False: 0]
  ------------------
 2898|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2899|      0|                return -1;
 2900|      0|            }
 2901|      0|            i = strtol(q, &p, 10);
 2902|      0|            if (q == p) {
  ------------------
  |  Branch (2902:17): [True: 0, False: 0]
  ------------------
 2903|      0|                SSH_LOG(SSH_LOG_DEBUG, "No log verbositiy was parsed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2904|      0|                SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2905|      0|                return -1;
 2906|      0|            }
 2907|      0|            SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2908|       |
 2909|      0|            ssh_set_log_level(i & 0xffffU);
 2910|      0|        }
 2911|      0|        break;
 2912|      0|    case SSH_BIND_OPTIONS_BANNER:
  ------------------
  |  Branch (2912:5): [True: 0, False: 355]
  ------------------
 2913|      0|        if (value == NULL) {
  ------------------
  |  Branch (2913:13): [True: 0, False: 0]
  ------------------
 2914|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2915|      0|            return -1;
 2916|      0|        } else {
 2917|      0|            SAFE_FREE(sshbind->banner);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2918|      0|            sshbind->banner = strdup(value);
 2919|      0|            if (sshbind->banner == NULL) {
  ------------------
  |  Branch (2919:17): [True: 0, False: 0]
  ------------------
 2920|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2921|      0|                return -1;
 2922|      0|            }
 2923|      0|        }
 2924|      0|        break;
 2925|     38|    case SSH_BIND_OPTIONS_CIPHERS_C_S:
  ------------------
  |  Branch (2925:5): [True: 38, False: 317]
  ------------------
 2926|     38|        v = value;
 2927|     38|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2927:13): [True: 0, False: 38]
  |  Branch (2927:26): [True: 0, False: 38]
  ------------------
 2928|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2929|      0|            return -1;
 2930|     38|        } else {
 2931|     38|            rc = ssh_bind_set_algo(sshbind,
 2932|     38|                                   SSH_CRYPT_C_S,
 2933|     38|                                   v,
 2934|     38|                                   &wanted_methods[SSH_CRYPT_C_S]);
 2935|     38|            if (rc < 0) {
  ------------------
  |  Branch (2935:17): [True: 1, False: 37]
  ------------------
 2936|      1|                return -1;
 2937|      1|            }
 2938|     38|        }
 2939|     37|        break;
 2940|     37|    case SSH_BIND_OPTIONS_CIPHERS_S_C:
  ------------------
  |  Branch (2940:5): [True: 37, False: 318]
  ------------------
 2941|     37|        v = value;
 2942|     37|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2942:13): [True: 0, False: 37]
  |  Branch (2942:26): [True: 0, False: 37]
  ------------------
 2943|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2944|      0|            return -1;
 2945|     37|        } else {
 2946|     37|            rc = ssh_bind_set_algo(sshbind,
 2947|     37|                                   SSH_CRYPT_S_C,
 2948|     37|                                   v,
 2949|     37|                                   &wanted_methods[SSH_CRYPT_S_C]);
 2950|     37|            if (rc < 0) {
  ------------------
  |  Branch (2950:17): [True: 0, False: 37]
  ------------------
 2951|      0|                return -1;
 2952|      0|            }
 2953|     37|        }
 2954|     37|        break;
 2955|     37|    case SSH_BIND_OPTIONS_KEY_EXCHANGE:
  ------------------
  |  Branch (2955:5): [True: 4, False: 351]
  ------------------
 2956|      4|        v = value;
 2957|      4|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2957:13): [True: 0, False: 4]
  |  Branch (2957:26): [True: 0, False: 4]
  ------------------
 2958|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2959|      0|            return -1;
 2960|      4|        } else {
 2961|      4|            rc = ssh_bind_set_algo(sshbind,
 2962|      4|                                   SSH_KEX,
 2963|      4|                                   v,
 2964|      4|                                   &wanted_methods[SSH_KEX]);
 2965|      4|            if (rc < 0) {
  ------------------
  |  Branch (2965:17): [True: 0, False: 4]
  ------------------
 2966|      0|                return -1;
 2967|      0|            }
 2968|      4|        }
 2969|      4|        break;
 2970|     81|    case SSH_BIND_OPTIONS_HMAC_C_S:
  ------------------
  |  Branch (2970:5): [True: 81, False: 274]
  ------------------
 2971|     81|        v = value;
 2972|     81|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2972:13): [True: 0, False: 81]
  |  Branch (2972:26): [True: 0, False: 81]
  ------------------
 2973|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2974|      0|            return -1;
 2975|     81|        } else {
 2976|     81|            rc = ssh_bind_set_algo(sshbind,
 2977|     81|                                   SSH_MAC_C_S,
 2978|     81|                                   v,
 2979|     81|                                   &wanted_methods[SSH_MAC_C_S]);
 2980|     81|            if (rc < 0) {
  ------------------
  |  Branch (2980:17): [True: 5, False: 76]
  ------------------
 2981|      5|                return -1;
 2982|      5|            }
 2983|     81|        }
 2984|     76|        break;
 2985|     76|    case SSH_BIND_OPTIONS_HMAC_S_C:
  ------------------
  |  Branch (2985:5): [True: 76, False: 279]
  ------------------
 2986|     76|        v = value;
 2987|     76|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2987:13): [True: 0, False: 76]
  |  Branch (2987:26): [True: 0, False: 76]
  ------------------
 2988|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2989|      0|            return -1;
 2990|     76|        } else {
 2991|     76|            rc = ssh_bind_set_algo(sshbind,
 2992|     76|                                   SSH_MAC_S_C,
 2993|     76|                                   v,
 2994|     76|                                   &wanted_methods[SSH_MAC_S_C]);
 2995|     76|            if (rc < 0) {
  ------------------
  |  Branch (2995:17): [True: 0, False: 76]
  ------------------
 2996|      0|                return -1;
 2997|      0|            }
 2998|     76|        }
 2999|     76|        break;
 3000|     76|    case SSH_BIND_OPTIONS_CONFIG_DIR:
  ------------------
  |  Branch (3000:5): [True: 0, False: 355]
  ------------------
 3001|      0|        v = value;
 3002|      0|        SAFE_FREE(sshbind->config_dir);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3003|      0|        if (v == NULL) {
  ------------------
  |  Branch (3003:13): [True: 0, False: 0]
  ------------------
 3004|      0|            break;
 3005|      0|        } else if (v[0] == '\0') {
  ------------------
  |  Branch (3005:20): [True: 0, False: 0]
  ------------------
 3006|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3007|      0|            return -1;
 3008|      0|        } else {
 3009|      0|            sshbind->config_dir = ssh_path_expand_tilde(v);
 3010|      0|            if (sshbind->config_dir == NULL) {
  ------------------
  |  Branch (3010:17): [True: 0, False: 0]
  ------------------
 3011|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 3012|      0|                return -1;
 3013|      0|            }
 3014|      0|        }
 3015|      0|        break;
 3016|     19|    case SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES:
  ------------------
  |  Branch (3016:5): [True: 19, False: 336]
  ------------------
 3017|     19|        v = value;
 3018|     19|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (3018:13): [True: 0, False: 19]
  |  Branch (3018:26): [True: 0, False: 19]
  ------------------
 3019|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3020|      0|            return -1;
 3021|     19|        } else {
 3022|     19|            rc = ssh_bind_set_algo(sshbind,
 3023|     19|                                   SSH_HOSTKEYS,
 3024|     19|                                   v,
 3025|     19|                                   &sshbind->pubkey_accepted_key_types);
 3026|     19|            if (rc < 0) {
  ------------------
  |  Branch (3026:17): [True: 5, False: 14]
  ------------------
 3027|      5|                return -1;
 3028|      5|            }
 3029|     19|        }
 3030|     14|        break;
 3031|     56|    case SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS:
  ------------------
  |  Branch (3031:5): [True: 56, False: 299]
  ------------------
 3032|     56|        v = value;
 3033|     56|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (3033:13): [True: 0, False: 56]
  |  Branch (3033:26): [True: 0, False: 56]
  ------------------
 3034|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3035|      0|            return -1;
 3036|     56|        } else {
 3037|     56|            rc = ssh_bind_set_algo(sshbind,
 3038|     56|                                   SSH_HOSTKEYS,
 3039|     56|                                   v,
 3040|     56|                                   &wanted_methods[SSH_HOSTKEYS]);
 3041|     56|            if (rc < 0) {
  ------------------
  |  Branch (3041:17): [True: 5, False: 51]
  ------------------
 3042|      5|                return -1;
 3043|      5|            }
 3044|     56|        }
 3045|     51|        break;
 3046|     51|    case SSH_BIND_OPTIONS_PROCESS_CONFIG:
  ------------------
  |  Branch (3046:5): [True: 0, False: 355]
  ------------------
 3047|      0|        if (value == NULL) {
  ------------------
  |  Branch (3047:13): [True: 0, False: 0]
  ------------------
 3048|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3049|      0|            return -1;
 3050|      0|        } else {
 3051|      0|            bool *x = (bool *)value;
 3052|      0|            sshbind->config_processed = !(*x);
 3053|      0|        }
 3054|      0|        break;
 3055|      0|    case SSH_BIND_OPTIONS_MODULI:
  ------------------
  |  Branch (3055:5): [True: 0, False: 355]
  ------------------
 3056|      0|        if (value == NULL) {
  ------------------
  |  Branch (3056:13): [True: 0, False: 0]
  ------------------
 3057|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3058|      0|            return -1;
 3059|      0|        } else {
 3060|      0|            SAFE_FREE(sshbind->moduli_file);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3061|      0|            sshbind->moduli_file = strdup(value);
 3062|      0|            if (sshbind->moduli_file == NULL) {
  ------------------
  |  Branch (3062:17): [True: 0, False: 0]
  ------------------
 3063|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 3064|      0|                return -1;
 3065|      0|            }
 3066|      0|        }
 3067|      0|        break;
 3068|     30|    case SSH_BIND_OPTIONS_RSA_MIN_SIZE:
  ------------------
  |  Branch (3068:5): [True: 30, False: 325]
  ------------------
 3069|     30|        if (value == NULL) {
  ------------------
  |  Branch (3069:13): [True: 0, False: 30]
  ------------------
 3070|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3071|      0|            return -1;
 3072|     30|        } else {
 3073|     30|            int *x = (int *)value;
 3074|       |
 3075|     30|            if (*x < 0) {
  ------------------
  |  Branch (3075:17): [True: 0, False: 30]
  ------------------
 3076|      0|                ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3077|      0|                return -1;
 3078|      0|            }
 3079|       |
 3080|       |            /* (*x == 0) is allowed as it is used to revert to default */
 3081|       |
 3082|     30|            if (*x > 0 && *x < RSA_MIN_KEY_SIZE) {
  ------------------
  |  |   49|     30|#define RSA_MIN_KEY_SIZE      1024
  ------------------
  |  Branch (3082:17): [True: 30, False: 0]
  |  Branch (3082:27): [True: 0, False: 30]
  ------------------
 3083|      0|                ssh_set_error(sshbind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 3084|      0|                              SSH_REQUEST_DENIED,
 3085|      0|                              "The provided value (%d) for minimal RSA key "
 3086|      0|                              "size is too small. Use at least %d bits.",
 3087|      0|                              *x,
 3088|      0|                              RSA_MIN_KEY_SIZE);
 3089|      0|                return -1;
 3090|      0|            }
 3091|     30|            sshbind->rsa_min_size = *x;
 3092|     30|        }
 3093|     30|        break;
 3094|       |#ifdef WITH_GSSAPI
 3095|       |    case SSH_BIND_OPTIONS_GSSAPI_KEY_EXCHANGE:
 3096|       |        if (value == NULL) {
 3097|       |            ssh_set_error_invalid(sshbind);
 3098|       |            return -1;
 3099|       |        } else {
 3100|       |            bool *x = (bool *)value;
 3101|       |            sshbind->gssapi_key_exchange = *x;
 3102|       |        }
 3103|       |        break;
 3104|       |    case SSH_BIND_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS:
 3105|       |        if (value == NULL) {
 3106|       |            ssh_set_error_invalid(sshbind);
 3107|       |            return -1;
 3108|       |        } else {
 3109|       |            char *ret = NULL;
 3110|       |            SAFE_FREE(sshbind->gssapi_key_exchange_algs);
 3111|       |            ret = ssh_find_all_matching(GSSAPI_KEY_EXCHANGE_SUPPORTED, value);
 3112|       |            if (ret == NULL) {
 3113|       |                ssh_set_error(
 3114|       |                    sshbind,
 3115|       |                    SSH_REQUEST_DENIED,
 3116|       |                    "GSSAPI key exchange algorithms not supported or invalid");
 3117|       |                return -1;
 3118|       |            }
 3119|       |            sshbind->gssapi_key_exchange_algs = ret;
 3120|       |        }
 3121|       |        break;
 3122|       |#endif /* WITH_GSSAPI */
 3123|     30|    default:
  ------------------
  |  Branch (3123:5): [True: 0, False: 355]
  ------------------
 3124|      0|        ssh_set_error(sshbind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 3125|      0|                      SSH_REQUEST_DENIED,
 3126|      0|                      "Unknown ssh option %d",
 3127|      0|                      type);
 3128|      0|        return -1;
 3129|      0|        break;
 3130|    355|    }
 3131|       |
 3132|    339|    return 0;
 3133|    355|}
options.c:ssh_bind_set_algo:
 2543|    311|{
 2544|       |    /* sshbind is needed only for ssh_set_error which takes void*
 2545|       |     * the typecast is only to satisfy function parameter type */
 2546|    311|    return ssh_options_set_algo((ssh_session)sshbind, algo, list, place);
 2547|    311|}

ssh_key_free:
  261|  1.22k|{
  262|  1.22k|    if (key) {
  ------------------
  |  Branch (262:9): [True: 0, False: 1.22k]
  ------------------
  263|      0|        ssh_key_clean(key);
  264|       |        SAFE_FREE(key);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  265|      0|    }
  266|  1.22k|}

ssh_poll_init:
   91|      2|{
   92|      2|    return;
   93|      2|}

ssh_socket_init:
  132|      2|{
  133|      2|    if (sockets_initialized == 0) {
  ------------------
  |  Branch (133:9): [True: 2, False: 0]
  ------------------
  134|       |#ifdef _WIN32
  135|       |        struct WSAData wsaData;
  136|       |
  137|       |        /* Initiates use of the Winsock DLL by a process. */
  138|       |        if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
  139|       |            return -1;
  140|       |        }
  141|       |#endif
  142|      2|        ssh_poll_init();
  143|       |
  144|      2|        sockets_initialized = 1;
  145|      2|    }
  146|       |
  147|      2|    return 0;
  148|      2|}

ssh_threads_init:
   42|      2|{
   43|      2|    static int threads_initialized = 0;
   44|      2|    int rc;
   45|       |
   46|      2|    if (threads_initialized) {
  ------------------
  |  Branch (46:9): [True: 0, False: 2]
  ------------------
   47|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
   48|      0|    }
   49|       |
   50|       |    /* first initialize the user_callbacks with our default handlers if not
   51|       |     * already the case
   52|       |     */
   53|      2|    if (user_callbacks == NULL){
  ------------------
  |  Branch (53:9): [True: 2, False: 0]
  ------------------
   54|      2|        user_callbacks = ssh_threads_get_default();
   55|      2|    }
   56|       |
   57|       |    /* Then initialize the crypto libraries threading callbacks */
   58|      2|    rc = crypto_thread_init(user_callbacks);
   59|      2|    if (rc == SSH_OK) {
  ------------------
  |  |  316|      2|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (59:9): [True: 2, False: 0]
  ------------------
   60|      2|        threads_initialized = 1;
   61|      2|    }
   62|      2|    return rc;
   63|      2|}

crypto_thread_init:
   28|      2|{
   29|      2|    (void) cb;
   30|      2|    return SSH_OK;
  ------------------
  |  |  316|      2|#define SSH_OK 0     /* No error */
  ------------------
   31|      2|}

ssh_mutex_lock:
  102|      4|{
  103|      4|    int rc;
  104|       |
  105|      4|    if (mutex == NULL) {
  ------------------
  |  Branch (105:9): [True: 0, False: 4]
  ------------------
  106|      0|        exit(EINVAL);
  107|      0|    }
  108|       |
  109|      4|    rc = pthread_mutex_lock(mutex);
  110|       |
  111|      4|    if (rc) {
  ------------------
  |  Branch (111:9): [True: 0, False: 4]
  ------------------
  112|      0|        exit(rc);
  113|      0|    }
  114|      4|}
ssh_mutex_unlock:
  117|      4|{
  118|      4|    int rc;
  119|       |
  120|      4|    if (mutex == NULL) {
  ------------------
  |  Branch (120:9): [True: 0, False: 4]
  ------------------
  121|      0|        exit(EINVAL);
  122|      0|    }
  123|       |
  124|      4|    rc = pthread_mutex_unlock(mutex);
  125|       |
  126|      4|    if (rc) {
  ------------------
  |  Branch (126:9): [True: 0, False: 4]
  ------------------
  127|      0|        exit(rc);
  128|      0|    }
  129|      4|}
ssh_threads_get_default:
  132|      2|{
  133|      2|    return &ssh_threads_pthread;
  134|      2|}

ssh_tokens_free:
   43|    837|{
   44|    837|    int i;
   45|    837|    if (tokens == NULL) {
  ------------------
  |  Branch (45:9): [True: 0, False: 837]
  ------------------
   46|      0|        return;
   47|      0|    }
   48|       |
   49|    837|    if (tokens->tokens != NULL) {
  ------------------
  |  Branch (49:9): [True: 837, False: 0]
  ------------------
   50|  29.0k|        for (i = 0; tokens->tokens[i] != NULL; i++) {
  ------------------
  |  Branch (50:21): [True: 28.2k, False: 837]
  ------------------
   51|  28.2k|            ssh_burn(tokens->tokens[i], strlen(tokens->tokens[i]));
  ------------------
  |  |  388|  28.2k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
   52|  28.2k|        }
   53|    837|    }
   54|       |
   55|    837|    SAFE_FREE(tokens->buffer);
  ------------------
  |  |  373|    837|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 837, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 837]
  |  |  ------------------
  ------------------
   56|    837|    SAFE_FREE(tokens->tokens);
  ------------------
  |  |  373|    837|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 837, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 837]
  |  |  ------------------
  ------------------
   57|       |    SAFE_FREE(tokens);
  ------------------
  |  |  373|    837|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 837, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 837]
  |  |  ------------------
  ------------------
   58|    837|}
ssh_tokenize:
   74|    837|{
   75|       |
   76|    837|    struct ssh_tokens_st *tokens = NULL;
   77|    837|    size_t num_tokens = 1, i = 1;
   78|       |
   79|    837|    char *found, *c;
   80|       |
   81|    837|    if (chain == NULL) {
  ------------------
  |  Branch (81:9): [True: 0, False: 837]
  ------------------
   82|      0|        return NULL;
   83|      0|    }
   84|       |
   85|    837|    tokens = calloc(1, sizeof(struct ssh_tokens_st));
   86|    837|    if (tokens == NULL) {
  ------------------
  |  Branch (86:9): [True: 0, False: 837]
  ------------------
   87|      0|        return NULL;
   88|      0|    }
   89|       |
   90|    837|    tokens->buffer = strdup(chain);
   91|    837|    if (tokens->buffer == NULL) {
  ------------------
  |  Branch (91:9): [True: 0, False: 837]
  ------------------
   92|      0|        goto error;
   93|      0|    }
   94|       |
   95|    837|    c = tokens->buffer;
   96|  28.2k|    do {
   97|  28.2k|        found = strchr(c, separator);
   98|  28.2k|        if (found != NULL) {
  ------------------
  |  Branch (98:13): [True: 27.4k, False: 837]
  ------------------
   99|  27.4k|            c = found + 1;
  100|  27.4k|            num_tokens++;
  101|  27.4k|        }
  102|  28.2k|    } while(found != NULL);
  ------------------
  |  Branch (102:13): [True: 27.4k, False: 837]
  ------------------
  103|       |
  104|       |    /* Allocate tokens list */
  105|    837|    tokens->tokens = calloc(num_tokens + 1, sizeof(char *));
  106|    837|    if (tokens->tokens == NULL) {
  ------------------
  |  Branch (106:9): [True: 0, False: 837]
  ------------------
  107|      0|        goto error;
  108|      0|    }
  109|       |
  110|       |    /* First token starts in the beginning of the chain */
  111|    837|    tokens->tokens[0] = tokens->buffer;
  112|    837|    c = tokens->buffer;
  113|       |
  114|  28.2k|    for (i = 1; i < num_tokens; i++) {
  ------------------
  |  Branch (114:17): [True: 27.4k, False: 796]
  ------------------
  115|       |        /* Find next separator */
  116|  27.4k|        found = strchr(c, separator);
  117|  27.4k|        if (found == NULL) {
  ------------------
  |  Branch (117:13): [True: 0, False: 27.4k]
  ------------------
  118|      0|            break;
  119|      0|        }
  120|       |
  121|       |        /* Replace it with a string terminator */
  122|  27.4k|        *found = '\0';
  123|       |
  124|       |        /* The next token starts in the next byte */
  125|  27.4k|        c = found + 1;
  126|       |
  127|       |        /* If we did not reach the end of the chain yet, set the next token */
  128|  27.4k|        if (*c != '\0') {
  ------------------
  |  Branch (128:13): [True: 27.4k, False: 41]
  ------------------
  129|  27.4k|            tokens->tokens[i] = c;
  130|  27.4k|        } else {
  131|     41|            break;
  132|     41|        }
  133|  27.4k|    }
  134|       |
  135|    837|    return tokens;
  136|       |
  137|      0|error:
  138|      0|    ssh_tokens_free(tokens);
  139|       |    return NULL;
  140|    837|}
ssh_find_all_matching:
  208|    255|{
  209|    255|    struct ssh_tokens_st *a_tok = NULL, *p_tok = NULL;
  210|    255|    int i, j;
  211|    255|    char *ret = NULL;
  212|    255|    size_t max, len, pos = 0;
  213|    255|    int match;
  214|       |
  215|    255|    if ((available_list == NULL) || (preferred_list == NULL)) {
  ------------------
  |  Branch (215:9): [True: 0, False: 255]
  |  Branch (215:37): [True: 0, False: 255]
  ------------------
  216|      0|        return NULL;
  217|      0|    }
  218|       |
  219|    255|    max = MAX(strlen(available_list), strlen(preferred_list));
  ------------------
  |  |  369|    255|#define MAX(a,b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (369:19): [True: 186, False: 69]
  |  |  ------------------
  ------------------
  220|       |
  221|    255|    ret = calloc(1, max + 1);
  222|    255|    if (ret == NULL) {
  ------------------
  |  Branch (222:9): [True: 0, False: 255]
  ------------------
  223|      0|        return NULL;
  224|      0|    }
  225|       |
  226|    255|    a_tok = ssh_tokenize(available_list, ',');
  227|    255|    if (a_tok == NULL) {
  ------------------
  |  Branch (227:9): [True: 0, False: 255]
  ------------------
  228|      0|        SAFE_FREE(ret);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  229|      0|        goto out;
  230|      0|    }
  231|       |
  232|    255|    p_tok = ssh_tokenize(preferred_list, ',');
  233|    255|    if (p_tok == NULL) {
  ------------------
  |  Branch (233:9): [True: 0, False: 255]
  ------------------
  234|      0|        SAFE_FREE(ret);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  235|      0|        goto out;
  236|      0|    }
  237|       |
  238|  5.02k|    for (i = 0; p_tok->tokens[i] ; i++) {
  ------------------
  |  Branch (238:17): [True: 4.76k, False: 255]
  ------------------
  239|  54.5k|        for (j = 0; a_tok->tokens[j]; j++) {
  ------------------
  |  Branch (239:21): [True: 49.8k, False: 4.76k]
  ------------------
  240|  49.8k|            match = !strcmp(a_tok->tokens[j], p_tok->tokens[i]);
  241|  49.8k|            if (match) {
  ------------------
  |  Branch (241:17): [True: 1.66k, False: 48.1k]
  ------------------
  242|  1.66k|                if (pos != 0) {
  ------------------
  |  Branch (242:21): [True: 1.42k, False: 239]
  ------------------
  243|  1.42k|                    ret[pos] = ',';
  244|  1.42k|                    pos++;
  245|  1.42k|                }
  246|       |
  247|  1.66k|                len = strlen(a_tok->tokens[j]);
  248|  1.66k|                memcpy(&ret[pos], a_tok->tokens[j], len);
  249|  1.66k|                pos += len;
  250|  1.66k|                ret[pos] = '\0';
  251|  1.66k|            }
  252|  49.8k|        }
  253|  4.76k|    }
  254|       |
  255|    255|    if (ret[0] == '\0') {
  ------------------
  |  Branch (255:9): [True: 16, False: 239]
  ------------------
  256|     16|        SAFE_FREE(ret);
  ------------------
  |  |  373|     16|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 16, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 16]
  |  |  ------------------
  ------------------
  257|     16|    }
  258|       |
  259|    255|out:
  260|    255|    ssh_tokens_free(a_tok);
  261|    255|    ssh_tokens_free(p_tok);
  262|    255|    return ret;
  263|    255|}
ssh_remove_duplicates:
  277|    227|{
  278|    227|    struct ssh_tokens_st *tok = NULL;
  279|       |
  280|    227|    size_t i, j, num_tokens, max_len;
  281|    227|    char *ret = NULL;
  282|    227|    bool *should_copy = NULL, need_comma = false;
  283|       |
  284|    227|    if (list == NULL) {
  ------------------
  |  Branch (284:9): [True: 0, False: 227]
  ------------------
  285|      0|        return NULL;
  286|      0|    }
  287|       |
  288|       |    /* The maximum number of tokens is the size of the list */
  289|    227|    max_len = strlen(list);
  290|    227|    if (max_len == 0) {
  ------------------
  |  Branch (290:9): [True: 0, False: 227]
  ------------------
  291|      0|        return NULL;
  292|      0|    }
  293|       |
  294|       |    /* Add space for ending '\0' */
  295|    227|    max_len++;
  296|       |
  297|    227|    tok = ssh_tokenize(list, ',');
  298|    227|    if ((tok == NULL) || (tok->tokens == NULL) || (tok->tokens[0] == NULL)) {
  ------------------
  |  Branch (298:9): [True: 0, False: 227]
  |  Branch (298:26): [True: 0, False: 227]
  |  Branch (298:51): [True: 0, False: 227]
  ------------------
  299|      0|        goto out;
  300|      0|    }
  301|       |
  302|    227|    should_copy = calloc(1, max_len);
  303|    227|    if (should_copy == NULL) {
  ------------------
  |  Branch (303:9): [True: 0, False: 227]
  ------------------
  304|      0|        goto out;
  305|      0|    }
  306|       |
  307|    227|    if (strlen(tok->tokens[0]) > 0) {
  ------------------
  |  Branch (307:9): [True: 187, False: 40]
  ------------------
  308|    187|        should_copy[0] = true;
  309|    187|    }
  310|       |
  311|  20.0k|    for (i = 1; tok->tokens[i]; i++) {
  ------------------
  |  Branch (311:17): [True: 19.8k, False: 227]
  ------------------
  312|   408k|        for (j = 0; j < i; j++) {
  ------------------
  |  Branch (312:21): [True: 403k, False: 4.41k]
  ------------------
  313|   403k|            if (strcmp(tok->tokens[i], tok->tokens[j]) == 0) {
  ------------------
  |  Branch (313:17): [True: 15.4k, False: 388k]
  ------------------
  314|       |                /* Found a duplicate; do not copy */
  315|  15.4k|                should_copy[i] = false;
  316|  15.4k|                break;
  317|  15.4k|            }
  318|   403k|        }
  319|       |
  320|       |        /* No matching token before */
  321|  19.8k|        if (j == i) {
  ------------------
  |  Branch (321:13): [True: 4.41k, False: 15.4k]
  ------------------
  322|       |            /* Only copy if it is not an empty string */
  323|  4.41k|            if (strlen(tok->tokens[i]) > 0) {
  ------------------
  |  Branch (323:17): [True: 4.28k, False: 131]
  ------------------
  324|  4.28k|                should_copy[i] = true;
  325|  4.28k|            } else {
  326|    131|                should_copy[i] = false;
  327|    131|            }
  328|  4.41k|        }
  329|  19.8k|    }
  330|       |
  331|    227|    num_tokens = i;
  332|       |
  333|    227|    ret = calloc(1, max_len);
  334|    227|    if (ret == NULL) {
  ------------------
  |  Branch (334:9): [True: 0, False: 227]
  ------------------
  335|      0|        goto out;
  336|      0|    }
  337|       |
  338|  20.2k|    for (i = 0; i < num_tokens; i++) {
  ------------------
  |  Branch (338:17): [True: 20.0k, False: 227]
  ------------------
  339|  20.0k|        if (should_copy[i]) {
  ------------------
  |  Branch (339:13): [True: 4.47k, False: 15.5k]
  ------------------
  340|  4.47k|            if (need_comma) {
  ------------------
  |  Branch (340:17): [True: 4.24k, False: 227]
  ------------------
  341|  4.24k|                strlcat(ret, ",", max_len);
  342|  4.24k|            }
  343|  4.47k|            strlcat(ret, tok->tokens[i], max_len);
  344|  4.47k|            need_comma = true;
  345|  4.47k|        }
  346|  20.0k|    }
  347|       |
  348|       |    /* If no comma is needed, nothing was copied */
  349|    227|    if (!need_comma) {
  ------------------
  |  Branch (349:9): [True: 0, False: 227]
  ------------------
  350|      0|        SAFE_FREE(ret);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  351|      0|    }
  352|       |
  353|    227|out:
  354|       |    SAFE_FREE(should_copy);
  ------------------
  |  |  373|    227|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 227, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 227]
  |  |  ------------------
  ------------------
  355|    227|    ssh_tokens_free(tok);
  356|    227|    return ret;
  357|    227|}
ssh_append_without_duplicates:
  376|    105|{
  377|    105|    size_t concat_len = 0;
  378|    105|    char *ret = NULL, *concat = NULL;
  379|    105|    int rc = 0;
  380|       |
  381|    105|    if (list != NULL) {
  ------------------
  |  Branch (381:9): [True: 105, False: 0]
  ------------------
  382|    105|        concat_len = strlen(list);
  383|    105|    }
  384|       |
  385|    105|    if (appended_list != NULL) {
  ------------------
  |  Branch (385:9): [True: 105, False: 0]
  ------------------
  386|    105|        concat_len += strlen(appended_list);
  387|    105|    }
  388|       |
  389|    105|    if (concat_len == 0) {
  ------------------
  |  Branch (389:9): [True: 0, False: 105]
  ------------------
  390|      0|        return NULL;
  391|      0|    }
  392|       |
  393|       |    /* Add room for ending '\0' and for middle ',' */
  394|    105|    concat_len += 2;
  395|    105|    concat = calloc(1, concat_len);
  396|    105|    if (concat == NULL) {
  ------------------
  |  Branch (396:9): [True: 0, False: 105]
  ------------------
  397|      0|        return NULL;
  398|      0|    }
  399|       |
  400|    105|    rc = snprintf(concat, concat_len, "%s%s%s",
  401|    105|                  list == NULL ? "" : list,
  ------------------
  |  Branch (401:19): [True: 0, False: 105]
  ------------------
  402|    105|                  list == NULL ? "" : ",",
  ------------------
  |  Branch (402:19): [True: 0, False: 105]
  ------------------
  403|    105|                  appended_list == NULL ? "" : appended_list);
  ------------------
  |  Branch (403:19): [True: 0, False: 105]
  ------------------
  404|    105|    if (rc < 0) {
  ------------------
  |  Branch (404:9): [True: 0, False: 105]
  ------------------
  405|      0|        SAFE_FREE(concat);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  406|      0|        return NULL;
  407|      0|    }
  408|       |
  409|    105|    ret = ssh_remove_duplicates(concat);
  410|       |
  411|    105|    SAFE_FREE(concat);
  ------------------
  |  |  373|    105|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 105, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 105]
  |  |  ------------------
  ------------------
  412|       |
  413|    105|    return ret;
  414|    105|}
ssh_remove_all_matching:
  431|     50|{
  432|     50|    struct ssh_tokens_st *l_tok = NULL, *r_tok = NULL;
  433|     50|    int i, j, cmp;
  434|     50|    char *ret = NULL;
  435|     50|    size_t len, pos = 0;
  436|     50|    bool exclude;
  437|       |
  438|     50|    if (list == NULL) {
  ------------------
  |  Branch (438:9): [True: 0, False: 50]
  ------------------
  439|      0|        return NULL;
  440|      0|    }
  441|     50|    if (remove_list == NULL) {
  ------------------
  |  Branch (441:9): [True: 0, False: 50]
  ------------------
  442|      0|        return strdup (list);
  443|      0|    }
  444|       |
  445|     50|    l_tok = ssh_tokenize(list, ',');
  446|     50|    if (l_tok == NULL) {
  ------------------
  |  Branch (446:9): [True: 0, False: 50]
  ------------------
  447|      0|        goto out;
  448|      0|    }
  449|       |
  450|     50|    r_tok = ssh_tokenize(remove_list, ',');
  451|     50|    if (r_tok == NULL) {
  ------------------
  |  Branch (451:9): [True: 0, False: 50]
  ------------------
  452|      0|        goto out;
  453|      0|    }
  454|       |
  455|     50|    ret = calloc(1, strlen(list) + 1);
  456|     50|    if (ret == NULL) {
  ------------------
  |  Branch (456:9): [True: 0, False: 50]
  ------------------
  457|      0|        goto out;
  458|      0|    }
  459|       |
  460|    366|    for (i = 0; l_tok->tokens[i]; i++) {
  ------------------
  |  Branch (460:17): [True: 316, False: 50]
  ------------------
  461|    316|        exclude = false;
  462|  2.37k|        for (j = 0; r_tok->tokens[j]; j++) {
  ------------------
  |  Branch (462:21): [True: 2.08k, False: 289]
  ------------------
  463|  2.08k|            cmp = strcmp(l_tok->tokens[i], r_tok->tokens[j]);
  464|  2.08k|            if (cmp == 0) {
  ------------------
  |  Branch (464:17): [True: 27, False: 2.06k]
  ------------------
  465|     27|                exclude = true;
  466|     27|                break;
  467|     27|            }
  468|  2.08k|        }
  469|    316|        if (exclude == false) {
  ------------------
  |  Branch (469:13): [True: 289, False: 27]
  ------------------
  470|    289|            if (pos != 0) {
  ------------------
  |  Branch (470:17): [True: 239, False: 50]
  ------------------
  471|    239|                ret[pos] = ',';
  472|    239|                pos++;
  473|    239|            }
  474|       |
  475|    289|            len = strlen(l_tok->tokens[i]);
  476|    289|            memcpy(&ret[pos], l_tok->tokens[i], len);
  477|    289|            pos += len;
  478|    289|        }
  479|    316|    }
  480|       |
  481|     50|    if (ret[0] == '\0') {
  ------------------
  |  Branch (481:9): [True: 0, False: 50]
  ------------------
  482|      0|        SAFE_FREE(ret);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  483|      0|    }
  484|       |
  485|     50|out:
  486|     50|    ssh_tokens_free(l_tok);
  487|     50|    ssh_tokens_free(r_tok);
  488|     50|    return ret;
  489|     50|}
ssh_prefix_without_duplicates:
  507|    122|{
  508|    122|    size_t concat_len = 0;
  509|    122|    char *ret = NULL, *concat = NULL;
  510|    122|    int rc = 0;
  511|       |
  512|    122|    if (list != NULL) {
  ------------------
  |  Branch (512:9): [True: 122, False: 0]
  ------------------
  513|    122|        concat_len = strlen(list);
  514|    122|    }
  515|       |
  516|    122|    if (prefixed_list != NULL) {
  ------------------
  |  Branch (516:9): [True: 122, False: 0]
  ------------------
  517|    122|        concat_len += strlen(prefixed_list);
  518|    122|    }
  519|       |
  520|    122|    if (concat_len == 0) {
  ------------------
  |  Branch (520:9): [True: 0, False: 122]
  ------------------
  521|      0|        return NULL;
  522|      0|    }
  523|       |
  524|       |    /* Add room for ending '\0' and for middle ',' */
  525|    122|    concat_len += 2;
  526|    122|    concat = calloc(concat_len, 1);
  527|    122|    if (concat == NULL) {
  ------------------
  |  Branch (527:9): [True: 0, False: 122]
  ------------------
  528|      0|        return NULL;
  529|      0|    }
  530|       |
  531|    122|    rc = snprintf(concat, concat_len, "%s%s%s",
  532|    122|                  prefixed_list == NULL ? "" : prefixed_list,
  ------------------
  |  Branch (532:19): [True: 0, False: 122]
  ------------------
  533|    122|                  prefixed_list == NULL ? "" : ",",
  ------------------
  |  Branch (533:19): [True: 0, False: 122]
  ------------------
  534|    122|                  list == NULL ? "" : list);
  ------------------
  |  Branch (534:19): [True: 0, False: 122]
  ------------------
  535|    122|    if (rc < 0) {
  ------------------
  |  Branch (535:9): [True: 0, False: 122]
  ------------------
  536|      0|        SAFE_FREE(concat);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  537|      0|        return NULL;
  538|      0|    }
  539|       |
  540|    122|    ret = ssh_remove_duplicates(concat);
  541|       |
  542|    122|    SAFE_FREE(concat);
  ------------------
  |  |  373|    122|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 122, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 122]
  |  |  ------------------
  ------------------
  543|       |
  544|    122|    return ret;
  545|    122|}

nalloc_init:
  114|      2|{
  115|      2|    if (nalloc_initialized) {
  ------------------
  |  Branch (115:9): [True: 0, False: 2]
  ------------------
  116|      0|        return;
  117|      0|    }
  118|      2|    nalloc_initialized = true;
  119|      2|    char *bitmask = getenv("NALLOC_FREQ");
  120|      2|    if (bitmask) {
  ------------------
  |  Branch (120:9): [True: 0, False: 2]
  ------------------
  121|      0|        int shift = atoi(bitmask);
  122|      0|        if (shift > 0 && shift < 31) {
  ------------------
  |  Branch (122:13): [True: 0, False: 0]
  |  Branch (122:26): [True: 0, False: 0]
  ------------------
  123|      0|            nalloc_bitmask = 1 << shift;
  124|      0|            nalloc_random_bitmask = false;
  125|      0|        } else if (shift == 0) {
  ------------------
  |  Branch (125:20): [True: 0, False: 0]
  ------------------
  126|      0|            nalloc_random_bitmask = false;
  127|      0|            nalloc_bitmask = 0;
  128|      0|        }
  129|      2|    } else if (prog == NULL || strstr(prog, "nalloc") == NULL) {
  ------------------
  |  Branch (129:16): [True: 0, False: 2]
  |  Branch (129:32): [True: 2, False: 0]
  ------------------
  130|      2|        nalloc_random_bitmask = false;
  131|      2|        nalloc_bitmask = 0;
  132|      2|        return;
  133|      2|    }
  134|       |
  135|      0|    char *verbose = getenv("NALLOC_VERBOSE");
  136|      0|    if (verbose) {
  ------------------
  |  Branch (136:9): [True: 0, False: 0]
  ------------------
  137|       |        nalloc_verbose = true;
  138|      0|    }
  139|      0|}
calloc:
  307|  3.07k|{
  308|  3.07k|    if (nalloc_fail(size, "calloc")) {
  ------------------
  |  Branch (308:9): [True: 0, False: 3.07k]
  ------------------
  309|      0|        errno = ENOMEM;
  310|      0|        return NULL;
  311|      0|    }
  312|  3.07k|    return nalloc_calloc(nmemb, size);
  ------------------
  |  |  259|  3.07k|#define nalloc_calloc(s, n)          __libc_calloc(s, n)
  ------------------
  313|  3.07k|}
malloc:
  316|  2.51M|{
  317|  2.51M|    if (nalloc_fail(size, "malloc")) {
  ------------------
  |  Branch (317:9): [True: 0, False: 2.51M]
  ------------------
  318|      0|        errno = ENOMEM;
  319|      0|        return NULL;
  320|      0|    }
  321|  2.51M|    return nalloc_malloc(size);
  ------------------
  |  |  258|  2.51M|#define nalloc_malloc(s)             __libc_malloc(s)
  ------------------
  322|  2.51M|}
realloc:
  325|  9.91k|{
  326|  9.91k|    if (nalloc_fail(size, "realloc")) {
  ------------------
  |  Branch (326:9): [True: 0, False: 9.91k]
  ------------------
  327|      0|        errno = ENOMEM;
  328|      0|        return NULL;
  329|      0|    }
  330|  9.91k|    return nalloc_realloc(ptr, size);
  ------------------
  |  |  260|  9.91k|#define nalloc_realloc(p, s)         __libc_realloc(p, s)
  ------------------
  331|  9.91k|}
ssh_bind_config_fuzzer.c:nalloc_fail:
  194|  2.52M|{
  195|       |    // do not fail before thread init
  196|  2.52M|    if (nalloc_runs == 0) {
  ------------------
  |  Branch (196:9): [True: 2.52M, False: 0]
  ------------------
  197|  2.52M|        return false;
  198|  2.52M|    }
  199|      0|    if (__sync_fetch_and_add(&nalloc_running, 1) != 1) {
  ------------------
  |  Branch (199:9): [True: 0, False: 0]
  ------------------
  200|       |        // do not fail allocations outside of fuzzer input
  201|       |        // and do not fail inside of this function
  202|      0|        __sync_fetch_and_sub(&nalloc_running, 1);
  203|      0|        return false;
  204|      0|    }
  205|      0|    nalloc_random_update((uint8_t)size);
  206|      0|    if (size >= 0x100) {
  ------------------
  |  Branch (206:9): [True: 0, False: 0]
  ------------------
  207|      0|        nalloc_random_update((uint8_t)(size >> 8));
  208|      0|        if (size >= 0x10000) {
  ------------------
  |  Branch (208:13): [True: 0, False: 0]
  ------------------
  209|      0|            nalloc_random_update((uint8_t)(size >> 16));
  210|       |            // bigger may already fail or oom
  211|      0|        }
  212|      0|    }
  213|      0|    if (((nalloc_random_state ^ nalloc_magic) & nalloc_bitmask) == 0) {
  ------------------
  |  Branch (213:9): [True: 0, False: 0]
  ------------------
  214|      0|        if (nalloc_backtrace_exclude(size, op)) {
  ------------------
  |  Branch (214:13): [True: 0, False: 0]
  ------------------
  215|      0|            __sync_fetch_and_sub(&nalloc_running, 1);
  216|      0|            return false;
  217|      0|        }
  218|      0|        __sync_fetch_and_sub(&nalloc_running, 1);
  219|      0|        return true;
  220|      0|    }
  221|      0|    __sync_fetch_and_sub(&nalloc_running, 1);
  222|       |    return false;
  223|      0|}
ssh_bind_config_fuzzer.c:nalloc_start:
  151|    408|{
  152|    408|    if (nalloc_random_bitmask) {
  ------------------
  |  Branch (152:9): [True: 0, False: 408]
  ------------------
  153|      0|        if (nalloc_random_state & 0x10) {
  ------------------
  |  Branch (153:13): [True: 0, False: 0]
  ------------------
  154|      0|            nalloc_bitmask = 0xFFFFFFFF;
  155|      0|        } else {
  156|      0|            nalloc_bitmask = 1 << (5 + (nalloc_random_state & 0xF));
  157|      0|        }
  158|    408|    } else if (nalloc_bitmask == 0) {
  ------------------
  |  Branch (158:16): [True: 408, False: 0]
  ------------------
  159|       |        // nalloc disabled
  160|    408|        return 2;
  161|    408|    }
  162|      0|    nalloc_random_state = 0;
  163|      0|    for (size_t i = 0; i < size; i++) {
  ------------------
  |  Branch (163:24): [True: 0, False: 0]
  ------------------
  164|      0|        nalloc_random_update(data[i]);
  165|      0|    }
  166|      0|    if (__sync_fetch_and_add(&nalloc_running, 1)) {
  ------------------
  |  Branch (166:9): [True: 0, False: 0]
  ------------------
  167|      0|        __sync_fetch_and_sub(&nalloc_running, 1);
  168|      0|        return 0;
  169|      0|    }
  170|      0|    nalloc_runs++;
  171|      0|    return 1;
  172|      0|}
ssh_bind_config_fuzzer.c:nalloc_end:
  176|    408|{
  177|    408|    __sync_fetch_and_sub(&nalloc_running, 1);
  178|    408|}

LLVMFuzzerInitialize:
   35|      2|{
   36|      2|    (void)argc;
   37|       |
   38|      2|    nalloc_init(*argv[0]);
   39|       |
   40|      2|    ssh_init();
   41|       |
   42|      2|    atexit(_fuzz_finalize);
   43|       |
   44|      2|    return 0;
   45|      2|}
LLVMFuzzerTestOneInput:
   48|    408|{
   49|    408|    ssh_bind bind = NULL;
   50|    408|    char *input = NULL;
   51|       |
   52|    408|    input = (char *)malloc(size + 1);
   53|    408|    if (!input) {
  ------------------
  |  Branch (53:9): [True: 0, False: 408]
  ------------------
   54|      0|        return 1;
   55|      0|    }
   56|    408|    memcpy(input, data, size);
   57|    408|    input[size] = '\0';
   58|       |
   59|    408|    assert(nalloc_start(data, size) > 0);
  ------------------
  |  Branch (59:5): [True: 0, False: 408]
  |  Branch (59:5): [True: 408, False: 0]
  ------------------
   60|       |
   61|    408|    bind = ssh_bind_new();
   62|    408|    if (bind == NULL) {
  ------------------
  |  Branch (62:9): [True: 0, False: 408]
  ------------------
   63|      0|        goto out;
   64|      0|    }
   65|       |
   66|    408|    ssh_bind_config_parse_string(bind, input);
   67|       |
   68|    408|    ssh_bind_free(bind);
   69|       |
   70|    408|out:
   71|    408|    free(input);
   72|       |
   73|    408|    nalloc_end();
   74|    408|    return 0;
   75|    408|}
ssh_bind_config_fuzzer.c:_fuzz_finalize:
   30|      2|{
   31|      2|    ssh_finalize();
   32|      2|}

