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

ssh_bind_config_parse_string:
  669|    383|{
  670|    383|    char line[MAX_LINE_SIZE] = {0};
  671|    383|    const char *c = input, *line_start = input;
  672|    383|    unsigned int line_num = 0, line_len;
  673|    383|    uint32_t parser_flags;
  674|    383|    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|    383|    uint8_t seen[BIND_CFG_MAX] = {0};
  681|       |
  682|    383|    SSH_LOG(SSH_LOG_DEBUG, "Reading bind configuration data from string:");
  ------------------
  |  |  251|    383|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  683|    383|    SSH_LOG(SSH_LOG_DEBUG, "START\n%s\nEND", input);
  ------------------
  |  |  251|    383|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  684|       |
  685|    383|    parser_flags = PARSING;
  ------------------
  |  |   48|    383|#define PARSING     1
  ------------------
  686|  7.03k|    while (1) {
  ------------------
  |  Branch (686:12): [Folded - Ignored]
  ------------------
  687|  7.03k|        line_num++;
  688|  7.03k|        line_start = c;
  689|  7.03k|        c = strchr(line_start, '\n');
  690|  7.03k|        if (c == NULL) {
  ------------------
  |  Branch (690:13): [True: 381, False: 6.65k]
  ------------------
  691|       |            /* if there is no newline at the end of the string */
  692|    381|            c = strchr(line_start, '\0');
  693|    381|        }
  694|  7.03k|        if (c == NULL) {
  ------------------
  |  Branch (694:13): [True: 0, False: 7.03k]
  ------------------
  695|       |            /* should not happen, would mean a string without trailing '\0' */
  696|      0|            SSH_LOG(SSH_LOG_WARN, "No trailing '\\0' in config string");
  ------------------
  |  |  251|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  697|      0|            return SSH_ERROR;
  ------------------
  |  |  312|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  698|      0|        }
  699|  7.03k|        line_len = c - line_start;
  700|  7.03k|        if (line_len > MAX_LINE_SIZE - 1) {
  ------------------
  |  |   44|  7.03k|#define MAX_LINE_SIZE 1024
  ------------------
  |  Branch (700:13): [True: 11, False: 7.02k]
  ------------------
  701|     11|            SSH_LOG(SSH_LOG_WARN, "Line %u too long: %u characters",
  ------------------
  |  |  251|     11|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  702|     11|                    line_num, line_len);
  703|     11|            return SSH_ERROR;
  ------------------
  |  |  312|     11|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  704|     11|        }
  705|  7.02k|        memcpy(line, line_start, line_len);
  706|  7.02k|        line[line_len] = '\0';
  707|  7.02k|        SSH_LOG(SSH_LOG_DEBUG, "Line %u: %s", line_num, line);
  ------------------
  |  |  251|  7.02k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  708|  7.02k|        rv = ssh_bind_config_parse_line(bind, line, line_num, &parser_flags, seen, 0);
  709|  7.02k|        if (rv < 0) {
  ------------------
  |  Branch (709:13): [True: 29, False: 6.99k]
  ------------------
  710|     29|            return SSH_ERROR;
  ------------------
  |  |  312|     29|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  711|     29|        }
  712|  6.99k|        if (*c == '\0') {
  ------------------
  |  Branch (712:13): [True: 343, False: 6.65k]
  ------------------
  713|    343|            break;
  714|    343|        }
  715|  6.65k|        c++;
  716|  6.65k|    }
  717|       |
  718|    343|    return SSH_OK;
  ------------------
  |  |  311|    343|#define SSH_OK 0     /* No error */
  ------------------
  719|    383|}
bind_config.c:ssh_bind_config_parse_line:
  291|   533k|{
  292|   533k|    enum ssh_bind_config_opcode_e opcode;
  293|   533k|    const char *p = NULL;
  294|   533k|    char *s = NULL, *x = NULL;
  295|   533k|    char *keyword = NULL;
  296|   533k|    size_t len;
  297|       |
  298|   533k|    int rc = 0;
  299|       |
  300|   533k|    if (bind == NULL) {
  ------------------
  |  Branch (300:9): [True: 0, False: 533k]
  ------------------
  301|      0|        return -1;
  302|      0|    }
  303|       |
  304|       |    /* Ignore empty lines */
  305|   533k|    if (line == NULL || *line == '\0') {
  ------------------
  |  Branch (305:9): [True: 0, False: 533k]
  |  Branch (305:25): [True: 10.7k, False: 522k]
  ------------------
  306|  10.7k|        return 0;
  307|  10.7k|    }
  308|       |
  309|   522k|    if (parser_flags == NULL) {
  ------------------
  |  Branch (309:9): [True: 0, False: 522k]
  ------------------
  310|      0|        ssh_set_error_invalid(bind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  311|      0|        return -1;
  312|      0|    }
  313|       |
  314|   522k|    x = s = strdup(line);
  315|   522k|    if (s == NULL) {
  ------------------
  |  Branch (315:9): [True: 0, False: 522k]
  ------------------
  316|      0|        ssh_set_error_oom(bind);
  ------------------
  |  |  276|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  317|      0|        return -1;
  318|      0|    }
  319|       |
  320|       |    /* Remove trailing spaces */
  321|   952k|    for (len = strlen(s) - 1; len > 0; len--) {
  ------------------
  |  Branch (321:31): [True: 852k, False: 100k]
  ------------------
  322|   852k|        if (! isspace(s[len])) {
  ------------------
  |  Branch (322:13): [True: 422k, False: 429k]
  ------------------
  323|   422k|            break;
  324|   422k|        }
  325|   429k|        s[len] = '\0';
  326|   429k|    }
  327|       |
  328|   522k|    keyword = ssh_config_get_token(&s);
  329|   522k|    if (keyword == NULL || *keyword == '#' ||
  ------------------
  |  Branch (329:9): [True: 0, False: 522k]
  |  Branch (329:28): [True: 55.1k, False: 467k]
  ------------------
  330|   522k|            *keyword == '\0' || *keyword == '\n') {
  ------------------
  |  Branch (330:13): [True: 87.7k, False: 379k]
  |  Branch (330:33): [True: 0, False: 379k]
  ------------------
  331|   142k|        SAFE_FREE(x);
  ------------------
  |  |  324|   142k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 142k, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  332|   142k|        return 0;
  333|   142k|    }
  334|       |
  335|   379k|    opcode = ssh_bind_config_get_opcode(keyword, parser_flags);
  336|   379k|    if ((*parser_flags & PARSING) &&
  ------------------
  |  |   48|   379k|#define PARSING     1
  ------------------
  |  Branch (336:9): [True: 379k, False: 3]
  ------------------
  337|   379k|            opcode != BIND_CFG_HOSTKEY &&
  ------------------
  |  Branch (337:13): [True: 379k, False: 8]
  ------------------
  338|   379k|            opcode != BIND_CFG_INCLUDE &&
  ------------------
  |  Branch (338:13): [True: 379k, False: 343]
  ------------------
  339|   379k|            opcode != BIND_CFG_MATCH &&
  ------------------
  |  Branch (339:13): [True: 379k, False: 16]
  ------------------
  340|   379k|            opcode > BIND_CFG_UNSUPPORTED) { /* Ignore all unknown types here */
  ------------------
  |  Branch (340:13): [True: 346, False: 378k]
  ------------------
  341|       |        /* Skip all the options that were already applied */
  342|    346|        if (seen[opcode] != 0) {
  ------------------
  |  Branch (342:13): [True: 68, False: 278]
  ------------------
  343|     68|            SAFE_FREE(x);
  ------------------
  |  |  324|     68|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 68, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  344|     68|            return 0;
  345|     68|        }
  346|    278|        seen[opcode] = 1;
  347|    278|    }
  348|       |
  349|   379k|    switch (opcode) {
  350|    343|    case BIND_CFG_INCLUDE:
  ------------------
  |  Branch (350:5): [True: 343, False: 379k]
  ------------------
  351|    343|        p = ssh_config_get_str_tok(&s, NULL);
  352|    343|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|    267|#define PARSING     1
  ------------------
  |  Branch (352:13): [True: 267, False: 76]
  |  Branch (352:18): [True: 267, False: 0]
  ------------------
  353|    267|#if defined(HAVE_GLOB) && defined(HAVE_GLOB_GL_FLAGS_MEMBER)
  354|    267|            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|    267|        }
  359|    343|        break;
  360|       |
  361|      8|    case BIND_CFG_HOSTKEY:
  ------------------
  |  Branch (361:5): [True: 8, False: 379k]
  ------------------
  362|      8|        p = ssh_config_get_str_tok(&s, NULL);
  363|      8|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      0|#define PARSING     1
  ------------------
  |  Branch (363:13): [True: 0, False: 8]
  |  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,
  ------------------
  |  |  251|      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|      8|        break;
  372|      0|    case BIND_CFG_LISTENADDRESS:
  ------------------
  |  Branch (372:5): [True: 0, False: 379k]
  ------------------
  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,
  ------------------
  |  |  251|      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|      5|    case BIND_CFG_PORT:
  ------------------
  |  Branch (383:5): [True: 5, False: 379k]
  ------------------
  384|      5|        p = ssh_config_get_str_tok(&s, NULL);
  385|      5|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      5|#define PARSING     1
  ------------------
  |  Branch (385:13): [True: 5, False: 0]
  |  Branch (385:18): [True: 5, False: 0]
  ------------------
  386|      5|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_BINDPORT_STR, p);
  387|      5|            if (rc != 0) {
  ------------------
  |  Branch (387:17): [True: 0, False: 5]
  ------------------
  388|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  251|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  389|      0|                        "line %d: Failed to set Port value '%s'",
  390|      0|                        count, p);
  391|      0|            }
  392|      5|        }
  393|      5|        break;
  394|     36|    case BIND_CFG_CIPHERS:
  ------------------
  |  Branch (394:5): [True: 36, False: 379k]
  ------------------
  395|     36|        p = ssh_config_get_str_tok(&s, NULL);
  396|     36|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     36|#define PARSING     1
  ------------------
  |  Branch (396:13): [True: 36, False: 0]
  |  Branch (396:18): [True: 36, False: 0]
  ------------------
  397|     36|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_CIPHERS_C_S, p);
  398|     36|            if (rc != 0) {
  ------------------
  |  Branch (398:17): [True: 2, False: 34]
  ------------------
  399|      2|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  251|      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|     34|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_CIPHERS_S_C, p);
  406|     34|            if (rc != 0) {
  ------------------
  |  Branch (406:17): [True: 0, False: 34]
  ------------------
  407|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  251|      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|     34|        }
  412|     34|        break;
  413|    190|    case BIND_CFG_MACS:
  ------------------
  |  Branch (413:5): [True: 190, False: 379k]
  ------------------
  414|    190|        p = ssh_config_get_str_tok(&s, NULL);
  415|    190|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|    190|#define PARSING     1
  ------------------
  |  Branch (415:13): [True: 190, False: 0]
  |  Branch (415:18): [True: 190, False: 0]
  ------------------
  416|    190|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HMAC_C_S, p);
  417|    190|            if (rc != 0) {
  ------------------
  |  Branch (417:17): [True: 23, False: 167]
  ------------------
  418|     23|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  251|     23|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  419|     23|                        "line %d: Failed to set C->S MAC value '%s'",
  420|     23|                        count, p);
  421|     23|                break;
  422|     23|            }
  423|       |
  424|    167|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HMAC_S_C, p);
  425|    167|            if (rc != 0) {
  ------------------
  |  Branch (425:17): [True: 0, False: 167]
  ------------------
  426|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  251|      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|    167|        }
  431|    167|        break;
  432|    167|    case BIND_CFG_LOGLEVEL:
  ------------------
  |  Branch (432:5): [True: 15, False: 379k]
  ------------------
  433|     15|        p = ssh_config_get_str_tok(&s, NULL);
  434|     15|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     15|#define PARSING     1
  ------------------
  |  Branch (434:13): [True: 15, False: 0]
  |  Branch (434:18): [True: 15, False: 0]
  ------------------
  435|     15|            int value = -1;
  436|       |
  437|     15|            if (strcasecmp(p, "quiet") == 0) {
  ------------------
  |  Branch (437:17): [True: 2, False: 13]
  ------------------
  438|      2|                value = SSH_LOG_NONE;
  ------------------
  |  |  350|      2|#define SSH_LOG_NONE 0
  ------------------
  439|     13|            } else if (strcasecmp(p, "fatal") == 0 ||
  ------------------
  |  Branch (439:24): [True: 2, False: 11]
  ------------------
  440|     13|                    strcasecmp(p, "error")== 0) {
  ------------------
  |  Branch (440:21): [True: 2, False: 9]
  ------------------
  441|      4|                value = SSH_LOG_WARN;
  ------------------
  |  |  352|      4|#define SSH_LOG_WARN 1
  ------------------
  442|      9|            } else if (strcasecmp(p, "verbose") == 0 ||
  ------------------
  |  Branch (442:24): [True: 2, False: 7]
  ------------------
  443|      9|                    strcasecmp(p, "info") == 0) {
  ------------------
  |  Branch (443:21): [True: 2, False: 5]
  ------------------
  444|      4|                value = SSH_LOG_INFO;
  ------------------
  |  |  354|      4|#define SSH_LOG_INFO 2
  ------------------
  445|      5|            } else if (strcasecmp(p, "DEBUG") == 0 ||
  ------------------
  |  Branch (445:24): [True: 0, False: 5]
  ------------------
  446|      5|                    strcasecmp(p, "DEBUG1") == 0) {
  ------------------
  |  Branch (446:21): [True: 2, False: 3]
  ------------------
  447|      2|                value = SSH_LOG_DEBUG;
  ------------------
  |  |  356|      2|#define SSH_LOG_DEBUG 3
  ------------------
  448|      3|            } else if (strcasecmp(p, "DEBUG2") == 0 ||
  ------------------
  |  Branch (448:24): [True: 1, False: 2]
  ------------------
  449|      3|                    strcasecmp(p, "DEBUG3") == 0) {
  ------------------
  |  Branch (449:21): [True: 2, False: 0]
  ------------------
  450|      3|                value = SSH_LOG_TRACE;
  ------------------
  |  |  358|      3|#define SSH_LOG_TRACE 4
  ------------------
  451|      3|            }
  452|     15|            if (value != -1) {
  ------------------
  |  Branch (452:17): [True: 15, False: 0]
  ------------------
  453|     15|                rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_LOG_VERBOSITY,
  454|     15|                        &value);
  455|     15|                if (rc != 0) {
  ------------------
  |  Branch (455:21): [True: 0, False: 15]
  ------------------
  456|      0|                    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  251|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  457|      0|                            "line %d: Failed to set LogLevel value '%s'",
  458|      0|                            count, p);
  459|      0|                }
  460|     15|            }
  461|     15|        }
  462|     15|        break;
  463|      7|    case BIND_CFG_KEXALGORITHMS:
  ------------------
  |  Branch (463:5): [True: 7, False: 379k]
  ------------------
  464|      7|        p = ssh_config_get_str_tok(&s, NULL);
  465|      7|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      5|#define PARSING     1
  ------------------
  |  Branch (465:13): [True: 5, False: 2]
  |  Branch (465:18): [True: 5, False: 0]
  ------------------
  466|      5|            rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_KEY_EXCHANGE, p);
  467|      5|            if (rc != 0) {
  ------------------
  |  Branch (467:17): [True: 0, False: 5]
  ------------------
  468|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  251|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  469|      0|                        "line %d: Failed to set KexAlgorithms value '%s'",
  470|      0|                        count, p);
  471|      0|            }
  472|      5|        }
  473|      7|        break;
  474|     16|    case BIND_CFG_MATCH: {
  ------------------
  |  Branch (474:5): [True: 16, False: 379k]
  ------------------
  475|     16|        bool negate;
  476|     16|        int result = PARSING;
  ------------------
  |  |   48|     16|#define PARSING     1
  ------------------
  477|     16|        size_t args = 0;
  478|     16|        enum ssh_bind_config_match_e opt;
  479|     16|        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|     16|        if (!(*parser_flags & IN_MATCH)) {
  ------------------
  |  |   49|     16|#define IN_MATCH    (1<<1)
  ------------------
  |  Branch (493:13): [True: 14, False: 2]
  ------------------
  494|     14|            memset(seen, 0x00, BIND_CFG_MAX * sizeof(uint8_t));
  495|     14|        }
  496|       |
  497|       |        /* In this line the PARSING bit is cleared from the flags */
  498|     16|        *parser_flags = IN_MATCH;
  ------------------
  |  |   49|     16|#define IN_MATCH    (1<<1)
  ------------------
  499|     18|        do {
  500|     18|            p = p2 = ssh_config_get_str_tok(&s, NULL);
  501|     18|            if (p == NULL || p[0] == '\0') {
  ------------------
  |  Branch (501:17): [True: 1, False: 17]
  |  Branch (501:30): [True: 0, False: 17]
  ------------------
  502|      1|                break;
  503|      1|            }
  504|     17|            args++;
  505|     17|            SSH_LOG(SSH_LOG_TRACE, "line %d: Processing Match keyword '%s'",
  ------------------
  |  |  251|     17|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  506|     17|                    count, p);
  507|       |
  508|       |            /* If the option is prefixed with ! the result should be negated */
  509|     17|            negate = false;
  510|     17|            if (p[0] == '!') {
  ------------------
  |  Branch (510:17): [True: 0, False: 17]
  ------------------
  511|      0|                negate = true;
  512|      0|                p++;
  513|      0|            }
  514|       |
  515|     17|            opt = ssh_bind_config_get_match_opcode(p);
  516|     17|            switch (opt) {
  517|     11|            case BIND_MATCH_ALL:
  ------------------
  |  Branch (517:13): [True: 11, False: 6]
  ------------------
  518|     11|                p = ssh_config_get_str_tok(&s, NULL);
  519|     11|                if ((args == 1) && (p == NULL || p[0] == '\0')) {
  ------------------
  |  Branch (519:21): [True: 11, False: 0]
  |  Branch (519:37): [True: 11, False: 0]
  |  Branch (519:50): [True: 0, False: 0]
  ------------------
  520|       |                    /* The "all" keyword does not accept arguments or modifiers
  521|       |                     */
  522|     11|                    if (negate == true) {
  ------------------
  |  Branch (522:25): [True: 0, False: 11]
  ------------------
  523|      0|                        result = 0;
  524|      0|                    }
  525|     11|                    break;
  526|     11|                }
  527|      0|                ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  269|      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);
  ------------------
  |  |  324|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  531|      0|                return -1;
  532|      2|            case BIND_MATCH_USER:
  ------------------
  |  Branch (532:13): [True: 2, False: 15]
  ------------------
  533|      2|            case BIND_MATCH_GROUP:
  ------------------
  |  Branch (533:13): [True: 0, False: 17]
  ------------------
  534|      2|            case BIND_MATCH_HOST:
  ------------------
  |  Branch (534:13): [True: 0, False: 17]
  ------------------
  535|      2|            case BIND_MATCH_LOCALADDRESS:
  ------------------
  |  Branch (535:13): [True: 0, False: 17]
  ------------------
  536|      2|            case BIND_MATCH_LOCALPORT:
  ------------------
  |  Branch (536:13): [True: 0, False: 17]
  ------------------
  537|      3|            case BIND_MATCH_RDOMAIN:
  ------------------
  |  Branch (537:13): [True: 1, False: 16]
  ------------------
  538|      3|            case BIND_MATCH_ADDRESS:
  ------------------
  |  Branch (538:13): [True: 0, False: 17]
  ------------------
  539|       |                /* Only "All" is supported for now */
  540|       |                /* Skip one argument */
  541|      3|                p = ssh_config_get_str_tok(&s, NULL);
  542|      3|                if (p == NULL || p[0] == '\0') {
  ------------------
  |  Branch (542:21): [True: 1, False: 2]
  |  Branch (542:34): [True: 0, False: 2]
  ------------------
  543|      1|                    SSH_LOG(SSH_LOG_TRACE, "line %d: Match keyword "
  ------------------
  |  |  251|      1|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  544|      1|                            "'%s' requires argument\n", count, p2);
  545|      1|                    SAFE_FREE(x);
  ------------------
  |  |  324|      1|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 1, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  546|      1|                    return -1;
  547|      1|                }
  548|      2|                args++;
  549|      2|                SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  251|      2|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  550|      2|                        "line %d: Unsupported Match keyword '%s', ignoring\n",
  551|      2|                        count,
  552|      2|                        p2);
  553|      2|                result = 0;
  554|      2|                break;
  555|      3|            case BIND_MATCH_UNKNOWN:
  ------------------
  |  Branch (555:13): [True: 3, False: 14]
  ------------------
  556|      3|            default:
  ------------------
  |  Branch (556:13): [True: 0, False: 17]
  ------------------
  557|      3|                ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  269|      3|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  558|      3|                              "ERROR - Unknown argument '%s' for Match keyword", p);
  559|      3|                SAFE_FREE(x);
  ------------------
  |  |  324|      3|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 3, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  560|      3|                return -1;
  561|     17|            }
  562|     17|        } while (p != NULL && p[0] != '\0');
  ------------------
  |  Branch (562:18): [True: 2, False: 11]
  |  Branch (562:31): [True: 2, False: 0]
  ------------------
  563|     12|        if (args == 0) {
  ------------------
  |  Branch (563:13): [True: 0, False: 12]
  ------------------
  564|      0|            ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  269|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  565|      0|                          "ERROR - Match keyword requires an argument");
  566|      0|            SAFE_FREE(x);
  ------------------
  |  |  324|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  567|      0|            return -1;
  568|      0|        }
  569|       |        /* This line only sets the PARSING flag if all checks passed */
  570|     12|        *parser_flags |= result;
  571|     12|        break;
  572|     12|    }
  573|     10|    case BIND_CFG_PUBKEY_ACCEPTED_KEY_TYPES:
  ------------------
  |  Branch (573:5): [True: 10, False: 379k]
  ------------------
  574|     10|        p = ssh_config_get_str_tok(&s, NULL);
  575|     10|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|      9|#define PARSING     1
  ------------------
  |  Branch (575:13): [True: 9, False: 1]
  |  Branch (575:18): [True: 9, False: 0]
  ------------------
  576|      9|            rc = ssh_bind_options_set(bind,
  577|      9|                                 SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES, p);
  578|      9|            if (rc != 0) {
  ------------------
  |  Branch (578:17): [True: 1, False: 8]
  ------------------
  579|      1|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  251|      1|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  580|      1|                        "line %d: Failed to set PubKeyAcceptedKeyTypes value '%s'",
  581|      1|                        count, p);
  582|      1|            }
  583|      9|        }
  584|     10|        break;
  585|     15|    case BIND_CFG_HOSTKEY_ALGORITHMS:
  ------------------
  |  Branch (585:5): [True: 15, False: 379k]
  ------------------
  586|     15|        p = ssh_config_get_str_tok(&s, NULL);
  587|     15|        if (p && (*parser_flags & PARSING)) {
  ------------------
  |  |   48|     15|#define PARSING     1
  ------------------
  |  Branch (587:13): [True: 15, False: 0]
  |  Branch (587:18): [True: 15, False: 0]
  ------------------
  588|     15|            rc = ssh_bind_options_set(bind,
  589|     15|                                 SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS, p);
  590|     15|            if (rc != 0) {
  ------------------
  |  Branch (590:17): [True: 1, False: 14]
  ------------------
  591|      1|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  251|      1|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  592|      1|                        "line %d: Failed to set HostkeyAlgorithms value '%s'",
  593|      1|                        count, p);
  594|      1|            }
  595|     15|        }
  596|     15|        break;
  597|      6|    case BIND_CFG_NOT_ALLOWED_IN_MATCH:
  ------------------
  |  Branch (597:5): [True: 6, False: 379k]
  ------------------
  598|      6|        SSH_LOG(SSH_LOG_DEBUG, "Option not allowed in Match block: %s, line: %d",
  ------------------
  |  |  251|      6|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  599|      6|                keyword, count);
  600|      6|        break;
  601|   378k|    case BIND_CFG_UNKNOWN:
  ------------------
  |  Branch (601:5): [True: 378k, False: 651]
  ------------------
  602|   378k|        SSH_LOG(SSH_LOG_TRACE, "Unknown option: %s, line: %d",
  ------------------
  |  |  251|   378k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  603|   378k|                keyword, count);
  604|   378k|        break;
  605|      0|    case BIND_CFG_UNSUPPORTED:
  ------------------
  |  Branch (605:5): [True: 0, False: 379k]
  ------------------
  606|      0|        SSH_LOG(SSH_LOG_TRACE, "Unsupported option: %s, line: %d",
  ------------------
  |  |  251|      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: 379k]
  ------------------
  610|      0|        SSH_LOG(SSH_LOG_TRACE, "Option not applicable: %s, line: %d",
  ------------------
  |  |  251|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  611|      0|                keyword, count);
  612|      0|        break;
  613|      0|    default:
  ------------------
  |  Branch (613:5): [True: 0, False: 379k]
  ------------------
  614|      0|        ssh_set_error(bind, SSH_FATAL, "ERROR - unimplemented opcode: %d",
  ------------------
  |  |  269|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  615|      0|                opcode);
  616|      0|        SAFE_FREE(x);
  ------------------
  |  |  324|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  617|      0|        return -1;
  618|      0|        break;
  619|   379k|    }
  620|       |
  621|   379k|    SAFE_FREE(x);
  ------------------
  |  |  324|   379k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 379k, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  622|   379k|    return rc;
  623|   379k|}
bind_config.c:ssh_bind_config_get_opcode:
  170|   379k|{
  171|   379k|    int i;
  172|       |
  173|  4.54M|    for (i = 0; ssh_bind_config_keyword_table[i].name != NULL; i++) {
  ------------------
  |  Branch (173:17): [True: 4.16M, False: 378k]
  ------------------
  174|  4.16M|        if (strcasecmp(keyword, ssh_bind_config_keyword_table[i].name) == 0) {
  ------------------
  |  Branch (174:13): [True: 719, False: 4.16M]
  ------------------
  175|    719|            if ((*parser_flags & IN_MATCH) &&
  ------------------
  |  |   49|    719|#define IN_MATCH    (1<<1)
  ------------------
  |  Branch (175:17): [True: 20, False: 699]
  ------------------
  176|    719|                !(ssh_bind_config_keyword_table[i].allowed_in_match))
  ------------------
  |  Branch (176:17): [True: 6, False: 14]
  ------------------
  177|      6|            {
  178|      6|                return BIND_CFG_NOT_ALLOWED_IN_MATCH;
  179|      6|            }
  180|    713|            return ssh_bind_config_keyword_table[i].opcode;
  181|    719|        }
  182|  4.16M|    }
  183|       |
  184|   378k|    return BIND_CFG_UNKNOWN;
  185|   379k|}
bind_config.c:local_parse_glob:
  244|    267|{
  245|    267|    glob_t globbuf = {
  246|    267|        .gl_flags = 0,
  247|    267|    };
  248|    267|    int rt;
  249|    267|    u_int i;
  250|       |
  251|    267|    rt = glob(fileglob, GLOB_TILDE, NULL, &globbuf);
  252|    267|    if (rt == GLOB_NOMATCH) {
  ------------------
  |  Branch (252:9): [True: 56, False: 211]
  ------------------
  253|     56|        globfree(&globbuf);
  254|     56|        return;
  255|    211|    } else if (rt != 0) {
  ------------------
  |  Branch (255:16): [True: 0, False: 211]
  ------------------
  256|      0|        SSH_LOG(SSH_LOG_RARE, "Glob error: %s",
  ------------------
  |  |  251|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  257|      0|                fileglob);
  258|      0|        globfree(&globbuf);
  259|      0|        return;
  260|      0|    }
  261|       |
  262|  4.01k|    for (i = 0; i < globbuf.gl_pathc; i++) {
  ------------------
  |  Branch (262:17): [True: 3.80k, False: 211]
  ------------------
  263|  3.80k|        local_parse_file(bind, globbuf.gl_pathv[i], parser_flags, seen, depth);
  264|  3.80k|    }
  265|       |
  266|    211|    globfree(&globbuf);
  267|    211|}
bind_config.c:local_parse_file:
  202|  3.80k|{
  203|  3.80k|    FILE *f;
  204|  3.80k|    char line[MAX_LINE_SIZE] = {0};
  205|  3.80k|    unsigned int count = 0;
  206|  3.80k|    int rv;
  207|       |
  208|  3.80k|    if (depth > LIBSSH_BIND_CONF_MAX_DEPTH) {
  ------------------
  |  |  195|  3.80k|#define LIBSSH_BIND_CONF_MAX_DEPTH 16
  ------------------
  |  Branch (208:9): [True: 0, False: 3.80k]
  ------------------
  209|      0|        ssh_set_error(bind, SSH_FATAL,
  ------------------
  |  |  269|      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|  3.80k|    f = fopen(filename, "r");
  216|  3.80k|    if (f == NULL) {
  ------------------
  |  Branch (216:9): [True: 138, False: 3.66k]
  ------------------
  217|    138|        SSH_LOG(SSH_LOG_RARE, "Cannot find file %s to load",
  ------------------
  |  |  251|    138|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  218|    138|                filename);
  219|    138|        return;
  220|    138|    }
  221|       |
  222|  3.66k|    SSH_LOG(SSH_LOG_PACKET, "Reading additional configuration data from %s",
  ------------------
  |  |  251|  3.66k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  223|  3.66k|            filename);
  224|       |
  225|   529k|    while (fgets(line, sizeof(line), f)) {
  ------------------
  |  Branch (225:12): [True: 526k, False: 3.66k]
  ------------------
  226|   526k|        count++;
  227|   526k|        rv = ssh_bind_config_parse_line(bind, line, count, parser_flags, seen, depth);
  228|   526k|        if (rv < 0) {
  ------------------
  |  Branch (228:13): [True: 2, False: 526k]
  ------------------
  229|      2|            fclose(f);
  230|      2|            return;
  231|      2|        }
  232|   526k|    }
  233|       |
  234|  3.66k|    fclose(f);
  235|  3.66k|    return;
  236|  3.66k|}
bind_config.c:ssh_bind_config_get_match_opcode:
  272|     17|{
  273|     17|    size_t i;
  274|       |
  275|     49|    for (i = 0; ssh_bind_config_match_keyword_table[i].name != NULL; i++) {
  ------------------
  |  Branch (275:17): [True: 46, False: 3]
  ------------------
  276|     46|        if (strcasecmp(keyword, ssh_bind_config_match_keyword_table[i].name) == 0) {
  ------------------
  |  Branch (276:13): [True: 14, False: 32]
  ------------------
  277|     14|            return ssh_bind_config_match_keyword_table[i].opcode;
  278|     14|        }
  279|     46|    }
  280|       |
  281|      3|    return BIND_MATCH_UNKNOWN;
  282|     17|}

ssh_config_get_token:
   77|   523k|{
   78|   523k|    register char *c;
   79|   523k|    bool had_equal = false;
   80|   523k|    char *r = NULL;
   81|       |
   82|       |    /* Ignore leading spaces */
   83|  2.16M|    for (c = *str; *c; c++) {
  ------------------
  |  Branch (83:20): [True: 2.16M, False: 274]
  ------------------
   84|  2.16M|        if (! isblank(*c)) {
  ------------------
  |  Branch (84:13): [True: 522k, False: 1.63M]
  ------------------
   85|   522k|            break;
   86|   522k|        }
   87|  2.16M|    }
   88|       |
   89|       |    /* If we start with quote, return the whole quoted block */
   90|   523k|    if (*c == '\"') {
  ------------------
  |  Branch (90:9): [True: 4.88k, False: 518k]
  ------------------
   91|  93.9k|        for (r = ++c; *c; c++) {
  ------------------
  |  Branch (91:23): [True: 93.9k, False: 25]
  ------------------
   92|  93.9k|            if (*c == '\"' || *c == '\n') {
  ------------------
  |  Branch (92:17): [True: 4.85k, False: 89.1k]
  |  Branch (92:31): [True: 0, False: 89.1k]
  ------------------
   93|  4.85k|                *c = '\0';
   94|  4.85k|                c++;
   95|  4.85k|                break;
   96|  4.85k|            }
   97|       |            /* XXX Unmatched quotes extend to the end of line */
   98|  93.9k|        }
   99|   518k|    } else {
  100|       |        /* Otherwise terminate on space, equal or newline */
  101|  4.04M|        for (r = c; *c; c++) {
  ------------------
  |  Branch (101:21): [True: 3.94M, False: 105k]
  ------------------
  102|  3.94M|            if (*c == '\0') {
  ------------------
  |  Branch (102:17): [True: 0, False: 3.94M]
  ------------------
  103|      0|                goto out;
  104|  3.94M|            } else if (isblank(*c) || *c == '=' || *c == '\n') {
  ------------------
  |  Branch (104:39): [True: 1.79k, False: 3.61M]
  |  Branch (104:52): [True: 87.1k, False: 3.53M]
  ------------------
  105|   413k|                had_equal = (*c == '=');
  106|   413k|                *c = '\0';
  107|   413k|                c++;
  108|   413k|                break;
  109|   413k|            }
  110|  3.94M|        }
  111|   518k|    }
  112|       |
  113|       |    /* Skip any other remaining whitespace */
  114|   788k|    while (isblank(*c) || *c == '\n' || (!had_equal && *c == '=')) {
  ------------------
  |  Branch (114:27): [True: 0, False: 573k]
  |  Branch (114:42): [True: 521k, False: 52.3k]
  |  Branch (114:56): [True: 50.5k, False: 470k]
  ------------------
  115|   265k|        if (*c == '=') {
  ------------------
  |  Branch (115:13): [True: 50.5k, False: 214k]
  ------------------
  116|  50.5k|            had_equal = true;
  117|  50.5k|        }
  118|   265k|        c++;
  119|   265k|    }
  120|   523k|out:
  121|   523k|    *str = c;
  122|   523k|    return r;
  123|   523k|}
ssh_config_get_str_tok:
  143|    661|{
  144|    661|    char *p;
  145|       |
  146|    661|    p = ssh_config_get_token(str);
  147|    661|    if (p && *p) {
  ------------------
  |  Branch (147:9): [True: 661, False: 0]
  |  Branch (147:14): [True: 561, False: 100]
  ------------------
  148|    561|        return p;
  149|    561|    }
  150|       |
  151|    100|    return def;
  152|    661|}

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;
  ------------------
  |  |  311|      0|#define SSH_OK 0     /* No error */
  ------------------
  235|      0|    }
  236|      2|    dh_crypto_initialized = 1;
  237|       |
  238|      2|    ssh_dh_generator = bignum_new();
  ------------------
  |  |   68|      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);
  ------------------
  |  |   75|      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);
  ------------------
  |  |   77|      2|    do {                                     \
  |  |   78|      2|        (*dest) = BN_new();                  \
  |  |   79|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (79:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   80|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   81|      2|        }                                    \
  |  |   82|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (82: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);
  ------------------
  |  |   77|      2|    do {                                     \
  |  |   78|      2|        (*dest) = BN_new();                  \
  |  |   79|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (79:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   80|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   81|      2|        }                                    \
  |  |   82|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (82: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);
  ------------------
  |  |   77|      2|    do {                                     \
  |  |   78|      2|        (*dest) = BN_new();                  \
  |  |   79|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (79:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   80|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   81|      2|        }                                    \
  |  |   82|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (82: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);
  ------------------
  |  |   77|      2|    do {                                     \
  |  |   78|      2|        (*dest) = BN_new();                  \
  |  |   79|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (79:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   80|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   81|      2|        }                                    \
  |  |   82|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (82: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;
  ------------------
  |  |  312|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  268|      2|}

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

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|    383|int ssh_init(void) {
  157|    383|    return _ssh_init(0);
  158|    383|}
ssh_finalize:
  241|    383|int ssh_finalize(void) {
  242|    383|    return _ssh_finalize(0);
  243|    383|}
init.c:_ssh_init:
   62|    385|static int _ssh_init(unsigned constructor) {
   63|       |
   64|    385|    int rc = 0;
   65|       |
   66|    385|    if (!constructor) {
  ------------------
  |  Branch (66:9): [True: 383, False: 2]
  ------------------
   67|    383|        ssh_mutex_lock(&ssh_init_mutex);
   68|    383|    }
   69|       |
   70|    385|    _ssh_initialized++;
   71|       |
   72|    385|    if (_ssh_initialized > 1) {
  ------------------
  |  Branch (72:9): [True: 383, False: 2]
  ------------------
   73|    383|        rc = _ssh_init_ret;
   74|    383|        goto _ret;
   75|    383|    }
   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|    385|_ret:
   98|    385|    _ssh_init_ret = rc;
   99|       |
  100|    385|    if (!constructor) {
  ------------------
  |  Branch (100:9): [True: 383, False: 2]
  ------------------
  101|    383|        ssh_mutex_unlock(&ssh_init_mutex);
  102|    383|    }
  103|       |
  104|    385|    return rc;
  105|      2|}
init.c:_ssh_finalize:
  160|    383|static int _ssh_finalize(unsigned destructor) {
  161|       |
  162|    383|    if (!destructor) {
  ------------------
  |  Branch (162:9): [True: 383, False: 0]
  ------------------
  163|    383|        ssh_mutex_lock(&ssh_init_mutex);
  164|       |
  165|    383|        if (_ssh_initialized > 1) {
  ------------------
  |  Branch (165:13): [True: 383, False: 0]
  ------------------
  166|    383|            _ssh_initialized--;
  167|    383|            ssh_mutex_unlock(&ssh_init_mutex);
  168|    383|            return 0;
  169|    383|        }
  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|    383|}

ssh_kex_get_description:
  289|     27|const char *ssh_kex_get_description(uint32_t algo) {
  290|     27|  if (algo >= SSH_KEX_METHODS) {
  ------------------
  |  |   27|     27|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (290:7): [True: 0, False: 27]
  ------------------
  291|      0|    return NULL;
  292|      0|  }
  293|       |
  294|     27|  return ssh_kex_descriptions[algo];
  295|     27|}
ssh_keep_known_algos:
  959|     33|{
  960|     33|    if (algo > SSH_LANG_S_C) {
  ------------------
  |  Branch (960:9): [True: 0, False: 33]
  ------------------
  961|      0|        return NULL;
  962|      0|    }
  963|       |
  964|     33|    return ssh_find_all_matching(supported_methods[algo], list);
  965|     33|}
ssh_add_to_default_algos:
 1003|    101|{
 1004|    101|    char *tmp = NULL, *ret = NULL;
 1005|       |
 1006|    101|    if (algo > SSH_LANG_S_C || list == NULL || list[0] == '\0') {
  ------------------
  |  Branch (1006:9): [True: 0, False: 101]
  |  Branch (1006:32): [True: 0, False: 101]
  |  Branch (1006:48): [True: 0, False: 101]
  ------------------
 1007|      0|        return NULL;
 1008|      0|    }
 1009|       |
 1010|    101|    if (ssh_fips_mode()) {
  ------------------
  |  |  113|    101|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (113:25): [True: 0, False: 101]
  |  |  ------------------
  ------------------
 1011|      0|        tmp = ssh_append_without_duplicates(fips_methods[algo], list);
 1012|      0|        ret = ssh_find_all_matching(fips_methods[algo], tmp);
 1013|    101|    } else {
 1014|    101|        tmp = ssh_append_without_duplicates(default_methods[algo], list);
 1015|    101|        ret = ssh_find_all_matching(supported_methods[algo], tmp);
 1016|    101|    }
 1017|       |
 1018|    101|    free(tmp);
 1019|    101|    return ret;
 1020|    101|}
ssh_remove_from_default_algos:
 1036|    243|{
 1037|    243|    if (algo > SSH_LANG_S_C) {
  ------------------
  |  Branch (1037:9): [True: 0, False: 243]
  ------------------
 1038|      0|        return NULL;
 1039|      0|    }
 1040|       |
 1041|    243|    if (list == NULL || list[0] == '\0') {
  ------------------
  |  Branch (1041:9): [True: 0, False: 243]
  |  Branch (1041:25): [True: 5, False: 238]
  ------------------
 1042|      5|        if (ssh_fips_mode()) {
  ------------------
  |  |  113|      5|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (113:25): [True: 0, False: 5]
  |  |  ------------------
  ------------------
 1043|      0|            return strdup(fips_methods[algo]);
 1044|      5|        } else {
 1045|      5|            return strdup(default_methods[algo]);
 1046|      5|        }
 1047|      5|    }
 1048|       |
 1049|    238|    if (ssh_fips_mode()) {
  ------------------
  |  |  113|    238|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (113:25): [True: 0, False: 238]
  |  |  ------------------
  ------------------
 1050|      0|        return ssh_remove_all_matching(fips_methods[algo], list);
 1051|    238|    } else {
 1052|    238|        return ssh_remove_all_matching(default_methods[algo], list);
 1053|    238|    }
 1054|    238|}
ssh_prefix_default_algos:
 1074|     79|{
 1075|     79|    char *ret = NULL, *tmp = NULL;
 1076|       |
 1077|     79|    if (algo > SSH_LANG_S_C || list == NULL || list[0] == '\0') {
  ------------------
  |  Branch (1077:9): [True: 0, False: 79]
  |  Branch (1077:32): [True: 0, False: 79]
  |  Branch (1077:48): [True: 0, False: 79]
  ------------------
 1078|      0|        return NULL;
 1079|      0|    }
 1080|       |
 1081|     79|    if (ssh_fips_mode()) {
  ------------------
  |  |  113|     79|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (113:25): [True: 0, False: 79]
  |  |  ------------------
  ------------------
 1082|      0|        tmp = ssh_prefix_without_duplicates(fips_methods[algo], list);
 1083|      0|        ret = ssh_find_all_matching(fips_methods[algo], tmp);
 1084|     79|    } else {
 1085|     79|        tmp = ssh_prefix_without_duplicates(default_methods[algo], list);
 1086|     79|        ret = ssh_find_all_matching(supported_methods[algo], tmp);
 1087|     79|    }
 1088|       |
 1089|     79|    free(tmp);
 1090|     79|    return ret;
 1091|     79|}

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;
  ------------------
  |  |  311|      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 "
  ------------------
  |  |  251|      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;
  ------------------
  |  |  311|      2|#define SSH_OK 0     /* No error */
  ------------------
 1417|      2|}

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

ssh_options_set_algo:
  232|    456|{
  233|       |    /* When the list start with +,-,^ the filtration of unknown algorithms
  234|       |     * gets handled inside the helper functions, otherwise the list is taken
  235|       |     * as it is. */
  236|    456|    char *p = (char *)list;
  237|       |
  238|    456|    if (algo < SSH_COMP_C_S) {
  ------------------
  |  Branch (238:9): [True: 456, False: 0]
  ------------------
  239|    456|        if (list[0] == '+') {
  ------------------
  |  Branch (239:13): [True: 101, False: 355]
  ------------------
  240|    101|            p = ssh_add_to_default_algos(algo, list+1);
  241|    355|        } else if (list[0] == '-') {
  ------------------
  |  Branch (241:20): [True: 243, False: 112]
  ------------------
  242|    243|            p = ssh_remove_from_default_algos(algo, list+1);
  243|    243|        } else if (list[0] == '^') {
  ------------------
  |  Branch (243:20): [True: 79, False: 33]
  ------------------
  244|     79|            p = ssh_prefix_default_algos(algo, list+1);
  245|     79|        }
  246|    456|    }
  247|       |
  248|    456|    if (p == list) {
  ------------------
  |  Branch (248:9): [True: 33, False: 423]
  ------------------
  249|     33|        if (ssh_fips_mode()) {
  ------------------
  |  |  113|     33|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (113:25): [True: 0, False: 33]
  |  |  ------------------
  ------------------
  250|      0|            p = ssh_keep_fips_algos(algo, list);
  251|     33|        } else {
  252|     33|            p = ssh_keep_known_algos(algo, list);
  253|     33|        }
  254|     33|    }
  255|       |
  256|    456|    if (p == NULL) {
  ------------------
  |  Branch (256:9): [True: 27, False: 429]
  ------------------
  257|     27|        ssh_set_error(session, SSH_REQUEST_DENIED,
  ------------------
  |  |  269|     27|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  258|     27|                "Setting method: no allowed algorithm for method \"%s\" (%s)",
  259|     27|                ssh_kex_get_description(algo), list);
  260|     27|        return -1;
  261|     27|    }
  262|       |
  263|    429|    SAFE_FREE(*place);
  ------------------
  |  |  324|    429|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 4, False: 425]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  264|    429|    *place = p;
  265|       |
  266|    429|    return 0;
  267|    456|}
ssh_bind_options_set:
 1860|    476|{
 1861|    476|  bool allowed;
 1862|    476|  char *p, *q;
 1863|    476|  const char *v;
 1864|    476|  int i, rc;
 1865|    476|  char **wanted_methods = sshbind->wanted_methods;
 1866|       |
 1867|    476|  if (sshbind == NULL) {
  ------------------
  |  Branch (1867:7): [True: 0, False: 476]
  ------------------
 1868|      0|    return -1;
 1869|      0|  }
 1870|       |
 1871|    476|  switch (type) {
 1872|      0|    case SSH_BIND_OPTIONS_HOSTKEY:
  ------------------
  |  Branch (1872:5): [True: 0, False: 476]
  ------------------
 1873|      0|      if (value == NULL) {
  ------------------
  |  Branch (1873:11): [True: 0, False: 0]
  ------------------
 1874|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1875|      0|        return -1;
 1876|      0|      } else {
 1877|      0|          int key_type;
 1878|      0|          ssh_key key;
 1879|      0|          ssh_key *bind_key_loc = NULL;
 1880|      0|          char **bind_key_path_loc;
 1881|       |
 1882|      0|          rc = ssh_pki_import_privkey_file(value, NULL, NULL, NULL, &key);
 1883|      0|          if (rc != SSH_OK) {
  ------------------
  |  |  311|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1883:15): [True: 0, False: 0]
  ------------------
 1884|      0|              return -1;
 1885|      0|          }
 1886|      0|          allowed = ssh_bind_key_size_allowed(sshbind, key);
 1887|      0|          if (!allowed) {
  ------------------
  |  Branch (1887:15): [True: 0, False: 0]
  ------------------
 1888|      0|              ssh_set_error(sshbind,
  ------------------
  |  |  269|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1889|      0|                            SSH_FATAL,
 1890|      0|                            "The host key size %d is too small.",
 1891|      0|                            ssh_key_size(key));
 1892|      0|              ssh_key_free(key);
 1893|      0|              return -1;
 1894|      0|          }
 1895|       |
 1896|      0|          key_type = ssh_key_type(key);
 1897|      0|          switch (key_type) {
 1898|      0|          case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (1898:11): [True: 0, False: 0]
  ------------------
 1899|      0|          case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (1899:11): [True: 0, False: 0]
  ------------------
 1900|      0|          case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (1900:11): [True: 0, False: 0]
  ------------------
 1901|      0|#ifdef HAVE_ECC
 1902|      0|              bind_key_loc = &sshbind->ecdsa;
 1903|      0|              bind_key_path_loc = &sshbind->ecdsakey;
 1904|       |#else
 1905|       |              ssh_set_error(sshbind,
 1906|       |                            SSH_FATAL,
 1907|       |                            "ECDSA key used and libssh compiled "
 1908|       |                            "without ECDSA support");
 1909|       |#endif
 1910|      0|              break;
 1911|      0|          case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (1911:11): [True: 0, False: 0]
  ------------------
 1912|      0|              bind_key_loc = &sshbind->rsa;
 1913|      0|              bind_key_path_loc = &sshbind->rsakey;
 1914|      0|              break;
 1915|      0|          case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (1915:11): [True: 0, False: 0]
  ------------------
 1916|      0|              bind_key_loc = &sshbind->ed25519;
 1917|      0|              bind_key_path_loc = &sshbind->ed25519key;
 1918|      0|              break;
 1919|      0|          default:
  ------------------
  |  Branch (1919:11): [True: 0, False: 0]
  ------------------
 1920|      0|              ssh_set_error(sshbind,
  ------------------
  |  |  269|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1921|      0|                            SSH_FATAL,
 1922|      0|                            "Unsupported key type %d", key_type);
 1923|      0|          }
 1924|       |
 1925|      0|          if (bind_key_loc == NULL) {
  ------------------
  |  Branch (1925:15): [True: 0, False: 0]
  ------------------
 1926|      0|              ssh_key_free(key);
 1927|      0|              return -1;
 1928|      0|          }
 1929|       |
 1930|       |          /* Set the location of the key on disk even though we don't
 1931|       |             need it in case some other function wants it */
 1932|      0|          rc = ssh_bind_set_key(sshbind, bind_key_path_loc, value);
 1933|      0|          if (rc < 0) {
  ------------------
  |  Branch (1933:15): [True: 0, False: 0]
  ------------------
 1934|      0|              ssh_key_free(key);
 1935|      0|              return -1;
 1936|      0|          }
 1937|      0|          ssh_key_free(*bind_key_loc);
 1938|      0|          *bind_key_loc = key;
 1939|      0|      }
 1940|      0|      break;
 1941|      0|    case SSH_BIND_OPTIONS_IMPORT_KEY:
  ------------------
  |  Branch (1941:5): [True: 0, False: 476]
  ------------------
 1942|      0|        if (value == NULL) {
  ------------------
  |  Branch (1942:13): [True: 0, False: 0]
  ------------------
 1943|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1944|      0|            return -1;
 1945|      0|        } else {
 1946|      0|            int key_type;
 1947|      0|            ssh_key *bind_key_loc = NULL;
 1948|      0|            ssh_key key = (ssh_key)value;
 1949|       |
 1950|      0|            allowed = ssh_bind_key_size_allowed(sshbind, key);
 1951|      0|            if (!allowed) {
  ------------------
  |  Branch (1951:17): [True: 0, False: 0]
  ------------------
 1952|      0|                ssh_set_error(sshbind,
  ------------------
  |  |  269|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1953|      0|                              SSH_FATAL,
 1954|      0|                              "The host key size %d is too small.",
 1955|      0|                              ssh_key_size(key));
 1956|      0|                return -1;
 1957|      0|            }
 1958|       |
 1959|      0|            key_type = ssh_key_type(key);
 1960|      0|            switch (key_type) {
 1961|      0|                case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (1961:17): [True: 0, False: 0]
  ------------------
 1962|      0|                case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (1962:17): [True: 0, False: 0]
  ------------------
 1963|      0|                case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (1963:17): [True: 0, False: 0]
  ------------------
 1964|      0|#ifdef HAVE_ECC
 1965|      0|                    bind_key_loc = &sshbind->ecdsa;
 1966|       |#else
 1967|       |                    ssh_set_error(sshbind,
 1968|       |                                  SSH_FATAL,
 1969|       |                                  "ECDSA key used and libssh compiled "
 1970|       |                                  "without ECDSA support");
 1971|       |#endif
 1972|      0|                    break;
 1973|      0|                case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (1973:17): [True: 0, False: 0]
  ------------------
 1974|      0|                    bind_key_loc = &sshbind->rsa;
 1975|      0|                    break;
 1976|      0|                case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (1976:17): [True: 0, False: 0]
  ------------------
 1977|      0|                    bind_key_loc = &sshbind->ed25519;
 1978|      0|                    break;
 1979|      0|                default:
  ------------------
  |  Branch (1979:17): [True: 0, False: 0]
  ------------------
 1980|      0|                    ssh_set_error(sshbind,
  ------------------
  |  |  269|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1981|      0|                                  SSH_FATAL,
 1982|      0|                                  "Unsupported key type %d", key_type);
 1983|      0|            }
 1984|      0|            if (bind_key_loc == NULL)
  ------------------
  |  Branch (1984:17): [True: 0, False: 0]
  ------------------
 1985|      0|                return -1;
 1986|      0|            ssh_key_free(*bind_key_loc);
 1987|      0|            *bind_key_loc = key;
 1988|      0|        }
 1989|      0|        break;
 1990|      0|    case SSH_BIND_OPTIONS_BINDADDR:
  ------------------
  |  Branch (1990:5): [True: 0, False: 476]
  ------------------
 1991|      0|      if (value == NULL) {
  ------------------
  |  Branch (1991:11): [True: 0, False: 0]
  ------------------
 1992|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1993|      0|        return -1;
 1994|      0|      } else {
 1995|      0|        SAFE_FREE(sshbind->bindaddr);
  ------------------
  |  |  324|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1996|      0|        sshbind->bindaddr = strdup(value);
 1997|      0|        if (sshbind->bindaddr == NULL) {
  ------------------
  |  Branch (1997:13): [True: 0, False: 0]
  ------------------
 1998|      0|          ssh_set_error_oom(sshbind);
  ------------------
  |  |  276|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1999|      0|          return -1;
 2000|      0|        }
 2001|      0|      }
 2002|      0|      break;
 2003|      0|    case SSH_BIND_OPTIONS_BINDPORT:
  ------------------
  |  Branch (2003:5): [True: 0, False: 476]
  ------------------
 2004|      0|      if (value == NULL) {
  ------------------
  |  Branch (2004:11): [True: 0, False: 0]
  ------------------
 2005|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2006|      0|        return -1;
 2007|      0|      } else {
 2008|      0|        int *x = (int *) value;
 2009|      0|        sshbind->bindport = *x & 0xffffU;
 2010|      0|      }
 2011|      0|      break;
 2012|      5|    case SSH_BIND_OPTIONS_BINDPORT_STR:
  ------------------
  |  Branch (2012:5): [True: 5, False: 471]
  ------------------
 2013|      5|      if (value == NULL) {
  ------------------
  |  Branch (2013:11): [True: 0, False: 5]
  ------------------
 2014|      0|        sshbind->bindport = 22 & 0xffffU;
 2015|      5|      } else {
 2016|      5|        q = strdup(value);
 2017|      5|        if (q == NULL) {
  ------------------
  |  Branch (2017:13): [True: 0, False: 5]
  ------------------
 2018|      0|          ssh_set_error_oom(sshbind);
  ------------------
  |  |  276|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2019|      0|          return -1;
 2020|      0|        }
 2021|      5|        i = strtol(q, &p, 10);
 2022|      5|        if (q == p) {
  ------------------
  |  Branch (2022:13): [True: 5, False: 0]
  ------------------
 2023|      5|          SAFE_FREE(q);
  ------------------
  |  |  324|      5|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 5, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2024|      5|        }
 2025|      5|        SAFE_FREE(q);
  ------------------
  |  |  324|      5|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 5]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2026|       |
 2027|      5|        sshbind->bindport = i & 0xffffU;
 2028|      5|      }
 2029|      5|      break;
 2030|     15|    case SSH_BIND_OPTIONS_LOG_VERBOSITY:
  ------------------
  |  Branch (2030:5): [True: 15, False: 461]
  ------------------
 2031|     15|      if (value == NULL) {
  ------------------
  |  Branch (2031:11): [True: 0, False: 15]
  ------------------
 2032|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2033|      0|        return -1;
 2034|     15|      } else {
 2035|     15|        int *x = (int *) value;
 2036|     15|        ssh_set_log_level(*x & 0xffffU);
 2037|     15|      }
 2038|     15|      break;
 2039|     15|    case SSH_BIND_OPTIONS_LOG_VERBOSITY_STR:
  ------------------
  |  Branch (2039:5): [True: 0, False: 476]
  ------------------
 2040|      0|      if (value == NULL) {
  ------------------
  |  Branch (2040:11): [True: 0, False: 0]
  ------------------
 2041|      0|      	ssh_set_log_level(0);
 2042|      0|      } else {
 2043|      0|        q = strdup(value);
 2044|      0|        if (q == NULL) {
  ------------------
  |  Branch (2044:13): [True: 0, False: 0]
  ------------------
 2045|      0|          ssh_set_error_oom(sshbind);
  ------------------
  |  |  276|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2046|      0|          return -1;
 2047|      0|        }
 2048|      0|        i = strtol(q, &p, 10);
 2049|      0|        if (q == p) {
  ------------------
  |  Branch (2049:13): [True: 0, False: 0]
  ------------------
 2050|      0|          SAFE_FREE(q);
  ------------------
  |  |  324|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2051|      0|        }
 2052|      0|        SAFE_FREE(q);
  ------------------
  |  |  324|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2053|       |
 2054|      0|        ssh_set_log_level(i & 0xffffU);
 2055|      0|      }
 2056|      0|      break;
 2057|      0|    case SSH_BIND_OPTIONS_RSAKEY:
  ------------------
  |  Branch (2057:5): [True: 0, False: 476]
  ------------------
 2058|      0|        rc = ssh_bind_set_key(sshbind, &sshbind->rsakey, value);
 2059|      0|        if (rc < 0) {
  ------------------
  |  Branch (2059:13): [True: 0, False: 0]
  ------------------
 2060|      0|            return -1;
 2061|      0|        }
 2062|      0|        break;
 2063|      0|    case SSH_BIND_OPTIONS_ECDSAKEY:
  ------------------
  |  Branch (2063:5): [True: 0, False: 476]
  ------------------
 2064|      0|        rc = ssh_bind_set_key(sshbind, &sshbind->ecdsakey, value);
 2065|      0|        if (rc < 0) {
  ------------------
  |  Branch (2065:13): [True: 0, False: 0]
  ------------------
 2066|      0|            return -1;
 2067|      0|        }
 2068|      0|        break;
 2069|      0|    case SSH_BIND_OPTIONS_BANNER:
  ------------------
  |  Branch (2069:5): [True: 0, False: 476]
  ------------------
 2070|      0|      if (value == NULL) {
  ------------------
  |  Branch (2070:11): [True: 0, False: 0]
  ------------------
 2071|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2072|      0|        return -1;
 2073|      0|      } else {
 2074|      0|        SAFE_FREE(sshbind->banner);
  ------------------
  |  |  324|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2075|      0|        sshbind->banner = strdup(value);
 2076|      0|        if (sshbind->banner == NULL) {
  ------------------
  |  Branch (2076:13): [True: 0, False: 0]
  ------------------
 2077|      0|          ssh_set_error_oom(sshbind);
  ------------------
  |  |  276|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2078|      0|          return -1;
 2079|      0|        }
 2080|      0|      }
 2081|      0|      break;
 2082|     36|    case SSH_BIND_OPTIONS_CIPHERS_C_S:
  ------------------
  |  Branch (2082:5): [True: 36, False: 440]
  ------------------
 2083|     36|        v = value;
 2084|     36|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2084:13): [True: 0, False: 36]
  |  Branch (2084:26): [True: 0, False: 36]
  ------------------
 2085|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2086|      0|            return -1;
 2087|     36|        } else {
 2088|     36|            rc = ssh_bind_set_algo(sshbind,
 2089|     36|                                   SSH_CRYPT_C_S,
 2090|     36|                                   v,
 2091|     36|                                   &wanted_methods[SSH_CRYPT_C_S]);
 2092|     36|            if (rc < 0) {
  ------------------
  |  Branch (2092:17): [True: 2, False: 34]
  ------------------
 2093|      2|                return -1;
 2094|      2|            }
 2095|     36|        }
 2096|     34|        break;
 2097|     34|    case SSH_BIND_OPTIONS_CIPHERS_S_C:
  ------------------
  |  Branch (2097:5): [True: 34, False: 442]
  ------------------
 2098|     34|        v = value;
 2099|     34|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2099:13): [True: 0, False: 34]
  |  Branch (2099:26): [True: 0, False: 34]
  ------------------
 2100|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2101|      0|            return -1;
 2102|     34|        } else {
 2103|     34|            rc = ssh_bind_set_algo(sshbind,
 2104|     34|                                   SSH_CRYPT_S_C,
 2105|     34|                                   v,
 2106|     34|                                   &wanted_methods[SSH_CRYPT_S_C]);
 2107|     34|            if (rc < 0) {
  ------------------
  |  Branch (2107:17): [True: 0, False: 34]
  ------------------
 2108|      0|                return -1;
 2109|      0|            }
 2110|     34|        }
 2111|     34|        break;
 2112|     34|    case SSH_BIND_OPTIONS_KEY_EXCHANGE:
  ------------------
  |  Branch (2112:5): [True: 5, False: 471]
  ------------------
 2113|      5|        v = value;
 2114|      5|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2114:13): [True: 0, False: 5]
  |  Branch (2114:26): [True: 0, False: 5]
  ------------------
 2115|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2116|      0|            return -1;
 2117|      5|        } else {
 2118|      5|            rc = ssh_bind_set_algo(sshbind,
 2119|      5|                                   SSH_KEX,
 2120|      5|                                   v,
 2121|      5|                                   &wanted_methods[SSH_KEX]);
 2122|      5|            if (rc < 0) {
  ------------------
  |  Branch (2122:17): [True: 0, False: 5]
  ------------------
 2123|      0|                return -1;
 2124|      0|            }
 2125|      5|        }
 2126|      5|        break;
 2127|    190|    case SSH_BIND_OPTIONS_HMAC_C_S:
  ------------------
  |  Branch (2127:5): [True: 190, False: 286]
  ------------------
 2128|    190|        v = value;
 2129|    190|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2129:13): [True: 0, False: 190]
  |  Branch (2129:26): [True: 0, False: 190]
  ------------------
 2130|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2131|      0|            return -1;
 2132|    190|        } else {
 2133|    190|            rc = ssh_bind_set_algo(sshbind,
 2134|    190|                                   SSH_MAC_C_S,
 2135|    190|                                   v,
 2136|    190|                                   &wanted_methods[SSH_MAC_C_S]);
 2137|    190|            if (rc < 0) {
  ------------------
  |  Branch (2137:17): [True: 23, False: 167]
  ------------------
 2138|     23|                return -1;
 2139|     23|            }
 2140|    190|        }
 2141|    167|        break;
 2142|    167|     case SSH_BIND_OPTIONS_HMAC_S_C:
  ------------------
  |  Branch (2142:6): [True: 167, False: 309]
  ------------------
 2143|    167|        v = value;
 2144|    167|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2144:13): [True: 0, False: 167]
  |  Branch (2144:26): [True: 0, False: 167]
  ------------------
 2145|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2146|      0|            return -1;
 2147|    167|        } else {
 2148|    167|            rc = ssh_bind_set_algo(sshbind,
 2149|    167|                                   SSH_MAC_S_C,
 2150|    167|                                   v,
 2151|    167|                                   &wanted_methods[SSH_MAC_S_C]);
 2152|    167|            if (rc < 0) {
  ------------------
  |  Branch (2152:17): [True: 0, False: 167]
  ------------------
 2153|      0|                return -1;
 2154|      0|            }
 2155|    167|        }
 2156|    167|        break;
 2157|    167|    case SSH_BIND_OPTIONS_CONFIG_DIR:
  ------------------
  |  Branch (2157:5): [True: 0, False: 476]
  ------------------
 2158|      0|        v = value;
 2159|      0|        SAFE_FREE(sshbind->config_dir);
  ------------------
  |  |  324|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2160|      0|        if (v == NULL) {
  ------------------
  |  Branch (2160:13): [True: 0, False: 0]
  ------------------
 2161|      0|            break;
 2162|      0|        } else if (v[0] == '\0') {
  ------------------
  |  Branch (2162:20): [True: 0, False: 0]
  ------------------
 2163|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2164|      0|            return -1;
 2165|      0|        } else {
 2166|      0|            sshbind->config_dir = ssh_path_expand_tilde(v);
 2167|      0|            if (sshbind->config_dir == NULL) {
  ------------------
  |  Branch (2167:17): [True: 0, False: 0]
  ------------------
 2168|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  276|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2169|      0|                return -1;
 2170|      0|            }
 2171|      0|        }
 2172|      0|        break;
 2173|      9|    case SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES:
  ------------------
  |  Branch (2173:5): [True: 9, False: 467]
  ------------------
 2174|      9|        v = value;
 2175|      9|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2175:13): [True: 0, False: 9]
  |  Branch (2175:26): [True: 0, False: 9]
  ------------------
 2176|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2177|      0|            return -1;
 2178|      9|        } else {
 2179|      9|            rc = ssh_bind_set_algo(sshbind,
 2180|      9|                                   SSH_HOSTKEYS,
 2181|      9|                                   v,
 2182|      9|                                   &sshbind->pubkey_accepted_key_types);
 2183|      9|            if (rc < 0) {
  ------------------
  |  Branch (2183:17): [True: 1, False: 8]
  ------------------
 2184|      1|                return -1;
 2185|      1|            }
 2186|      9|        }
 2187|      8|        break;
 2188|     15|    case SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS:
  ------------------
  |  Branch (2188:5): [True: 15, False: 461]
  ------------------
 2189|     15|        v = value;
 2190|     15|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2190:13): [True: 0, False: 15]
  |  Branch (2190:26): [True: 0, False: 15]
  ------------------
 2191|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2192|      0|            return -1;
 2193|     15|        } else {
 2194|     15|            rc = ssh_bind_set_algo(sshbind,
 2195|     15|                                   SSH_HOSTKEYS,
 2196|     15|                                   v,
 2197|     15|                                   &wanted_methods[SSH_HOSTKEYS]);
 2198|     15|            if (rc < 0) {
  ------------------
  |  Branch (2198:17): [True: 1, False: 14]
  ------------------
 2199|      1|                return -1;
 2200|      1|            }
 2201|     15|        }
 2202|     14|        break;
 2203|     14|    case SSH_BIND_OPTIONS_PROCESS_CONFIG:
  ------------------
  |  Branch (2203:5): [True: 0, False: 476]
  ------------------
 2204|      0|        if (value == NULL) {
  ------------------
  |  Branch (2204:13): [True: 0, False: 0]
  ------------------
 2205|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2206|      0|            return -1;
 2207|      0|        } else {
 2208|      0|            bool *x = (bool *)value;
 2209|      0|            sshbind->config_processed = !(*x);
 2210|      0|        }
 2211|      0|        break;
 2212|      0|    case SSH_BIND_OPTIONS_MODULI:
  ------------------
  |  Branch (2212:5): [True: 0, False: 476]
  ------------------
 2213|      0|        if (value == NULL) {
  ------------------
  |  Branch (2213:13): [True: 0, False: 0]
  ------------------
 2214|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2215|      0|            return -1;
 2216|      0|        } else {
 2217|      0|            SAFE_FREE(sshbind->moduli_file);
  ------------------
  |  |  324|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2218|      0|            sshbind->moduli_file = strdup(value);
 2219|      0|            if (sshbind->moduli_file == NULL) {
  ------------------
  |  Branch (2219:17): [True: 0, False: 0]
  ------------------
 2220|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  276|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2221|      0|                return -1;
 2222|      0|            }
 2223|      0|        }
 2224|      0|        break;
 2225|      0|    case SSH_BIND_OPTIONS_RSA_MIN_SIZE:
  ------------------
  |  Branch (2225:5): [True: 0, False: 476]
  ------------------
 2226|      0|        if (value == NULL) {
  ------------------
  |  Branch (2226:13): [True: 0, False: 0]
  ------------------
 2227|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  280|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2228|      0|            return -1;
 2229|      0|        } else {
 2230|      0|            int *x = (int *)value;
 2231|      0|            if (*x > 0 && *x < 768) {
  ------------------
  |  Branch (2231:17): [True: 0, False: 0]
  |  Branch (2231:27): [True: 0, False: 0]
  ------------------
 2232|      0|                ssh_set_error(sshbind, SSH_REQUEST_DENIED,
  ------------------
  |  |  269|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2233|      0|                              "The provided value (%u) for minimal RSA key "
 2234|      0|                              "size is too small. Use at least 768 bits.", *x);
 2235|      0|                return -1;
 2236|      0|            }
 2237|      0|            sshbind->rsa_min_size = *x;
 2238|      0|        }
 2239|      0|        break;
 2240|      0|    default:
  ------------------
  |  Branch (2240:5): [True: 0, False: 476]
  ------------------
 2241|      0|      ssh_set_error(sshbind, SSH_REQUEST_DENIED, "Unknown ssh option %d", type);
  ------------------
  |  |  269|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2242|      0|      return -1;
 2243|      0|    break;
 2244|    476|  }
 2245|       |
 2246|    449|  return 0;
 2247|    476|}
options.c:ssh_bind_set_algo:
 1720|    456|{
 1721|       |    /* sshbind is needed only for ssh_set_error which takes void*
 1722|       |     * the typecast is only to satisfy function parameter type */
 1723|    456|    return ssh_options_set_algo((ssh_session)sshbind, algo, list, place);
 1724|    456|}

ssh_key_free:
  194|  1.14k|{
  195|  1.14k|    if (key) {
  ------------------
  |  Branch (195:9): [True: 0, False: 1.14k]
  ------------------
  196|      0|        ssh_key_clean(key);
  197|      0|        SAFE_FREE(key);
  ------------------
  |  |  324|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (324:31): [True: 0, False: 0]
  |  |  |  Branch (324:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  198|      0|    }
  199|  1.14k|}

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

ssh_socket_init:
  118|      2|{
  119|      2|    if (sockets_initialized == 0) {
  ------------------
  |  Branch (119:9): [True: 2, False: 0]
  ------------------
  120|       |#ifdef _WIN32
  121|       |        struct WSAData wsaData;
  122|       |
  123|       |        /* Initiates use of the Winsock DLL by a process. */
  124|       |        if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
  125|       |            return -1;
  126|       |        }
  127|       |#endif
  128|      2|        ssh_poll_init();
  129|       |
  130|      2|        sockets_initialized = 1;
  131|      2|    }
  132|       |
  133|      2|    return 0;
  134|      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;
  ------------------
  |  |  311|      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) {
  ------------------
  |  |  311|      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;
  ------------------
  |  |  311|      2|#define SSH_OK 0     /* No error */
  ------------------
   31|      2|}

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

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

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

