fuzz_early_setup:
   23|      2|void fuzz_early_setup(void) {
   24|       |    /* Set stderr to point to normal stderr by default */
   25|       |    fuzz.fake_stderr = stderr;
   26|      2|}
fuzz_common_setup:
   28|      1|void fuzz_common_setup(void) {
   29|      1|	disallow_core();
   30|      1|    fuzz.fuzzing = 1;
   31|      1|    fuzz.wrapfds = 1;
   32|      1|    fuzz.do_jmp = 1;
   33|      1|    fuzz.input = m_malloc(sizeof(buffer));
   34|      1|    _dropbear_log = fuzz_dropbear_log;
   35|      1|    crypto_init();
   36|      1|    fuzz_seed("start", 5);
   37|       |    /* let any messages get flushed */
   38|      1|    setlinebuf(stdout);
   39|       |#if DEBUG_TRACE
   40|       |    if (debug_trace)
   41|       |    {
   42|       |        fprintf(stderr, "Dropbear fuzzer: -v specified, not disabling stderr output\n");
   43|       |    }
   44|       |    else
   45|       |#endif
   46|      1|    if (getenv("DROPBEAR_KEEP_STDERR")) {
  ------------------
  |  Branch (46:9): [True: 0, False: 1]
  ------------------
   47|      0|        fprintf(stderr, "Dropbear fuzzer: DROPBEAR_KEEP_STDERR, not disabling stderr output\n");
   48|      0|    } 
   49|      1|    else 
   50|      1|    {
   51|      1|        fprintf(stderr, "Dropbear fuzzer: Disabling stderr output\n");
   52|      1|        fuzz.fake_stderr = fopen("/dev/null", "w");
   53|       |        assert(fuzz.fake_stderr);
  ------------------
  |  Branch (53:9): [True: 0, False: 1]
  |  Branch (53:9): [True: 1, False: 0]
  ------------------
   54|      1|    }
   55|      1|}
fuzz_set_input:
   57|  2.51k|int fuzz_set_input(const uint8_t *Data, size_t Size) {
   58|       |
   59|  2.51k|    fuzz.input->data = (unsigned char*)Data;
   60|  2.51k|    fuzz.input->size = Size;
   61|  2.51k|    fuzz.input->len = Size;
   62|  2.51k|    fuzz.input->pos = 0;
   63|       |
   64|  2.51k|    memset(&ses, 0x0, sizeof(ses));
   65|  2.51k|    memset(&svr_ses, 0x0, sizeof(svr_ses));
   66|  2.51k|    memset(&cli_ses, 0x0, sizeof(cli_ses));
   67|  2.51k|    wrapfd_setup(fuzz.input);
   68|       |    // printhex("input", fuzz.input->data, fuzz.input->len);
   69|       |
   70|  2.51k|    fuzz_seed(fuzz.input->data, MIN(fuzz.input->len, 16));
  ------------------
  |  Branch (70:33): [True: 143, False: 2.37k]
  ------------------
   71|       |
   72|  2.51k|    return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|  2.51k|#define DROPBEAR_SUCCESS 0
  ------------------
   73|  2.51k|}
fuzz-common.c:fuzz_dropbear_log:
   84|  3.28k|static void fuzz_dropbear_log(int UNUSED(priority), const char* UNUSED(format), va_list UNUSED(param)) {
   85|       |    /* No print */
   86|  3.28k|}

wrapfd_setup:
   32|  2.51k|void wrapfd_setup(buffer *buf) {
   33|  2.51k|	TRACE(("wrapfd_setup"))
   34|       |
   35|       |	// clean old ones
   36|  2.51k|	int i;
   37|  2.51k|	for (i = 0; i <= wrapfd_maxfd; i++) {
  ------------------
  |  Branch (37:14): [True: 0, False: 2.51k]
  ------------------
   38|      0|		if (wrap_fds[i].mode != UNUSED) {
  ------------------
  |  Branch (38:7): [True: 0, False: 0]
  ------------------
   39|      0|			wrapfd_remove(i);
   40|      0|		}
   41|      0|	}
   42|  2.51k|	wrapfd_maxfd = -1;
   43|       |
   44|  2.51k|	memset(rand_state, 0x0, sizeof(rand_state));
   45|  2.51k|	wrapfd_setseed(50);
   46|  2.51k|	input_buf = buf;
   47|  2.51k|}
wrapfd_setseed:
   49|  2.51k|void wrapfd_setseed(uint32_t seed) {
   50|  2.51k|	memcpy(rand_state, &seed, sizeof(seed));
   51|  2.51k|	nrand48(rand_state);
   52|  2.51k|}

LLVMFuzzerTestOneInput:
   10|  2.51k|int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   11|  2.51k|	static int once = 0;
   12|  2.51k|	if (!once) {
  ------------------
  |  Branch (12:6): [True: 1, False: 2.51k]
  ------------------
   13|      1|		setup_fuzzer();
   14|      1|		once = 1;
   15|      1|	}
   16|       |
   17|  2.51k|	if (fuzz_set_input(Data, Size) == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|  2.51k|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (17:6): [True: 0, False: 2.51k]
  ------------------
   18|      0|		return 0;
   19|      0|	}
   20|       |
   21|  2.51k|	m_malloc_set_epoch(1);
   22|       |
   23|  2.51k|	if (setjmp(fuzz.jmp) == 0) {
  ------------------
  |  Branch (23:6): [True: 2.51k, False: 0]
  ------------------
   24|  2.51k|		buffer *line = buf_getstringbuf(fuzz.input);
   25|  2.51k|		buffer *keyblob = buf_getstringbuf(fuzz.input);
   26|       |
   27|  2.51k|		unsigned int algolen;
   28|  2.51k|		char* algoname = buf_getstring(keyblob, &algolen);
   29|       |
   30|  2.51k|		if (signature_type_from_name(algoname, algolen) == DROPBEAR_SIGNATURE_NONE) {
  ------------------
  |  Branch (30:7): [True: 188, False: 2.32k]
  ------------------
   31|    188|			dropbear_exit("fuzzer imagined a bogus algorithm");
   32|    188|		}
   33|       |
   34|  2.32k|		fuzz_checkpubkey_line(line, 5, "/home/me/authorized_keys",
   35|  2.32k|			algoname, algolen,
   36|  2.32k|			keyblob->data, keyblob->len);
   37|       |
   38|  2.32k|		buf_free(line);
   39|  2.32k|		buf_free(keyblob);
   40|  2.32k|		m_free(algoname);
  ------------------
  |  |   24|  2.32k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 2.32k]
  |  |  ------------------
  ------------------
   41|  2.32k|		m_malloc_free_epoch(1, 0);
   42|  2.32k|	} else {
   43|      0|		m_malloc_free_epoch(1, 1);
   44|      0|		TRACE(("dropbear_exit longjmped"))
   45|       |		/* dropbear_exit jumped here */
   46|      0|	}
   47|       |
   48|  2.32k|	return 0;
   49|  2.51k|}
fuzzer-pubkey.c:setup_fuzzer:
    6|      1|static void setup_fuzzer(void) {
    7|      1|	fuzz_common_setup();
    8|      1|}

sha256_init:
  205|  2.51k|{
  206|  2.51k|    LTC_ARGCHK(md != NULL);
  ------------------
  |  |   32|  2.51k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.51k]
  |  |  |  Branch (32:87): [Folded, False: 2.51k]
  |  |  ------------------
  ------------------
  207|       |
  208|  2.51k|    md->sha256.curlen = 0;
  209|  2.51k|    md->sha256.length = 0;
  210|  2.51k|    md->sha256.state[0] = 0x6A09E667UL;
  211|  2.51k|    md->sha256.state[1] = 0xBB67AE85UL;
  212|  2.51k|    md->sha256.state[2] = 0x3C6EF372UL;
  213|  2.51k|    md->sha256.state[3] = 0xA54FF53AUL;
  214|  2.51k|    md->sha256.state[4] = 0x510E527FUL;
  215|  2.51k|    md->sha256.state[5] = 0x9B05688CUL;
  216|  2.51k|    md->sha256.state[6] = 0x1F83D9ABUL;
  217|  2.51k|    md->sha256.state[7] = 0x5BE0CD19UL;
  218|  2.51k|    return CRYPT_OK;
  219|  2.51k|}
sha256_done:
  237|  2.51k|{
  238|  2.51k|    int i;
  239|       |
  240|  2.51k|    LTC_ARGCHK(md  != NULL);
  ------------------
  |  |   32|  2.51k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.51k]
  |  |  |  Branch (32:87): [Folded, False: 2.51k]
  |  |  ------------------
  ------------------
  241|  2.51k|    LTC_ARGCHK(out != NULL);
  ------------------
  |  |   32|  2.51k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.51k]
  |  |  |  Branch (32:87): [Folded, False: 2.51k]
  |  |  ------------------
  ------------------
  242|       |
  243|  2.51k|    if (md->sha256.curlen >= sizeof(md->sha256.buf)) {
  ------------------
  |  Branch (243:9): [True: 0, False: 2.51k]
  ------------------
  244|      0|       return CRYPT_INVALID_ARG;
  245|      0|    }
  246|       |
  247|       |
  248|       |    /* increase the length of the message */
  249|  2.51k|    md->sha256.length += md->sha256.curlen * 8;
  250|       |
  251|       |    /* append the '1' bit */
  252|  2.51k|    md->sha256.buf[md->sha256.curlen++] = (unsigned char)0x80;
  253|       |
  254|       |    /* if the length is currently above 56 bytes we append zeros
  255|       |     * then compress.  Then we can fall back to padding zeros and length
  256|       |     * encoding like normal.
  257|       |     */
  258|  2.51k|    if (md->sha256.curlen > 56) {
  ------------------
  |  Branch (258:9): [True: 0, False: 2.51k]
  ------------------
  259|      0|        while (md->sha256.curlen < 64) {
  ------------------
  |  Branch (259:16): [True: 0, False: 0]
  ------------------
  260|      0|            md->sha256.buf[md->sha256.curlen++] = (unsigned char)0;
  261|      0|        }
  262|      0|        sha256_compress(md, md->sha256.buf);
  263|      0|        md->sha256.curlen = 0;
  264|      0|    }
  265|       |
  266|       |    /* pad upto 56 bytes of zeroes */
  267|  71.5k|    while (md->sha256.curlen < 56) {
  ------------------
  |  Branch (267:12): [True: 69.0k, False: 2.51k]
  ------------------
  268|  69.0k|        md->sha256.buf[md->sha256.curlen++] = (unsigned char)0;
  269|  69.0k|    }
  270|       |
  271|       |    /* store length */
  272|  2.51k|    STORE64H(md->sha256.length, md->sha256.buf+56);
  ------------------
  |  |  101|  2.51k|#define STORE64H(x, y)                          \
  |  |  102|  2.51k|do { ulong64 __t = __builtin_bswap64 ((x));     \
  |  |  103|  2.51k|      XMEMCPY ((y), &__t, 8); } while(0)
  |  |  ------------------
  |  |  |  |   39|  2.51k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  |  Branch (103:39): [Folded, False: 2.51k]
  |  |  ------------------
  ------------------
  273|  2.51k|    sha256_compress(md, md->sha256.buf);
  274|       |
  275|       |    /* copy output */
  276|  22.6k|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (276:17): [True: 20.1k, False: 2.51k]
  ------------------
  277|  20.1k|        STORE32H(md->sha256.state[i], out+(4*i));
  ------------------
  |  |   62|  20.1k|#define STORE32H(x, y)                          \
  |  |   63|  20.1k|do { ulong32 __t = __builtin_bswap32 ((x));     \
  |  |   64|  20.1k|      XMEMCPY ((y), &__t, 4); } while(0)
  |  |  ------------------
  |  |  |  |   39|  20.1k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  |  Branch (64:39): [Folded, False: 20.1k]
  |  |  ------------------
  ------------------
  278|  20.1k|    }
  279|       |#ifdef LTC_CLEAN_STACK
  280|       |    zeromem(md, sizeof(hash_state));
  281|       |#endif
  282|  2.51k|    return CRYPT_OK;
  283|  2.51k|}
sha256.c:sha256_compress:
   71|  2.51k|{
   72|  2.51k|    ulong32 S[8], W[64], t0, t1;
   73|  2.51k|#ifdef LTC_SMALL_CODE
   74|  2.51k|    ulong32 t;
   75|  2.51k|#endif
   76|  2.51k|    int i;
   77|       |
   78|       |    /* copy state into S */
   79|  22.6k|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (79:17): [True: 20.1k, False: 2.51k]
  ------------------
   80|  20.1k|        S[i] = md->sha256.state[i];
   81|  20.1k|    }
   82|       |
   83|       |    /* copy the state into 512-bits into W[0..15] */
   84|  42.7k|    for (i = 0; i < 16; i++) {
  ------------------
  |  Branch (84:17): [True: 40.2k, False: 2.51k]
  ------------------
   85|  40.2k|        LOAD32H(W[i], buf + (4*i));
  ------------------
  |  |   66|  40.2k|#define LOAD32H(x, y)                           \
  |  |   67|  40.2k|do { XMEMCPY (&(x), (y), 4);                    \
  |  |  ------------------
  |  |  |  |   39|  40.2k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |   68|  40.2k|      (x) = __builtin_bswap32 ((x)); } while(0)
  |  |  ------------------
  |  |  |  Branch (68:46): [Folded, False: 40.2k]
  |  |  ------------------
  ------------------
   86|  40.2k|    }
   87|       |
   88|       |    /* fill W[16..63] */
   89|   123k|    for (i = 16; i < 64; i++) {
  ------------------
  |  Branch (89:18): [True: 120k, False: 2.51k]
  ------------------
   90|   120k|        W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
  ------------------
  |  |   63|   120k|#define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   58|   120k|#define S(x, n)         RORc((x),(n))
  |  |  |  |  ------------------
  |  |  |  |  |  |  283|   120k|#define RORc(word,i) ({ \
  |  |  |  |  |  |  284|   120k|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  285|   120k|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  286|   120k|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  287|   120k|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  288|   120k|            "I" (i)); \
  |  |  |  |  |  |  289|   120k|            __RORc_tmp; \
  |  |  |  |  |  |  290|   120k|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   58|   120k|#define S(x, n)         RORc((x),(n))
  |  |  |  |  ------------------
  |  |  |  |  |  |  283|   120k|#define RORc(word,i) ({ \
  |  |  |  |  |  |  284|   120k|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  285|   120k|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  286|   120k|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  287|   120k|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  288|   120k|            "I" (i)); \
  |  |  |  |  |  |  289|   120k|            __RORc_tmp; \
  |  |  |  |  |  |  290|   120k|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   59|   120k|#define R(x, n)         (((x)&0xFFFFFFFFUL)>>(n))
  |  |  ------------------
  ------------------
                      W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
  ------------------
  |  |   62|   120k|#define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   58|   120k|#define S(x, n)         RORc((x),(n))
  |  |  |  |  ------------------
  |  |  |  |  |  |  283|   120k|#define RORc(word,i) ({ \
  |  |  |  |  |  |  284|   120k|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  285|   120k|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  286|   120k|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  287|   120k|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  288|   120k|            "I" (i)); \
  |  |  |  |  |  |  289|   120k|            __RORc_tmp; \
  |  |  |  |  |  |  290|   120k|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   58|   120k|#define S(x, n)         RORc((x),(n))
  |  |  |  |  ------------------
  |  |  |  |  |  |  283|   120k|#define RORc(word,i) ({ \
  |  |  |  |  |  |  284|   120k|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  285|   120k|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  286|   120k|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  287|   120k|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  288|   120k|            "I" (i)); \
  |  |  |  |  |  |  289|   120k|            __RORc_tmp; \
  |  |  |  |  |  |  290|   120k|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   59|   120k|#define R(x, n)         (((x)&0xFFFFFFFFUL)>>(n))
  |  |  ------------------
  ------------------
   91|   120k|    }
   92|       |
   93|       |    /* Compress */
   94|  2.51k|#ifdef LTC_SMALL_CODE
   95|  2.51k|#define RND(a,b,c,d,e,f,g,h,i)                         \
   96|  2.51k|     t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];   \
   97|  2.51k|     t1 = Sigma0(a) + Maj(a, b, c);                    \
   98|  2.51k|     d += t0;                                          \
   99|  2.51k|     h  = t0 + t1;
  100|       |
  101|   163k|     for (i = 0; i < 64; ++i) {
  ------------------
  |  Branch (101:18): [True: 160k, False: 2.51k]
  ------------------
  102|   160k|         RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i);
  ------------------
  |  |   96|   160k|     t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];   \
  |  |  ------------------
  |  |  |  |   61|   160k|#define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   160k|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   160k|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   160k|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   160k|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   160k|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   160k|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   160k|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   160k|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   160k|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   160k|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   160k|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   160k|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   160k|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   160k|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   160k|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   160k|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   160k|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   160k|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   160k|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   160k|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   160k|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   160k|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   160k|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   160k|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   160k|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   160k|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   160k|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                    t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];   \
  |  |  ------------------
  |  |  |  |   56|   160k|#define Ch(x,y,z)       (z ^ (x & (y ^ z)))
  |  |  ------------------
  |  |   97|   160k|     t1 = Sigma0(a) + Maj(a, b, c);                    \
  |  |  ------------------
  |  |  |  |   60|   160k|#define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   160k|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   160k|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   160k|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   160k|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   160k|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   160k|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   160k|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   160k|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   160k|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   160k|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   160k|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   160k|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   160k|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   160k|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   160k|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   160k|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   160k|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   160k|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   160k|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   160k|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   160k|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   160k|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   160k|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   160k|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   160k|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   160k|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   160k|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                    t1 = Sigma0(a) + Maj(a, b, c);                    \
  |  |  ------------------
  |  |  |  |   57|   160k|#define Maj(x,y,z)      (((x | y) & z) | (x & y))
  |  |  ------------------
  |  |   98|   160k|     d += t0;                                          \
  |  |   99|   160k|     h  = t0 + t1;
  ------------------
  103|   160k|         t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
  104|   160k|         S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
  105|   160k|     }
  106|       |#else
  107|       |#define RND(a,b,c,d,e,f,g,h,i,ki)                    \
  108|       |     t0 = h + Sigma1(e) + Ch(e, f, g) + ki + W[i];   \
  109|       |     t1 = Sigma0(a) + Maj(a, b, c);                  \
  110|       |     d += t0;                                        \
  111|       |     h  = t0 + t1;
  112|       |
  113|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],0,0x428a2f98);
  114|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],1,0x71374491);
  115|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],2,0xb5c0fbcf);
  116|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],3,0xe9b5dba5);
  117|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],4,0x3956c25b);
  118|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],5,0x59f111f1);
  119|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],6,0x923f82a4);
  120|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],7,0xab1c5ed5);
  121|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],8,0xd807aa98);
  122|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],9,0x12835b01);
  123|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],10,0x243185be);
  124|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],11,0x550c7dc3);
  125|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],12,0x72be5d74);
  126|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],13,0x80deb1fe);
  127|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],14,0x9bdc06a7);
  128|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],15,0xc19bf174);
  129|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],16,0xe49b69c1);
  130|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],17,0xefbe4786);
  131|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],18,0x0fc19dc6);
  132|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],19,0x240ca1cc);
  133|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],20,0x2de92c6f);
  134|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],21,0x4a7484aa);
  135|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],22,0x5cb0a9dc);
  136|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],23,0x76f988da);
  137|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],24,0x983e5152);
  138|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],25,0xa831c66d);
  139|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],26,0xb00327c8);
  140|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],27,0xbf597fc7);
  141|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],28,0xc6e00bf3);
  142|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],29,0xd5a79147);
  143|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],30,0x06ca6351);
  144|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],31,0x14292967);
  145|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],32,0x27b70a85);
  146|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],33,0x2e1b2138);
  147|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],34,0x4d2c6dfc);
  148|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],35,0x53380d13);
  149|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],36,0x650a7354);
  150|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],37,0x766a0abb);
  151|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],38,0x81c2c92e);
  152|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],39,0x92722c85);
  153|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],40,0xa2bfe8a1);
  154|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],41,0xa81a664b);
  155|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],42,0xc24b8b70);
  156|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],43,0xc76c51a3);
  157|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],44,0xd192e819);
  158|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],45,0xd6990624);
  159|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],46,0xf40e3585);
  160|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],47,0x106aa070);
  161|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],48,0x19a4c116);
  162|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],49,0x1e376c08);
  163|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],50,0x2748774c);
  164|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],51,0x34b0bcb5);
  165|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],52,0x391c0cb3);
  166|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],53,0x4ed8aa4a);
  167|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],54,0x5b9cca4f);
  168|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],55,0x682e6ff3);
  169|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],56,0x748f82ee);
  170|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],57,0x78a5636f);
  171|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],58,0x84c87814);
  172|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],59,0x8cc70208);
  173|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],60,0x90befffa);
  174|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],61,0xa4506ceb);
  175|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],62,0xbef9a3f7);
  176|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],63,0xc67178f2);
  177|       |
  178|       |#undef RND
  179|       |
  180|       |#endif
  181|       |
  182|       |    /* feedback */
  183|  22.6k|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (183:17): [True: 20.1k, False: 2.51k]
  ------------------
  184|  20.1k|        md->sha256.state[i] = md->sha256.state[i] + S[i];
  185|  20.1k|    }
  186|  2.51k|    return CRYPT_OK;
  187|  2.51k|}

sha256_process:
  491|  5.02k|int func_name (hash_state * md, const unsigned char *in, unsigned long inlen)               \
  492|  5.02k|{                                                                                           \
  493|  5.02k|    unsigned long n;                                                                        \
  494|  5.02k|    int           err;                                                                      \
  495|  5.02k|    LTC_ARGCHK(md != NULL);                                                                 \
  ------------------
  |  |   32|  5.02k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 5.02k]
  |  |  |  Branch (32:87): [Folded, False: 5.02k]
  |  |  ------------------
  ------------------
  496|  5.02k|    LTC_ARGCHK(in != NULL);                                                                 \
  ------------------
  |  |   32|  5.02k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 5.02k]
  |  |  |  Branch (32:87): [Folded, False: 5.02k]
  |  |  ------------------
  ------------------
  497|  5.02k|    if (md-> state_var .curlen > sizeof(md-> state_var .buf)) {                             \
  ------------------
  |  Branch (497:9): [True: 0, False: 5.02k]
  ------------------
  498|      0|       return CRYPT_INVALID_ARG;                                                            \
  499|      0|    }                                                                                       \
  500|  5.02k|    if ((md-> state_var .length + inlen) < md-> state_var .length) {                        \
  ------------------
  |  Branch (500:9): [True: 0, False: 5.02k]
  ------------------
  501|      0|      return CRYPT_HASH_OVERFLOW;                                                           \
  502|      0|    }                                                                                       \
  503|  10.0k|    while (inlen > 0) {                                                                     \
  ------------------
  |  Branch (503:12): [True: 5.02k, False: 5.02k]
  ------------------
  504|  5.02k|        if (md-> state_var .curlen == 0 && inlen >= block_size) {                           \
  ------------------
  |  Branch (504:13): [True: 2.51k, False: 2.51k]
  |  Branch (504:44): [True: 0, False: 2.51k]
  ------------------
  505|      0|           if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) {               \
  ------------------
  |  Branch (505:16): [True: 0, False: 0]
  ------------------
  506|      0|              return err;                                                                   \
  507|      0|           }                                                                                \
  508|      0|           md-> state_var .length += block_size * 8;                                        \
  509|      0|           in             += block_size;                                                    \
  510|      0|           inlen          -= block_size;                                                    \
  511|  5.02k|        } else {                                                                            \
  512|  5.02k|           n = MIN(inlen, (block_size - md-> state_var .curlen));                           \
  ------------------
  |  |  425|  5.02k|   #define MIN(x, y) ( ((x)<(y))?(x):(y) )
  |  |  ------------------
  |  |  |  Branch (425:24): [True: 5.02k, False: 0]
  |  |  ------------------
  ------------------
  513|  5.02k|           XMEMCPY(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n);             \
  ------------------
  |  |   39|  5.02k|#define XMEMCPY  memcpy
  ------------------
  514|  5.02k|           md-> state_var .curlen += n;                                                     \
  515|  5.02k|           in             += n;                                                             \
  516|  5.02k|           inlen          -= n;                                                             \
  517|  5.02k|           if (md-> state_var .curlen == block_size) {                                      \
  ------------------
  |  Branch (517:16): [True: 0, False: 5.02k]
  ------------------
  518|      0|              if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) {            \
  ------------------
  |  Branch (518:19): [True: 0, False: 0]
  ------------------
  519|      0|                 return err;                                                                \
  520|      0|              }                                                                             \
  521|      0|              md-> state_var .length += 8*block_size;                                       \
  522|      0|              md-> state_var .curlen = 0;                                                   \
  523|      0|           }                                                                                \
  524|  5.02k|       }                                                                                    \
  525|  5.02k|    }                                                                                       \
  526|  5.02k|    return CRYPT_OK;                                                                        \
  527|  5.02k|}

base64_decode:
  148|  1.70k|{
  149|  1.70k|    return _base64_decode_internal(in, inlen, out, outlen, map_base64, relaxed);
  150|  1.70k|}
base64_decode.c:_base64_decode_internal:
   81|  1.70k|{
   82|  1.70k|   unsigned long t, x, y, z;
   83|  1.70k|   unsigned char c;
   84|  1.70k|   int           g;
   85|       |
   86|  1.70k|   LTC_ARGCHK(in     != NULL);
  ------------------
  |  |   32|  1.70k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1.70k]
  |  |  |  Branch (32:87): [Folded, False: 1.70k]
  |  |  ------------------
  ------------------
   87|  1.70k|   LTC_ARGCHK(out    != NULL);
  ------------------
  |  |   32|  1.70k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1.70k]
  |  |  |  Branch (32:87): [Folded, False: 1.70k]
  |  |  ------------------
  ------------------
   88|  1.70k|   LTC_ARGCHK(outlen != NULL);
  ------------------
  |  |   32|  1.70k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1.70k]
  |  |  |  Branch (32:87): [Folded, False: 1.70k]
  |  |  ------------------
  ------------------
   89|       |
   90|  1.70k|   g = 0; /* '=' counter */
   91|  72.7k|   for (x = y = z = t = 0; x < inlen; x++) {
  ------------------
  |  Branch (91:28): [True: 71.0k, False: 1.70k]
  ------------------
   92|  71.0k|       c = map[in[x]&0xFF];
   93|  71.0k|       if (c == 254) {
  ------------------
  |  Branch (93:12): [True: 3.19k, False: 67.8k]
  ------------------
   94|  3.19k|          g++;
   95|  3.19k|          continue;
   96|  3.19k|       }
   97|  67.8k|       else if (is_strict && g > 0) {
  ------------------
  |  Branch (97:17): [True: 0, False: 67.8k]
  |  Branch (97:30): [True: 0, False: 0]
  ------------------
   98|       |          /* we only allow '=' to be at the end */
   99|      0|          return CRYPT_INVALID_PACKET;
  100|      0|       }
  101|  67.8k|       if (c == 255) {
  ------------------
  |  Branch (101:12): [True: 9.05k, False: 58.7k]
  ------------------
  102|  9.05k|          if (is_strict)
  ------------------
  |  Branch (102:15): [True: 0, False: 9.05k]
  ------------------
  103|      0|             return CRYPT_INVALID_PACKET;
  104|  9.05k|          else
  105|  9.05k|             continue;
  106|  9.05k|       }
  107|       |
  108|  58.7k|       t = (t<<6)|c;
  109|       |
  110|  58.7k|       if (++y == 4) {
  ------------------
  |  Branch (110:12): [True: 13.4k, False: 45.2k]
  ------------------
  111|  13.4k|          if (z + 3 > *outlen) return CRYPT_BUFFER_OVERFLOW;
  ------------------
  |  Branch (111:15): [True: 0, False: 13.4k]
  ------------------
  112|  13.4k|          out[z++] = (unsigned char)((t>>16)&255);
  113|  13.4k|          out[z++] = (unsigned char)((t>>8)&255);
  114|  13.4k|          out[z++] = (unsigned char)(t&255);
  115|  13.4k|          y = t = 0;
  116|  13.4k|       }
  117|  58.7k|   }
  118|       |
  119|  1.70k|   if (y != 0) {
  ------------------
  |  Branch (119:8): [True: 1.64k, False: 57]
  ------------------
  120|  1.64k|      int allow_b64url = 0;
  121|       |#ifdef LTC_BASE64_URL
  122|       |      if (map == map_base64url) {
  123|       |        allow_b64url = 1;
  124|       |      }
  125|       |#endif
  126|  1.64k|      if (y == 1) return CRYPT_INVALID_PACKET;
  ------------------
  |  Branch (126:11): [True: 25, False: 1.61k]
  ------------------
  127|  1.61k|      if ((y + g) != 4 && is_strict && !allow_b64url) return CRYPT_INVALID_PACKET;
  ------------------
  |  Branch (127:11): [True: 1.61k, False: 9]
  |  Branch (127:27): [True: 0, False: 1.61k]
  |  Branch (127:40): [True: 0, False: 0]
  ------------------
  128|  1.61k|      t = t << (6 * (4 - y));
  129|  1.61k|      if (z + y - 1 > *outlen) return CRYPT_BUFFER_OVERFLOW;
  ------------------
  |  Branch (129:11): [True: 0, False: 1.61k]
  ------------------
  130|  1.61k|      if (y >= 2) out[z++] = (unsigned char) ((t >> 16) & 255);
  ------------------
  |  Branch (130:11): [True: 1.61k, False: 0]
  ------------------
  131|  1.61k|      if (y == 3) out[z++] = (unsigned char) ((t >> 8) & 255);
  ------------------
  |  Branch (131:11): [True: 1.57k, False: 41]
  ------------------
  132|  1.61k|   }
  133|  1.67k|   *outlen = z;
  134|  1.67k|   return CRYPT_OK;
  135|  1.70k|}

register_cipher:
   22|      1|{
   23|      1|   int x;
   24|       |
   25|      1|   LTC_ARGCHK(cipher != NULL);
  ------------------
  |  |   32|      1|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1]
  |  |  |  Branch (32:87): [Folded, False: 1]
  |  |  ------------------
  ------------------
   26|       |
   27|       |   /* is it already registered? */
   28|      1|   LTC_MUTEX_LOCK(&ltc_cipher_mutex);
   29|      6|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|      6|#define TAB_SIZE      5
  ------------------
  |  Branch (29:16): [True: 5, False: 1]
  ------------------
   30|      5|       if (cipher_descriptor[x].name != NULL && cipher_descriptor[x].ID == cipher->ID) {
  ------------------
  |  Branch (30:12): [True: 0, False: 5]
  |  Branch (30:49): [True: 0, False: 0]
  ------------------
   31|      0|          LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
   32|      0|          return x;
   33|      0|       }
   34|      5|   }
   35|       |
   36|       |   /* find a blank spot */
   37|      1|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|      1|#define TAB_SIZE      5
  ------------------
  |  Branch (37:16): [True: 1, False: 0]
  ------------------
   38|      1|       if (cipher_descriptor[x].name == NULL) {
  ------------------
  |  Branch (38:12): [True: 1, False: 0]
  ------------------
   39|      1|          XMEMCPY(&cipher_descriptor[x], cipher, sizeof(struct ltc_cipher_descriptor));
  ------------------
  |  |   39|      1|#define XMEMCPY  memcpy
  ------------------
   40|      1|          LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
   41|      1|          return x;
   42|      1|       }
   43|      1|   }
   44|       |
   45|       |   /* no spot */
   46|      0|   LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
   47|      0|   return -1;
   48|      1|}

register_hash:
   22|      3|{
   23|      3|   int x;
   24|       |
   25|      3|   LTC_ARGCHK(hash != NULL);
  ------------------
  |  |   32|      3|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3]
  |  |  |  Branch (32:87): [Folded, False: 3]
  |  |  ------------------
  ------------------
   26|       |
   27|       |   /* is it already registered? */
   28|      3|   LTC_MUTEX_LOCK(&ltc_hash_mutex);
   29|     18|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|     18|#define TAB_SIZE      5
  ------------------
  |  Branch (29:16): [True: 15, False: 3]
  ------------------
   30|     15|       if (XMEMCMP(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor)) == 0) {
  ------------------
  |  |   45|     15|#define XMEMCMP  memcmp
  ------------------
  |  Branch (30:12): [True: 0, False: 15]
  ------------------
   31|      0|          LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
   32|      0|          return x;
   33|      0|       }
   34|     15|   }
   35|       |
   36|       |   /* find a blank spot */
   37|      6|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|      6|#define TAB_SIZE      5
  ------------------
  |  Branch (37:16): [True: 6, False: 0]
  ------------------
   38|      6|       if (hash_descriptor[x].name == NULL) {
  ------------------
  |  Branch (38:12): [True: 3, False: 3]
  ------------------
   39|      3|          XMEMCPY(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor));
  ------------------
  |  |   39|      3|#define XMEMCPY  memcpy
  ------------------
   40|      3|          LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
   41|      3|          return x;
   42|      3|       }
   43|      6|   }
   44|       |
   45|       |   /* no spot */
   46|      0|   LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
   47|      0|   return -1;
   48|      3|}

register_prng:
   22|      1|{
   23|      1|   int x;
   24|       |
   25|      1|   LTC_ARGCHK(prng != NULL);
  ------------------
  |  |   32|      1|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1]
  |  |  |  Branch (32:87): [Folded, False: 1]
  |  |  ------------------
  ------------------
   26|       |
   27|       |   /* is it already registered? */
   28|      1|   LTC_MUTEX_LOCK(&ltc_prng_mutex);
   29|      6|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|      6|#define TAB_SIZE      5
  ------------------
  |  Branch (29:16): [True: 5, False: 1]
  ------------------
   30|      5|       if (XMEMCMP(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)) == 0) {
  ------------------
  |  |   45|      5|#define XMEMCMP  memcmp
  ------------------
  |  Branch (30:12): [True: 0, False: 5]
  ------------------
   31|      0|          LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
   32|      0|          return x;
   33|      0|       }
   34|      5|   }
   35|       |
   36|       |   /* find a blank spot */
   37|      1|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|      1|#define TAB_SIZE      5
  ------------------
  |  Branch (37:16): [True: 1, False: 0]
  ------------------
   38|      1|       if (prng_descriptor[x].name == NULL) {
  ------------------
  |  Branch (38:12): [True: 1, False: 0]
  ------------------
   39|      1|          XMEMCPY(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor));
  ------------------
  |  |   39|      1|#define XMEMCPY  memcpy
  ------------------
   40|      1|          LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
   41|      1|          return x;
   42|      1|       }
   43|      1|   }
   44|       |
   45|       |   /* no spot */
   46|      0|   LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
   47|      0|   return -1;
   48|      1|}

mp_rand_source:
   10|      1|{
   11|       |   /* Dropbear, don't reset to platform if source==NULL */
   12|      1|   s_mp_rand_source = source;
   13|      1|}

buf_new:
   41|  8.49k|buffer* buf_new(unsigned int size) {
   42|  8.49k|	buffer* buf;
   43|  8.49k|	if (size > BUF_MAX_SIZE) {
  ------------------
  |  |   35|  8.49k|#define BUF_MAX_SIZE 1000000000
  ------------------
  |  Branch (43:6): [True: 0, False: 8.49k]
  ------------------
   44|      0|		dropbear_exit("buf->size too big");
   45|      0|	}
   46|       |
   47|  8.49k|	buf = (buffer*)m_malloc(sizeof(buffer)+size);
   48|  8.49k|	buf->data = (unsigned char*)buf + sizeof(buffer);
   49|  8.49k|	buf->size = size;
   50|  8.49k|	return buf;
   51|  8.49k|}
buf_free:
   54|  7.88k|void buf_free(buffer* buf) {
   55|       |	m_free(buf);
  ------------------
  |  |   24|  7.88k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 7.88k]
  |  |  ------------------
  ------------------
   56|  7.88k|}
buf_setlen:
   95|  1.78k|void buf_setlen(buffer* buf, unsigned int len) {
   96|  1.78k|	if (len > buf->size) {
  ------------------
  |  Branch (96:6): [True: 0, False: 1.78k]
  ------------------
   97|      0|		dropbear_exit("Bad buf_setlen");
   98|      0|	}
   99|  1.78k|	buf->len = len;
  100|       |	buf->pos = MIN(buf->pos, buf->len);
  ------------------
  |  Branch (100:13): [True: 1.70k, False: 80]
  ------------------
  101|  1.78k|}
buf_incrlen:
  104|  6.52k|void buf_incrlen(buffer* buf, unsigned int incr) {
  105|  6.52k|	if (incr > BUF_MAX_INCR || buf->len + incr > buf->size) {
  ------------------
  |  |   34|  13.0k|#define BUF_MAX_INCR 1000000000
  ------------------
  |  Branch (105:6): [True: 0, False: 6.52k]
  |  Branch (105:29): [True: 0, False: 6.52k]
  ------------------
  106|      0|		dropbear_exit("Bad buf_incrlen");
  107|      0|	}
  108|  6.52k|	buf->len += incr;
  109|  6.52k|}
buf_setpos:
  111|  8.23k|void buf_setpos(buffer* buf, unsigned int pos) {
  112|       |
  113|  8.23k|	if (pos > buf->len) {
  ------------------
  |  Branch (113:6): [True: 0, False: 8.23k]
  ------------------
  114|      0|		dropbear_exit("Bad buf_setpos");
  115|      0|	}
  116|  8.23k|	buf->pos = pos;
  117|  8.23k|}
buf_incrwritepos:
  120|  1.90k|void buf_incrwritepos(buffer* buf, unsigned int incr) {
  121|  1.90k|	if (incr > BUF_MAX_INCR || buf->pos + incr > buf->size) {
  ------------------
  |  |   34|  3.80k|#define BUF_MAX_INCR 1000000000
  ------------------
  |  Branch (121:6): [True: 0, False: 1.90k]
  |  Branch (121:29): [True: 0, False: 1.90k]
  ------------------
  122|      0|		dropbear_exit("Bad buf_incrwritepos");
  123|      0|	}
  124|  1.90k|	buf->pos += incr;
  125|  1.90k|	if (buf->pos > buf->len) {
  ------------------
  |  Branch (125:6): [True: 1.90k, False: 0]
  ------------------
  126|  1.90k|		buf->len = buf->pos;
  127|  1.90k|	}
  128|  1.90k|}
buf_incrpos:
  131|  20.5k|void buf_incrpos(buffer* buf, unsigned int incr) {
  132|  20.5k|	if (incr > BUF_MAX_INCR 
  ------------------
  |  |   34|  41.1k|#define BUF_MAX_INCR 1000000000
  ------------------
  |  Branch (132:6): [True: 0, False: 20.5k]
  ------------------
  133|  20.5k|		|| (buf->pos + incr) > buf->len) {
  ------------------
  |  Branch (133:6): [True: 0, False: 20.5k]
  ------------------
  134|      0|		dropbear_exit("Bad buf_incrpos");
  135|      0|	}
  136|  20.5k|	buf->pos += incr;
  137|  20.5k|}
buf_decrpos:
  140|  1.90k|void buf_decrpos(buffer* buf, unsigned int decr) {
  141|  1.90k|	if (decr > buf->pos) {
  ------------------
  |  Branch (141:6): [True: 0, False: 1.90k]
  ------------------
  142|      0|		dropbear_exit("Bad buf_decrpos");
  143|      0|	}
  144|  1.90k|	buf->pos -= decr;
  145|  1.90k|}
buf_getbyte:
  148|   274k|unsigned char buf_getbyte(buffer* buf) {
  149|       |
  150|       |	/* This check is really just ==, but the >= allows us to check for the
  151|       |	 * bad case of pos > len, which should _never_ happen. */
  152|   274k|	if (buf->pos >= buf->len) {
  ------------------
  |  Branch (152:6): [True: 0, False: 274k]
  ------------------
  153|      0|		dropbear_exit("Bad buf_getbyte");
  154|      0|	}
  155|   274k|	return buf->data[buf->pos++];
  156|   274k|}
buf_getptr:
  180|  81.6k|unsigned char* buf_getptr(const buffer* buf, unsigned int len) {
  181|       |
  182|  81.6k|	if (len > BUF_MAX_INCR || buf->pos + len > buf->len) {
  ------------------
  |  |   34|   163k|#define BUF_MAX_INCR 1000000000
  ------------------
  |  Branch (182:6): [True: 0, False: 81.6k]
  |  Branch (182:28): [True: 112, False: 81.5k]
  ------------------
  183|    112|		dropbear_exit("Bad buf_getptr");
  184|    112|	}
  185|  81.5k|	return &buf->data[buf->pos];
  186|  81.6k|}
buf_getwriteptr:
  190|  8.49k|unsigned char* buf_getwriteptr(const buffer* buf, unsigned int len) {
  191|       |
  192|  8.49k|	if (len > BUF_MAX_INCR || buf->pos + len > buf->size) {
  ------------------
  |  |   34|  16.9k|#define BUF_MAX_INCR 1000000000
  ------------------
  |  Branch (192:6): [True: 0, False: 8.49k]
  |  Branch (192:28): [True: 0, False: 8.49k]
  ------------------
  193|      0|		dropbear_exit("Bad buf_getwriteptr");
  194|      0|	}
  195|  8.49k|	return &buf->data[buf->pos];
  196|  8.49k|}
buf_getstring:
  201|  2.41k|char* buf_getstring(buffer* buf, unsigned int *retlen) {
  202|       |
  203|  2.41k|	unsigned int len;
  204|  2.41k|	char* ret;
  205|  2.41k|	void* src = NULL;
  206|  2.41k|	len = buf_getint(buf);
  207|  2.41k|	if (len > MAX_STRING_LEN) {
  ------------------
  |  |  259|  2.41k|#define MAX_STRING_LEN (MAX(MAX_CMD_LEN, 2400)) /* Sun SSH needs 2400 for algos,
  ------------------
  |  Branch (207:6): [True: 33, False: 2.38k]
  |  Branch (207:12): [True: 2.41k, Folded]
  ------------------
  208|     33|		dropbear_exit("String too long");
  209|     33|	}
  210|       |
  211|  2.38k|	if (retlen != NULL) {
  ------------------
  |  Branch (211:6): [True: 2.37k, False: 3]
  ------------------
  212|  2.37k|		*retlen = len;
  213|  2.37k|	}
  214|  2.38k|	src = buf_getptr(buf, len);
  215|  2.38k|	ret = m_malloc(len+1);
  216|  2.38k|	memcpy(ret, src, len);
  217|  2.38k|	buf_incrpos(buf, len);
  218|  2.38k|	ret[len] = '\0';
  219|       |
  220|  2.38k|	return ret;
  221|  2.41k|}
buf_getstringbuf:
  246|  4.95k|buffer * buf_getstringbuf(buffer *buf) {
  247|  4.95k|	return buf_getstringbuf_int(buf, 0);
  248|  4.95k|}
buf_getint:
  272|  8.88k|unsigned int buf_getint(buffer* buf) {
  273|  8.88k|	unsigned int ret;
  274|       |
  275|  8.88k|	LOAD32H(ret, buf_getptr(buf, 4));
  ------------------
  |  |   66|  8.88k|#define LOAD32H(x, y)                           \
  |  |   67|  8.88k|do { XMEMCPY (&(x), (y), 4);                    \
  |  |  ------------------
  |  |  |  |   39|  8.88k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |   68|  8.88k|      (x) = __builtin_bswap32 ((x)); } while(0)
  |  |  ------------------
  |  |  |  Branch (68:46): [Folded, False: 8.88k]
  |  |  ------------------
  ------------------
  276|  8.88k|	buf_incrpos(buf, 4);
  277|  8.88k|	return ret;
  278|  8.88k|}
buf_putbytes:
  303|  1.90k|void buf_putbytes(buffer *buf, const unsigned char *bytes, unsigned int len) {
  304|  1.90k|	memcpy(buf_getwriteptr(buf, len), bytes, len);
  305|  1.90k|	buf_incrwritepos(buf, len);
  306|  1.90k|}
buffer.c:buf_getstringbuf_int:
  224|  4.95k|static buffer * buf_getstringbuf_int(buffer *buf, int incllen) {
  225|  4.95k|	buffer *ret = NULL;
  226|  4.95k|	unsigned int len = buf_getint(buf);
  227|  4.95k|	int extra = 0;
  228|  4.95k|	if (len > MAX_STRING_LEN) {
  ------------------
  |  |  259|  4.95k|#define MAX_STRING_LEN (MAX(MAX_CMD_LEN, 2400)) /* Sun SSH needs 2400 for algos,
  ------------------
  |  Branch (228:6): [True: 38, False: 4.91k]
  |  Branch (228:12): [True: 4.93k, Folded]
  ------------------
  229|     38|		dropbear_exit("String too long");
  230|     38|	}
  231|  4.91k|	if (incllen) {
  ------------------
  |  Branch (231:6): [True: 0, False: 4.91k]
  ------------------
  232|      0|		extra = 4;
  233|      0|	}
  234|  4.91k|	ret = buf_new(len+extra);
  235|  4.91k|	if (incllen) {
  ------------------
  |  Branch (235:6): [True: 0, False: 4.91k]
  ------------------
  236|      0|		buf_putint(ret, len);
  237|      0|	}
  238|  4.91k|	memcpy(buf_getwriteptr(ret, len), buf_getptr(buf, len), len);
  239|  4.91k|	buf_incrpos(buf, len);
  240|  4.91k|	buf_incrlen(ret, len);
  241|  4.91k|	buf_setpos(ret, 0);
  242|  4.91k|	return ret;
  243|  4.95k|}

split_address_port:
  128|  1.05k|int split_address_port(const char* spec, char **first, char ** second) {
  129|  1.05k|	char *spec_copy = NULL, *addr = NULL, *colon = NULL;
  130|  1.05k|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|  1.05k|#define DROPBEAR_FAILURE -1
  ------------------
  131|       |
  132|  1.05k|	*first = NULL;
  133|  1.05k|	*second = NULL;
  134|  1.05k|	spec_copy = m_strdup(spec);
  135|  1.05k|	addr = spec_copy;
  136|       |
  137|  1.05k|	if (*addr == '[') {
  ------------------
  |  Branch (137:6): [True: 113, False: 945]
  ------------------
  138|    113|		addr++;
  139|    113|		colon = strchr(addr, ']');
  140|    113|		if (!colon) {
  ------------------
  |  Branch (140:7): [True: 2, False: 111]
  ------------------
  141|      2|			dropbear_log(LOG_WARNING, "Bad address '%s'", spec);
  142|      2|			goto out;
  143|      2|		}
  144|    111|		*colon = '\0';
  145|    111|		colon++;
  146|    111|		if (*colon == '\0') {
  ------------------
  |  Branch (146:7): [True: 2, False: 109]
  ------------------
  147|       |			/* No port part */
  148|      2|			colon = NULL;
  149|    109|		} else if (*colon != ':') {
  ------------------
  |  Branch (149:14): [True: 14, False: 95]
  ------------------
  150|     14|			dropbear_log(LOG_WARNING, "Bad address '%s'", spec);
  151|     14|			goto out;
  152|     14|		}
  153|    945|	} else {
  154|       |		/* search for ':', that separates address and port */
  155|    945|		colon = strrchr(addr, ':');
  156|    945|	}
  157|       |
  158|       |	/* colon points to ':' now, or is NULL */
  159|  1.04k|	if (colon) {
  ------------------
  |  Branch (159:6): [True: 1.00k, False: 35]
  ------------------
  160|       |		/* Split the address/port */
  161|  1.00k|		*colon = '\0';
  162|  1.00k|		colon++;
  163|  1.00k|		*second = m_strdup(colon);
  164|  1.00k|	}
  165|  1.04k|	if (strlen(addr)) {
  ------------------
  |  Branch (165:6): [True: 1.02k, False: 14]
  ------------------
  166|  1.02k|		*first = m_strdup(addr);
  167|  1.02k|	}
  168|  1.04k|	ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|  1.04k|#define DROPBEAR_SUCCESS 0
  ------------------
  169|       |
  170|  1.05k|out:
  171|       |	m_free(spec_copy);
  ------------------
  |  |   24|  1.05k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  172|  1.05k|	return ret;
  173|  1.04k|}

crypto_init:
   21|      1|void crypto_init() {
   22|       |
   23|      1|	const struct ltc_cipher_descriptor *regciphers[] = {
   24|      1|#if DROPBEAR_AES
   25|      1|		&aes_desc,
   26|      1|#endif
   27|       |#if DROPBEAR_3DES
   28|       |		&des3_desc,
   29|       |#endif
   30|      1|		NULL
   31|      1|	};
   32|       |
   33|      1|	const struct ltc_hash_descriptor *reghashes[] = {
   34|       |#if DROPBEAR_SHA1_HMAC
   35|       |		&sha1_desc,
   36|       |#endif
   37|      1|#if DROPBEAR_SHA256
   38|      1|		&sha256_desc,
   39|      1|#endif
   40|      1|#if DROPBEAR_SHA384
   41|      1|		&sha384_desc,
   42|      1|#endif
   43|      1|#if DROPBEAR_SHA512
   44|      1|		&sha512_desc,
   45|      1|#endif
   46|      1|		NULL
   47|      1|	};
   48|      1|	int i;
   49|       |
   50|      2|	for (i = 0; regciphers[i] != NULL; i++) {
  ------------------
  |  Branch (50:14): [True: 1, False: 1]
  ------------------
   51|      1|		if (register_cipher(regciphers[i]) == -1) {
  ------------------
  |  Branch (51:7): [True: 0, False: 1]
  ------------------
   52|      0|			dropbear_exit("Error registering crypto");
   53|      0|		}
   54|      1|	}
   55|       |
   56|      4|	for (i = 0; reghashes[i] != NULL; i++) {
  ------------------
  |  Branch (56:14): [True: 3, False: 1]
  ------------------
   57|      3|		if (register_hash(reghashes[i]) == -1) {
  ------------------
  |  Branch (57:7): [True: 0, False: 3]
  ------------------
   58|      0|			dropbear_exit("Error registering crypto");
   59|      0|		}
   60|      3|	}
   61|       |
   62|      1|#if DROPBEAR_LTC_PRNG
   63|      1|	dropbear_ltc_prng = register_prng(&dropbear_prng_desc);
   64|      1|	if (dropbear_ltc_prng == -1) {
  ------------------
  |  Branch (64:6): [True: 0, False: 1]
  ------------------
   65|      0|		dropbear_exit("Error registering crypto");
   66|      0|	}
   67|      1|#endif
   68|       |
   69|      1|	mp_rand_source(dropbear_rand_source);
   70|       |
   71|      1|#if DROPBEAR_ECC
   72|      1|	ltc_mp = ltm_desc;
   73|      1|	dropbear_ecc_fill_dp();
   74|      1|#endif
   75|      1|}

ascii_isdigit:
   10|  1.67k|int ascii_isdigit(char c) {
   11|  1.67k|    return c >= '0' && c <= '9';
  ------------------
  |  Branch (11:12): [True: 431, False: 1.24k]
  |  Branch (11:24): [True: 383, False: 48]
  ------------------
   12|  1.67k|}
ascii_isalpha:
   14|  6.26k|int ascii_isalpha(char c) {
   15|  6.26k|    return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
  ------------------
  |  Branch (15:13): [True: 4.07k, False: 2.19k]
  |  Branch (15:25): [True: 4.06k, False: 5]
  |  Branch (15:39): [True: 553, False: 1.65k]
  |  Branch (15:51): [True: 526, False: 27]
  ------------------
   16|  6.26k|}
ascii_isalnum:
   18|  6.26k|int ascii_isalnum(char c) {
   19|  6.26k|    return ascii_isalpha(c) || ascii_isdigit(c);
  ------------------
  |  Branch (19:12): [True: 4.59k, False: 1.67k]
  |  Branch (19:32): [True: 383, False: 1.29k]
  ------------------
   20|  6.26k|}

m_strdup:
   12|  3.09k|void * m_strdup(const char * str) {
   13|  3.09k|    char* ret;
   14|  3.09k|    unsigned int len;
   15|  3.09k|    len = strlen(str);
   16|       |
   17|  3.09k|    ret = m_malloc(len+1);
   18|  3.09k|    if (ret == NULL) {
  ------------------
  |  Branch (18:9): [True: 0, False: 3.09k]
  ------------------
   19|      0|        dropbear_exit("m_strdup failed");
   20|      0|    }
   21|  3.09k|    memcpy(ret, str, len+1);
   22|  3.09k|    return ret;
   23|  3.09k|}
m_malloc_set_epoch:
   76|  2.51k|void m_malloc_set_epoch(unsigned int epoch) {
   77|  2.51k|    current_epoch = epoch;
   78|  2.51k|}
m_malloc_free_epoch:
   80|  2.51k|void m_malloc_free_epoch(unsigned int epoch, int dofree) {
   81|  2.51k|    struct dbmalloc_header* header;
   82|  2.51k|    struct dbmalloc_header* nextheader = NULL;
   83|  2.51k|    struct dbmalloc_header* oldstaple = staple;
   84|  2.51k|    staple = NULL;
   85|       |    /* free allocations from this epoch, create a new staple-anchored list from
   86|       |    the remainder */
   87|  5.84k|    for (header = oldstaple; header; header = nextheader)
  ------------------
  |  Branch (87:30): [True: 3.32k, False: 2.51k]
  ------------------
   88|  3.32k|    {
   89|  3.32k|        nextheader = header->next;
   90|  3.32k|        if (header->epoch == epoch) {
  ------------------
  |  Branch (90:13): [True: 815, False: 2.51k]
  ------------------
   91|    815|            if (dofree) {
  ------------------
  |  Branch (91:17): [True: 815, False: 0]
  ------------------
   92|    815|                free(header);
   93|    815|            }
   94|  2.51k|        } else {
   95|  2.51k|            header->prev = NULL;
   96|       |            header->next = NULL;
   97|  2.51k|            put_alloc(header);
   98|  2.51k|        }
   99|  3.32k|    }
  100|  2.51k|}
m_malloc:
  131|  19.9k|void * m_malloc(size_t size) {
  132|  19.9k|    char* mem = NULL;
  133|  19.9k|    struct dbmalloc_header* header = NULL;
  134|       |
  135|  19.9k|    if (size == 0 || size > 1e9) {
  ------------------
  |  Branch (135:9): [True: 0, False: 19.9k]
  |  Branch (135:22): [True: 0, False: 19.9k]
  ------------------
  136|      0|        dropbear_exit("m_malloc failed");
  137|      0|    }
  138|       |
  139|  19.9k|    size = size + sizeof(struct dbmalloc_header);
  140|       |
  141|  19.9k|    mem = calloc(1, size);
  142|  19.9k|    if (mem == NULL) {
  ------------------
  |  Branch (142:9): [True: 0, False: 19.9k]
  ------------------
  143|      0|        dropbear_exit("m_malloc failed");
  144|      0|    }
  145|  19.9k|    header = (struct dbmalloc_header*)mem;
  146|  19.9k|    put_alloc(header);
  147|  19.9k|    header->epoch = current_epoch;
  148|  19.9k|    return &mem[sizeof(struct dbmalloc_header)];
  149|  19.9k|}
m_free_direct:
  172|  22.4k|void m_free_direct(void* ptr) {
  173|  22.4k|    struct dbmalloc_header* header = NULL;
  174|  22.4k|    if (!ptr) {
  ------------------
  |  Branch (174:9): [True: 3.33k, False: 19.0k]
  ------------------
  175|  3.33k|        return;
  176|  3.33k|    }
  177|  19.0k|    header = get_header(ptr);
  178|  19.0k|    remove_alloc(header);
  179|  19.0k|    free(header);
  180|  19.0k|}
dbmalloc.c:put_alloc:
  102|  22.4k|static void put_alloc(struct dbmalloc_header *header) {
  103|  22.4k|    assert(header->next == NULL);
  ------------------
  |  Branch (103:5): [True: 0, False: 22.4k]
  |  Branch (103:5): [True: 22.4k, False: 0]
  ------------------
  104|  22.4k|    assert(header->prev == NULL);
  ------------------
  |  Branch (104:5): [True: 0, False: 22.4k]
  |  Branch (104:5): [True: 22.4k, False: 0]
  ------------------
  105|  22.4k|    if (staple) {
  ------------------
  |  Branch (105:9): [True: 19.9k, False: 2.51k]
  ------------------
  106|  19.9k|        staple->prev = header;
  107|  19.9k|    }
  108|  22.4k|    header->next = staple;
  109|  22.4k|    staple = header;
  110|  22.4k|}
dbmalloc.c:get_header:
  126|  19.0k|static struct dbmalloc_header* get_header(void* ptr) {
  127|  19.0k|    char* bptr = ptr;
  128|  19.0k|    return (struct dbmalloc_header*)&bptr[-sizeof(struct dbmalloc_header)];
  129|  19.0k|}
dbmalloc.c:remove_alloc:
  112|  19.0k|static void remove_alloc(struct dbmalloc_header *header) {
  113|  19.0k|    if (header->prev) {
  ------------------
  |  Branch (113:9): [True: 10.5k, False: 8.57k]
  ------------------
  114|  10.5k|        header->prev->next = header->next;
  115|  10.5k|    }
  116|  19.0k|    if (header->next) {
  ------------------
  |  Branch (116:9): [True: 19.0k, False: 0]
  ------------------
  117|  19.0k|        header->next->prev = header->prev;
  118|  19.0k|    }
  119|  19.0k|    if (staple == header) {
  ------------------
  |  Branch (119:9): [True: 8.57k, False: 10.5k]
  ------------------
  120|  8.57k|        staple = header->next;
  121|  8.57k|    }
  122|  19.0k|    header->prev = NULL;
  123|       |    header->next = NULL;
  124|  19.0k|}

fuzz_seed:
  153|  2.51k|void fuzz_seed(const unsigned char* dat, unsigned int len) {
  154|  2.51k|	hash_state hs;
  155|  2.51k|	sha256_init(&hs);
  156|  2.51k|	sha256_process(&hs, "fuzzfuzzfuzz", strlen("fuzzfuzzfuzz"));
  157|  2.51k|	sha256_process(&hs, dat, len);
  158|  2.51k|	sha256_done(&hs, hashpool);
  159|  2.51k|	counter = 0;
  160|  2.51k|	donerandinit = 1;
  161|  2.51k|}

dropbear_exit:
  105|    371|void dropbear_exit(const char* format, ...) {
  106|       |
  107|    371|	va_list param;
  108|       |
  109|    371|	va_start(param, format);
  110|    371|	_dropbear_exit(EXIT_FAILURE, format, param);
  111|    371|	va_end(param);
  112|      0|}
dropbear_log:
  148|  2.91k|void dropbear_log(int priority, const char* format, ...) {
  149|       |
  150|  2.91k|	va_list param;
  151|       |
  152|  2.91k|	va_start(param, format);
  153|  2.91k|	_dropbear_log(priority, format, param);
  154|       |	va_end(param);
  155|  2.91k|}
disallow_core:
  660|      1|void disallow_core() {
  661|      1|	struct rlimit lim = {0};
  662|      1|	if (getrlimit(RLIMIT_CORE, &lim) < 0) {
  ------------------
  |  Branch (662:6): [True: 0, False: 1]
  ------------------
  663|      0|		TRACE(("getrlimit(RLIMIT_CORE) failed"));
  664|      0|	}
  665|      1|	lim.rlim_cur = 0;
  666|      1|	if (setrlimit(RLIMIT_CORE, &lim) < 0) {
  ------------------
  |  Branch (666:6): [True: 0, False: 1]
  ------------------
  667|      0|		TRACE(("setrlimit(RLIMIT_CORE) failed"));
  668|      0|	}
  669|      1|}
m_str_to_uint:
  672|  1.04k|int m_str_to_uint(const char* str, unsigned int *val) {
  673|  1.04k|	unsigned long l;
  674|  1.04k|	char *endp;
  675|       |
  676|  1.04k|	l = strtoul(str, &endp, 10);
  677|       |
  678|  1.04k|	if (endp == str || *endp != '\0') {
  ------------------
  |  Branch (678:6): [True: 28, False: 1.01k]
  |  Branch (678:21): [True: 11, False: 1.00k]
  ------------------
  679|       |		/* parse error */
  680|     39|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|     39|#define DROPBEAR_FAILURE -1
  ------------------
  681|     39|	}
  682|       |
  683|       |	/* The c99 spec doesn't actually seem to define EINVAL, but most platforms
  684|       |	 * I've looked at mention it in their manpage */
  685|  1.00k|	if ((l == 0 && errno == EINVAL)
  ------------------
  |  Branch (685:7): [True: 470, False: 535]
  |  Branch (685:17): [True: 0, False: 470]
  ------------------
  686|  1.00k|		|| (l == ULONG_MAX && errno == ERANGE)
  ------------------
  |  Branch (686:7): [True: 3, False: 1.00k]
  |  Branch (686:25): [True: 2, False: 1]
  ------------------
  687|  1.00k|		|| (l > UINT_MAX)) {
  ------------------
  |  Branch (687:6): [True: 80, False: 923]
  ------------------
  688|     82|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|     82|#define DROPBEAR_FAILURE -1
  ------------------
  689|    923|	} else {
  690|    923|		*val = l;
  691|    923|		return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|    923|#define DROPBEAR_SUCCESS 0
  ------------------
  692|    923|	}
  693|  1.00k|}
dbutil.c:generic_dropbear_exit:
  115|    371|		va_list param) {
  116|       |
  117|    371|	char fmtbuf[300];
  118|       |
  119|    371|	snprintf(fmtbuf, sizeof(fmtbuf), "Exited: %s", format);
  120|       |
  121|    371|	_dropbear_log(LOG_INFO, fmtbuf, param);
  122|       |
  123|    371|#if DROPBEAR_FUZZ
  124|    371|    if (fuzz.do_jmp) {
  ------------------
  |  Branch (124:9): [True: 371, False: 0]
  ------------------
  125|    371|        longjmp(fuzz.jmp, 1);
  126|    371|    }
  127|      0|#endif
  128|       |
  129|      0|	exit(exitcode);
  130|    371|}

dropbear_ecc_fill_dp:
   47|      1|void dropbear_ecc_fill_dp() {
   48|      1|	struct dropbear_ecc_curve **curve;
   49|       |	/* libtomcrypt guarantees they're ordered by size */
   50|      1|	const ltc_ecc_set_type *dp = ltc_ecc_sets;
   51|      4|	for (curve = dropbear_ecc_curves; *curve; curve++) {
  ------------------
  |  Branch (51:36): [True: 3, False: 1]
  ------------------
   52|      5|		for (;dp->size > 0; dp++) {
  ------------------
  |  Branch (52:9): [True: 5, False: 0]
  ------------------
   53|      5|			if (dp->size == (*curve)->ltc_size) {
  ------------------
  |  Branch (53:8): [True: 3, False: 2]
  ------------------
   54|      3|				(*curve)->dp = dp;
   55|      3|				break;
   56|      3|			}
   57|      5|		}
   58|      3|		if (!(*curve)->dp) {
  ------------------
  |  Branch (58:7): [True: 0, False: 3]
  ------------------
   59|      0|			dropbear_exit("Missing ECC params %s", (*curve)->name);
   60|      0|		}
   61|      3|	}
   62|      1|}

list_append:
    5|  1.32k|void list_append(m_list *list, void *item) {
    6|  1.32k|	m_list_elem *elem;
    7|       |	
    8|  1.32k|	elem = m_malloc(sizeof(*elem));
    9|  1.32k|	elem->item = item;
   10|  1.32k|	elem->list = list;
   11|  1.32k|	elem->next = NULL;
   12|  1.32k|	if (!list->first) {
  ------------------
  |  Branch (12:6): [True: 353, False: 968]
  ------------------
   13|    353|		list->first = elem;
   14|    353|		elem->prev = NULL;
   15|    968|	} else {
   16|    968|		elem->prev = list->last;
   17|    968|		list->last->next = elem;
   18|    968|	}
   19|  1.32k|	list->last = elem;
   20|  1.32k|}
list_new:
   22|    357|m_list * list_new() {
   23|    357|	m_list *ret = m_malloc(sizeof(m_list));
   24|       |	ret->first = ret->last = NULL;
   25|    357|	return ret;
   26|    357|}
list_remove:
   28|  1.32k|void * list_remove(m_list_elem *elem) {
   29|  1.32k|	void *item = elem->item;
   30|  1.32k|	m_list *list = elem->list;
   31|  1.32k|	if (list->first == elem)
  ------------------
  |  Branch (31:6): [True: 1.32k, False: 0]
  ------------------
   32|  1.32k|	{
   33|  1.32k|		list->first = elem->next;
   34|  1.32k|	}
   35|  1.32k|	if (list->last == elem)
  ------------------
  |  Branch (35:6): [True: 353, False: 968]
  ------------------
   36|    353|	{
   37|    353|		list->last = elem->prev;
   38|    353|	}
   39|  1.32k|	if (elem->prev)
  ------------------
  |  Branch (39:6): [True: 0, False: 1.32k]
  ------------------
   40|      0|	{
   41|      0|		elem->prev->next = elem->next;
   42|      0|	}
   43|  1.32k|	if (elem->next)
  ------------------
  |  Branch (43:6): [True: 968, False: 353]
  ------------------
   44|    968|	{
   45|    968|		elem->next->prev = elem->prev;
   46|    968|	}
   47|       |	m_free(elem);
  ------------------
  |  |   24|  1.32k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.32k]
  |  |  ------------------
  ------------------
   48|  1.32k|	return item;
   49|  1.32k|}

signkey_type_from_name:
   86|  2.34k|enum signkey_type signkey_type_from_name(const char* name, unsigned int namelen) {
   87|  2.34k|	int i;
   88|  6.58k|	for (i = 0; i < DROPBEAR_SIGNKEY_NUM_NAMED; i++) {
  ------------------
  |  Branch (88:14): [True: 6.38k, False: 204]
  ------------------
   89|  6.38k|		const char *fixed_name = signkey_names[i];
   90|  6.38k|		if (namelen == strlen(fixed_name)
  ------------------
  |  Branch (90:7): [True: 4.45k, False: 1.92k]
  ------------------
   91|  4.45k|			&& memcmp(fixed_name, name, namelen) == 0) {
  ------------------
  |  Branch (91:7): [True: 2.14k, False: 2.30k]
  ------------------
   92|       |
   93|  2.14k|#if DROPBEAR_ECDSA
   94|       |			/* Some of the ECDSA key sizes are defined even if they're not compiled in */
   95|  2.14k|			if (0
  ------------------
  |  Branch (95:8): [Folded, False: 2.14k]
  ------------------
   96|       |#if !DROPBEAR_ECC_256
   97|       |				|| i == DROPBEAR_SIGNKEY_ECDSA_NISTP256
   98|       |#endif
   99|       |#if !DROPBEAR_ECC_384
  100|       |				|| i == DROPBEAR_SIGNKEY_ECDSA_NISTP384
  101|       |#endif
  102|       |#if !DROPBEAR_ECC_521
  103|       |				|| i == DROPBEAR_SIGNKEY_ECDSA_NISTP521
  104|       |#endif
  105|  2.14k|				) {
  106|      0|				TRACE(("attempt to use ecdsa type %d not compiled in", i))
  107|      0|				return DROPBEAR_SIGNKEY_NONE;
  108|      0|			}
  109|  2.14k|#endif
  110|       |
  111|  2.14k|			return (enum signkey_type)i;
  112|  2.14k|		}
  113|  6.38k|	}
  114|       |
  115|    204|	TRACE(("signkey_type_from_name unexpected key type."))
  116|       |
  117|    204|	return DROPBEAR_SIGNKEY_NONE;
  118|  2.34k|}
signature_type_from_name:
  145|  2.34k|enum signature_type signature_type_from_name(const char* name, unsigned int namelen) {
  146|  2.34k|	enum signkey_type keytype = signkey_type_from_name(name, namelen);
  147|  2.34k|#if DROPBEAR_RSA
  148|  2.34k|#if DROPBEAR_RSA_SHA256
  149|  2.34k|	if (namelen == strlen(SSH_SIGNATURE_RSA_SHA256) 
  ------------------
  |  |  121|  2.34k|#define SSH_SIGNATURE_RSA_SHA256 "rsa-sha2-256"
  ------------------
  |  Branch (149:6): [True: 38, False: 2.31k]
  ------------------
  150|     38|		&& memcmp(name, SSH_SIGNATURE_RSA_SHA256, namelen) == 0) {
  ------------------
  |  |  121|     38|#define SSH_SIGNATURE_RSA_SHA256 "rsa-sha2-256"
  ------------------
  |  Branch (150:6): [True: 16, False: 22]
  ------------------
  151|     16|		return DROPBEAR_SIGNATURE_RSA_SHA256;
  152|     16|	}
  153|  2.33k|#endif
  154|       |	/* keytype == DROPBEAR_SIGNKEY_RSA iff name is "ssh-rsa" (SHA1 sig algo) */
  155|  2.33k|	if (keytype == DROPBEAR_SIGNKEY_RSA) {
  ------------------
  |  Branch (155:6): [True: 23, False: 2.30k]
  ------------------
  156|     23|#if DROPBEAR_RSA_SHA1
  157|     23|		return DROPBEAR_SIGNATURE_RSA_SHA1;
  158|       |#else
  159|       |		return DROPBEAR_SIGNATURE_NONE;
  160|       |#endif
  161|     23|	}
  162|  2.30k|#endif /* DROPBEAR_RSA */
  163|  2.30k|	return (enum signature_type)keytype;
  164|  2.33k|}
cmp_base64_key:
  731|  1.78k|					const buffer * line, char ** fingerprint) {
  732|       |
  733|  1.78k|	buffer * decodekey = NULL;
  734|  1.78k|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|  1.78k|#define DROPBEAR_FAILURE -1
  ------------------
  735|  1.78k|	unsigned int len, filealgolen;
  736|  1.78k|	unsigned long decodekeylen;
  737|  1.78k|	unsigned char* filealgo = NULL;
  738|       |
  739|       |	/* now we have the actual data */
  740|  1.78k|	len = line->len - line->pos;
  741|  1.78k|	if (len == 0) {
  ------------------
  |  Branch (741:6): [True: 80, False: 1.70k]
  ------------------
  742|       |		/* base64_decode doesn't like NULL argument */
  743|     80|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|     80|#define DROPBEAR_FAILURE -1
  ------------------
  744|     80|	}
  745|  1.70k|	decodekeylen = len * 2; /* big to be safe */
  746|  1.70k|	decodekey = buf_new(decodekeylen);
  747|       |
  748|  1.70k|	if (base64_decode(buf_getptr(line, len), len,
  ------------------
  |  Branch (748:6): [True: 25, False: 1.67k]
  ------------------
  749|  1.70k|				buf_getwriteptr(decodekey, decodekey->size),
  750|  1.70k|				&decodekeylen) != CRYPT_OK) {
  751|     25|		TRACE(("checkpubkey: base64 decode failed"))
  752|     25|		goto out;
  753|     25|	}
  754|  1.67k|	TRACE(("checkpubkey: base64_decode success"))
  755|  1.67k|	buf_incrlen(decodekey, decodekeylen);
  756|       |	
  757|  1.67k|	if (fingerprint) {
  ------------------
  |  Branch (757:6): [True: 0, False: 1.67k]
  ------------------
  758|      0|		*fingerprint = sign_key_fingerprint(buf_getptr(decodekey, decodekeylen),
  759|      0|											decodekeylen);
  760|      0|	}
  761|       |	
  762|       |	/* compare the keys */
  763|  1.67k|	if ( ( decodekeylen != keybloblen )
  ------------------
  |  Branch (763:7): [True: 134, False: 1.54k]
  ------------------
  764|  1.54k|			|| memcmp( buf_getptr(decodekey, decodekey->len),
  ------------------
  |  Branch (764:7): [True: 20, False: 1.52k]
  ------------------
  765|  1.54k|						keyblob, decodekey->len) != 0) {
  766|    154|		TRACE(("checkpubkey: compare failed"))
  767|    154|		goto out;
  768|    154|	}
  769|       |
  770|       |	/* ... and also check that the algo specified and the algo in the key
  771|       |	 * itself match */
  772|  1.52k|	filealgolen = buf_getint(decodekey);
  773|  1.52k|	filealgo = buf_getptr(decodekey, filealgolen);
  774|  1.52k|	if (filealgolen != algolen || memcmp(filealgo, algoname, algolen) != 0) {
  ------------------
  |  Branch (774:6): [True: 0, False: 1.52k]
  |  Branch (774:32): [True: 0, False: 1.52k]
  ------------------
  775|      0|		TRACE(("checkpubkey: algo match failed")) 
  776|      0|		goto out;
  777|      0|	}
  778|       |
  779|       |	/* All checks passed */
  780|  1.52k|	ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|  1.52k|#define DROPBEAR_SUCCESS 0
  ------------------
  781|       |
  782|  1.70k|out:
  783|  1.70k|	buf_free(decodekey);
  784|       |	decodekey = NULL;
  785|  1.70k|	return ret;
  786|  1.52k|}

fuzz_checkpubkey_line:
  608|  2.16k|		const unsigned char* keyblob, unsigned int keybloblen) {
  609|       |	struct PubKeyOptions *options = NULL;
  610|  2.16k|	checkpubkey_line(line, line_num, filename, algo, algolen, keyblob, keybloblen, &options);
  611|  2.16k|	svr_pubkey_options_cleanup(options);
  612|  2.16k|}
svr-authpubkey.c:checkpubkey_line:
  274|  2.16k|		struct PubKeyOptions ** ret_options) {
  275|  2.16k|	buffer *options_buf = NULL;
  276|  2.16k|	char *info_str = NULL;
  277|  2.16k|	unsigned int pos, len, infopos, infolen;
  278|  2.16k|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|  2.16k|#define DROPBEAR_FAILURE -1
  ------------------
  279|       |
  280|  2.16k|	if (ret_options) {
  ------------------
  |  Branch (280:6): [True: 2.16k, False: 0]
  ------------------
  281|  2.16k|		*ret_options = NULL;
  282|  2.16k|	}
  283|       |
  284|  2.16k|	if (line->len < MIN_AUTHKEYS_LINE || line->len > MAX_AUTHKEYS_LINE) {
  ------------------
  |  |   72|  4.32k|#define MIN_AUTHKEYS_LINE 10
  ------------------
              	if (line->len < MIN_AUTHKEYS_LINE || line->len > MAX_AUTHKEYS_LINE) {
  ------------------
  |  |   76|  2.14k|#define MAX_AUTHKEYS_LINE 3000
  ------------------
  |  Branch (284:6): [True: 13, False: 2.14k]
  |  Branch (284:39): [True: 3, False: 2.14k]
  ------------------
  285|     16|		TRACE(("checkpubkey_line: bad line length %d", line->len))
  286|     16|		goto out;
  287|     16|	}
  288|       |
  289|  2.14k|	if (memchr(line->data, 0x0, line->len) != NULL) {
  ------------------
  |  Branch (289:6): [True: 7, False: 2.13k]
  ------------------
  290|      7|		TRACE(("checkpubkey_line: bad line has null char"))
  291|      7|		goto out;
  292|      7|	}
  293|       |
  294|       |	/* compare the algorithm. +3 so we have enough bytes to read a space and some base64 characters too. */
  295|  2.13k|	if (line->pos + algolen+3 > line->len) {
  ------------------
  |  Branch (295:6): [True: 5, False: 2.13k]
  ------------------
  296|      5|		goto out;
  297|      5|	}
  298|       |	/* check the key type */
  299|  2.13k|	if (strncmp((const char *) buf_getptr(line, algolen), algo, algolen) != 0) {
  ------------------
  |  Branch (299:6): [True: 1.92k, False: 210]
  ------------------
  300|  1.92k|		int is_comment = 0;
  301|  1.92k|		unsigned char *options_start = NULL;
  302|  1.92k|		int options_len = 0;
  303|  1.92k|		int escape, quoted;
  304|       |
  305|       |		/* skip over any comments or leading whitespace */
  306|  12.4k|		while (line->pos < line->len) {
  ------------------
  |  Branch (306:10): [True: 12.4k, False: 18]
  ------------------
  307|  12.4k|			const char c = buf_getbyte(line);
  308|  12.4k|			if (c == ' ' || c == '\t') {
  ------------------
  |  Branch (308:8): [True: 2.72k, False: 9.68k]
  |  Branch (308:20): [True: 7.78k, False: 1.90k]
  ------------------
  309|  10.5k|				continue;
  310|  10.5k|			} else if (c == '#') {
  ------------------
  |  Branch (310:15): [True: 3, False: 1.90k]
  ------------------
  311|      3|				is_comment = 1;
  312|      3|				break;
  313|      3|			}
  314|  1.90k|			buf_decrpos(line, 1);
  315|  1.90k|			break;
  316|  12.4k|		}
  317|  1.92k|		if (is_comment) {
  ------------------
  |  Branch (317:7): [True: 3, False: 1.91k]
  ------------------
  318|       |			/* next line */
  319|      3|			goto out;
  320|      3|		}
  321|       |
  322|       |		/* remember start of options */
  323|  1.91k|		options_start = buf_getptr(line, 1);
  324|  1.91k|		quoted = 0;
  325|  1.91k|		escape = 0;
  326|  1.91k|		options_len = 0;
  327|       |
  328|       |		/* figure out where the options are */
  329|   150k|		while (line->pos < line->len) {
  ------------------
  |  Branch (329:10): [True: 150k, False: 164]
  ------------------
  330|   150k|			const char c = buf_getbyte(line);
  331|   150k|			if (!quoted && (c == ' ' || c == '\t')) {
  ------------------
  |  Branch (331:8): [True: 98.3k, False: 52.2k]
  |  Branch (331:20): [True: 79, False: 98.3k]
  |  Branch (331:32): [True: 1.67k, False: 96.6k]
  ------------------
  332|  1.75k|				break;
  333|  1.75k|			}
  334|   148k|			escape = (!escape && c == '\\');
  ------------------
  |  Branch (334:14): [True: 147k, False: 1.66k]
  |  Branch (334:25): [True: 1.67k, False: 145k]
  ------------------
  335|   148k|			if (!escape && c == '"') {
  ------------------
  |  Branch (335:8): [True: 147k, False: 1.67k]
  |  Branch (335:19): [True: 5.21k, False: 141k]
  ------------------
  336|  5.21k|				quoted = !quoted;
  337|  5.21k|			}
  338|   148k|			options_len++;
  339|   148k|		}
  340|  1.91k|		options_buf = buf_new(options_len);
  341|  1.91k|		buf_putbytes(options_buf, options_start, options_len);
  342|       |
  343|       |		/* compare the algorithm. +3 so we have enough bytes to read a space and some base64 characters too. */
  344|  1.91k|		if (line->pos + algolen+3 > line->len) {
  ------------------
  |  Branch (344:7): [True: 199, False: 1.72k]
  ------------------
  345|    199|			goto out;
  346|    199|		}
  347|  1.72k|		if (strncmp((const char *) buf_getptr(line, algolen), algo, algolen) != 0) {
  ------------------
  |  Branch (347:7): [True: 119, False: 1.60k]
  ------------------
  348|    119|			goto out;
  349|    119|		}
  350|  1.72k|	}
  351|  1.81k|	buf_incrpos(line, algolen);
  352|       |
  353|       |	/* check for space (' ') character */
  354|  1.81k|	if (buf_getbyte(line) != ' ') {
  ------------------
  |  Branch (354:6): [True: 12, False: 1.79k]
  ------------------
  355|     12|		TRACE(("checkpubkey_line: space character expected, isn't there"))
  356|     12|		goto out;
  357|     12|	}
  358|       |
  359|       |	/* find the length of base64 data */
  360|  1.79k|	pos = line->pos;
  361|  72.8k|	for (len = 0; line->pos < line->len; len++) {
  ------------------
  |  Branch (361:16): [True: 71.1k, False: 1.65k]
  ------------------
  362|  71.1k|		if (buf_getbyte(line) == ' ') {
  ------------------
  |  Branch (362:7): [True: 141, False: 71.0k]
  ------------------
  363|    141|			break;
  364|    141|		}
  365|  71.1k|	}
  366|       |
  367|       |	/* find out the length of the public key info, stop at the first space */
  368|  1.79k|	infopos = line->pos;
  369|  8.02k|	for (infolen = 0; line->pos < line->len; infolen++) {
  ------------------
  |  Branch (369:20): [True: 6.27k, False: 1.74k]
  ------------------
  370|  6.27k|		const char c = buf_getbyte(line);
  371|  6.27k|		if (c == ' ') {
  ------------------
  |  Branch (371:7): [True: 6, False: 6.26k]
  ------------------
  372|      6|			break;
  373|      6|		}
  374|       |		/* We have an allowlist - authorized_keys lines can't be fully trusted,
  375|       |		some shell scripts may do unsafe things with env var values */
  376|  6.26k|		if (!(ascii_isalnum(c) || strchr(".,_-+@", c))) {
  ------------------
  |  Branch (376:9): [True: 4.97k, False: 1.29k]
  |  Branch (376:29): [True: 1.24k, False: 46]
  ------------------
  377|     46|			TRACE(("Not setting SSH_PUBKEYINFO, special characters"))
  378|     46|			infolen = 0;
  379|     46|			break;
  380|     46|		}
  381|  6.26k|	}
  382|  1.79k|	if (infolen > 0) {
  ------------------
  |  Branch (382:6): [True: 83, False: 1.71k]
  ------------------
  383|     83|		info_str = m_malloc(infolen + 1);
  384|     83|		buf_setpos(line, infopos);
  385|     83|		strncpy(info_str, buf_getptr(line, infolen), infolen);
  386|     83|	}
  387|       |
  388|       |	/* truncate to base64 data length */
  389|  1.79k|	buf_setpos(line, pos);
  390|  1.79k|	buf_setlen(line, line->pos + len);
  391|       |
  392|  1.79k|	TRACE(("checkpubkey_line: line pos = %d len = %d", line->pos, line->len))
  393|       |
  394|  1.79k|	ret = cmp_base64_key(keyblob, keybloblen, (const unsigned char *) algo, algolen, line, NULL);
  395|       |
  396|       |	/* free pubkey_info if it is filled */
  397|  1.79k|	if (ret == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  1.79k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (397:6): [True: 1.52k, False: 277]
  ------------------
  398|  1.52k|#if DROPBEAR_SVR_PUBKEY_OPTIONS_BUILT
  399|  1.52k|		if (ret_options) {
  ------------------
  |  Branch (399:7): [True: 1.52k, False: 0]
  ------------------
  400|  1.52k|			*ret_options = svr_parse_pubkey_options(options_buf, line_num, filename);
  401|  1.52k|			if (*ret_options == NULL) {
  ------------------
  |  Branch (401:8): [True: 1.37k, False: 151]
  ------------------
  402|  1.37k|				ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|  1.37k|#define DROPBEAR_FAILURE -1
  ------------------
  403|  1.37k|				goto out;
  404|  1.37k|			}
  405|       |			/* take the (optional) public key information */
  406|    151|			(*ret_options)->info_env = info_str;
  407|    151|			info_str = NULL;
  408|    151|		}
  409|  1.52k|#endif
  410|  1.52k|	}
  411|       |
  412|  2.14k|out:
  413|  2.14k|	if (options_buf) {
  ------------------
  |  Branch (413:6): [True: 1.90k, False: 241]
  ------------------
  414|  1.90k|		buf_free(options_buf);
  415|  1.90k|	}
  416|  2.14k|	if (info_str) {
  ------------------
  |  Branch (416:6): [True: 77, False: 2.06k]
  ------------------
  417|       |		m_free(info_str);
  ------------------
  |  |   24|     77|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 77]
  |  |  ------------------
  ------------------
  418|     77|	}
  419|  2.14k|	return ret;
  420|  1.79k|}

svr_pubkey_options_cleanup:
  165|  3.51k|void svr_pubkey_options_cleanup(struct PubKeyOptions *pubkey_options) {
  166|  3.51k|	if (pubkey_options) {
  ------------------
  |  Branch (166:6): [True: 1.52k, False: 1.99k]
  ------------------
  167|  1.52k|		m_free(pubkey_options->forced_command);
  ------------------
  |  |   24|  1.52k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.52k]
  |  |  ------------------
  ------------------
  168|  1.52k|		if (pubkey_options->permit_open_destinations) {
  ------------------
  |  Branch (168:7): [True: 263, False: 1.25k]
  ------------------
  169|    263|			m_list_elem *iter = pubkey_options->permit_open_destinations->first;
  170|  1.32k|			while (iter) {
  ------------------
  |  Branch (170:11): [True: 1.05k, False: 263]
  ------------------
  171|  1.05k|				struct PermitTCPFwdEntry *entry = (struct PermitTCPFwdEntry*)list_remove(iter);
  172|  1.05k|				m_free(entry->host);
  ------------------
  |  |   24|  1.05k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  173|  1.05k|				m_free(entry);
  ------------------
  |  |   24|  1.05k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  174|  1.05k|				iter = pubkey_options->permit_open_destinations->first;
  175|  1.05k|			}
  176|    263|			m_free(pubkey_options->permit_open_destinations);
  ------------------
  |  |   24|    263|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 263]
  |  |  ------------------
  ------------------
  177|    263|		}
  178|  1.52k|		if (pubkey_options->permit_listens) {
  ------------------
  |  Branch (178:7): [True: 94, False: 1.42k]
  ------------------
  179|     94|			m_list_elem *iter = pubkey_options->permit_listens->first;
  180|    357|			while (iter) {
  ------------------
  |  Branch (180:11): [True: 263, False: 94]
  ------------------
  181|    263|				struct PermitTCPFwdEntry *entry = (struct PermitTCPFwdEntry*)list_remove(iter);
  182|    263|				m_free(entry->host);
  ------------------
  |  |   24|    263|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 263]
  |  |  ------------------
  ------------------
  183|    263|				m_free(entry);
  ------------------
  |  |   24|    263|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 263]
  |  |  ------------------
  ------------------
  184|    263|				iter = pubkey_options->permit_listens->first;
  185|    263|			}
  186|     94|			m_free(pubkey_options->permit_listens);
  ------------------
  |  |   24|     94|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 94]
  |  |  ------------------
  ------------------
  187|     94|		}
  188|  1.52k|		m_free(pubkey_options->info_env);
  ------------------
  |  |   24|  1.52k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.52k]
  |  |  ------------------
  ------------------
  189|       |		m_free(pubkey_options);
  ------------------
  |  |   24|  1.52k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.52k]
  |  |  ------------------
  ------------------
  190|  1.52k|	}
  191|  3.51k|}
svr_parse_pubkey_options:
  211|  1.52k|svr_parse_pubkey_options(buffer *options_buf, int line_num, const char* filename) {
  212|  1.52k|	struct PubKeyOptions *pubkey_options = NULL;
  213|       |
  214|  1.52k|	TRACE(("enter addpubkeyoptions"))
  215|       |
  216|  1.52k|	pubkey_options = (struct PubKeyOptions*)m_malloc(sizeof( struct PubKeyOptions ));
  217|       |
  218|  1.52k|	if (!options_buf) {
  ------------------
  |  Branch (218:6): [True: 5, False: 1.51k]
  ------------------
  219|      5|		TRACE(("leave addpubkeyoptions, null options"))
  220|      5|		return pubkey_options;
  221|      5|	}
  222|       |
  223|  1.51k|	buf_setpos(options_buf, 0);
  224|  7.29k|	while (options_buf->pos < options_buf->len) {
  ------------------
  |  Branch (224:9): [True: 7.14k, False: 146]
  ------------------
  225|  7.14k|		if (match_option(options_buf, "no-port-forwarding") == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  7.14k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (225:7): [True: 215, False: 6.93k]
  ------------------
  226|    215|			dropbear_log(LOG_WARNING, "Port forwarding disabled.");
  227|    215|			pubkey_options->no_port_forwarding_flag = 1;
  228|    215|			goto next_option;
  229|    215|		}
  230|  6.93k|		if (match_option(options_buf, "no-agent-forwarding") == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  6.93k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (230:7): [True: 205, False: 6.72k]
  ------------------
  231|    205|#if DROPBEAR_SVR_AGENTFWD
  232|    205|			dropbear_log(LOG_WARNING, "Agent forwarding disabled.");
  233|    205|			pubkey_options->no_agent_forwarding_flag = 1;
  234|    205|#endif
  235|    205|			goto next_option;
  236|    205|		}
  237|  6.72k|		if (match_option(options_buf, "no-X11-forwarding") == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  6.72k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (237:7): [True: 77, False: 6.64k]
  ------------------
  238|       |#if DROPBEAR_X11FWD
  239|       |			dropbear_log(LOG_WARNING, "X11 forwarding disabled.");
  240|       |			pubkey_options->no_x11_forwarding_flag = 1;
  241|       |#endif
  242|     77|			goto next_option;
  243|     77|		}
  244|  6.64k|		if (match_option(options_buf, "no-pty") == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  6.64k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (244:7): [True: 349, False: 6.30k]
  ------------------
  245|    349|			dropbear_log(LOG_WARNING, "Pty allocation disabled.");
  246|    349|			pubkey_options->no_pty_flag = 1;
  247|    349|			goto next_option;
  248|    349|		}
  249|  6.30k|		if (match_option(options_buf, "restrict") == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  6.30k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (249:7): [True: 220, False: 6.08k]
  ------------------
  250|    220|			dropbear_log(LOG_WARNING, "Restrict option set");
  251|    220|			pubkey_options->no_port_forwarding_flag = 1;
  252|    220|#if DROPBEAR_SVR_AGENTFWD
  253|    220|			pubkey_options->no_agent_forwarding_flag = 1;
  254|    220|#endif
  255|       |#if DROPBEAR_X11FWD
  256|       |			pubkey_options->no_x11_forwarding_flag = 1;
  257|       |#endif
  258|    220|			pubkey_options->no_pty_flag = 1;
  259|    220|			goto next_option;
  260|    220|		}
  261|  6.08k|		if (match_option(options_buf, "command=\"") == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  6.08k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (261:7): [True: 67, False: 6.01k]
  ------------------
  262|     67|			int escaped = 0;
  263|     67|			const unsigned char* command_start = buf_getptr(options_buf, 0);
  264|       |
  265|     67|			if (pubkey_options->forced_command) {
  ------------------
  |  Branch (265:8): [True: 2, False: 65]
  ------------------
  266|       |				/* multiple command= options */
  267|      2|				goto bad_option;
  268|      2|			}
  269|       |
  270|  12.5k|			while (options_buf->pos < options_buf->len) {
  ------------------
  |  Branch (270:11): [True: 12.5k, False: 18]
  ------------------
  271|  12.5k|				const char c = buf_getbyte(options_buf);
  272|  12.5k|				if (!escaped && c == '"') {
  ------------------
  |  Branch (272:9): [True: 12.2k, False: 269]
  |  Branch (272:21): [True: 47, False: 12.2k]
  ------------------
  273|     47|					const int command_len = buf_getptr(options_buf, 0) - command_start;
  274|     47|					pubkey_options->forced_command = m_malloc(command_len);
  275|     47|					memcpy(pubkey_options->forced_command,
  276|     47|							command_start, command_len-1);
  277|     47|					pubkey_options->forced_command[command_len-1] = '\0';
  278|     47|					goto next_option;
  279|     47|				}
  280|  12.4k|				escaped = (!escaped && c == '\\');
  ------------------
  |  Branch (280:16): [True: 12.2k, False: 269]
  |  Branch (280:28): [True: 269, False: 11.9k]
  ------------------
  281|  12.4k|			}
  282|     18|			dropbear_log(LOG_WARNING, "Badly formatted command= authorized_keys option");
  283|     18|			goto bad_option;
  284|     65|		}
  285|       |
  286|  6.01k|		if (match_option(options_buf, "permitopen=\"") == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  6.01k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (286:7): [True: 1.06k, False: 4.95k]
  ------------------
  287|  1.06k|			int valid_option = 0;
  288|  1.06k|			const unsigned char* permitopen_start = buf_getptr(options_buf, 0);
  289|       |
  290|  1.06k|			if (!pubkey_options->permit_open_destinations) {
  ------------------
  |  Branch (290:8): [True: 263, False: 797]
  ------------------
  291|    263|				pubkey_options->permit_open_destinations = list_new();
  292|    263|			}
  293|       |
  294|  9.99k|			while (options_buf->pos < options_buf->len) {
  ------------------
  |  Branch (294:11): [True: 9.98k, False: 2]
  ------------------
  295|  9.98k|				const char c = buf_getbyte(options_buf);
  296|  9.98k|				if (c == '"') {
  ------------------
  |  Branch (296:9): [True: 1.05k, False: 8.93k]
  ------------------
  297|  1.05k|					char *spec = NULL;
  298|  1.05k|					char *portstring = NULL;
  299|  1.05k|					const int permitopen_len = buf_getptr(options_buf, 0) - permitopen_start;
  300|  1.05k|					struct PermitTCPFwdEntry *entry =
  301|  1.05k|							(struct PermitTCPFwdEntry*)m_malloc(sizeof(struct PermitTCPFwdEntry));
  302|       |
  303|  1.05k|					list_append(pubkey_options->permit_open_destinations, entry);
  304|  1.05k|					spec = m_malloc(permitopen_len);
  305|  1.05k|					memcpy(spec, permitopen_start, permitopen_len - 1);
  306|  1.05k|					spec[permitopen_len - 1] = '\0';
  307|  1.05k|					if ((split_address_port(spec, &entry->host, &portstring) == DROPBEAR_SUCCESS)
  ------------------
  |  |  111|  1.05k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (307:10): [True: 1.04k, False: 16]
  ------------------
  308|  1.04k|						&& entry->host && portstring) {
  ------------------
  |  Branch (308:10): [True: 1.02k, False: 14]
  |  Branch (308:25): [True: 1.00k, False: 26]
  ------------------
  309|  1.00k|						if (strcmp(portstring, "*") == 0) {
  ------------------
  |  Branch (309:11): [True: 221, False: 781]
  ------------------
  310|    221|							valid_option = 1;
  311|    221|							entry->port = PUBKEY_OPTIONS_ANY_PORT;
  ------------------
  |  |  116|    221|#define PUBKEY_OPTIONS_ANY_PORT UINT_MAX
  ------------------
  312|    221|							TRACE(("local port forwarding allowed to host '%s'", entry->host));
  313|    781|						} else if (m_str_to_uint(portstring, &entry->port) == DROPBEAR_SUCCESS
  ------------------
  |  |  111|  1.56k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (313:18): [True: 682, False: 99]
  ------------------
  314|    682|							&& entry->port <= 65535) {
  ------------------
  |  Branch (314:11): [True: 640, False: 42]
  ------------------
  315|    640|							valid_option = 1;
  316|    640|							TRACE(("local port forwarding allowed to host '%s' and port '%u'",
  317|    640|									entry->host, entry->port));
  318|    640|						}
  319|  1.00k|					}
  320|       |
  321|  1.05k|					m_free(spec);
  ------------------
  |  |   24|  1.05k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  322|  1.05k|					m_free(portstring);
  ------------------
  |  |   24|  1.05k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  323|  1.05k|					break;
  324|  1.05k|				}
  325|  9.98k|			}
  326|       |
  327|  1.06k|			if (valid_option) {
  ------------------
  |  Branch (327:8): [True: 861, False: 199]
  ------------------
  328|    861|				goto next_option;
  329|    861|			} else {
  330|    199|				dropbear_log(LOG_WARNING, "Badly formatted permitopen= authorized_keys option");
  331|    199|				goto bad_option;
  332|    199|			}
  333|  1.06k|		}
  334|       |
  335|  4.95k|		if (match_option(options_buf, "permitlisten=\"") == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  4.95k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (335:7): [True: 265, False: 4.68k]
  ------------------
  336|    265|			int valid_option = 0;
  337|    265|			const unsigned char* permitlisten_start = buf_getptr(options_buf, 0);
  338|       |
  339|    265|			if (!pubkey_options->permit_listens) {
  ------------------
  |  Branch (339:8): [True: 94, False: 171]
  ------------------
  340|     94|				pubkey_options->permit_listens = list_new();
  341|     94|			}
  342|       |
  343|  2.47k|			while (options_buf->pos < options_buf->len) {
  ------------------
  |  Branch (343:11): [True: 2.47k, False: 2]
  ------------------
  344|  2.47k|				const char c = buf_getbyte(options_buf);
  345|  2.47k|				if (c == '"') {
  ------------------
  |  Branch (345:9): [True: 263, False: 2.21k]
  ------------------
  346|    263|					char *spec = NULL;
  347|    263|					const int permitlisten_len = buf_getptr(options_buf, 0) - permitlisten_start;
  348|    263|					struct PermitTCPFwdEntry *entry =
  349|    263|							(struct PermitTCPFwdEntry*)m_malloc(sizeof(struct PermitTCPFwdEntry));
  350|       |
  351|    263|					list_append(pubkey_options->permit_listens, entry);
  352|       |					/* permitlisten_len includes trailing '"' */
  353|    263|					spec = m_malloc(permitlisten_len);
  354|    263|					memcpy(spec, permitlisten_start, permitlisten_len - 1);
  355|    263|					spec[permitlisten_len - 1] = '\0';
  356|       |
  357|       |					/* Only a plain port accepted.
  358|       |					 * OpenSSH supports [host:]port, but that isn't implemented.
  359|       |					 * port="*" isn't supported either, since it only is useful
  360|       |					 * with a host: part. */
  361|       |
  362|    263|					if (m_str_to_uint(spec, &entry->port) == DROPBEAR_SUCCESS
  ------------------
  |  |  111|    526|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (362:10): [True: 241, False: 22]
  ------------------
  363|    241|						&& entry->port <= 65535) {
  ------------------
  |  Branch (363:10): [True: 210, False: 31]
  ------------------
  364|    210|						valid_option = 1;
  365|    210|						TRACE(("remote forwarding allows listening on port %u",
  366|    210|								entry->port));
  367|    210|					}
  368|       |
  369|    263|					m_free(spec);
  ------------------
  |  |   24|    263|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 263]
  |  |  ------------------
  ------------------
  370|    263|					break;
  371|    263|				}
  372|  2.47k|			}
  373|       |
  374|    265|			if (valid_option) {
  ------------------
  |  Branch (374:8): [True: 210, False: 55]
  ------------------
  375|    210|				goto next_option;
  376|    210|			} else {
  377|     55|				dropbear_log(LOG_WARNING, "Badly formatted permitlisten= authorized_keys option");
  378|     55|				goto bad_option;
  379|     55|			}
  380|    265|		}
  381|       |
  382|  4.68k|		if (match_option(options_buf, "no-touch-required") == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  4.68k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (382:7): [True: 72, False: 4.61k]
  ------------------
  383|     72|#if DROPBEAR_SK_ECDSA || DROPBEAR_SK_ED25519
  384|     72|			dropbear_log(LOG_WARNING, "No user presence check required for U2F/FIDO key.");
  385|     72|			pubkey_options->no_touch_required_flag = 1;
  386|     72|#endif
  387|     72|			goto next_option;
  388|     72|		}
  389|  4.61k|		if (match_option(options_buf, "verify-required") == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  4.61k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (389:7): [True: 195, False: 4.42k]
  ------------------
  390|    195|#if DROPBEAR_SK_ECDSA || DROPBEAR_SK_ED25519
  391|    195|			dropbear_log(LOG_WARNING, "User verification required for U2F/FIDO key.");
  392|    195|			pubkey_options->verify_required_flag = 1;
  393|    195|#endif
  394|    195|			goto next_option;
  395|    195|		}
  396|       |
  397|  6.87k|next_option:
  398|       |		/*
  399|       |		 * Skip the comma, and move to the next option
  400|       |		 * (or break out if there are no more).
  401|       |		 */
  402|  6.87k|		if (options_buf->pos < options_buf->len 
  ------------------
  |  Branch (402:7): [True: 6.74k, False: 126]
  ------------------
  403|  6.74k|				&& buf_getbyte(options_buf) != ',') {
  ------------------
  |  Branch (403:8): [True: 1.09k, False: 5.64k]
  ------------------
  404|  1.09k|			goto bad_option;
  405|  1.09k|		}
  406|       |		/* Process the next option. */
  407|  6.87k|	}
  408|       |	/* parsed all options with no problem */
  409|    146|	goto end;
  410|       |
  411|  1.37k|bad_option:
  412|  1.37k|	svr_pubkey_options_cleanup(pubkey_options);
  413|  1.37k|	pubkey_options = NULL;
  414|  1.37k|	dropbear_log(LOG_WARNING, "Bad public key options at %s:%d", filename, line_num);
  415|       |
  416|  1.51k|end:
  417|  1.51k|	TRACE(("leave addpubkeyoptions"))
  418|  1.51k|	return pubkey_options;
  419|  1.37k|}
svr-authpubkeyoptions.c:match_option:
  195|  60.1k|static int match_option(buffer *options_buf, const char *opt_name) {
  196|  60.1k|	const unsigned int len = strlen(opt_name);
  197|  60.1k|	if (options_buf->len - options_buf->pos < len) {
  ------------------
  |  Branch (197:6): [True: 8.00k, False: 52.1k]
  ------------------
  198|  8.00k|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|  8.00k|#define DROPBEAR_FAILURE -1
  ------------------
  199|  8.00k|	}
  200|  52.1k|	if (strncasecmp((const char *) buf_getptr(options_buf, len), opt_name, len) == 0) {
  ------------------
  |  Branch (200:6): [True: 2.72k, False: 49.3k]
  ------------------
  201|  2.72k|		buf_incrpos(options_buf, len);
  202|  2.72k|		return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|  2.72k|#define DROPBEAR_SUCCESS 0
  ------------------
  203|  2.72k|	}
  204|  49.3k|	return DROPBEAR_FAILURE;
  ------------------
  |  |  112|  49.3k|#define DROPBEAR_FAILURE -1
  ------------------
  205|  52.1k|}

