ssh_bind_new:
  135|    377|ssh_bind ssh_bind_new(void) {
  136|    377|    ssh_bind ptr;
  137|       |
  138|    377|    ptr = calloc(1, sizeof(struct ssh_bind_struct));
  139|    377|    if (ptr == NULL) {
  ------------------
  |  Branch (139:9): [True: 0, False: 377]
  ------------------
  140|      0|        return NULL;
  141|      0|    }
  142|    377|    ptr->bindfd = SSH_INVALID_SOCKET;
  ------------------
  |  |  122|    377|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  143|    377|    ptr->bindport = 22;
  144|    377|    ptr->common.log_verbosity = 0;
  145|       |
  146|    377|    return ptr;
  147|    377|}
ssh_bind_free:
  355|    377|void ssh_bind_free(ssh_bind sshbind){
  356|    377|  int i;
  357|       |
  358|    377|  if (sshbind == NULL) {
  ------------------
  |  Branch (358:7): [True: 0, False: 377]
  ------------------
  359|      0|    return;
  360|      0|  }
  361|       |
  362|    377|  if (sshbind->bindfd >= 0) {
  ------------------
  |  Branch (362:7): [True: 0, False: 377]
  ------------------
  363|      0|      CLOSE_SOCKET(sshbind->bindfd);
  ------------------
  |  |  404|      0|#define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  122|      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)
  |  |  ------------------
  |  |  |  |  183|      0|#define _XCLOSESOCKET close
  |  |  ------------------
  |  |               #define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  122|      0|#define SSH_INVALID_SOCKET ((socket_t) -1)
  |  |  ------------------
  |  |  |  Branch (404:34): [True: 0, False: 0]
  |  |  |  Branch (404:116): [Folded - Ignored]
  |  |  ------------------
  ------------------
  364|      0|  }
  365|    377|  sshbind->bindfd = SSH_INVALID_SOCKET;
  ------------------
  |  |  122|    377|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  366|       |
  367|       |  /* options */
  368|    377|  SAFE_FREE(sshbind->banner);
  ------------------
  |  |  338|    377|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 377]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  369|    377|  SAFE_FREE(sshbind->moduli_file);
  ------------------
  |  |  338|    377|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 377]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  370|    377|  SAFE_FREE(sshbind->bindaddr);
  ------------------
  |  |  338|    377|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 377]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  371|    377|  SAFE_FREE(sshbind->config_dir);
  ------------------
  |  |  338|    377|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 377]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  372|    377|  SAFE_FREE(sshbind->pubkey_accepted_key_types);
  ------------------
  |  |  338|    377|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 2, False: 375]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  373|       |
  374|    377|  SAFE_FREE(sshbind->rsakey);
  ------------------
  |  |  338|    377|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 377]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  375|    377|  SAFE_FREE(sshbind->ecdsakey);
  ------------------
  |  |  338|    377|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 377]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  376|    377|  SAFE_FREE(sshbind->ed25519key);
  ------------------
  |  |  338|    377|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 377]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  377|       |
  378|    377|  ssh_key_free(sshbind->rsa);
  379|    377|  sshbind->rsa = NULL;
  380|    377|  ssh_key_free(sshbind->ecdsa);
  381|    377|  sshbind->ecdsa = NULL;
  382|    377|  ssh_key_free(sshbind->ed25519);
  383|    377|  sshbind->ed25519 = NULL;
  384|       |
  385|  4.14k|  for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  4.14k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (385:15): [True: 3.77k, False: 377]
  ------------------
  386|  3.77k|    if (sshbind->wanted_methods[i]) {
  ------------------
  |  Branch (386:9): [True: 402, False: 3.36k]
  ------------------
  387|    402|      SAFE_FREE(sshbind->wanted_methods[i]);
  ------------------
  |  |  338|    402|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 402, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  388|    402|    }
  389|  3.77k|  }
  390|       |
  391|    377|  SAFE_FREE(sshbind);
  ------------------
  |  |  338|    377|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 377, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  392|    377|}

ssh_bind_config_parse_string:
  669|    377|{
  670|    377|    char line[MAX_LINE_SIZE] = {0};
  671|    377|    const char *c = input, *line_start = input;
  672|    377|    unsigned int line_num = 0, line_len;
  673|    377|    uint32_t parser_flags;
  674|    377|    int rv;
  675|       |
  676|       |    /* This local table is used during the parsing of the current file (and
  677|       |     * files included recursively in this file) to prevent an option to be
  678|       |     * redefined, i.e. the first value set is kept. But this DO NOT prevent the
  679|       |     * option to be redefined later by another file. */
  680|    377|    uint8_t seen[BIND_CFG_MAX] = {0};
  681|       |
  682|    377|    SSH_LOG(SSH_LOG_DEBUG, "Reading bind configuration data from string:");
  ------------------
  |  |  265|    377|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  683|    377|    SSH_LOG(SSH_LOG_DEBUG, "START\n%s\nEND", input);
  ------------------
  |  |  265|    377|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  684|       |
  685|    377|    parser_flags = PARSING;
  ------------------
  |  |   48|    377|#define PARSING     1
  ------------------
  686|  1.64k|    while (1) {
  ------------------
  |  Branch (686:12): [Folded - Ignored]
  ------------------
  687|  1.64k|        line_num++;
  688|  1.64k|        line_start = c;
  689|  1.64k|        c = strchr(line_start, '\n');
  690|  1.64k|        if (c == NULL) {
  ------------------
  |  Branch (690:13): [True: 374, False: 1.27k]
  ------------------
  691|       |            /* if there is no newline at the end of the string */
  692|    374|            c = strchr(line_start, '\0');
  693|    374|        }
  694|  1.64k|        if (c == NULL) {
  ------------------
  |  Branch (694:13): [True: 0, False: 1.64k]
  ------------------
  695|       |            /* should not happen, would mean a string without trailing '\0' */
  696|      0|            SSH_LOG(SSH_LOG_WARN, "No trailing '\\0' in config string");
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  697|      0|            return SSH_ERROR;
  ------------------
  |  |  313|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  698|      0|        }
  699|  1.64k|        line_len = c - line_start;
  700|  1.64k|        if (line_len > MAX_LINE_SIZE - 1) {
  ------------------
  |  |   44|  1.64k|#define MAX_LINE_SIZE 1024
  ------------------
  |  Branch (700:13): [True: 11, False: 1.63k]
  ------------------
  701|     11|            SSH_LOG(SSH_LOG_WARN, "Line %u too long: %u characters",
  ------------------
  |  |  265|     11|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  702|     11|                    line_num, line_len);
  703|     11|            return SSH_ERROR;
  ------------------
  |  |  313|     11|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  704|     11|        }
  705|  1.63k|        memcpy(line, line_start, line_len);
  706|  1.63k|        line[line_len] = '\0';
  707|  1.63k|        SSH_LOG(SSH_LOG_DEBUG, "Line %u: %s", line_num, line);
  ------------------
  |  |  265|  1.63k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  708|  1.63k|        rv = ssh_bind_config_parse_line(bind, line, line_num, &parser_flags, seen, 0);
  709|  1.63k|        if (rv < 0) {
  ------------------
  |  Branch (709:13): [True: 23, False: 1.61k]
  ------------------
  710|     23|            return SSH_ERROR;
  ------------------
  |  |  313|     23|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  711|     23|        }
  712|  1.61k|        if (*c == '\0') {
  ------------------
  |  Branch (712:13): [True: 343, False: 1.27k]
  ------------------
  713|    343|            break;
  714|    343|        }
  715|  1.27k|        c++;
  716|  1.27k|    }
  717|       |
  718|    343|    return SSH_OK;
  ------------------
  |  |  312|    343|#define SSH_OK 0     /* No error */
  ------------------
  719|    377|}
bind_config.c:ssh_bind_config_parse_line:
  291|  4.04M|{
  292|  4.04M|    enum ssh_bind_config_opcode_e opcode;
  293|  4.04M|    const char *p = NULL;
  294|  4.04M|    char *s = NULL, *x = NULL;
  295|  4.04M|    char *keyword = NULL;
  296|  4.04M|    size_t len;
  297|       |
  298|  4.04M|    int rc = 0;
  299|       |
  300|  4.04M|    if (bind == NULL) {
  ------------------
  |  Branch (300:9): [True: 0, False: 4.04M]
  ------------------
  301|      0|        return -1;
  302|      0|    }
  303|       |
  304|       |    /* Ignore empty lines */
  305|  4.04M|    if (line == NULL || *line == '\0') {
  ------------------
  |  Branch (305:9): [True: 0, False: 4.04M]
  |  Branch (305:25): [True: 139k, False: 3.90M]
  ------------------
  306|   139k|        return 0;
  307|   139k|    }
  308|       |
  309|  3.90M|    if (parser_flags == NULL) {
  ------------------
  |  Branch (309:9): [True: 0, False: 3.90M]
  ------------------
  310|      0|        ssh_set_error_invalid(bind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  311|      0|        return -1;
  312|      0|    }
  313|       |
  314|  3.90M|    x = s = strdup(line);
  315|  3.90M|    if (s == NULL) {
  ------------------
  |  Branch (315:9): [True: 0, False: 3.90M]
  ------------------
  316|      0|        ssh_set_error_oom(bind);
  ------------------
  |  |  290|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  317|      0|        return -1;
  318|      0|    }
  319|       |
  320|       |    /* Remove trailing spaces */
  321|  6.79M|    for (len = strlen(s) - 1; len > 0; len--) {
  ------------------
  |  Branch (321:31): [True: 6.20M, False: 588k]
  ------------------
  322|  6.20M|        if (! isspace(s[len])) {
  ------------------
  |  Branch (322:13): [True: 3.32M, False: 2.88M]
  ------------------
  323|  3.32M|            break;
  324|  3.32M|        }
  325|  2.88M|        s[len] = '\0';
  326|  2.88M|    }
  327|       |
  328|  3.90M|    keyword = ssh_config_get_token(&s);
  329|  3.90M|    if (keyword == NULL || *keyword == '#' ||
  ------------------
  |  Branch (329:9): [True: 0, False: 3.90M]
  |  Branch (329:28): [True: 387k, False: 3.52M]
  ------------------
  330|  3.90M|            *keyword == '\0' || *keyword == '\n') {
  ------------------
  |  Branch (330:13): [True: 491k, False: 3.03M]
  |  Branch (330:33): [True: 0, False: 3.03M]
  ------------------
  331|   878k|        SAFE_FREE(x);
  ------------------
  |  |  338|   878k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 878k, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  332|   878k|        return 0;
  333|   878k|    }
  334|       |
  335|  3.03M|    opcode = ssh_bind_config_get_opcode(keyword, parser_flags);
  336|  3.03M|    if ((*parser_flags & PARSING) &&
  ------------------
  |  |   48|  3.03M|#define PARSING     1
  ------------------
  |  Branch (336:9): [True: 1.44M, False: 1.58M]
  ------------------
  337|  3.03M|            opcode != BIND_CFG_HOSTKEY &&
  ------------------
  |  Branch (337:13): [True: 1.44M, False: 201]
  ------------------
  338|  3.03M|            opcode != BIND_CFG_INCLUDE &&
  ------------------
  |  Branch (338:13): [True: 1.44M, False: 366]
  ------------------
  339|  3.03M|            opcode != BIND_CFG_MATCH &&
  ------------------
  |  Branch (339:13): [True: 1.44M, False: 14]
  ------------------
  340|  3.03M|            opcode > BIND_CFG_UNSUPPORTED) { /* Ignore all unknown types here */
  ------------------
  |  Branch (340:13): [True: 263, False: 1.44M]
  ------------------
  341|       |        /* Skip all the options that were already applied */
  342|    263|        if (seen[opcode] != 0) {
  ------------------
  |  Branch (342:13): [True: 9, False: 254]
  ------------------
  343|      9|            SAFE_FREE(x);
  ------------------
  |  |  338|      9|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 9, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  344|      9|            return 0;
  345|      9|        }
  346|    254|        seen[opcode] = 1;
  347|    254|    }
  348|       |
  349|  3.03M|    switch (opcode) {
  350|    366|    case BIND_CFG_INCLUDE:
  ------------------
  |  Branch (350:5): [True: 366, False: 3.02M]
  ------------------
  351|    366|        p = ssh_config_get_str_tok(&s, NULL);
  352|    366|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|    158|#define PARSING     1
  ------------------
  |  Branch (352:13): [True: 158, False: 208]
  |  Branch (352:18): [True: 158, False: 0]
  ------------------
  353|    158|#if defined(HAVE_GLOB) && defined(HAVE_GLOB_GL_FLAGS_MEMBER)
  354|    158|            local_parse_glob(bind, p, parser_flags, seen, depth + 1);
  355|       |#else
  356|       |            local_parse_file(bind, p, parser_flags, seen, depth + 1);
  357|       |#endif /* HAVE_GLOB */
  358|    158|        }
  359|    366|        break;
  360|       |
  361|    201|    case BIND_CFG_HOSTKEY:
  ------------------
  |  Branch (361:5): [True: 201, False: 3.02M]
  ------------------
  362|    201|        p = ssh_config_get_str_tok(&s, NULL);
  363|    201|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      0|#define PARSING     1
  ------------------
  |  Branch (363:13): [True: 0, False: 201]
  |  Branch (363:18): [True: 0, False: 0]
  ------------------
  364|      0|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HOSTKEY, p);
  365|      0|            if (rc != 0) {
  ------------------
  |  Branch (365:17): [True: 0, False: 0]
  ------------------
  366|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  367|      0|                        "line %d: Failed to set Hostkey value '%s'",
  368|      0|                        count, p);
  369|      0|            }
  370|      0|        }
  371|    201|        break;
  372|      0|    case BIND_CFG_LISTENADDRESS:
  ------------------
  |  Branch (372:5): [True: 0, False: 3.03M]
  ------------------
  373|      0|        p = ssh_config_get_str_tok(&s, NULL);
  374|      0|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      0|#define PARSING     1
  ------------------
  |  Branch (374:13): [True: 0, False: 0]
  |  Branch (374:18): [True: 0, False: 0]
  ------------------
  375|      0|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_BINDADDR, p);
  376|      0|            if (rc != 0) {
  ------------------
  |  Branch (376:17): [True: 0, False: 0]
  ------------------
  377|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  378|      0|                        "line %d: Failed to set ListenAddress value '%s'",
  379|      0|                        count, p);
  380|      0|            }
  381|      0|        }
  382|      0|        break;
  383|      2|    case BIND_CFG_PORT:
  ------------------
  |  Branch (383:5): [True: 2, False: 3.03M]
  ------------------
  384|      2|        p = ssh_config_get_str_tok(&s, NULL);
  385|      2|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      2|#define PARSING     1
  ------------------
  |  Branch (385:13): [True: 2, False: 0]
  |  Branch (385:18): [True: 2, False: 0]
  ------------------
  386|      2|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_BINDPORT_STR, p);
  387|      2|            if (rc != 0) {
  ------------------
  |  Branch (387:17): [True: 2, False: 0]
  ------------------
  388|      2|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|      2|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  389|      2|                        "line %d: Failed to set Port value '%s'",
  390|      2|                        count, p);
  391|      2|            }
  392|      2|        }
  393|      2|        break;
  394|     26|    case BIND_CFG_CIPHERS:
  ------------------
  |  Branch (394:5): [True: 26, False: 3.03M]
  ------------------
  395|     26|        p = ssh_config_get_str_tok(&s, NULL);
  396|     26|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     26|#define PARSING     1
  ------------------
  |  Branch (396:13): [True: 26, False: 0]
  |  Branch (396:18): [True: 26, False: 0]
  ------------------
  397|     26|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_CIPHERS_C_S, p);
  398|     26|            if (rc != 0) {
  ------------------
  |  Branch (398:17): [True: 2, False: 24]
  ------------------
  399|      2|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|      2|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  400|      2|                        "line %d: Failed to set C->S Ciphers value '%s'",
  401|      2|                        count, p);
  402|      2|                break;
  403|      2|            }
  404|       |
  405|     24|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_CIPHERS_S_C, p);
  406|     24|            if (rc != 0) {
  ------------------
  |  Branch (406:17): [True: 0, False: 24]
  ------------------
  407|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  408|      0|                        "line %d: Failed to set S->C Ciphers value '%s'",
  409|      0|                        count, p);
  410|      0|            }
  411|     24|        }
  412|     24|        break;
  413|    181|    case BIND_CFG_MACS:
  ------------------
  |  Branch (413:5): [True: 181, False: 3.02M]
  ------------------
  414|    181|        p = ssh_config_get_str_tok(&s, NULL);
  415|    181|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|    181|#define PARSING     1
  ------------------
  |  Branch (415:13): [True: 181, False: 0]
  |  Branch (415:18): [True: 181, False: 0]
  ------------------
  416|    181|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HMAC_C_S, p);
  417|    181|            if (rc != 0) {
  ------------------
  |  Branch (417:17): [True: 19, False: 162]
  ------------------
  418|     19|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|     19|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  419|     19|                        "line %d: Failed to set C->S MAC value '%s'",
  420|     19|                        count, p);
  421|     19|                break;
  422|     19|            }
  423|       |
  424|    162|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HMAC_S_C, p);
  425|    162|            if (rc != 0) {
  ------------------
  |  Branch (425:17): [True: 0, False: 162]
  ------------------
  426|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  427|      0|                        "line %d: Failed to set S->C MAC value '%s'",
  428|      0|                        count, p);
  429|      0|            }
  430|    162|        }
  431|    162|        break;
  432|    162|    case BIND_CFG_LOGLEVEL:
  ------------------
  |  Branch (432:5): [True: 8, False: 3.03M]
  ------------------
  433|      8|        p = ssh_config_get_str_tok(&s, NULL);
  434|      8|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      8|#define PARSING     1
  ------------------
  |  Branch (434:13): [True: 8, False: 0]
  |  Branch (434:18): [True: 8, False: 0]
  ------------------
  435|      8|            int value = -1;
  436|       |
  437|      8|            if (strcasecmp(p, "quiet") == 0) {
  ------------------
  |  Branch (437:17): [True: 2, False: 6]
  ------------------
  438|      2|                value = SSH_LOG_NONE;
  ------------------
  |  |  351|      2|#define SSH_LOG_NONE 0
  ------------------
  439|      6|            } else if (strcasecmp(p, "fatal") == 0 ||
  ------------------
  |  Branch (439:24): [True: 0, False: 6]
  ------------------
  440|      6|                    strcasecmp(p, "error")== 0) {
  ------------------
  |  Branch (440:21): [True: 0, False: 6]
  ------------------
  441|      0|                value = SSH_LOG_WARN;
  ------------------
  |  |  353|      0|#define SSH_LOG_WARN 1
  ------------------
  442|      6|            } else if (strcasecmp(p, "verbose") == 0 ||
  ------------------
  |  Branch (442:24): [True: 0, False: 6]
  ------------------
  443|      6|                    strcasecmp(p, "info") == 0) {
  ------------------
  |  Branch (443:21): [True: 0, False: 6]
  ------------------
  444|      0|                value = SSH_LOG_INFO;
  ------------------
  |  |  355|      0|#define SSH_LOG_INFO 2
  ------------------
  445|      6|            } else if (strcasecmp(p, "DEBUG") == 0 ||
  ------------------
  |  Branch (445:24): [True: 0, False: 6]
  ------------------
  446|      6|                    strcasecmp(p, "DEBUG1") == 0) {
  ------------------
  |  Branch (446:21): [True: 2, False: 4]
  ------------------
  447|      2|                value = SSH_LOG_DEBUG;
  ------------------
  |  |  357|      2|#define SSH_LOG_DEBUG 3
  ------------------
  448|      4|            } else if (strcasecmp(p, "DEBUG2") == 0 ||
  ------------------
  |  Branch (448:24): [True: 2, False: 2]
  ------------------
  449|      4|                    strcasecmp(p, "DEBUG3") == 0) {
  ------------------
  |  Branch (449:21): [True: 2, False: 0]
  ------------------
  450|      4|                value = SSH_LOG_TRACE;
  ------------------
  |  |  359|      4|#define SSH_LOG_TRACE 4
  ------------------
  451|      4|            }
  452|      8|            if (value != -1) {
  ------------------
  |  Branch (452:17): [True: 8, False: 0]
  ------------------
  453|      8|                rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_LOG_VERBOSITY,
  454|      8|                        &value);
  455|      8|                if (rc != 0) {
  ------------------
  |  Branch (455:21): [True: 0, False: 8]
  ------------------
  456|      0|                    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  457|      0|                            "line %d: Failed to set LogLevel value '%s'",
  458|      0|                            count, p);
  459|      0|                }
  460|      8|            }
  461|      8|        }
  462|      8|        break;
  463|     22|    case BIND_CFG_KEXALGORITHMS:
  ------------------
  |  Branch (463:5): [True: 22, False: 3.03M]
  ------------------
  464|     22|        p = ssh_config_get_str_tok(&s, NULL);
  465|     22|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     22|#define PARSING     1
  ------------------
  |  Branch (465:13): [True: 22, False: 0]
  |  Branch (465:18): [True: 22, False: 0]
  ------------------
  466|     22|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_KEY_EXCHANGE, p);
  467|     22|            if (rc != 0) {
  ------------------
  |  Branch (467:17): [True: 1, False: 21]
  ------------------
  468|      1|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|      1|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  469|      1|                        "line %d: Failed to set KexAlgorithms value '%s'",
  470|      1|                        count, p);
  471|      1|            }
  472|     22|        }
  473|     22|        break;
  474|     62|    case BIND_CFG_MATCH: {
  ------------------
  |  Branch (474:5): [True: 62, False: 3.03M]
  ------------------
  475|     62|        bool negate;
  476|     62|        int result = PARSING;
  ------------------
  |  |   48|     62|#define PARSING     1
  ------------------
  477|     62|        size_t args = 0;
  478|     62|        enum ssh_bind_config_match_e opt;
  479|     62|        const char *p2 = NULL;
  480|       |
  481|       |        /* The options set in Match blocks should be applied when a connection
  482|       |         * is accepted, and not right away when parsing the file (as it is
  483|       |         * currently done). This means the configuration files should be parsed
  484|       |         * again or the options set in the Match blocks should be stored and
  485|       |         * applied as necessary. */
  486|       |
  487|       |        /* If this is the first Match block, erase the seen table to allow
  488|       |         * options to be overridden. Erasing the seen table was the easiest way
  489|       |         * to allow overriding an option, but only for the first occurrence of
  490|       |         * an option in a Match block. This is sufficient for the current
  491|       |         * implementation which supports only the 'All' criterion, meaning the
  492|       |         * options can be applied right away. */
  493|     62|        if (!(*parser_flags & IN_MATCH)) {
  ------------------
  |  |   49|     62|#define IN_MATCH    (1<<1)
  ------------------
  |  Branch (493:13): [True: 8, False: 54]
  ------------------
  494|      8|            memset(seen, 0x00, BIND_CFG_MAX * sizeof(uint8_t));
  495|      8|        }
  496|       |
  497|       |        /* In this line the PARSING bit is cleared from the flags */
  498|     62|        *parser_flags = IN_MATCH;
  ------------------
  |  |   49|     62|#define IN_MATCH    (1<<1)
  ------------------
  499|     62|        do {
  500|     62|            p = p2 = ssh_config_get_str_tok(&s, NULL);
  501|     62|            if (p == NULL || p[0] == '\0') {
  ------------------
  |  Branch (501:17): [True: 0, False: 62]
  |  Branch (501:30): [True: 0, False: 62]
  ------------------
  502|      0|                break;
  503|      0|            }
  504|     62|            args++;
  505|     62|            SSH_LOG(SSH_LOG_TRACE, "line %d: Processing Match keyword '%s'",
  ------------------
  |  |  265|     62|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  506|     62|                    count, p);
  507|       |
  508|       |            /* If the option is prefixed with ! the result should be negated */
  509|     62|            negate = false;
  510|     62|            if (p[0] == '!') {
  ------------------
  |  Branch (510:17): [True: 8, False: 54]
  ------------------
  511|      8|                negate = true;
  512|      8|                p++;
  513|      8|            }
  514|       |
  515|     62|            opt = ssh_bind_config_get_match_opcode(p);
  516|     62|            switch (opt) {
  517|     14|            case BIND_MATCH_ALL:
  ------------------
  |  Branch (517:13): [True: 14, False: 48]
  ------------------
  518|     14|                p = ssh_config_get_str_tok(&s, NULL);
  519|     14|                if ((args == 1) && (p == NULL || p[0] == '\0')) {
  ------------------
  |  Branch (519:21): [True: 14, False: 0]
  |  Branch (519:37): [True: 14, False: 0]
  |  Branch (519:50): [True: 0, False: 0]
  ------------------
  520|       |                    /* The "all" keyword does not accept arguments or modifiers
  521|       |                     */
  522|     14|                    if (negate == true) {
  ------------------
  |  Branch (522:25): [True: 3, False: 11]
  ------------------
  523|      3|                        result = 0;
  524|      3|                    }
  525|     14|                    break;
  526|     14|                }
  527|      0|                ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  283|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  528|      0|                              "line %d: ERROR - Match all cannot be combined with "
  529|      0|                              "other Match attributes", count);
  530|      0|                SAFE_FREE(x);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  531|      0|                return -1;
  532|      0|            case BIND_MATCH_USER:
  ------------------
  |  Branch (532:13): [True: 0, False: 62]
  ------------------
  533|      0|            case BIND_MATCH_GROUP:
  ------------------
  |  Branch (533:13): [True: 0, False: 62]
  ------------------
  534|      0|            case BIND_MATCH_HOST:
  ------------------
  |  Branch (534:13): [True: 0, False: 62]
  ------------------
  535|      0|            case BIND_MATCH_LOCALADDRESS:
  ------------------
  |  Branch (535:13): [True: 0, False: 62]
  ------------------
  536|      0|            case BIND_MATCH_LOCALPORT:
  ------------------
  |  Branch (536:13): [True: 0, False: 62]
  ------------------
  537|      0|            case BIND_MATCH_RDOMAIN:
  ------------------
  |  Branch (537:13): [True: 0, False: 62]
  ------------------
  538|      0|            case BIND_MATCH_ADDRESS:
  ------------------
  |  Branch (538:13): [True: 0, False: 62]
  ------------------
  539|       |                /* Only "All" is supported for now */
  540|       |                /* Skip one argument */
  541|      0|                p = ssh_config_get_str_tok(&s, NULL);
  542|      0|                if (p == NULL || p[0] == '\0') {
  ------------------
  |  Branch (542:21): [True: 0, False: 0]
  |  Branch (542:34): [True: 0, False: 0]
  ------------------
  543|      0|                    SSH_LOG(SSH_LOG_TRACE, "line %d: Match keyword "
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  544|      0|                            "'%s' requires argument\n", count, p2);
  545|      0|                    SAFE_FREE(x);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  546|      0|                    return -1;
  547|      0|                }
  548|      0|                args++;
  549|      0|                SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  550|      0|                        "line %d: Unsupported Match keyword '%s', ignoring\n",
  551|      0|                        count,
  552|      0|                        p2);
  553|      0|                result = 0;
  554|      0|                break;
  555|     48|            case BIND_MATCH_UNKNOWN:
  ------------------
  |  Branch (555:13): [True: 48, False: 14]
  ------------------
  556|     48|            default:
  ------------------
  |  Branch (556:13): [True: 0, False: 62]
  ------------------
  557|     48|                ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  283|     48|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  558|     48|                              "ERROR - Unknown argument '%s' for Match keyword", p);
  559|     48|                SAFE_FREE(x);
  ------------------
  |  |  338|     48|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 48, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  560|     48|                return -1;
  561|     62|            }
  562|     62|        } while (p != NULL && p[0] != '\0');
  ------------------
  |  Branch (562:18): [True: 0, False: 14]
  |  Branch (562:31): [True: 0, False: 0]
  ------------------
  563|     14|        if (args == 0) {
  ------------------
  |  Branch (563:13): [True: 0, False: 14]
  ------------------
  564|      0|            ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  283|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  565|      0|                          "ERROR - Match keyword requires an argument");
  566|      0|            SAFE_FREE(x);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  567|      0|            return -1;
  568|      0|        }
  569|       |        /* This line only sets the PARSING flag if all checks passed */
  570|     14|        *parser_flags |= result;
  571|     14|        break;
  572|     14|    }
  573|      5|    case BIND_CFG_PUBKEY_ACCEPTED_KEY_TYPES:
  ------------------
  |  Branch (573:5): [True: 5, False: 3.03M]
  ------------------
  574|      5|        p = ssh_config_get_str_tok(&s, NULL);
  575|      5|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      5|#define PARSING     1
  ------------------
  |  Branch (575:13): [True: 5, False: 0]
  |  Branch (575:18): [True: 5, False: 0]
  ------------------
  576|      5|            rc = ssh_bind_options_set(bind,
  577|      5|                                 SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES, p);
  578|      5|            if (rc != 0) {
  ------------------
  |  Branch (578:17): [True: 2, False: 3]
  ------------------
  579|      2|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|      2|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  580|      2|                        "line %d: Failed to set PubKeyAcceptedKeyTypes value '%s'",
  581|      2|                        count, p);
  582|      2|            }
  583|      5|        }
  584|      5|        break;
  585|     10|    case BIND_CFG_HOSTKEY_ALGORITHMS:
  ------------------
  |  Branch (585:5): [True: 10, False: 3.03M]
  ------------------
  586|     10|        p = ssh_config_get_str_tok(&s, NULL);
  587|     10|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     10|#define PARSING     1
  ------------------
  |  Branch (587:13): [True: 10, False: 0]
  |  Branch (587:18): [True: 10, False: 0]
  ------------------
  588|     10|            rc = ssh_bind_options_set(bind,
  589|     10|                                 SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS, p);
  590|     10|            if (rc != 0) {
  ------------------
  |  Branch (590:17): [True: 1, False: 9]
  ------------------
  591|      1|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  265|      1|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  592|      1|                        "line %d: Failed to set HostkeyAlgorithms value '%s'",
  593|      1|                        count, p);
  594|      1|            }
  595|     10|        }
  596|     10|        break;
  597|    236|    case BIND_CFG_NOT_ALLOWED_IN_MATCH:
  ------------------
  |  Branch (597:5): [True: 236, False: 3.02M]
  ------------------
  598|    236|        SSH_LOG(SSH_LOG_DEBUG, "Option not allowed in Match block: %s, line: %d",
  ------------------
  |  |  265|    236|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  599|    236|                keyword, count);
  600|    236|        break;
  601|  3.02M|    case BIND_CFG_UNKNOWN:
  ------------------
  |  Branch (601:5): [True: 3.02M, False: 1.11k]
  ------------------
  602|  3.02M|        SSH_LOG(SSH_LOG_TRACE, "Unknown option: %s, line: %d",
  ------------------
  |  |  265|  3.02M|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  603|  3.02M|                keyword, count);
  604|  3.02M|        break;
  605|      0|    case BIND_CFG_UNSUPPORTED:
  ------------------
  |  Branch (605:5): [True: 0, False: 3.03M]
  ------------------
  606|      0|        SSH_LOG(SSH_LOG_TRACE, "Unsupported option: %s, line: %d",
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  607|      0|                keyword, count);
  608|      0|        break;
  609|      0|    case BIND_CFG_NA:
  ------------------
  |  Branch (609:5): [True: 0, False: 3.03M]
  ------------------
  610|      0|        SSH_LOG(SSH_LOG_TRACE, "Option not applicable: %s, line: %d",
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  611|      0|                keyword, count);
  612|      0|        break;
  613|      0|    default:
  ------------------
  |  Branch (613:5): [True: 0, False: 3.03M]
  ------------------
  614|      0|        ssh_set_error(bind, SSH_FATAL, "ERROR - unimplemented opcode: %d",
  ------------------
  |  |  283|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  615|      0|                opcode);
  616|      0|        SAFE_FREE(x);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  617|      0|        return -1;
  618|      0|        break;
  619|  3.03M|    }
  620|       |
  621|  3.03M|    SAFE_FREE(x);
  ------------------
  |  |  338|  3.03M|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 3.03M, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  622|  3.03M|    return rc;
  623|  3.03M|}
bind_config.c:ssh_bind_config_get_opcode:
  170|  3.03M|{
  171|  3.03M|    int i;
  172|       |
  173|  36.3M|    for (i = 0; ssh_bind_config_keyword_table[i].name != NULL; i++) {
  ------------------
  |  Branch (173:17): [True: 33.3M, False: 3.02M]
  ------------------
  174|  33.3M|        if (strcasecmp(keyword, ssh_bind_config_keyword_table[i].name) == 0) {
  ------------------
  |  Branch (174:13): [True: 1.12k, False: 33.3M]
  ------------------
  175|  1.12k|            if ((*parser_flags & IN_MATCH) &&
  ------------------
  |  |   49|  1.12k|#define IN_MATCH    (1<<1)
  ------------------
  |  Branch (175:17): [True: 296, False: 832]
  ------------------
  176|  1.12k|                !(ssh_bind_config_keyword_table[i].allowed_in_match))
  ------------------
  |  Branch (176:17): [True: 236, False: 60]
  ------------------
  177|    236|            {
  178|    236|                return BIND_CFG_NOT_ALLOWED_IN_MATCH;
  179|    236|            }
  180|    892|            return ssh_bind_config_keyword_table[i].opcode;
  181|  1.12k|        }
  182|  33.3M|    }
  183|       |
  184|  3.02M|    return BIND_CFG_UNKNOWN;
  185|  3.03M|}
bind_config.c:local_parse_glob:
  244|    158|{
  245|    158|    glob_t globbuf = {
  246|    158|        .gl_flags = 0,
  247|    158|    };
  248|    158|    int rt;
  249|    158|    u_int i;
  250|       |
  251|    158|    rt = glob(fileglob, GLOB_TILDE, NULL, &globbuf);
  252|    158|    if (rt == GLOB_NOMATCH) {
  ------------------
  |  Branch (252:9): [True: 66, False: 92]
  ------------------
  253|     66|        globfree(&globbuf);
  254|     66|        return;
  255|     92|    } else if (rt != 0) {
  ------------------
  |  Branch (255:16): [True: 0, False: 92]
  ------------------
  256|      0|        SSH_LOG(SSH_LOG_RARE, "Glob error: %s",
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  257|      0|                fileglob);
  258|      0|        globfree(&globbuf);
  259|      0|        return;
  260|      0|    }
  261|       |
  262|  12.9k|    for (i = 0; i < globbuf.gl_pathc; i++) {
  ------------------
  |  Branch (262:17): [True: 12.8k, False: 92]
  ------------------
  263|  12.8k|        local_parse_file(bind, globbuf.gl_pathv[i], parser_flags, seen, depth);
  264|  12.8k|    }
  265|       |
  266|     92|    globfree(&globbuf);
  267|     92|}
bind_config.c:local_parse_file:
  202|  12.8k|{
  203|  12.8k|    FILE *f;
  204|  12.8k|    char line[MAX_LINE_SIZE] = {0};
  205|  12.8k|    unsigned int count = 0;
  206|  12.8k|    int rv;
  207|       |
  208|  12.8k|    if (depth > LIBSSH_BIND_CONF_MAX_DEPTH) {
  ------------------
  |  |  195|  12.8k|#define LIBSSH_BIND_CONF_MAX_DEPTH 16
  ------------------
  |  Branch (208:9): [True: 0, False: 12.8k]
  ------------------
  209|      0|        ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  283|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  210|      0|                      "ERROR - Too many levels of configuration includes "
  211|      0|                      "when processing file '%s'", filename);
  212|      0|        return;
  213|      0|    }
  214|       |
  215|  12.8k|    f = fopen(filename, "r");
  216|  12.8k|    if (f == NULL) {
  ------------------
  |  Branch (216:9): [True: 53, False: 12.7k]
  ------------------
  217|     53|        SSH_LOG(SSH_LOG_RARE, "Cannot find file %s to load",
  ------------------
  |  |  265|     53|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  218|     53|                filename);
  219|     53|        return;
  220|     53|    }
  221|       |
  222|  12.7k|    SSH_LOG(SSH_LOG_PACKET, "Reading additional configuration data from %s",
  ------------------
  |  |  265|  12.7k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  223|  12.7k|            filename);
  224|       |
  225|  4.05M|    while (fgets(line, sizeof(line), f)) {
  ------------------
  |  Branch (225:12): [True: 4.04M, False: 12.7k]
  ------------------
  226|  4.04M|        count++;
  227|  4.04M|        rv = ssh_bind_config_parse_line(bind, line, count, parser_flags, seen, depth);
  228|  4.04M|        if (rv < 0) {
  ------------------
  |  Branch (228:13): [True: 52, False: 4.04M]
  ------------------
  229|     52|            fclose(f);
  230|     52|            return;
  231|     52|        }
  232|  4.04M|    }
  233|       |
  234|  12.7k|    fclose(f);
  235|  12.7k|    return;
  236|  12.7k|}
bind_config.c:ssh_bind_config_get_match_opcode:
  272|     62|{
  273|     62|    size_t i;
  274|       |
  275|    446|    for (i = 0; ssh_bind_config_match_keyword_table[i].name != NULL; i++) {
  ------------------
  |  Branch (275:17): [True: 398, False: 48]
  ------------------
  276|    398|        if (strcasecmp(keyword, ssh_bind_config_match_keyword_table[i].name) == 0) {
  ------------------
  |  Branch (276:13): [True: 14, False: 384]
  ------------------
  277|     14|            return ssh_bind_config_match_keyword_table[i].opcode;
  278|     14|        }
  279|    398|    }
  280|       |
  281|     48|    return BIND_MATCH_UNKNOWN;
  282|     62|}

ssh_config_get_token:
   68|  3.90M|{
   69|  3.90M|    register char *c;
   70|  3.90M|    bool had_equal = false;
   71|  3.90M|    char *r = NULL;
   72|       |
   73|       |    /* Ignore leading spaces */
   74|  12.3M|    for (c = *str; *c; c++) {
  ------------------
  |  Branch (74:20): [True: 12.3M, False: 1.40k]
  ------------------
   75|  12.3M|        if (! isblank(*c)) {
  ------------------
  |  Branch (75:13): [True: 3.90M, False: 8.41M]
  ------------------
   76|  3.90M|            break;
   77|  3.90M|        }
   78|  12.3M|    }
   79|       |
   80|       |    /* If we start with quote, return the whole quoted block */
   81|  3.90M|    if (*c == '\"') {
  ------------------
  |  Branch (81:9): [True: 97.1k, False: 3.81M]
  ------------------
   82|  1.88M|        for (r = ++c; *c; c++) {
  ------------------
  |  Branch (82:23): [True: 1.87M, False: 4.00k]
  ------------------
   83|  1.87M|            if (*c == '\"' || *c == '\n') {
  ------------------
  |  Branch (83:17): [True: 93.1k, False: 1.78M]
  |  Branch (83:31): [True: 0, False: 1.78M]
  ------------------
   84|  93.1k|                *c = '\0';
   85|  93.1k|                c++;
   86|  93.1k|                break;
   87|  93.1k|            }
   88|       |            /* XXX Unmatched quotes extend to the end of line */
   89|  1.87M|        }
   90|  3.81M|    } else {
   91|       |        /* Otherwise terminate on space, equal or newline */
   92|  30.8M|        for (r = c; *c; c++) {
  ------------------
  |  Branch (92:21): [True: 29.6M, False: 1.18M]
  ------------------
   93|  29.6M|            if (*c == '\0') {
  ------------------
  |  Branch (93:17): [True: 0, False: 29.6M]
  ------------------
   94|      0|                goto out;
   95|  29.6M|            } else if (isblank(*c) || *c == '=' || *c == '\n') {
  ------------------
  |  Branch (95:39): [True: 38.6k, False: 27.4M]
  |  Branch (95:52): [True: 488k, False: 27.0M]
  ------------------
   96|  2.62M|                had_equal = (*c == '=');
   97|  2.62M|                *c = '\0';
   98|  2.62M|                c++;
   99|  2.62M|                break;
  100|  2.62M|            }
  101|  29.6M|        }
  102|  3.81M|    }
  103|       |
  104|       |    /* Skip any other remaining whitespace */
  105|  5.02M|    while (isblank(*c) || *c == '\n' || (!had_equal && *c == '=')) {
  ------------------
  |  Branch (105:27): [True: 0, False: 4.10M]
  |  Branch (105:42): [True: 3.87M, False: 233k]
  |  Branch (105:56): [True: 195k, False: 3.67M]
  ------------------
  106|  1.11M|        if (*c == '=') {
  ------------------
  |  Branch (106:13): [True: 195k, False: 917k]
  ------------------
  107|   195k|            had_equal = true;
  108|   195k|        }
  109|  1.11M|        c++;
  110|  1.11M|    }
  111|  3.90M|out:
  112|  3.90M|    *str = c;
  113|  3.90M|    return r;
  114|  3.90M|}
ssh_config_get_str_tok:
  134|    897|{
  135|    897|    char *p;
  136|       |
  137|    897|    p = ssh_config_get_token(str);
  138|    897|    if (p && *p) {
  ------------------
  |  Branch (138:9): [True: 897, False: 0]
  |  Branch (138:14): [True: 474, False: 423]
  ------------------
  139|    474|        return p;
  140|    474|    }
  141|       |
  142|    423|    return def;
  143|    897|}

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

_ssh_set_error:
   57|     73|{
   58|     73|    struct ssh_common_struct *err = error;
   59|     73|    va_list va;
   60|       |
   61|     73|    va_start(va, descr);
   62|     73|    vsnprintf(err->error.error_buffer, ERROR_BUFFERLEN, descr, va);
  ------------------
  |  |  203|     73|#define ERROR_BUFFERLEN 1024
  ------------------
   63|     73|    va_end(va);
   64|       |
   65|     73|    err->error.error_code = code;
   66|     73|    if (ssh_get_log_level() == SSH_LOG_TRACE) {
  ------------------
  |  |  359|     73|#define SSH_LOG_TRACE 4
  ------------------
  |  Branch (66:9): [True: 0, False: 73]
  ------------------
   67|      0|        ssh_log_function(SSH_LOG_TRACE,
  ------------------
  |  |  359|      0|#define SSH_LOG_TRACE 4
  ------------------
   68|      0|                         function,
   69|      0|                         err->error.error_buffer);
   70|      0|    }
   71|     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|    377|int ssh_init(void) {
  157|    377|    return _ssh_init(0);
  158|    377|}
ssh_finalize:
  241|    377|int ssh_finalize(void) {
  242|    377|    return _ssh_finalize(0);
  243|    377|}
init.c:_ssh_init:
   62|    379|static int _ssh_init(unsigned constructor) {
   63|       |
   64|    379|    int rc = 0;
   65|       |
   66|    379|    if (!constructor) {
  ------------------
  |  Branch (66:9): [True: 377, False: 2]
  ------------------
   67|    377|        ssh_mutex_lock(&ssh_init_mutex);
   68|    377|    }
   69|       |
   70|    379|    _ssh_initialized++;
   71|       |
   72|    379|    if (_ssh_initialized > 1) {
  ------------------
  |  Branch (72:9): [True: 377, False: 2]
  ------------------
   73|    377|        rc = _ssh_init_ret;
   74|    377|        goto _ret;
   75|    377|    }
   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|    379|_ret:
   98|    379|    _ssh_init_ret = rc;
   99|       |
  100|    379|    if (!constructor) {
  ------------------
  |  Branch (100:9): [True: 377, False: 2]
  ------------------
  101|    377|        ssh_mutex_unlock(&ssh_init_mutex);
  102|    377|    }
  103|       |
  104|    379|    return rc;
  105|      2|}
init.c:_ssh_finalize:
  160|    377|static int _ssh_finalize(unsigned destructor) {
  161|       |
  162|    377|    if (!destructor) {
  ------------------
  |  Branch (162:9): [True: 377, False: 0]
  ------------------
  163|    377|        ssh_mutex_lock(&ssh_init_mutex);
  164|       |
  165|    377|        if (_ssh_initialized > 1) {
  ------------------
  |  Branch (165:13): [True: 377, False: 0]
  ------------------
  166|    377|            _ssh_initialized--;
  167|    377|            ssh_mutex_unlock(&ssh_init_mutex);
  168|    377|            return 0;
  169|    377|        }
  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|    377|}

ssh_kex_get_description:
  292|     25|const char *ssh_kex_get_description(uint32_t algo) {
  293|     25|  if (algo >= SSH_KEX_METHODS) {
  ------------------
  |  |   27|     25|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (293:7): [True: 0, False: 25]
  ------------------
  294|      0|    return NULL;
  295|      0|  }
  296|       |
  297|     25|  return ssh_kex_descriptions[algo];
  298|     25|}
ssh_keep_known_algos:
 1136|     33|{
 1137|     33|    if (algo > SSH_LANG_S_C) {
  ------------------
  |  Branch (1137:9): [True: 0, False: 33]
  ------------------
 1138|      0|        return NULL;
 1139|      0|    }
 1140|       |
 1141|     33|    return ssh_find_all_matching(supported_methods[algo], list);
 1142|     33|}
ssh_add_to_default_algos:
 1180|     81|{
 1181|     81|    char *tmp = NULL, *ret = NULL;
 1182|       |
 1183|     81|    if (algo > SSH_LANG_S_C || list == NULL || list[0] == '\0') {
  ------------------
  |  Branch (1183:9): [True: 0, False: 81]
  |  Branch (1183:32): [True: 0, False: 81]
  |  Branch (1183:48): [True: 0, False: 81]
  ------------------
 1184|      0|        return NULL;
 1185|      0|    }
 1186|       |
 1187|     81|    if (ssh_fips_mode()) {
  ------------------
  |  |  120|     81|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (120:25): [True: 0, False: 81]
  |  |  ------------------
  ------------------
 1188|      0|        tmp = ssh_append_without_duplicates(fips_methods[algo], list);
 1189|      0|        ret = ssh_find_all_matching(fips_methods[algo], tmp);
 1190|     81|    } else {
 1191|     81|        tmp = ssh_append_without_duplicates(default_methods[algo], list);
 1192|     81|        ret = ssh_find_all_matching(supported_methods[algo], tmp);
 1193|     81|    }
 1194|       |
 1195|     81|    free(tmp);
 1196|     81|    return ret;
 1197|     81|}
ssh_remove_from_default_algos:
 1213|    215|{
 1214|    215|    if (algo > SSH_LANG_S_C) {
  ------------------
  |  Branch (1214:9): [True: 0, False: 215]
  ------------------
 1215|      0|        return NULL;
 1216|      0|    }
 1217|       |
 1218|    215|    if (list == NULL || list[0] == '\0') {
  ------------------
  |  Branch (1218:9): [True: 0, False: 215]
  |  Branch (1218:25): [True: 3, False: 212]
  ------------------
 1219|      3|        if (ssh_fips_mode()) {
  ------------------
  |  |  120|      3|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (120:25): [True: 0, False: 3]
  |  |  ------------------
  ------------------
 1220|      0|            return strdup(fips_methods[algo]);
 1221|      3|        } else {
 1222|      3|            return strdup(default_methods[algo]);
 1223|      3|        }
 1224|      3|    }
 1225|       |
 1226|    212|    if (ssh_fips_mode()) {
  ------------------
  |  |  120|    212|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (120:25): [True: 0, False: 212]
  |  |  ------------------
  ------------------
 1227|      0|        return ssh_remove_all_matching(fips_methods[algo], list);
 1228|    212|    } else {
 1229|    212|        return ssh_remove_all_matching(default_methods[algo], list);
 1230|    212|    }
 1231|    212|}
ssh_prefix_default_algos:
 1251|    101|{
 1252|    101|    char *ret = NULL, *tmp = NULL;
 1253|       |
 1254|    101|    if (algo > SSH_LANG_S_C || list == NULL || list[0] == '\0') {
  ------------------
  |  Branch (1254:9): [True: 0, False: 101]
  |  Branch (1254:32): [True: 0, False: 101]
  |  Branch (1254:48): [True: 0, False: 101]
  ------------------
 1255|      0|        return NULL;
 1256|      0|    }
 1257|       |
 1258|    101|    if (ssh_fips_mode()) {
  ------------------
  |  |  120|    101|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (120:25): [True: 0, False: 101]
  |  |  ------------------
  ------------------
 1259|      0|        tmp = ssh_prefix_without_duplicates(fips_methods[algo], list);
 1260|      0|        ret = ssh_find_all_matching(fips_methods[algo], tmp);
 1261|    101|    } else {
 1262|    101|        tmp = ssh_prefix_without_duplicates(default_methods[algo], list);
 1263|    101|        ret = ssh_find_all_matching(supported_methods[algo], tmp);
 1264|    101|    }
 1265|       |
 1266|    101|    free(tmp);
 1267|    101|    return ret;
 1268|    101|}

ssh_crypto_init:
 1373|      2|{
 1374|       |#ifndef HAVE_OPENSSL_EVP_CHACHA20
 1375|       |    size_t i;
 1376|       |#endif
 1377|       |
 1378|      2|    if (libcrypto_initialized) {
  ------------------
  |  Branch (1378:9): [True: 0, False: 2]
  ------------------
 1379|      0|        return SSH_OK;
  ------------------
  |  |  312|      0|#define SSH_OK 0     /* No error */
  ------------------
 1380|      0|    }
 1381|      2|    if (OpenSSL_version_num() != OPENSSL_VERSION_NUMBER){
  ------------------
  |  Branch (1381:9): [True: 0, False: 2]
  ------------------
 1382|      0|        SSH_LOG(SSH_LOG_DEBUG, "libssh compiled with %s "
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1383|      0|            "headers, currently running with %s.",
 1384|      0|            OPENSSL_VERSION_TEXT,
 1385|      0|            OpenSSL_version(OpenSSL_version_num())
 1386|      0|        );
 1387|      0|    }
 1388|       |#ifdef CAN_DISABLE_AESNI
 1389|       |    /*
 1390|       |     * disable AES-NI when running within Valgrind, because they generate
 1391|       |     * too many "uninitialized memory access" false positives
 1392|       |     */
 1393|       |    if (RUNNING_ON_VALGRIND){
 1394|       |        SSH_LOG(SSH_LOG_INFO, "Running within Valgrind, disabling AES-NI");
 1395|       |        /* Bit #57 denotes AES-NI instruction set extension */
 1396|       |        OPENSSL_ia32cap &= ~(1LL << 57);
 1397|       |    }
 1398|       |#endif /* CAN_DISABLE_AESNI */
 1399|       |
 1400|       |#ifndef HAVE_OPENSSL_EVP_CHACHA20
 1401|       |    for (i = 0; ssh_ciphertab[i].name != NULL; i++) {
 1402|       |        int cmp;
 1403|       |
 1404|       |        cmp = strcmp(ssh_ciphertab[i].name, "chacha20-poly1305@openssh.com");
 1405|       |        if (cmp == 0) {
 1406|       |            memcpy(&ssh_ciphertab[i],
 1407|       |                   ssh_get_chacha20poly1305_cipher(),
 1408|       |                   sizeof(struct ssh_cipher_struct));
 1409|       |            break;
 1410|       |        }
 1411|       |    }
 1412|       |#endif /* HAVE_OPENSSL_EVP_CHACHA20 */
 1413|       |
 1414|      2|    libcrypto_initialized = 1;
 1415|       |
 1416|      2|    return SSH_OK;
  ------------------
  |  |  312|      2|#define SSH_OK 0     /* No error */
  ------------------
 1417|      2|}

ssh_log_function:
  115|    880|{
  116|    880|    ssh_logging_callback log_fn = ssh_get_log_callback();
  117|       |
  118|    880|    if (log_fn) {
  ------------------
  |  Branch (118:9): [True: 0, False: 880]
  ------------------
  119|      0|        ssh_log_custom(log_fn, verbosity, function, buffer);
  120|      0|        return;
  121|      0|    }
  122|       |
  123|    880|    ssh_log_stderr(verbosity, function, buffer);
  124|    880|}
ssh_vlog:
  130|    880|{
  131|    880|    char buffer[LOG_SIZE];
  132|       |
  133|    880|    vsnprintf(buffer, sizeof(buffer), format, *va);
  134|    880|    ssh_log_function(verbosity, function, buffer);
  135|    880|}
_ssh_log:
  140|  3.04M|{
  141|  3.04M|    va_list va;
  142|       |
  143|  3.04M|    if (verbosity <= ssh_get_log_level()) {
  ------------------
  |  Branch (143:9): [True: 880, False: 3.04M]
  ------------------
  144|    880|        va_start(va, format);
  145|    880|        ssh_vlog(verbosity, function, format, &va);
  146|    880|        va_end(va);
  147|    880|    }
  148|  3.04M|}
ssh_set_log_level:
  195|      8|int ssh_set_log_level(int level) {
  196|      8|  if (level < 0) {
  ------------------
  |  Branch (196:7): [True: 0, False: 8]
  ------------------
  197|      0|    return SSH_ERROR;
  ------------------
  |  |  313|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  198|      0|  }
  199|       |
  200|      8|  ssh_log_level = level;
  201|       |
  202|      8|  return SSH_OK;
  ------------------
  |  |  312|      8|#define SSH_OK 0     /* No error */
  ------------------
  203|      8|}
ssh_get_log_level:
  210|  3.04M|int ssh_get_log_level(void) {
  211|  3.04M|  return ssh_log_level;
  212|  3.04M|}
ssh_get_log_callback:
  224|    880|ssh_logging_callback ssh_get_log_callback(void) {
  225|    880|  return ssh_log_cb;
  226|    880|}
log.c:ssh_log_stderr:
   87|    880|{
   88|    880|    char date[128] = {0};
   89|    880|    int rc;
   90|       |
   91|    880|    rc = current_timestring(1, date, sizeof(date));
   92|    880|    if (rc == 0) {
  ------------------
  |  Branch (92:9): [True: 880, False: 0]
  ------------------
   93|    880|        fprintf(stderr, "[%s, %d] %s:", date, verbosity, function);
   94|    880|    } else {
   95|      0|        fprintf(stderr, "[%d] %s", verbosity, function);
   96|      0|    }
   97|       |
   98|    880|    fprintf(stderr, "  %s\n", buffer);
   99|    880|}
log.c:current_timestring:
   59|    880|{
   60|    880|    char tbuf[64];
   61|    880|    struct timeval tv;
   62|    880|    struct tm *tm;
   63|    880|    time_t t;
   64|       |
   65|    880|    gettimeofday(&tv, NULL);
   66|    880|    t = (time_t) tv.tv_sec;
   67|       |
   68|    880|    tm = localtime(&t);
   69|    880|    if (tm == NULL) {
  ------------------
  |  Branch (69:9): [True: 0, False: 880]
  ------------------
   70|      0|        return -1;
   71|      0|    }
   72|       |
   73|    880|    if (hires) {
  ------------------
  |  Branch (73:9): [True: 880, False: 0]
  ------------------
   74|    880|        strftime(tbuf, sizeof(tbuf) - 1, "%Y/%m/%d %H:%M:%S", tm);
   75|    880|        snprintf(buf, len, "%s.%06ld", tbuf, (long)tv.tv_usec);
   76|    880|    } else {
   77|      0|        strftime(tbuf, sizeof(tbuf) - 1, "%Y/%m/%d %H:%M:%S", tm);
   78|      0|        snprintf(buf, len, "%s", tbuf);
   79|      0|    }
   80|       |
   81|    880|    return 0;
   82|    880|}

ssh_options_set_algo:
  241|    430|{
  242|       |    /* When the list start with +,-,^ the filtration of unknown algorithms
  243|       |     * gets handled inside the helper functions, otherwise the list is taken
  244|       |     * as it is. */
  245|    430|    char *p = (char *)list;
  246|       |
  247|    430|    if (algo < SSH_COMP_C_S) {
  ------------------
  |  Branch (247:9): [True: 430, False: 0]
  ------------------
  248|    430|        if (list[0] == '+') {
  ------------------
  |  Branch (248:13): [True: 81, False: 349]
  ------------------
  249|     81|            p = ssh_add_to_default_algos(algo, list+1);
  250|    349|        } else if (list[0] == '-') {
  ------------------
  |  Branch (250:20): [True: 215, False: 134]
  ------------------
  251|    215|            p = ssh_remove_from_default_algos(algo, list+1);
  252|    215|        } else if (list[0] == '^') {
  ------------------
  |  Branch (252:20): [True: 101, False: 33]
  ------------------
  253|    101|            p = ssh_prefix_default_algos(algo, list+1);
  254|    101|        }
  255|    430|    }
  256|       |
  257|    430|    if (p == list) {
  ------------------
  |  Branch (257:9): [True: 33, False: 397]
  ------------------
  258|     33|        if (ssh_fips_mode()) {
  ------------------
  |  |  120|     33|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (120:25): [True: 0, False: 33]
  |  |  ------------------
  ------------------
  259|      0|            p = ssh_keep_fips_algos(algo, list);
  260|     33|        } else {
  261|     33|            p = ssh_keep_known_algos(algo, list);
  262|     33|        }
  263|     33|    }
  264|       |
  265|    430|    if (p == NULL) {
  ------------------
  |  Branch (265:9): [True: 25, False: 405]
  ------------------
  266|     25|        ssh_set_error(session, SSH_REQUEST_DENIED,
  ------------------
  |  |  283|     25|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  267|     25|                "Setting method: no allowed algorithm for method \"%s\" (%s)",
  268|     25|                ssh_kex_get_description(algo), list);
  269|     25|        return -1;
  270|     25|    }
  271|       |
  272|    405|    SAFE_FREE(*place);
  ------------------
  |  |  338|    405|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 1, False: 404]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  273|    405|    *place = p;
  274|       |
  275|    405|    return 0;
  276|    430|}
ssh_bind_options_set:
 1941|    440|{
 1942|    440|  bool allowed;
 1943|    440|  char *p, *q;
 1944|    440|  const char *v;
 1945|    440|  int i, rc;
 1946|    440|  char **wanted_methods = sshbind->wanted_methods;
 1947|       |
 1948|    440|  if (sshbind == NULL) {
  ------------------
  |  Branch (1948:7): [True: 0, False: 440]
  ------------------
 1949|      0|    return -1;
 1950|      0|  }
 1951|       |
 1952|    440|  switch (type) {
 1953|      0|    case SSH_BIND_OPTIONS_RSAKEY:
  ------------------
  |  Branch (1953:5): [True: 0, False: 440]
  ------------------
 1954|      0|    case SSH_BIND_OPTIONS_ECDSAKEY:
  ------------------
  |  Branch (1954:5): [True: 0, False: 440]
  ------------------
 1955|       |        /* deprecated */
 1956|      0|    case SSH_BIND_OPTIONS_HOSTKEY:
  ------------------
  |  Branch (1956:5): [True: 0, False: 440]
  ------------------
 1957|      0|      if (value == NULL) {
  ------------------
  |  Branch (1957:11): [True: 0, False: 0]
  ------------------
 1958|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1959|      0|        return -1;
 1960|      0|      } else {
 1961|      0|          int key_type;
 1962|      0|          ssh_key key;
 1963|      0|          ssh_key *bind_key_loc = NULL;
 1964|      0|          char **bind_key_path_loc;
 1965|       |
 1966|      0|          rc = ssh_pki_import_privkey_file(value, NULL, NULL, NULL, &key);
 1967|      0|          if (rc != SSH_OK) {
  ------------------
  |  |  312|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1967:15): [True: 0, False: 0]
  ------------------
 1968|      0|              return -1;
 1969|      0|          }
 1970|      0|          allowed = ssh_bind_key_size_allowed(sshbind, key);
 1971|      0|          if (!allowed) {
  ------------------
  |  Branch (1971:15): [True: 0, False: 0]
  ------------------
 1972|      0|              ssh_set_error(sshbind,
  ------------------
  |  |  283|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1973|      0|                            SSH_FATAL,
 1974|      0|                            "The host key size %d is too small.",
 1975|      0|                            ssh_key_size(key));
 1976|      0|              ssh_key_free(key);
 1977|      0|              return -1;
 1978|      0|          }
 1979|       |
 1980|      0|          key_type = ssh_key_type(key);
 1981|      0|          switch (key_type) {
 1982|      0|          case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (1982:11): [True: 0, False: 0]
  ------------------
 1983|      0|          case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (1983:11): [True: 0, False: 0]
  ------------------
 1984|      0|          case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (1984:11): [True: 0, False: 0]
  ------------------
 1985|      0|#ifdef HAVE_ECC
 1986|      0|              bind_key_loc = &sshbind->ecdsa;
 1987|      0|              bind_key_path_loc = &sshbind->ecdsakey;
 1988|       |#else
 1989|       |              ssh_set_error(sshbind,
 1990|       |                            SSH_FATAL,
 1991|       |                            "ECDSA key used and libssh compiled "
 1992|       |                            "without ECDSA support");
 1993|       |#endif
 1994|      0|              break;
 1995|      0|          case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (1995:11): [True: 0, False: 0]
  ------------------
 1996|      0|              bind_key_loc = &sshbind->rsa;
 1997|      0|              bind_key_path_loc = &sshbind->rsakey;
 1998|      0|              break;
 1999|      0|          case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (1999:11): [True: 0, False: 0]
  ------------------
 2000|      0|              bind_key_loc = &sshbind->ed25519;
 2001|      0|              bind_key_path_loc = &sshbind->ed25519key;
 2002|      0|              break;
 2003|      0|          default:
  ------------------
  |  Branch (2003:11): [True: 0, False: 0]
  ------------------
 2004|      0|              ssh_set_error(sshbind,
  ------------------
  |  |  283|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2005|      0|                            SSH_FATAL,
 2006|      0|                            "Unsupported key type %d", key_type);
 2007|      0|          }
 2008|       |
 2009|      0|          if (bind_key_loc == NULL) {
  ------------------
  |  Branch (2009:15): [True: 0, False: 0]
  ------------------
 2010|      0|              ssh_key_free(key);
 2011|      0|              return -1;
 2012|      0|          }
 2013|       |
 2014|       |          /* Set the location of the key on disk even though we don't
 2015|       |             need it in case some other function wants it */
 2016|      0|          rc = ssh_bind_set_key(sshbind, bind_key_path_loc, value);
 2017|      0|          if (rc < 0) {
  ------------------
  |  Branch (2017:15): [True: 0, False: 0]
  ------------------
 2018|      0|              ssh_key_free(key);
 2019|      0|              return -1;
 2020|      0|          }
 2021|      0|          ssh_key_free(*bind_key_loc);
 2022|      0|          *bind_key_loc = key;
 2023|      0|      }
 2024|      0|      break;
 2025|      0|    case SSH_BIND_OPTIONS_IMPORT_KEY:
  ------------------
  |  Branch (2025:5): [True: 0, False: 440]
  ------------------
 2026|      0|        if (value == NULL) {
  ------------------
  |  Branch (2026:13): [True: 0, False: 0]
  ------------------
 2027|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2028|      0|            return -1;
 2029|      0|        } else {
 2030|      0|            int key_type;
 2031|      0|            ssh_key *bind_key_loc = NULL;
 2032|      0|            ssh_key key = (ssh_key)value;
 2033|       |
 2034|      0|            allowed = ssh_bind_key_size_allowed(sshbind, key);
 2035|      0|            if (!allowed) {
  ------------------
  |  Branch (2035:17): [True: 0, False: 0]
  ------------------
 2036|      0|                ssh_set_error(sshbind,
  ------------------
  |  |  283|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2037|      0|                              SSH_FATAL,
 2038|      0|                              "The host key size %d is too small.",
 2039|      0|                              ssh_key_size(key));
 2040|      0|                return -1;
 2041|      0|            }
 2042|       |
 2043|      0|            key_type = ssh_key_type(key);
 2044|      0|            switch (key_type) {
 2045|      0|                case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (2045:17): [True: 0, False: 0]
  ------------------
 2046|      0|                case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (2046:17): [True: 0, False: 0]
  ------------------
 2047|      0|                case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (2047:17): [True: 0, False: 0]
  ------------------
 2048|      0|#ifdef HAVE_ECC
 2049|      0|                    bind_key_loc = &sshbind->ecdsa;
 2050|       |#else
 2051|       |                    ssh_set_error(sshbind,
 2052|       |                                  SSH_FATAL,
 2053|       |                                  "ECDSA key used and libssh compiled "
 2054|       |                                  "without ECDSA support");
 2055|       |#endif
 2056|      0|                    break;
 2057|      0|                case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (2057:17): [True: 0, False: 0]
  ------------------
 2058|      0|                    bind_key_loc = &sshbind->rsa;
 2059|      0|                    break;
 2060|      0|                case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (2060:17): [True: 0, False: 0]
  ------------------
 2061|      0|                    bind_key_loc = &sshbind->ed25519;
 2062|      0|                    break;
 2063|      0|                default:
  ------------------
  |  Branch (2063:17): [True: 0, False: 0]
  ------------------
 2064|      0|                    ssh_set_error(sshbind,
  ------------------
  |  |  283|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2065|      0|                                  SSH_FATAL,
 2066|      0|                                  "Unsupported key type %d", key_type);
 2067|      0|            }
 2068|      0|            if (bind_key_loc == NULL)
  ------------------
  |  Branch (2068:17): [True: 0, False: 0]
  ------------------
 2069|      0|                return -1;
 2070|      0|            ssh_key_free(*bind_key_loc);
 2071|      0|            *bind_key_loc = key;
 2072|      0|        }
 2073|      0|        break;
 2074|      0|    case SSH_BIND_OPTIONS_BINDADDR:
  ------------------
  |  Branch (2074:5): [True: 0, False: 440]
  ------------------
 2075|      0|      if (value == NULL) {
  ------------------
  |  Branch (2075:11): [True: 0, False: 0]
  ------------------
 2076|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2077|      0|        return -1;
 2078|      0|      } else {
 2079|      0|        SAFE_FREE(sshbind->bindaddr);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2080|      0|        sshbind->bindaddr = strdup(value);
 2081|      0|        if (sshbind->bindaddr == NULL) {
  ------------------
  |  Branch (2081:13): [True: 0, False: 0]
  ------------------
 2082|      0|          ssh_set_error_oom(sshbind);
  ------------------
  |  |  290|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2083|      0|          return -1;
 2084|      0|        }
 2085|      0|      }
 2086|      0|      break;
 2087|      0|    case SSH_BIND_OPTIONS_BINDPORT:
  ------------------
  |  Branch (2087:5): [True: 0, False: 440]
  ------------------
 2088|      0|      if (value == NULL) {
  ------------------
  |  Branch (2088:11): [True: 0, False: 0]
  ------------------
 2089|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2090|      0|        return -1;
 2091|      0|      } else {
 2092|      0|        int *x = (int *) value;
 2093|      0|        sshbind->bindport = *x & 0xffffU;
 2094|      0|      }
 2095|      0|      break;
 2096|      2|    case SSH_BIND_OPTIONS_BINDPORT_STR:
  ------------------
  |  Branch (2096:5): [True: 2, False: 438]
  ------------------
 2097|      2|      if (value == NULL) {
  ------------------
  |  Branch (2097:11): [True: 0, False: 2]
  ------------------
 2098|      0|        sshbind->bindport = 22 & 0xffffU;
 2099|      2|      } else {
 2100|      2|        q = strdup(value);
 2101|      2|        if (q == NULL) {
  ------------------
  |  Branch (2101:13): [True: 0, False: 2]
  ------------------
 2102|      0|          ssh_set_error_oom(sshbind);
  ------------------
  |  |  290|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2103|      0|          return -1;
 2104|      0|        }
 2105|      2|        i = strtol(q, &p, 10);
 2106|      2|        if (q == p) {
  ------------------
  |  Branch (2106:13): [True: 2, False: 0]
  ------------------
 2107|      2|            SSH_LOG(SSH_LOG_DEBUG, "No bind port was parsed");
  ------------------
  |  |  265|      2|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2108|      2|            SAFE_FREE(q);
  ------------------
  |  |  338|      2|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 2, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2109|      2|            return -1;
 2110|      2|        }
 2111|      0|        SAFE_FREE(q);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2112|       |
 2113|      0|        sshbind->bindport = i & 0xffffU;
 2114|      0|      }
 2115|      0|      break;
 2116|      8|    case SSH_BIND_OPTIONS_LOG_VERBOSITY:
  ------------------
  |  Branch (2116:5): [True: 8, False: 432]
  ------------------
 2117|      8|      if (value == NULL) {
  ------------------
  |  Branch (2117:11): [True: 0, False: 8]
  ------------------
 2118|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2119|      0|        return -1;
 2120|      8|      } else {
 2121|      8|        int *x = (int *) value;
 2122|      8|        ssh_set_log_level(*x & 0xffffU);
 2123|      8|      }
 2124|      8|      break;
 2125|      8|    case SSH_BIND_OPTIONS_LOG_VERBOSITY_STR:
  ------------------
  |  Branch (2125:5): [True: 0, False: 440]
  ------------------
 2126|      0|      if (value == NULL) {
  ------------------
  |  Branch (2126:11): [True: 0, False: 0]
  ------------------
 2127|      0|      	ssh_set_log_level(0);
 2128|      0|      } else {
 2129|      0|        q = strdup(value);
 2130|      0|        if (q == NULL) {
  ------------------
  |  Branch (2130:13): [True: 0, False: 0]
  ------------------
 2131|      0|          ssh_set_error_oom(sshbind);
  ------------------
  |  |  290|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2132|      0|          return -1;
 2133|      0|        }
 2134|      0|        i = strtol(q, &p, 10);
 2135|      0|        if (q == p) {
  ------------------
  |  Branch (2135:13): [True: 0, False: 0]
  ------------------
 2136|      0|            SSH_LOG(SSH_LOG_DEBUG, "No log verbositiy was parsed");
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2137|      0|            SAFE_FREE(q);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2138|      0|            return -1;
 2139|      0|        }
 2140|      0|        SAFE_FREE(q);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2141|       |
 2142|      0|        ssh_set_log_level(i & 0xffffU);
 2143|      0|      }
 2144|      0|      break;
 2145|      0|    case SSH_BIND_OPTIONS_BANNER:
  ------------------
  |  Branch (2145:5): [True: 0, False: 440]
  ------------------
 2146|      0|      if (value == NULL) {
  ------------------
  |  Branch (2146:11): [True: 0, False: 0]
  ------------------
 2147|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2148|      0|        return -1;
 2149|      0|      } else {
 2150|      0|        SAFE_FREE(sshbind->banner);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2151|      0|        sshbind->banner = strdup(value);
 2152|      0|        if (sshbind->banner == NULL) {
  ------------------
  |  Branch (2152:13): [True: 0, False: 0]
  ------------------
 2153|      0|          ssh_set_error_oom(sshbind);
  ------------------
  |  |  290|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2154|      0|          return -1;
 2155|      0|        }
 2156|      0|      }
 2157|      0|      break;
 2158|     26|    case SSH_BIND_OPTIONS_CIPHERS_C_S:
  ------------------
  |  Branch (2158:5): [True: 26, False: 414]
  ------------------
 2159|     26|        v = value;
 2160|     26|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2160:13): [True: 0, False: 26]
  |  Branch (2160:26): [True: 0, False: 26]
  ------------------
 2161|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2162|      0|            return -1;
 2163|     26|        } else {
 2164|     26|            rc = ssh_bind_set_algo(sshbind,
 2165|     26|                                   SSH_CRYPT_C_S,
 2166|     26|                                   v,
 2167|     26|                                   &wanted_methods[SSH_CRYPT_C_S]);
 2168|     26|            if (rc < 0) {
  ------------------
  |  Branch (2168:17): [True: 2, False: 24]
  ------------------
 2169|      2|                return -1;
 2170|      2|            }
 2171|     26|        }
 2172|     24|        break;
 2173|     24|    case SSH_BIND_OPTIONS_CIPHERS_S_C:
  ------------------
  |  Branch (2173:5): [True: 24, False: 416]
  ------------------
 2174|     24|        v = value;
 2175|     24|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2175:13): [True: 0, False: 24]
  |  Branch (2175:26): [True: 0, False: 24]
  ------------------
 2176|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2177|      0|            return -1;
 2178|     24|        } else {
 2179|     24|            rc = ssh_bind_set_algo(sshbind,
 2180|     24|                                   SSH_CRYPT_S_C,
 2181|     24|                                   v,
 2182|     24|                                   &wanted_methods[SSH_CRYPT_S_C]);
 2183|     24|            if (rc < 0) {
  ------------------
  |  Branch (2183:17): [True: 0, False: 24]
  ------------------
 2184|      0|                return -1;
 2185|      0|            }
 2186|     24|        }
 2187|     24|        break;
 2188|     24|    case SSH_BIND_OPTIONS_KEY_EXCHANGE:
  ------------------
  |  Branch (2188:5): [True: 22, False: 418]
  ------------------
 2189|     22|        v = value;
 2190|     22|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2190:13): [True: 0, False: 22]
  |  Branch (2190:26): [True: 0, False: 22]
  ------------------
 2191|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2192|      0|            return -1;
 2193|     22|        } else {
 2194|     22|            rc = ssh_bind_set_algo(sshbind,
 2195|     22|                                   SSH_KEX,
 2196|     22|                                   v,
 2197|     22|                                   &wanted_methods[SSH_KEX]);
 2198|     22|            if (rc < 0) {
  ------------------
  |  Branch (2198:17): [True: 1, False: 21]
  ------------------
 2199|      1|                return -1;
 2200|      1|            }
 2201|     22|        }
 2202|     21|        break;
 2203|    181|    case SSH_BIND_OPTIONS_HMAC_C_S:
  ------------------
  |  Branch (2203:5): [True: 181, False: 259]
  ------------------
 2204|    181|        v = value;
 2205|    181|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2205:13): [True: 0, False: 181]
  |  Branch (2205:26): [True: 0, False: 181]
  ------------------
 2206|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2207|      0|            return -1;
 2208|    181|        } else {
 2209|    181|            rc = ssh_bind_set_algo(sshbind,
 2210|    181|                                   SSH_MAC_C_S,
 2211|    181|                                   v,
 2212|    181|                                   &wanted_methods[SSH_MAC_C_S]);
 2213|    181|            if (rc < 0) {
  ------------------
  |  Branch (2213:17): [True: 19, False: 162]
  ------------------
 2214|     19|                return -1;
 2215|     19|            }
 2216|    181|        }
 2217|    162|        break;
 2218|    162|     case SSH_BIND_OPTIONS_HMAC_S_C:
  ------------------
  |  Branch (2218:6): [True: 162, False: 278]
  ------------------
 2219|    162|        v = value;
 2220|    162|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2220:13): [True: 0, False: 162]
  |  Branch (2220:26): [True: 0, False: 162]
  ------------------
 2221|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2222|      0|            return -1;
 2223|    162|        } else {
 2224|    162|            rc = ssh_bind_set_algo(sshbind,
 2225|    162|                                   SSH_MAC_S_C,
 2226|    162|                                   v,
 2227|    162|                                   &wanted_methods[SSH_MAC_S_C]);
 2228|    162|            if (rc < 0) {
  ------------------
  |  Branch (2228:17): [True: 0, False: 162]
  ------------------
 2229|      0|                return -1;
 2230|      0|            }
 2231|    162|        }
 2232|    162|        break;
 2233|    162|    case SSH_BIND_OPTIONS_CONFIG_DIR:
  ------------------
  |  Branch (2233:5): [True: 0, False: 440]
  ------------------
 2234|      0|        v = value;
 2235|      0|        SAFE_FREE(sshbind->config_dir);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2236|      0|        if (v == NULL) {
  ------------------
  |  Branch (2236:13): [True: 0, False: 0]
  ------------------
 2237|      0|            break;
 2238|      0|        } else if (v[0] == '\0') {
  ------------------
  |  Branch (2238:20): [True: 0, False: 0]
  ------------------
 2239|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2240|      0|            return -1;
 2241|      0|        } else {
 2242|      0|            sshbind->config_dir = ssh_path_expand_tilde(v);
 2243|      0|            if (sshbind->config_dir == NULL) {
  ------------------
  |  Branch (2243:17): [True: 0, False: 0]
  ------------------
 2244|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  290|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2245|      0|                return -1;
 2246|      0|            }
 2247|      0|        }
 2248|      0|        break;
 2249|      5|    case SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES:
  ------------------
  |  Branch (2249:5): [True: 5, False: 435]
  ------------------
 2250|      5|        v = value;
 2251|      5|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2251:13): [True: 0, False: 5]
  |  Branch (2251:26): [True: 0, False: 5]
  ------------------
 2252|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2253|      0|            return -1;
 2254|      5|        } else {
 2255|      5|            rc = ssh_bind_set_algo(sshbind,
 2256|      5|                                   SSH_HOSTKEYS,
 2257|      5|                                   v,
 2258|      5|                                   &sshbind->pubkey_accepted_key_types);
 2259|      5|            if (rc < 0) {
  ------------------
  |  Branch (2259:17): [True: 2, False: 3]
  ------------------
 2260|      2|                return -1;
 2261|      2|            }
 2262|      5|        }
 2263|      3|        break;
 2264|     10|    case SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS:
  ------------------
  |  Branch (2264:5): [True: 10, False: 430]
  ------------------
 2265|     10|        v = value;
 2266|     10|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2266:13): [True: 0, False: 10]
  |  Branch (2266:26): [True: 0, False: 10]
  ------------------
 2267|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2268|      0|            return -1;
 2269|     10|        } else {
 2270|     10|            rc = ssh_bind_set_algo(sshbind,
 2271|     10|                                   SSH_HOSTKEYS,
 2272|     10|                                   v,
 2273|     10|                                   &wanted_methods[SSH_HOSTKEYS]);
 2274|     10|            if (rc < 0) {
  ------------------
  |  Branch (2274:17): [True: 1, False: 9]
  ------------------
 2275|      1|                return -1;
 2276|      1|            }
 2277|     10|        }
 2278|      9|        break;
 2279|      9|    case SSH_BIND_OPTIONS_PROCESS_CONFIG:
  ------------------
  |  Branch (2279:5): [True: 0, False: 440]
  ------------------
 2280|      0|        if (value == NULL) {
  ------------------
  |  Branch (2280:13): [True: 0, False: 0]
  ------------------
 2281|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2282|      0|            return -1;
 2283|      0|        } else {
 2284|      0|            bool *x = (bool *)value;
 2285|      0|            sshbind->config_processed = !(*x);
 2286|      0|        }
 2287|      0|        break;
 2288|      0|    case SSH_BIND_OPTIONS_MODULI:
  ------------------
  |  Branch (2288:5): [True: 0, False: 440]
  ------------------
 2289|      0|        if (value == NULL) {
  ------------------
  |  Branch (2289:13): [True: 0, False: 0]
  ------------------
 2290|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2291|      0|            return -1;
 2292|      0|        } else {
 2293|      0|            SAFE_FREE(sshbind->moduli_file);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2294|      0|            sshbind->moduli_file = strdup(value);
 2295|      0|            if (sshbind->moduli_file == NULL) {
  ------------------
  |  Branch (2295:17): [True: 0, False: 0]
  ------------------
 2296|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  290|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2297|      0|                return -1;
 2298|      0|            }
 2299|      0|        }
 2300|      0|        break;
 2301|      0|    case SSH_BIND_OPTIONS_RSA_MIN_SIZE:
  ------------------
  |  Branch (2301:5): [True: 0, False: 440]
  ------------------
 2302|      0|        if (value == NULL) {
  ------------------
  |  Branch (2302:13): [True: 0, False: 0]
  ------------------
 2303|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  294|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2304|      0|            return -1;
 2305|      0|        } else {
 2306|      0|            int *x = (int *)value;
 2307|      0|            if (*x > 0 && *x < 768) {
  ------------------
  |  Branch (2307:17): [True: 0, False: 0]
  |  Branch (2307:27): [True: 0, False: 0]
  ------------------
 2308|      0|                ssh_set_error(sshbind, SSH_REQUEST_DENIED,
  ------------------
  |  |  283|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2309|      0|                              "The provided value (%u) for minimal RSA key "
 2310|      0|                              "size is too small. Use at least 768 bits.", *x);
 2311|      0|                return -1;
 2312|      0|            }
 2313|      0|            sshbind->rsa_min_size = *x;
 2314|      0|        }
 2315|      0|        break;
 2316|      0|    default:
  ------------------
  |  Branch (2316:5): [True: 0, False: 440]
  ------------------
 2317|      0|      ssh_set_error(sshbind, SSH_REQUEST_DENIED, "Unknown ssh option %d", type);
  ------------------
  |  |  283|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2318|      0|      return -1;
 2319|      0|    break;
 2320|    440|  }
 2321|       |
 2322|    413|  return 0;
 2323|    440|}
options.c:ssh_bind_set_algo:
 1801|    430|{
 1802|       |    /* sshbind is needed only for ssh_set_error which takes void*
 1803|       |     * the typecast is only to satisfy function parameter type */
 1804|    430|    return ssh_options_set_algo((ssh_session)sshbind, algo, list, place);
 1805|    430|}

ssh_key_free:
  180|  1.13k|{
  181|  1.13k|    if (key) {
  ------------------
  |  Branch (181:9): [True: 0, False: 1.13k]
  ------------------
  182|      0|        ssh_key_clean(key);
  183|      0|        SAFE_FREE(key);
  ------------------
  |  |  338|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (338:31): [True: 0, False: 0]
  |  |  |  Branch (338:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  184|      0|    }
  185|  1.13k|}

ssh_poll_init:
   88|      2|{
   89|      2|    return;
   90|      2|}

ssh_socket_init:
  107|      2|{
  108|      2|    if (sockets_initialized == 0) {
  ------------------
  |  Branch (108:9): [True: 2, False: 0]
  ------------------
  109|       |#ifdef _WIN32
  110|       |        struct WSAData wsaData;
  111|       |
  112|       |        /* Initiates use of the Winsock DLL by a process. */
  113|       |        if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
  114|       |            return -1;
  115|       |        }
  116|       |#endif
  117|      2|        ssh_poll_init();
  118|       |
  119|      2|        sockets_initialized = 1;
  120|      2|    }
  121|       |
  122|      2|    return 0;
  123|      2|}

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

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

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

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

LLVMFuzzerTestOneInput:
   28|    377|{
   29|    377|    ssh_bind bind = NULL;
   30|    377|    char *input = NULL;
   31|       |
   32|    377|    input = (char *)malloc(size + 1);
   33|    377|    if (!input) {
  ------------------
  |  Branch (33:9): [True: 0, False: 377]
  ------------------
   34|      0|        return 1;
   35|      0|    }
   36|    377|    strncpy(input, (const char *)data, size);
   37|    377|    input[size] = '\0';
   38|       |
   39|    377|    ssh_init();
   40|       |
   41|    377|    bind = ssh_bind_new();
   42|    377|    assert(bind != NULL);
   43|       |
   44|    377|    ssh_bind_config_parse_string(bind, input);
   45|       |
   46|    377|    ssh_bind_free(bind);
   47|    377|    ssh_finalize();
   48|       |
   49|    377|    free(input);
   50|       |
   51|    377|    return 0;
   52|    377|}

