utf8_conv.c:k5_buf_add_uint16_le:
  134|  12.4k|{
  135|  12.4k|    void *p = k5_buf_get_space(buf, 2);
  136|       |
  137|  12.4k|    if (p != NULL)
  ------------------
  |  Branch (137:9): [True: 12.4k, False: 0]
  ------------------
  138|  12.4k|        store_16_le(val, p);
  139|  12.4k|}

utf8_conv.c:k5_input_init:
   53|    669|{
   54|    669|    in->ptr = ptr;
   55|    669|    in->len = len;
   56|    669|    in->status = 0;
   57|    669|}
utf8_conv.c:k5_input_get_uint16_le:
   96|  6.87k|{
   97|  6.87k|    const unsigned char *ptr = k5_input_get_bytes(in, 2);
   98|  6.87k|    return (ptr == NULL) ? 0 : load_16_le(ptr);
  ------------------
  |  Branch (98:12): [True: 16, False: 6.85k]
  ------------------
   99|  6.87k|}
utf8_conv.c:k5_input_get_bytes:
   70|  6.87k|{
   71|  6.87k|    if (in->len < len)
  ------------------
  |  Branch (71:9): [True: 16, False: 6.85k]
  ------------------
   72|     16|        k5_input_set_status(in, EINVAL);
   73|  6.87k|    if (in->status)
  ------------------
  |  Branch (73:9): [True: 16, False: 6.85k]
  ------------------
   74|     16|        return NULL;
   75|  6.85k|    in->len -= len;
   76|  6.85k|    in->ptr += len;
   77|  6.85k|    return in->ptr - len;
   78|  6.87k|}
utf8_conv.c:k5_input_set_status:
   63|     16|{
   64|     16|    if (!in->status)
  ------------------
  |  Branch (64:9): [True: 16, False: 0]
  ------------------
   65|     16|        in->status = status;
   66|     16|}

fuzz_util.c:k5memdup0:
 2311|    906|{
 2312|    906|    void *ptr = k5alloc(len + 1, code);
 2313|       |
 2314|    906|    if (ptr != NULL && len > 0)
  ------------------
  |  Branch (2314:9): [True: 906, False: 0]
  |  Branch (2314:24): [True: 906, False: 0]
  ------------------
 2315|    906|        memcpy(ptr, in, len);
 2316|    906|    return ptr;
 2317|    906|}
fuzz_util.c:k5alloc:
 2293|    906|{
 2294|    906|    return k5calloc(1, size, code);
 2295|    906|}
fuzz_util.c:k5calloc:
 2281|    906|{
 2282|    906|    void *ptr;
 2283|       |
 2284|       |    /* Allocate at least one byte since zero-byte allocs may return NULL. */
 2285|    906|    ptr = calloc(nmemb ? nmemb : 1, size ? size : 1);
  ------------------
  |  Branch (2285:18): [True: 906, False: 0]
  |  Branch (2285:37): [True: 906, False: 0]
  ------------------
 2286|    906|    *code = (ptr == NULL) ? ENOMEM : 0;
  ------------------
  |  Branch (2286:13): [True: 0, False: 906]
  ------------------
 2287|    906|    return ptr;
 2288|    906|}
parse.c:k5alloc:
 2293|  7.24k|{
 2294|  7.24k|    return k5calloc(1, size, code);
 2295|  7.24k|}
parse.c:k5calloc:
 2281|  7.24k|{
 2282|  7.24k|    void *ptr;
 2283|       |
 2284|       |    /* Allocate at least one byte since zero-byte allocs may return NULL. */
 2285|  7.24k|    ptr = calloc(nmemb ? nmemb : 1, size ? size : 1);
  ------------------
  |  Branch (2285:18): [True: 7.24k, False: 0]
  |  Branch (2285:37): [True: 7.24k, False: 0]
  ------------------
 2286|  7.24k|    *code = (ptr == NULL) ? ENOMEM : 0;
  ------------------
  |  Branch (2286:13): [True: 0, False: 7.24k]
  ------------------
 2287|  7.24k|    return ptr;
 2288|  7.24k|}
parse.c:make_data:
 2236|  5.44k|{
 2237|  5.44k|    krb5_data d;
 2238|       |
 2239|  5.44k|    d.magic = KV5M_DATA;
  ------------------
  |  | 9038|  5.44k|#define KV5M_DATA                                (-1760647422L)
  ------------------
 2240|  5.44k|    d.data = (char *) data;
 2241|  5.44k|    d.length = len;
 2242|  5.44k|    return d;
 2243|  5.44k|}
parse.c:empty_data:
 2247|  5.44k|{
 2248|       |    return make_data(NULL, 0);
 2249|  5.44k|}
parse_host_string.c:k5memdup0:
 2311|    714|{
 2312|    714|    void *ptr = k5alloc(len + 1, code);
 2313|       |
 2314|    714|    if (ptr != NULL && len > 0)
  ------------------
  |  Branch (2314:9): [True: 714, False: 0]
  |  Branch (2314:24): [True: 701, False: 13]
  ------------------
 2315|    701|        memcpy(ptr, in, len);
 2316|    714|    return ptr;
 2317|    714|}
parse_host_string.c:k5alloc:
 2293|    714|{
 2294|    714|    return k5calloc(1, size, code);
 2295|    714|}
parse_host_string.c:k5calloc:
 2281|    714|{
 2282|    714|    void *ptr;
 2283|       |
 2284|       |    /* Allocate at least one byte since zero-byte allocs may return NULL. */
 2285|    714|    ptr = calloc(nmemb ? nmemb : 1, size ? size : 1);
  ------------------
  |  Branch (2285:18): [True: 714, False: 0]
  |  Branch (2285:37): [True: 714, False: 0]
  ------------------
 2286|    714|    *code = (ptr == NULL) ? ENOMEM : 0;
  ------------------
  |  Branch (2286:13): [True: 0, False: 714]
  ------------------
 2287|    714|    return ptr;
 2288|    714|}
plugin.c:k5alloc:
 2293|  6.09k|{
 2294|  6.09k|    return k5calloc(1, size, code);
 2295|  6.09k|}
plugin.c:k5calloc:
 2281|  6.09k|{
 2282|  6.09k|    void *ptr;
 2283|       |
 2284|       |    /* Allocate at least one byte since zero-byte allocs may return NULL. */
 2285|  6.09k|    ptr = calloc(nmemb ? nmemb : 1, size ? size : 1);
  ------------------
  |  Branch (2285:18): [True: 6.09k, False: 0]
  |  Branch (2285:37): [True: 6.09k, False: 0]
  ------------------
 2286|  6.09k|    *code = (ptr == NULL) ? ENOMEM : 0;
  ------------------
  |  Branch (2286:13): [True: 0, False: 6.09k]
  ------------------
 2287|  6.09k|    return ptr;
 2288|  6.09k|}
plugin.c:k5memdup0:
 2311|  3.04k|{
 2312|  3.04k|    void *ptr = k5alloc(len + 1, code);
 2313|       |
 2314|  3.04k|    if (ptr != NULL && len > 0)
  ------------------
  |  Branch (2314:9): [True: 3.04k, False: 0]
  |  Branch (2314:24): [True: 3.04k, False: 0]
  ------------------
 2315|  3.04k|        memcpy(ptr, in, len);
 2316|  3.04k|    return ptr;
 2317|  3.04k|}
hostrealm.c:k5alloc:
 2293|  3.81k|{
 2294|  3.81k|    return k5calloc(1, size, code);
 2295|  3.81k|}
hostrealm.c:k5calloc:
 2281|  3.81k|{
 2282|  3.81k|    void *ptr;
 2283|       |
 2284|       |    /* Allocate at least one byte since zero-byte allocs may return NULL. */
 2285|  3.81k|    ptr = calloc(nmemb ? nmemb : 1, size ? size : 1);
  ------------------
  |  Branch (2285:18): [True: 3.81k, False: 0]
  |  Branch (2285:37): [True: 3.81k, False: 0]
  ------------------
 2286|  3.81k|    *code = (ptr == NULL) ? ENOMEM : 0;
  ------------------
  |  Branch (2286:13): [True: 0, False: 3.81k]
  ------------------
 2287|  3.81k|    return ptr;
 2288|  3.81k|}
bld_princ.c:data_eq_string:
 2229|    228|{
 2230|    228|    return (d.length == strlen(s) && (d.length == 0 ||
  ------------------
  |  Branch (2230:13): [True: 90, False: 138]
  |  Branch (2230:39): [True: 0, False: 90]
  ------------------
 2231|     90|                                      !memcmp(d.data, s, d.length)));
  ------------------
  |  Branch (2231:39): [True: 2, False: 88]
  ------------------
 2232|    228|}

fuzz_util.c:load_64_le:
  693|  3.17k|{
  694|  3.17k|    const unsigned char *p = (const unsigned char *) cvp;
  695|  3.17k|#if defined(__GNUC__) && defined(K5_LE) && !defined(__cplusplus)
  696|  3.17k|    return GET(64,p);
  ------------------
  |  |  490|  3.17k|# define GET(SIZE,PTR)          (((const struct { uint##SIZE##_t i; } __attribute__((packed)) *)(PTR))->i)
  ------------------
  697|       |#elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP64) && !defined(__cplusplus)
  698|       |    return GETSWAPPED(64,p);
  699|       |#else
  700|       |    return ((uint64_t)load_32_le(p+4) << 32) | load_32_le(p);
  701|       |#endif
  702|  3.17k|}
krb5_libinit.c:krb5int_lib_init__aux:
  284|      1|        {                                                       \
  285|      1|            JOIN__2(NAME, once).did_run = 1;                    \
  ------------------
  |  |  233|      1|# define JOIN__2(A,B) JOIN__2_2(A,B)
  |  |  ------------------
  |  |  |  |  232|      1|# define JOIN__2_2(A,B) A ## _ ## _ ## B
  |  |  ------------------
  ------------------
  286|      1|            JOIN__2(NAME, once).error = NAME();                 \
  ------------------
  |  |  233|      1|# define JOIN__2(A,B) JOIN__2_2(A,B)
  |  |  ------------------
  |  |  |  |  232|      1|# define JOIN__2_2(A,B) A ## _ ## _ ## B
  |  |  ------------------
  ------------------
  287|      1|        }                                                       \
prof_file.c:profile_library_initializer__aux:
  284|      1|        {                                                       \
  285|      1|            JOIN__2(NAME, once).did_run = 1;                    \
  ------------------
  |  |  233|      1|# define JOIN__2(A,B) JOIN__2_2(A,B)
  |  |  ------------------
  |  |  |  |  232|      1|# define JOIN__2_2(A,B) A ## _ ## _ ## B
  |  |  ------------------
  ------------------
  286|      1|            JOIN__2(NAME, once).error = NAME();                 \
  ------------------
  |  |  233|      1|# define JOIN__2(A,B) JOIN__2_2(A,B)
  |  |  ------------------
  |  |  |  |  232|      1|# define JOIN__2_2(A,B) A ## _ ## _ ## B
  |  |  ------------------
  ------------------
  287|      1|        }                                                       \
error_message.c:com_err_initialize__aux:
  284|      1|        {                                                       \
  285|      1|            JOIN__2(NAME, once).did_run = 1;                    \
  ------------------
  |  |  233|      1|# define JOIN__2(A,B) JOIN__2_2(A,B)
  |  |  ------------------
  |  |  |  |  232|      1|# define JOIN__2_2(A,B) A ## _ ## _ ## B
  |  |  ------------------
  ------------------
  286|      1|            JOIN__2(NAME, once).error = NAME();                 \
  ------------------
  |  |  233|      1|# define JOIN__2(A,B) JOIN__2_2(A,B)
  |  |  ------------------
  |  |  |  |  232|      1|# define JOIN__2_2(A,B) A ## _ ## _ ## B
  |  |  ------------------
  ------------------
  287|      1|        }                                                       \
threads.c:krb5int_thread_support_init__aux:
  284|      1|        {                                                       \
  285|      1|            JOIN__2(NAME, once).did_run = 1;                    \
  ------------------
  |  |  233|      1|# define JOIN__2(A,B) JOIN__2_2(A,B)
  |  |  ------------------
  |  |  |  |  232|      1|# define JOIN__2_2(A,B) A ## _ ## _ ## B
  |  |  ------------------
  ------------------
  286|      1|            JOIN__2(NAME, once).error = NAME();                 \
  ------------------
  |  |  233|      1|# define JOIN__2(A,B) JOIN__2_2(A,B)
  |  |  ------------------
  |  |  |  |  232|      1|# define JOIN__2_2(A,B) A ## _ ## _ ## B
  |  |  ------------------
  ------------------
  287|      1|        }                                                       \
utf8_conv.c:store_16_le:
  622|  12.4k|{
  623|  12.4k|    unsigned char *p = (unsigned char *) vp;
  624|  12.4k|#if defined(__GNUC__) && defined(K5_LE) && !defined(__cplusplus)
  625|  12.4k|    PUT(16,p,val);
  ------------------
  |  |  489|  12.4k|# define PUT(SIZE,PTR,VAL)      (((struct { uint##SIZE##_t i; } __attribute__((packed)) *)(PTR))->i = (VAL))
  ------------------
  626|       |#elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP16) && !defined(__cplusplus)
  627|       |    PUTSWAPPED(16,p,val);
  628|       |#else
  629|       |    p[1] = (val >>  8) & 0xff;
  630|       |    p[0] = (val      ) & 0xff;
  631|       |#endif
  632|  12.4k|}
utf8_conv.c:load_16_le:
  669|  6.85k|{
  670|  6.85k|    const unsigned char *p = (const unsigned char *) cvp;
  671|  6.85k|#if defined(__GNUC__) && defined(K5_LE) && !defined(__cplusplus)
  672|  6.85k|    return GET(16,p);
  ------------------
  |  |  490|  6.85k|# define GET(SIZE,PTR)          (((const struct { uint##SIZE##_t i; } __attribute__((packed)) *)(PTR))->i)
  ------------------
  673|       |#elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP16) && !defined(__cplusplus)
  674|       |    return GETSWAPPED(16,p);
  675|       |#else
  676|       |    return (p[0] | (p[1] << 8));
  677|       |#endif
  678|  6.85k|}

krb5_libinit.c:k5_mutex_finish_init:
  361|      1|{
  362|      1|    return k5_os_mutex_finish_init(m);
  ------------------
  |  |  289|      1|# define k5_os_mutex_finish_init(M)             (0)
  ------------------
  363|      1|}
ccbase.c:k5_mutex_finish_init:
  361|      4|{
  362|      4|    return k5_os_mutex_finish_init(m);
  ------------------
  |  |  289|      4|# define k5_os_mutex_finish_init(M)             (0)
  ------------------
  363|      4|}
ktbase.c:k5_mutex_finish_init:
  361|      1|{
  362|      1|    return k5_os_mutex_finish_init(m);
  ------------------
  |  |  289|      1|# define k5_os_mutex_finish_init(M)             (0)
  ------------------
  363|      1|}
kt_memory.c:k5_mutex_finish_init:
  361|      1|{
  362|      1|    return k5_os_mutex_finish_init(m);
  ------------------
  |  |  289|      1|# define k5_os_mutex_finish_init(M)             (0)
  ------------------
  363|      1|}
prof_file.c:k5_mutex_init:
  357|  1.81k|{
  358|  1.81k|    return k5_os_mutex_init(m);
  359|  1.81k|}
prof_file.c:k5_mutex_finish_init:
  361|      1|{
  362|      1|    return k5_os_mutex_finish_init(m);
  ------------------
  |  |  289|      1|# define k5_os_mutex_finish_init(M)             (0)
  ------------------
  363|      1|}
prof_file.c:k5_mutex_lock:
  368|  7.24k|{
  369|  7.24k|    int r = k5_os_mutex_lock(m);
  370|  7.24k|#ifndef NDEBUG
  371|  7.24k|    if (r != 0) {
  ------------------
  |  Branch (371:9): [True: 0, False: 7.24k]
  ------------------
  372|      0|        fprintf(stderr, "k5_mutex_lock: Received error %d (%s)\n",
  373|      0|                r, strerror(r));
  374|      0|    }
  375|  7.24k|#endif
  376|       |    assert(r == 0);
  ------------------
  |  Branch (376:5): [True: 0, False: 7.24k]
  |  Branch (376:5): [True: 7.24k, False: 0]
  ------------------
  377|  7.24k|}
prof_file.c:k5_mutex_unlock:
  380|  7.24k|{
  381|  7.24k|    int r = k5_os_mutex_unlock(m);
  382|  7.24k|#ifndef NDEBUG
  383|  7.24k|    if (r != 0) {
  ------------------
  |  Branch (383:9): [True: 0, False: 7.24k]
  ------------------
  384|      0|        fprintf(stderr, "k5_mutex_unlock: Received error %d (%s)\n",
  385|      0|                r, strerror(r));
  386|      0|    }
  387|  7.24k|#endif
  388|       |    assert(r == 0);
  ------------------
  |  Branch (388:5): [True: 0, False: 7.24k]
  |  Branch (388:5): [True: 7.24k, False: 0]
  ------------------
  389|  7.24k|}
error_message.c:k5_mutex_finish_init:
  361|      2|{
  362|      2|    return k5_os_mutex_finish_init(m);
  ------------------
  |  |  289|      2|# define k5_os_mutex_finish_init(M)             (0)
  ------------------
  363|      2|}
error_message.c:k5_mutex_lock:
  368|      7|{
  369|      7|    int r = k5_os_mutex_lock(m);
  370|      7|#ifndef NDEBUG
  371|      7|    if (r != 0) {
  ------------------
  |  Branch (371:9): [True: 0, False: 7]
  ------------------
  372|      0|        fprintf(stderr, "k5_mutex_lock: Received error %d (%s)\n",
  373|      0|                r, strerror(r));
  374|      0|    }
  375|      7|#endif
  376|       |    assert(r == 0);
  ------------------
  |  Branch (376:5): [True: 0, False: 7]
  |  Branch (376:5): [True: 7, False: 0]
  ------------------
  377|      7|}
error_message.c:k5_mutex_unlock:
  380|      7|{
  381|      7|    int r = k5_os_mutex_unlock(m);
  382|      7|#ifndef NDEBUG
  383|      7|    if (r != 0) {
  ------------------
  |  Branch (383:9): [True: 0, False: 7]
  ------------------
  384|      0|        fprintf(stderr, "k5_mutex_unlock: Received error %d (%s)\n",
  385|      0|                r, strerror(r));
  386|      0|    }
  387|      7|#endif
  388|       |    assert(r == 0);
  ------------------
  |  Branch (388:5): [True: 0, False: 7]
  |  Branch (388:5): [True: 7, False: 0]
  ------------------
  389|      7|}
threads.c:k5_mutex_finish_init:
  361|      1|{
  362|      1|    return k5_os_mutex_finish_init(m);
  ------------------
  |  |  289|      1|# define k5_os_mutex_finish_init(M)             (0)
  ------------------
  363|      1|}
threads.c:k5_mutex_lock:
  368|      1|{
  369|      1|    int r = k5_os_mutex_lock(m);
  370|      1|#ifndef NDEBUG
  371|      1|    if (r != 0) {
  ------------------
  |  Branch (371:9): [True: 0, False: 1]
  ------------------
  372|      0|        fprintf(stderr, "k5_mutex_lock: Received error %d (%s)\n",
  373|      0|                r, strerror(r));
  374|      0|    }
  375|      1|#endif
  376|       |    assert(r == 0);
  ------------------
  |  Branch (376:5): [True: 0, False: 1]
  |  Branch (376:5): [True: 1, False: 0]
  ------------------
  377|      1|}
threads.c:k5_mutex_unlock:
  380|      1|{
  381|      1|    int r = k5_os_mutex_unlock(m);
  382|      1|#ifndef NDEBUG
  383|      1|    if (r != 0) {
  ------------------
  |  Branch (383:9): [True: 0, False: 1]
  ------------------
  384|      0|        fprintf(stderr, "k5_mutex_unlock: Received error %d (%s)\n",
  385|      0|                r, strerror(r));
  386|      0|    }
  387|      1|#endif
  388|       |    assert(r == 0);
  ------------------
  |  Branch (388:5): [True: 0, False: 1]
  |  Branch (388:5): [True: 1, False: 0]
  ------------------
  389|      1|}
init-addrinfo.c:k5_mutex_finish_init:
  361|      1|{
  362|      1|    return k5_os_mutex_finish_init(m);
  ------------------
  |  |  289|      1|# define k5_os_mutex_finish_init(M)             (0)
  ------------------
  363|      1|}
errors.c:k5_mutex_finish_init:
  361|      1|{
  362|      1|    return k5_os_mutex_finish_init(m);
  ------------------
  |  |  289|      1|# define k5_os_mutex_finish_init(M)             (0)
  ------------------
  363|      1|}
errors.c:k5_mutex_lock:
  368|      1|{
  369|      1|    int r = k5_os_mutex_lock(m);
  370|      1|#ifndef NDEBUG
  371|      1|    if (r != 0) {
  ------------------
  |  Branch (371:9): [True: 0, False: 1]
  ------------------
  372|      0|        fprintf(stderr, "k5_mutex_lock: Received error %d (%s)\n",
  373|      0|                r, strerror(r));
  374|      0|    }
  375|      1|#endif
  376|       |    assert(r == 0);
  ------------------
  |  Branch (376:5): [True: 0, False: 1]
  |  Branch (376:5): [True: 1, False: 0]
  ------------------
  377|      1|}
errors.c:k5_mutex_unlock:
  380|      1|{
  381|      1|    int r = k5_os_mutex_unlock(m);
  382|      1|#ifndef NDEBUG
  383|      1|    if (r != 0) {
  ------------------
  |  Branch (383:9): [True: 0, False: 1]
  ------------------
  384|      0|        fprintf(stderr, "k5_mutex_unlock: Received error %d (%s)\n",
  385|      0|                r, strerror(r));
  386|      0|    }
  387|      1|#endif
  388|       |    assert(r == 0);
  ------------------
  |  Branch (388:5): [True: 0, False: 1]
  |  Branch (388:5): [True: 1, False: 0]
  ------------------
  389|      1|}

krb5int_cc_initialize:
  109|      1|{
  110|      1|    int err;
  111|       |
  112|      1|    err = k5_cc_mutex_finish_init(&cccol_lock);
  113|      1|    if (err)
  ------------------
  |  Branch (113:9): [True: 0, False: 1]
  ------------------
  114|      0|        return err;
  115|      1|    err = k5_cc_mutex_finish_init(&krb5int_mcc_mutex);
  116|      1|    if (err)
  ------------------
  |  Branch (116:9): [True: 0, False: 1]
  ------------------
  117|      0|        return err;
  118|      1|    err = k5_mutex_finish_init(&cc_typelist_lock);
  119|      1|    if (err)
  ------------------
  |  Branch (119:9): [True: 0, False: 1]
  ------------------
  120|      0|        return err;
  121|      1|#ifndef NO_FILE_CCACHE
  122|      1|    err = k5_cc_mutex_finish_init(&krb5int_cc_file_mutex);
  123|      1|    if (err)
  ------------------
  |  Branch (123:9): [True: 0, False: 1]
  ------------------
  124|      0|        return err;
  125|      1|#endif
  126|       |#ifdef USE_KEYRING_CCACHE
  127|       |    err = k5_cc_mutex_finish_init(&krb5int_krcc_mutex);
  128|       |    if (err)
  129|       |        return err;
  130|       |#endif
  131|      1|    return 0;
  132|      1|}
k5_cc_mutex_finish_init:
  482|      3|{
  483|      3|    krb5_error_code ret = 0;
  484|       |
  485|      3|    ret = k5_mutex_finish_init(&m->lock);
  486|      3|    if (ret) return ret;
  ------------------
  |  Branch (486:9): [True: 0, False: 3]
  ------------------
  487|      3|    m->owner = NULL;
  488|      3|    m->refcount = 0;
  489|       |
  490|      3|    return ret;
  491|      3|}

k5_ccselect_free_context:
  201|    906|{
  202|    906|    free_handles(context, context->ccselect_handles);
  203|       |    context->ccselect_handles = NULL;
  204|    906|}
ccselect.c:free_handles:
   40|    906|{
   41|    906|    struct ccselect_module_handle *h, **hp;
   42|       |
   43|    906|    if (handles == NULL)
  ------------------
  |  Branch (43:9): [True: 906, False: 0]
  ------------------
   44|    906|        return;
   45|      0|    for (hp = handles; *hp != NULL; hp++) {
  ------------------
  |  Branch (45:24): [True: 0, False: 0]
  ------------------
   46|      0|        h = *hp;
   47|      0|        if (h->vt.fini)
  ------------------
  |  Branch (47:13): [True: 0, False: 0]
  ------------------
   48|      0|            h->vt.fini(context, h->data);
   49|      0|        free(h);
   50|      0|    }
   51|      0|    free(handles);
   52|      0|}

krb5int_mkt_initialize:
  138|      1|{
  139|      1|    return k5_mutex_finish_init(&krb5int_mkt_mutex);
  140|      1|}

krb5int_kt_initialize:
   82|      1|{
   83|      1|    int err;
   84|       |
   85|      1|    err = k5_mutex_finish_init(&kt_typehead_lock);
   86|      1|    if (err)
  ------------------
  |  Branch (86:9): [True: 0, False: 1]
  ------------------
   87|      0|        goto done;
   88|      1|    err = krb5int_mkt_initialize();
   89|      1|    if (err)
  ------------------
  |  Branch (89:9): [True: 0, False: 1]
  ------------------
   90|      0|        goto done;
   91|       |
   92|      1|done:
   93|      1|    return(err);
   94|      1|}

k5_infer_principal_type:
   32|    138|{
   33|       |    /* RFC 4120 section 7.3 */
   34|    138|    if (princ->length == 2 && data_eq_string(princ->data[0], KRB5_TGS_NAME))
  ------------------
  |  | 6461|    104|#define KRB5_TGS_NAME           "krbtgt"
  ------------------
  |  Branch (34:9): [True: 104, False: 34]
  |  Branch (34:31): [True: 1, False: 103]
  ------------------
   35|      1|        return KRB5_NT_SRV_INST;
  ------------------
  |  |  241|      1|#define KRB5_NT_SRV_INST       2 /**< Service and other unique instance (krbtgt) */
  ------------------
   36|       |
   37|       |    /* RFC 6111 section 3.1 */
   38|    137|    if (princ->length >= 2 &&
  ------------------
  |  Branch (38:9): [True: 124, False: 13]
  ------------------
   39|    124|        data_eq_string(princ->data[0], KRB5_WELLKNOWN_NAMESTR))
  ------------------
  |  |  250|    124|#define KRB5_WELLKNOWN_NAMESTR "WELLKNOWN" /**< First component of
  ------------------
  |  Branch (39:9): [True: 1, False: 123]
  ------------------
   40|      1|        return KRB5_NT_WELLKNOWN;
  ------------------
  |  |  249|      1|#define KRB5_NT_WELLKNOWN      11 /**< Well-known (special) principal */
  ------------------
   41|       |
   42|    136|    return KRB5_NT_PRINCIPAL;
  ------------------
  |  |  239|    136|#define KRB5_NT_PRINCIPAL      1 /**< Just the name of the principal
  ------------------
   43|    137|}

krb5_init_context:
  125|    906|{
  126|       |    /*
  127|       |     * This is rather silly, but should improve our chances of
  128|       |     * retaining the krb5_brand array in the final linked library,
  129|       |     * better than a static variable that's unreferenced after
  130|       |     * optimization, or even a non-static symbol that's not exported
  131|       |     * from the library nor referenced from anywhere else in the
  132|       |     * library.
  133|       |     *
  134|       |     * If someday we grow an API to actually return the string, we can
  135|       |     * get rid of this silliness.
  136|       |     */
  137|    906|    int my_zero = (krb5_brand[0] == 0);
  138|       |
  139|       |    return krb5_init_context_profile(NULL, my_zero, context);
  140|    906|}
krb5_init_context_profile:
  157|    906|{
  158|    906|    krb5_context ctx = 0;
  159|    906|    krb5_error_code retval;
  160|    906|    int tmp;
  161|    906|    char *plugin_dir = NULL, *timeout_str = NULL;
  162|       |
  163|       |    /* Verify some assumptions.  If the assumptions hold and the
  164|       |       compiler is optimizing, this should result in no code being
  165|       |       executed.  If we're guessing "unsigned long long" instead
  166|       |       of using uint64_t, the possibility does exist that we're
  167|       |       wrong.  */
  168|    906|    {
  169|    906|        uint64_t i64;
  170|    906|        assert(sizeof(i64) == 8);
  ------------------
  |  Branch (170:9): [True: 0, Folded]
  |  Branch (170:9): [True: 906, Folded]
  ------------------
  171|    906|        i64 = 0, i64--, i64 >>= 62;
  172|    906|        assert(i64 == 3);
  ------------------
  |  Branch (172:9): [True: 0, False: 906]
  |  Branch (172:9): [True: 906, False: 0]
  ------------------
  173|    906|        i64 = 1, i64 <<= 31, i64 <<= 31, i64 <<= 1;
  174|    906|        assert(i64 != 0);
  ------------------
  |  Branch (174:9): [True: 0, False: 906]
  |  Branch (174:9): [True: 906, False: 0]
  ------------------
  175|    906|        i64 <<= 1;
  176|    906|        assert(i64 == 0);
  ------------------
  |  Branch (176:9): [True: 0, False: 906]
  |  Branch (176:9): [True: 906, False: 0]
  ------------------
  177|    906|    }
  178|       |
  179|    906|    retval = krb5int_initialize_library();
  180|    906|    if (retval)
  ------------------
  |  Branch (180:9): [True: 0, False: 906]
  ------------------
  181|      0|        return retval;
  182|       |
  183|       |#if (defined(_WIN32))
  184|       |    /*
  185|       |     * Load the krbcc32.dll if necessary.  We do this here so that
  186|       |     * we know to use API: later on during initialization.
  187|       |     * The context being NULL is ok.
  188|       |     */
  189|       |    krb5_win_ccdll_load(ctx);
  190|       |
  191|       |    /*
  192|       |     * krb5_vercheck() is defined in win_glue.c, and this is
  193|       |     * where we handle the timebomb and version server checks.
  194|       |     */
  195|       |    retval = krb5_vercheck();
  196|       |    if (retval)
  197|       |        return retval;
  198|       |#endif
  199|       |
  200|    906|    *context_out = NULL;
  201|       |
  202|    906|    ctx = calloc(1, sizeof(struct _krb5_context));
  203|    906|    if (!ctx)
  ------------------
  |  Branch (203:9): [True: 0, False: 906]
  ------------------
  204|      0|        return ENOMEM;
  205|    906|    ctx->magic = KV5M_CONTEXT;
  ------------------
  |  | 9072|    906|#define KV5M_CONTEXT                             (-1760647388L)
  ------------------
  206|       |
  207|    906|    ctx->profile_secure = (flags & KRB5_INIT_CONTEXT_SECURE) != 0;
  ------------------
  |  | 2860|    906|#define KRB5_INIT_CONTEXT_SECURE 0x1 /**< Use secure context configuration */
  ------------------
  208|       |
  209|    906|    retval = k5_os_init_context(ctx, profile, flags);
  210|    906|    if (retval)
  ------------------
  |  Branch (210:9): [True: 0, False: 906]
  ------------------
  211|      0|        goto cleanup;
  212|       |
  213|    906|    ctx->trace_callback = NULL;
  214|    906|#ifndef DISABLE_TRACING
  215|    906|    if (!ctx->profile_secure)
  ------------------
  |  Branch (215:9): [True: 906, False: 0]
  ------------------
  216|    906|        k5_init_trace(ctx);
  217|    906|#endif
  218|       |
  219|    906|    retval = get_boolean(ctx, KRB5_CONF_ALLOW_WEAK_CRYPTO, 0, &tmp);
  ------------------
  |  |  185|    906|#define KRB5_CONF_ALLOW_WEAK_CRYPTO            "allow_weak_crypto"
  ------------------
  220|    906|    if (retval)
  ------------------
  |  Branch (220:9): [True: 0, False: 906]
  ------------------
  221|      0|        goto cleanup;
  222|    906|    ctx->allow_weak_crypto = tmp;
  223|       |
  224|    906|    retval = get_boolean(ctx, KRB5_CONF_ALLOW_DES3, 0, &tmp);
  ------------------
  |  |  183|    906|#define KRB5_CONF_ALLOW_DES3                   "allow_des3"
  ------------------
  225|    906|    if (retval)
  ------------------
  |  Branch (225:9): [True: 0, False: 906]
  ------------------
  226|      0|        goto cleanup;
  227|    906|    ctx->allow_des3 = tmp;
  228|       |
  229|    906|    retval = get_boolean(ctx, KRB5_CONF_ALLOW_RC4, 0, &tmp);
  ------------------
  |  |  184|    906|#define KRB5_CONF_ALLOW_RC4                    "allow_rc4"
  ------------------
  230|    906|    if (retval)
  ------------------
  |  Branch (230:9): [True: 0, False: 906]
  ------------------
  231|      0|        goto cleanup;
  232|    906|    ctx->allow_rc4 = tmp;
  233|       |
  234|    906|    retval = get_boolean(ctx, KRB5_CONF_IGNORE_ACCEPTOR_HOSTNAME, 0, &tmp);
  ------------------
  |  |  225|    906|#define KRB5_CONF_IGNORE_ACCEPTOR_HOSTNAME     "ignore_acceptor_hostname"
  ------------------
  235|    906|    if (retval)
  ------------------
  |  Branch (235:9): [True: 0, False: 906]
  ------------------
  236|      0|        goto cleanup;
  237|    906|    ctx->ignore_acceptor_hostname = tmp;
  238|       |
  239|    906|    retval = get_boolean(ctx, KRB5_CONF_ENFORCE_OK_AS_DELEGATE, 0, &tmp);
  ------------------
  |  |  219|    906|#define KRB5_CONF_ENFORCE_OK_AS_DELEGATE       "enforce_ok_as_delegate"
  ------------------
  240|    906|    if (retval)
  ------------------
  |  Branch (240:9): [True: 0, False: 906]
  ------------------
  241|      0|        goto cleanup;
  242|    906|    ctx->enforce_ok_as_delegate = tmp;
  243|       |
  244|    906|    retval = get_tristate(ctx, KRB5_CONF_DNS_CANONICALIZE_HOSTNAME, "fallback",
  ------------------
  |  |  211|    906|#define KRB5_CONF_DNS_CANONICALIZE_HOSTNAME    "dns_canonicalize_hostname"
  ------------------
  245|    906|                          CANONHOST_FALLBACK, 1, &tmp);
  246|    906|    if (retval)
  ------------------
  |  Branch (246:9): [True: 0, False: 906]
  ------------------
  247|      0|        goto cleanup;
  248|    906|    ctx->dns_canonicalize_hostname = tmp;
  249|       |
  250|    906|    ctx->default_realm = 0;
  251|    906|    get_integer(ctx, KRB5_CONF_CLOCKSKEW, DEFAULT_CLOCKSKEW, &tmp);
  ------------------
  |  |  190|    906|#define KRB5_CONF_CLOCKSKEW                    "clockskew"
  ------------------
                  get_integer(ctx, KRB5_CONF_CLOCKSKEW, DEFAULT_CLOCKSKEW, &tmp);
  ------------------
  |  |   73|    906|#define DEFAULT_CLOCKSKEW  300 /* 5 min */
  ------------------
  252|    906|    ctx->clockskew = tmp;
  253|       |
  254|    906|    retval = profile_get_string(ctx->profile, KRB5_CONF_LIBDEFAULTS,
  ------------------
  |  |  271|    906|#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
  ------------------
  255|    906|                                KRB5_CONF_REQUEST_TIMEOUT, NULL, NULL,
  ------------------
  |  |  302|    906|#define KRB5_CONF_REQUEST_TIMEOUT              "request_timeout"
  ------------------
  256|    906|                                &timeout_str);
  257|    906|    if (retval)
  ------------------
  |  Branch (257:9): [True: 0, False: 906]
  ------------------
  258|      0|        goto cleanup;
  259|    906|    if (timeout_str != NULL) {
  ------------------
  |  Branch (259:9): [True: 0, False: 906]
  ------------------
  260|      0|        retval = krb5_string_to_deltat(timeout_str, &ctx->req_timeout);
  261|      0|        if (retval)
  ------------------
  |  Branch (261:13): [True: 0, False: 0]
  ------------------
  262|      0|            goto cleanup;
  263|      0|    }
  264|       |
  265|    906|    get_integer(ctx, KRB5_CONF_KDC_DEFAULT_OPTIONS, KDC_OPT_RENEWABLE_OK,
  ------------------
  |  |  243|    906|#define KRB5_CONF_KDC_DEFAULT_OPTIONS          "kdc_default_options"
  ------------------
                  get_integer(ctx, KRB5_CONF_KDC_DEFAULT_OPTIONS, KDC_OPT_RENEWABLE_OK,
  ------------------
  |  | 1649|    906|#define KDC_OPT_RENEWABLE_OK            0x00000010
  ------------------
  266|    906|                &tmp);
  267|    906|    ctx->kdc_default_options = tmp;
  268|    906|#define DEFAULT_KDC_TIMESYNC 1
  269|    906|    get_integer(ctx, KRB5_CONF_KDC_TIMESYNC, DEFAULT_KDC_TIMESYNC, &tmp);
  ------------------
  |  |  250|    906|#define KRB5_CONF_KDC_TIMESYNC                 "kdc_timesync"
  ------------------
                  get_integer(ctx, KRB5_CONF_KDC_TIMESYNC, DEFAULT_KDC_TIMESYNC, &tmp);
  ------------------
  |  |  268|    906|#define DEFAULT_KDC_TIMESYNC 1
  ------------------
  270|    906|    ctx->library_options = tmp ? KRB5_LIBOPT_SYNC_KDCTIME : 0;
  ------------------
  |  | 1270|    906|#define KRB5_LIBOPT_SYNC_KDCTIME        0x0001
  ------------------
  |  Branch (270:28): [True: 906, False: 0]
  ------------------
  271|       |
  272|    906|    retval = profile_get_string(ctx->profile, KRB5_CONF_LIBDEFAULTS,
  ------------------
  |  |  271|    906|#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
  ------------------
  273|    906|                                KRB5_CONF_PLUGIN_BASE_DIR, 0,
  ------------------
  |  |  286|    906|#define KRB5_CONF_PLUGIN_BASE_DIR              "plugin_base_dir"
  ------------------
  274|    906|                                DEFAULT_PLUGIN_BASE_DIR, &plugin_dir);
  ------------------
  |  |   61|    906|#define DEFAULT_PLUGIN_BASE_DIR "/usr/local/lib/krb5/plugins"
  ------------------
  275|    906|    if (!retval)
  ------------------
  |  Branch (275:9): [True: 906, False: 0]
  ------------------
  276|    906|        retval = k5_expand_path_tokens(ctx, plugin_dir, &ctx->plugin_base_dir);
  277|    906|    if (retval) {
  ------------------
  |  Branch (277:9): [True: 0, False: 906]
  ------------------
  278|      0|        TRACE_PROFILE_ERR(ctx, KRB5_CONF_PLUGIN_BASE_DIR,
  ------------------
  |  |  355|      0|    TRACE(c, "Bad value of {str} from [{str}] in conf file: {kerr}", \
  |  |  ------------------
  |  |  |  |  100|      0|    do { if (ctx->trace_callback != NULL)                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  101|      0|            krb5int_trace(ctx, __VA_ARGS__); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:55): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  356|      0|          subsection, section, retval)
  ------------------
  279|      0|                          KRB5_CONF_LIBDEFAULTS, retval);
  280|      0|        goto cleanup;
  281|      0|    }
  282|       |
  283|       |    /*
  284|       |     * We use a default file credentials cache of 3.  See
  285|       |     * lib/krb5/krb/ccache/file/fcc.h for a description of the
  286|       |     * credentials cache types.
  287|       |     *
  288|       |     * Note: DCE 1.0.3a only supports a cache type of 1
  289|       |     *      DCE 1.1 supports a cache type of 2.
  290|       |     */
  291|    906|#define DEFAULT_CCACHE_TYPE 4
  292|    906|    get_integer(ctx, KRB5_CONF_CCACHE_TYPE, DEFAULT_CCACHE_TYPE, &tmp);
  ------------------
  |  |  189|    906|#define KRB5_CONF_CCACHE_TYPE                  "ccache_type"
  ------------------
                  get_integer(ctx, KRB5_CONF_CCACHE_TYPE, DEFAULT_CCACHE_TYPE, &tmp);
  ------------------
  |  |  291|    906|#define DEFAULT_CCACHE_TYPE 4
  ------------------
  293|    906|    ctx->fcc_default_format = tmp + 0x0500;
  294|    906|    ctx->prompt_types = 0;
  295|    906|    ctx->use_conf_ktypes = 0;
  296|    906|    ctx->udp_pref_limit = -1;
  297|       |
  298|       |    /* It's OK if this fails */
  299|    906|    (void)profile_get_string(ctx->profile, KRB5_CONF_LIBDEFAULTS,
  ------------------
  |  |  271|    906|#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
  ------------------
  300|    906|                             KRB5_CONF_ERR_FMT, NULL, NULL, &ctx->err_fmt);
  ------------------
  |  |  220|    906|#define KRB5_CONF_ERR_FMT                      "err_fmt"
  ------------------
  301|    906|    *context_out = ctx;
  302|    906|    ctx = NULL;
  303|       |
  304|    906|cleanup:
  305|    906|    profile_release_string(plugin_dir);
  306|    906|    profile_release_string(timeout_str);
  307|    906|    krb5_free_context(ctx);
  308|    906|    return retval;
  309|    906|}
krb5_free_context:
  313|  1.81k|{
  314|  1.81k|    if (ctx == NULL)
  ------------------
  |  Branch (314:9): [True: 906, False: 906]
  ------------------
  315|    906|        return;
  316|    906|    k5_os_free_context(ctx);
  317|       |
  318|    906|    free(ctx->tgs_etypes);
  319|    906|    ctx->tgs_etypes = NULL;
  320|    906|    free(ctx->default_realm);
  321|    906|    ctx->default_realm = 0;
  322|       |
  323|    906|    krb5_clear_error_message(ctx);
  324|    906|    free(ctx->err_fmt);
  325|       |
  326|    906|#ifndef DISABLE_TRACING
  327|    906|    if (ctx->trace_callback)
  ------------------
  |  Branch (327:9): [True: 0, False: 906]
  ------------------
  328|      0|        ctx->trace_callback(ctx, NULL, ctx->trace_callback_data);
  329|    906|#endif
  330|       |
  331|    906|    k5_ccselect_free_context(ctx);
  332|    906|    k5_hostrealm_free_context(ctx);
  333|    906|    k5_localauth_free_context(ctx);
  334|    906|    k5_plugin_free_context(ctx);
  335|    906|    free(ctx->plugin_base_dir);
  336|    906|    free(ctx->tls);
  337|       |
  338|    906|    ctx->magic = 0;
  339|    906|    free(ctx);
  340|    906|}
init_ctx.c:get_boolean:
   89|  4.53k|{
   90|  4.53k|    krb5_error_code retval;
   91|       |
   92|  4.53k|    retval = profile_get_boolean(ctx->profile, KRB5_CONF_LIBDEFAULTS,
  ------------------
  |  |  271|  4.53k|#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
  ------------------
   93|  4.53k|                                 name, NULL, def_val, boolean_out);
   94|  4.53k|    if (retval)
  ------------------
  |  Branch (94:9): [True: 0, False: 4.53k]
  ------------------
   95|       |        TRACE_PROFILE_ERR(ctx, name, KRB5_CONF_LIBDEFAULTS, retval);
  ------------------
  |  |  355|      0|    TRACE(c, "Bad value of {str} from [{str}] in conf file: {kerr}", \
  |  |  ------------------
  |  |  |  |  100|      0|    do { if (ctx->trace_callback != NULL)                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  101|      0|            krb5int_trace(ctx, __VA_ARGS__); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:55): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  356|  4.53k|          subsection, section, retval)
  ------------------
   96|  4.53k|    return retval;
   97|  4.53k|}
init_ctx.c:get_tristate:
  102|    906|{
  103|    906|    krb5_error_code retval;
  104|    906|    char *str;
  105|    906|    int match;
  106|       |
  107|    906|    retval = profile_get_boolean(ctx->profile, KRB5_CONF_LIBDEFAULTS, name,
  ------------------
  |  |  271|    906|#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
  ------------------
  108|    906|                                 NULL, def_val, val_out);
  109|    906|    if (retval != PROF_BAD_BOOLEAN)
  ------------------
  |  |  334|    906|#define PROF_BAD_BOOLEAN                         (-1429577700L)
  ------------------
  |  Branch (109:9): [True: 906, False: 0]
  ------------------
  110|    906|        return retval;
  111|      0|    retval = profile_get_string(ctx->profile, KRB5_CONF_LIBDEFAULTS, name,
  ------------------
  |  |  271|      0|#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
  ------------------
  112|      0|                                NULL, NULL, &str);
  113|      0|    if (retval)
  ------------------
  |  Branch (113:9): [True: 0, False: 0]
  ------------------
  114|      0|        return retval;
  115|      0|    match = (strcasecmp(third_option, str) == 0);
  116|      0|    free(str);
  117|      0|    if (!match)
  ------------------
  |  Branch (117:9): [True: 0, False: 0]
  ------------------
  118|      0|        return EINVAL;
  119|      0|    *val_out = third_option_val;
  120|      0|    return 0;
  121|      0|}
init_ctx.c:get_integer:
   77|  3.62k|{
   78|  3.62k|    krb5_error_code retval;
   79|       |
   80|  3.62k|    retval = profile_get_integer(ctx->profile, KRB5_CONF_LIBDEFAULTS,
  ------------------
  |  |  271|  3.62k|#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
  ------------------
   81|  3.62k|                                 name, NULL, def_val, int_out);
   82|  3.62k|    if (retval)
  ------------------
  |  Branch (82:9): [True: 0, False: 3.62k]
  ------------------
   83|       |        TRACE_PROFILE_ERR(ctx, name, KRB5_CONF_LIBDEFAULTS, retval);
  ------------------
  |  |  355|      0|    TRACE(c, "Bad value of {str} from [{str}] in conf file: {kerr}", \
  |  |  ------------------
  |  |  |  |  100|      0|    do { if (ctx->trace_callback != NULL)                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  101|      0|            krb5int_trace(ctx, __VA_ARGS__); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:55): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  356|  3.62k|          subsection, section, retval)
  ------------------
   84|  3.62k|    return retval;
   85|  3.62k|}

krb5_clear_error_message:
  206|    906|{
  207|       |#ifdef DEBUG
  208|       |    if (ERROR_MESSAGE_DEBUG())
  209|       |        fprintf(stderr, "krb5_clear_error_message(%p)\n", ctx);
  210|       |#endif
  211|    906|    if (ctx == NULL)
  ------------------
  |  Branch (211:9): [True: 0, False: 906]
  ------------------
  212|      0|        return;
  213|    906|    k5_clear_error(&ctx->err);
  214|    906|}

krb5_free_principal:
  400|  2.71k|{
  401|  2.71k|    krb5_int32 i;
  402|       |
  403|  2.71k|    if (!val)
  ------------------
  |  Branch (403:9): [True: 1.81k, False: 906]
  ------------------
  404|  1.81k|        return;
  405|       |
  406|    906|    if (val->data) {
  ------------------
  |  Branch (406:9): [True: 906, False: 0]
  ------------------
  407|    906|        i = val->length;
  408|  5.44k|        while(--i >= 0)
  ------------------
  |  Branch (408:15): [True: 4.54k, False: 906]
  ------------------
  409|  4.54k|            free(val->data[i].data);
  410|    906|        free(val->data);
  411|    906|    }
  412|    906|    free(val->realm.data);
  413|    906|    free(val);
  414|    906|}

krb5_parse_name_flags:
  178|    906|{
  179|    906|    krb5_error_code ret;
  180|    906|    krb5_principal princ = NULL;
  181|    906|    char *default_realm;
  182|    906|    krb5_boolean has_realm;
  183|    906|    krb5_boolean enterprise = (flags & KRB5_PRINCIPAL_PARSE_ENTERPRISE);
  ------------------
  |  | 3454|    906|#define KRB5_PRINCIPAL_PARSE_ENTERPRISE    0x4 /**< Create single-component
  ------------------
  184|    906|    krb5_boolean require_realm = (flags & KRB5_PRINCIPAL_PARSE_REQUIRE_REALM);
  ------------------
  |  | 3453|    906|#define KRB5_PRINCIPAL_PARSE_REQUIRE_REALM 0x2 /**< Error if realm is not present */
  ------------------
  185|    906|    krb5_boolean no_realm = (flags & KRB5_PRINCIPAL_PARSE_NO_REALM);
  ------------------
  |  | 3452|    906|#define KRB5_PRINCIPAL_PARSE_NO_REALM      0x1 /**< Error if realm is present */
  ------------------
  186|    906|    krb5_boolean ignore_realm = (flags & KRB5_PRINCIPAL_PARSE_IGNORE_REALM);
  ------------------
  |  | 3456|    906|#define KRB5_PRINCIPAL_PARSE_IGNORE_REALM  0x8 /**< Ignore realm if present */
  ------------------
  187|    906|    krb5_boolean no_def_realm = (flags & KRB5_PRINCIPAL_PARSE_NO_DEF_REALM);
  ------------------
  |  | 3457|    906|#define KRB5_PRINCIPAL_PARSE_NO_DEF_REALM  0x10 /**< Don't add default realm */
  ------------------
  188|       |
  189|    906|    *principal_out = NULL;
  190|       |
  191|    906|    ret = allocate_princ(context, name, enterprise, &princ, &has_realm);
  192|    906|    if (ret)
  ------------------
  |  Branch (192:9): [True: 6, False: 900]
  ------------------
  193|      6|        goto cleanup;
  194|    900|    parse_name_into_princ(name, enterprise, princ);
  195|       |
  196|       |    /* If a realm was not included, use the default realm, unless flags
  197|       |     * indicate otherwise. */
  198|    900|    if (!has_realm) {
  ------------------
  |  Branch (198:9): [True: 762, False: 138]
  ------------------
  199|    762|        if (require_realm) {
  ------------------
  |  Branch (199:13): [True: 0, False: 762]
  ------------------
  200|      0|            ret = KRB5_PARSE_MALFORMED;
  ------------------
  |  | 8787|      0|#define KRB5_PARSE_MALFORMED                     (-1765328250L)
  ------------------
  201|      0|            k5_setmsg(context, ret,
  ------------------
  |  | 2414|      0|#define k5_setmsg krb5_set_error_message
  ------------------
  202|      0|                      _("Principal %s is missing required realm"), name);
  ------------------
  |  | 1069|      0|#define _(s) dgettext(KRB5_TEXTDOMAIN, s)
  ------------------
  203|      0|            goto cleanup;
  204|      0|        }
  205|    762|        if (!no_realm && !ignore_realm && !no_def_realm) {
  ------------------
  |  Branch (205:13): [True: 762, False: 0]
  |  Branch (205:26): [True: 762, False: 0]
  |  Branch (205:43): [True: 762, False: 0]
  ------------------
  206|    762|            ret = krb5_get_default_realm(context, &default_realm);
  207|    762|            if (ret)
  ------------------
  |  Branch (207:17): [True: 762, False: 0]
  ------------------
  208|    762|                goto cleanup;
  209|      0|            krb5_free_data_contents(context, &princ->realm);
  210|      0|            princ->realm = string2data(default_realm);
  211|      0|        }
  212|    762|    } else if (no_realm) {
  ------------------
  |  Branch (212:16): [True: 0, False: 138]
  ------------------
  213|      0|        ret = KRB5_PARSE_MALFORMED;
  ------------------
  |  | 8787|      0|#define KRB5_PARSE_MALFORMED                     (-1765328250L)
  ------------------
  214|      0|        k5_setmsg(context, ret, _("Principal %s has realm present"), name);
  ------------------
  |  | 2414|      0|#define k5_setmsg krb5_set_error_message
  ------------------
                      k5_setmsg(context, ret, _("Principal %s has realm present"), name);
  ------------------
  |  | 1069|      0|#define _(s) dgettext(KRB5_TEXTDOMAIN, s)
  ------------------
  215|      0|        goto cleanup;
  216|    138|    } else if (ignore_realm) {
  ------------------
  |  Branch (216:16): [True: 0, False: 138]
  ------------------
  217|      0|        krb5_free_data_contents(context, &princ->realm);
  218|      0|        princ->realm = empty_data();
  219|      0|    }
  220|       |
  221|    138|    princ->type = (enterprise) ? KRB5_NT_ENTERPRISE_PRINCIPAL :
  ------------------
  |  |  248|      0|#define KRB5_NT_ENTERPRISE_PRINCIPAL  10        /**< Windows 2000 UPN */
  ------------------
  |  Branch (221:19): [True: 0, False: 138]
  ------------------
  222|    138|        k5_infer_principal_type(princ);
  223|       |
  224|    138|    princ->magic = KV5M_PRINCIPAL;
  ------------------
  |  | 9037|    138|#define KV5M_PRINCIPAL                           (-1760647423L)
  ------------------
  225|    138|    *principal_out = princ;
  226|    138|    princ = NULL;
  227|       |
  228|    906|cleanup:
  229|    906|    krb5_free_principal(context, princ);
  230|    906|    return ret;
  231|    138|}
krb5_parse_name:
  236|    906|{
  237|    906|    return krb5_parse_name_flags(context, name, 0, principal_out);
  238|    906|}
parse.c:allocate_princ:
   39|    906|{
   40|    906|    krb5_error_code ret;
   41|    906|    const char *p;
   42|    906|    krb5_boolean first_at = TRUE;
  ------------------
  |  |  167|    906|#define TRUE    1
  ------------------
   43|    906|    krb5_principal princ = NULL;
   44|    906|    krb5_data *cur_data, *new_comps;
   45|    906|    krb5_int32 i;
   46|       |
   47|    906|    *princ_out = NULL;
   48|    906|    *has_realm_out = FALSE;
  ------------------
  |  |  164|    906|#define FALSE   0
  ------------------
   49|       |
   50|       |    /* Allocate a starting principal with one component. */
   51|    906|    princ = k5alloc(sizeof(*princ), &ret);
   52|    906|    if (princ == NULL)
  ------------------
  |  Branch (52:9): [True: 0, False: 906]
  ------------------
   53|      0|        goto cleanup;
   54|    906|    princ->data = k5alloc(sizeof(*princ->data), &ret);
   55|    906|    if (princ->data == NULL)
  ------------------
  |  Branch (55:9): [True: 0, False: 906]
  ------------------
   56|      0|        goto cleanup;
   57|    906|    princ->realm = empty_data();
   58|    906|    princ->data[0] = empty_data();
   59|    906|    princ->length = 1;
   60|       |
   61|    906|    cur_data = &princ->data[0];
   62|  17.9k|    for (p = name; *p != '\0'; p++) {
  ------------------
  |  Branch (62:20): [True: 17.0k, False: 900]
  ------------------
   63|  17.0k|        if (*p == '/' && !enterprise) {
  ------------------
  |  Branch (63:13): [True: 3.63k, False: 13.4k]
  |  Branch (63:26): [True: 3.63k, False: 0]
  ------------------
   64|       |            /* Component separator (for non-enterprise principals).  We
   65|       |             * shouldn't see this in the realm name. */
   66|  3.63k|            if (cur_data == &princ->realm) {
  ------------------
  |  Branch (66:17): [True: 1, False: 3.63k]
  ------------------
   67|      1|                ret = KRB5_PARSE_MALFORMED;
  ------------------
  |  | 8787|      1|#define KRB5_PARSE_MALFORMED                     (-1765328250L)
  ------------------
   68|      1|                goto cleanup;
   69|      1|            }
   70|  3.63k|            new_comps = realloc(princ->data,
   71|  3.63k|                                (princ->length + 1) * sizeof(*princ->data));
   72|  3.63k|            if (new_comps == NULL) {
  ------------------
  |  Branch (72:17): [True: 0, False: 3.63k]
  ------------------
   73|      0|                ret = ENOMEM;
   74|      0|                goto cleanup;
   75|      0|            }
   76|  3.63k|            princ->data = new_comps;
   77|  3.63k|            princ->length++;
   78|  3.63k|            cur_data = &princ->data[princ->length - 1];
   79|  3.63k|            *cur_data = empty_data();
   80|  13.4k|        } else if (*p == '@' && (!enterprise || !first_at)) {
  ------------------
  |  Branch (80:20): [True: 141, False: 13.2k]
  |  Branch (80:34): [True: 141, False: 0]
  |  Branch (80:49): [True: 0, False: 0]
  ------------------
   81|       |            /* Realm separator.  In enterprise principals, the first one of
   82|       |             * these we see is part of the component. */
   83|    141|            if (cur_data == &princ->realm) {
  ------------------
  |  Branch (83:17): [True: 1, False: 140]
  ------------------
   84|      1|                ret = KRB5_PARSE_MALFORMED;
  ------------------
  |  | 8787|      1|#define KRB5_PARSE_MALFORMED                     (-1765328250L)
  ------------------
   85|      1|                goto cleanup;
   86|      1|            }
   87|    140|            cur_data = &princ->realm;
   88|  13.2k|        } else {
   89|       |            /* Component or realm character, possibly quoted.  Make note if
   90|       |             * we're seeing the first '@' in an enterprise principal. */
   91|  13.2k|            cur_data->length++;
   92|  13.2k|            if (*p == '@' && enterprise)
  ------------------
  |  Branch (92:17): [True: 0, False: 13.2k]
  |  Branch (92:30): [True: 0, False: 0]
  ------------------
   93|      0|                first_at = FALSE;
  ------------------
  |  |  164|      0|#define FALSE   0
  ------------------
   94|  13.2k|            if (*p == '\\') {
  ------------------
  |  Branch (94:17): [True: 1.29k, False: 12.0k]
  ------------------
   95|       |                /* Quote character can't be the last character of the name. */
   96|  1.29k|                if (*++p == '\0') {
  ------------------
  |  Branch (96:21): [True: 4, False: 1.28k]
  ------------------
   97|      4|                    ret = KRB5_PARSE_MALFORMED;
  ------------------
  |  | 8787|      4|#define KRB5_PARSE_MALFORMED                     (-1765328250L)
  ------------------
   98|      4|                    goto cleanup;
   99|      4|                }
  100|  1.29k|            }
  101|  13.2k|        }
  102|  17.0k|    }
  103|       |
  104|       |    /* Allocate space for each component and the realm, with space for null
  105|       |     * terminators on each field. */
  106|  5.43k|    for (i = 0; i < princ->length; i++) {
  ------------------
  |  Branch (106:17): [True: 4.53k, False: 900]
  ------------------
  107|  4.53k|        princ->data[i].data = k5alloc(princ->data[i].length + 1, &ret);
  108|  4.53k|        if (princ->data[i].data == NULL)
  ------------------
  |  Branch (108:13): [True: 0, False: 4.53k]
  ------------------
  109|      0|            goto cleanup;
  110|  4.53k|    }
  111|    900|    princ->realm.data = k5alloc(princ->realm.length + 1, &ret);
  112|    900|    if (princ->realm.data == NULL)
  ------------------
  |  Branch (112:9): [True: 0, False: 900]
  ------------------
  113|      0|        goto cleanup;
  114|       |
  115|    900|    *princ_out = princ;
  116|    900|    *has_realm_out = (cur_data == &princ->realm);
  117|    900|    princ = NULL;
  118|    906|cleanup:
  119|    906|    krb5_free_principal(context, princ);
  120|    906|    return ret;
  121|    900|}
parse.c:parse_name_into_princ:
  132|    900|{
  133|    900|    const char *p;
  134|    900|    char c;
  135|    900|    krb5_boolean first_at = TRUE;
  ------------------
  |  |  167|    900|#define TRUE    1
  ------------------
  136|    900|    krb5_data *cur_data = princ->data;
  137|    900|    unsigned int pos = 0;
  138|       |
  139|  17.9k|    for (p = name; *p != '\0'; p++) {
  ------------------
  |  Branch (139:20): [True: 17.0k, False: 900]
  ------------------
  140|  17.0k|        if (*p == '/' && !enterprise) {
  ------------------
  |  Branch (140:13): [True: 3.63k, False: 13.4k]
  |  Branch (140:26): [True: 3.63k, False: 0]
  ------------------
  141|       |            /* Advance to the next component. */
  142|  3.63k|            assert(pos == cur_data->length);
  ------------------
  |  Branch (142:13): [True: 0, False: 3.63k]
  |  Branch (142:13): [True: 3.63k, False: 0]
  ------------------
  143|  3.63k|            assert(cur_data != &princ->realm);
  ------------------
  |  Branch (143:13): [True: 0, False: 3.63k]
  |  Branch (143:13): [True: 3.63k, False: 0]
  ------------------
  144|  3.63k|            assert(cur_data - princ->data + 1 < princ->length);
  ------------------
  |  Branch (144:13): [True: 0, False: 3.63k]
  |  Branch (144:13): [True: 3.63k, False: 0]
  ------------------
  145|  3.63k|            cur_data++;
  146|  3.63k|            pos = 0;
  147|  13.4k|        } else if (*p == '@' && (!enterprise || !first_at)) {
  ------------------
  |  Branch (147:20): [True: 138, False: 13.2k]
  |  Branch (147:34): [True: 138, False: 0]
  |  Branch (147:49): [True: 0, False: 0]
  ------------------
  148|       |            /* Advance to the realm. */
  149|    138|            assert(pos == cur_data->length);
  ------------------
  |  Branch (149:13): [True: 0, False: 138]
  |  Branch (149:13): [True: 138, False: 0]
  ------------------
  150|    138|            cur_data = &princ->realm;
  151|    138|            pos = 0;
  152|  13.2k|        } else {
  153|       |            /* Add to the current component or to the realm. */
  154|  13.2k|            if (*p == '@' && enterprise)
  ------------------
  |  Branch (154:17): [True: 0, False: 13.2k]
  |  Branch (154:30): [True: 0, False: 0]
  ------------------
  155|      0|                first_at = FALSE;
  ------------------
  |  |  164|      0|#define FALSE   0
  ------------------
  156|  13.2k|            c = *p;
  157|  13.2k|            if (c == '\\') {
  ------------------
  |  Branch (157:17): [True: 1.28k, False: 12.0k]
  ------------------
  158|  1.28k|                c = *++p;
  159|  1.28k|                if (c == 'n')
  ------------------
  |  Branch (159:21): [True: 345, False: 943]
  ------------------
  160|    345|                    c = '\n';
  161|    943|                else if (c == 't')
  ------------------
  |  Branch (161:26): [True: 203, False: 740]
  ------------------
  162|    203|                    c = '\t';
  163|    740|                else if (c == 'b')
  ------------------
  |  Branch (163:26): [True: 205, False: 535]
  ------------------
  164|    205|                    c = '\b';
  165|    535|                else if (c == '0')
  ------------------
  |  Branch (165:26): [True: 267, False: 268]
  ------------------
  166|    267|                    c = '\0';
  167|  1.28k|            }
  168|  13.2k|            assert(pos < cur_data->length);
  ------------------
  |  Branch (168:13): [True: 0, False: 13.2k]
  |  Branch (168:13): [True: 13.2k, False: 0]
  ------------------
  169|  13.2k|            cur_data->data[pos++] = c;
  170|  13.2k|        }
  171|  17.0k|    }
  172|    900|    assert(pos == cur_data->length);
  ------------------
  |  Branch (172:5): [True: 0, False: 900]
  |  Branch (172:5): [True: 900, False: 0]
  ------------------
  173|    900|}

k5_is_string_numeric:
   39|    873|{
   40|    873|    if (*s == '\0')
  ------------------
  |  Branch (40:9): [True: 0, False: 873]
  ------------------
   41|      0|        return FALSE;
  ------------------
  |  |  164|      0|#define FALSE   0
  ------------------
   42|       |
   43|  2.23k|    for (; *s != '\0'; s++) {
  ------------------
  |  Branch (43:12): [True: 2.15k, False: 73]
  ------------------
   44|  2.15k|        if (!isdigit(*s))
  ------------------
  |  Branch (44:13): [True: 800, False: 1.35k]
  ------------------
   45|    800|            return FALSE;
  ------------------
  |  |  164|    800|#define FALSE   0
  ------------------
   46|  2.15k|    }
   47|       |
   48|     73|    return TRUE;
  ------------------
  |  |  167|     73|#define TRUE    1
  ------------------
   49|    873|}
k5_parse_host_string:
   72|    906|{
   73|    906|    krb5_error_code ret;
   74|    906|    int port_num;
   75|    906|    const char *p, *host = NULL, *port = NULL;
   76|    906|    char *endptr, *hostname = NULL;
   77|    906|    size_t hostlen = 0;
   78|    906|    unsigned long l;
   79|       |
   80|    906|    *host_out = NULL;
   81|    906|    *port_out = 0;
   82|       |
   83|    906|    if (address == NULL || *address == '\0' || *address == ':')
  ------------------
  |  Branch (83:9): [True: 0, False: 906]
  |  Branch (83:28): [True: 29, False: 877]
  |  Branch (83:48): [True: 4, False: 873]
  ------------------
   84|     33|        return EINVAL;
   85|    873|    if (default_port < 0 || default_port > 65535)
  ------------------
  |  Branch (85:9): [True: 0, False: 873]
  |  Branch (85:29): [True: 0, False: 873]
  ------------------
   86|      0|        return EINVAL;
   87|       |
   88|       |    /* Find the bounds of the host string and the start of the port string. */
   89|    873|    if (k5_is_string_numeric(address)) {
  ------------------
  |  Branch (89:9): [True: 73, False: 800]
  ------------------
   90|     73|        port = address;
   91|    800|    } else if (*address == '[' && (p = strchr(address, ']')) != NULL) {
  ------------------
  |  Branch (91:16): [True: 15, False: 785]
  |  Branch (91:35): [True: 12, False: 3]
  ------------------
   92|     12|        host = address + 1;
   93|     12|        hostlen = p - host;
   94|     12|        if (*(p + 1) == ':')
  ------------------
  |  Branch (94:13): [True: 1, False: 11]
  ------------------
   95|      1|            port = p + 2;
   96|    788|    } else {
   97|    788|        host = address;
   98|    788|        hostlen = strcspn(host, " \t:");
   99|    788|        if (host[hostlen] == ':')
  ------------------
  |  Branch (99:13): [True: 86, False: 702]
  ------------------
  100|     86|            port = host + hostlen + 1;
  101|    788|    }
  102|       |
  103|       |    /* Parse the port number, or use the default port. */
  104|    873|    if (port != NULL) {
  ------------------
  |  Branch (104:9): [True: 160, False: 713]
  ------------------
  105|    160|        errno = 0;
  106|    160|        l = strtoul(port, &endptr, 10);
  107|    160|        if (errno || endptr == port || *endptr != '\0' || l > 65535)
  ------------------
  |  Branch (107:13): [True: 7, False: 153]
  |  Branch (107:22): [True: 8, False: 145]
  |  Branch (107:40): [True: 12, False: 133]
  |  Branch (107:59): [True: 99, False: 34]
  ------------------
  108|    126|            return EINVAL;
  109|     34|        port_num = l;
  110|    713|    } else {
  111|    713|        port_num = default_port;
  112|    713|    }
  113|       |
  114|       |    /* Copy the host if it was specified. */
  115|    747|    if (host != NULL) {
  ------------------
  |  Branch (115:9): [True: 714, False: 33]
  ------------------
  116|    714|        hostname = k5memdup0(host, hostlen, &ret);
  117|    714|        if (hostname == NULL)
  ------------------
  |  Branch (117:13): [True: 0, False: 714]
  ------------------
  118|      0|            return ENOMEM;
  119|    714|    }
  120|       |
  121|    747|    *host_out = hostname;
  122|    747|    *port_out = port_num;
  123|    747|    return 0;
  124|    747|}

k5_plugin_load_all:
  424|    762|{
  425|    762|    krb5_error_code ret;
  426|    762|    struct plugin_interface *interface = get_interface(context, interface_id);
  427|    762|    struct plugin_mapping **mp, *map;
  428|    762|    krb5_plugin_initvt_fn *list;
  429|    762|    size_t count;
  430|       |
  431|    762|    if (interface == NULL)
  ------------------
  |  Branch (431:9): [True: 0, False: 762]
  ------------------
  432|      0|        return EINVAL;
  433|    762|    ret = configure_interface(context, interface_id);
  434|    762|    if (ret != 0)
  ------------------
  |  Branch (434:9): [True: 0, False: 762]
  ------------------
  435|      0|        return ret;
  436|       |
  437|       |    /* Count the modules and allocate a list to hold them. */
  438|    762|    mp = interface->modules;
  439|  3.81k|    for (count = 0; mp != NULL && mp[count] != NULL; count++);
  ------------------
  |  Branch (439:21): [True: 3.81k, False: 0]
  |  Branch (439:35): [True: 3.04k, False: 762]
  ------------------
  440|    762|    list = calloc(count + 1, sizeof(*list));
  441|    762|    if (list == NULL)
  ------------------
  |  Branch (441:9): [True: 0, False: 762]
  ------------------
  442|      0|        return ENOMEM;
  443|       |
  444|       |    /* Place each module's initvt function into list. */
  445|    762|    count = 0;
  446|  3.81k|    for (mp = interface->modules; mp != NULL && *mp != NULL; mp++) {
  ------------------
  |  Branch (446:35): [True: 3.81k, False: 0]
  |  Branch (446:49): [True: 3.04k, False: 762]
  ------------------
  447|  3.04k|        map = *mp;
  448|  3.04k|        load_if_needed(context, map, interface_names[interface_id]);
  449|  3.04k|        if (map->module != NULL)
  ------------------
  |  Branch (449:13): [True: 3.04k, False: 0]
  ------------------
  450|  3.04k|            list[count++] = map->module;
  451|  3.04k|    }
  452|       |
  453|    762|    *modules = list;
  454|    762|    return 0;
  455|    762|}
k5_plugin_free_modules:
  459|    762|{
  460|    762|    free(modules);
  461|    762|}
k5_plugin_register:
  466|  3.04k|{
  467|  3.04k|    struct plugin_interface *interface = get_interface(context, interface_id);
  468|       |
  469|  3.04k|    if (interface == NULL)
  ------------------
  |  Branch (469:9): [True: 0, False: 3.04k]
  ------------------
  470|      0|        return EINVAL;
  471|       |
  472|       |    /* Disallow registering plugins after load.  We may need to reconsider
  473|       |     * this, but it simplifies the design. */
  474|  3.04k|    if (interface->configured)
  ------------------
  |  Branch (474:9): [True: 0, False: 3.04k]
  ------------------
  475|      0|        return EINVAL;
  476|       |
  477|  3.04k|    return register_module(context, interface, modname, NULL, module);
  478|  3.04k|}
k5_plugin_free_context:
  505|    906|{
  506|    906|    int i;
  507|       |
  508|  12.6k|    for (i = 0; i < PLUGIN_NUM_INTERFACES; i++)
  ------------------
  |  | 1149|  12.6k|#define PLUGIN_NUM_INTERFACES        13
  ------------------
  |  Branch (508:17): [True: 11.7k, False: 906]
  ------------------
  509|  11.7k|        free_mapping_list(context->plugins[i].modules);
  510|    906|    memset(context->plugins, 0, sizeof(context->plugins));
  511|    906|}
plugin.c:get_interface:
   69|  3.81k|{
   70|  3.81k|    if (context == NULL || id < 0 || id >= PLUGIN_NUM_INTERFACES)
  ------------------
  |  | 1149|  3.81k|#define PLUGIN_NUM_INTERFACES        13
  ------------------
  |  Branch (70:9): [True: 0, False: 3.81k]
  |  Branch (70:28): [True: 0, False: 3.81k]
  |  Branch (70:38): [True: 0, False: 3.81k]
  ------------------
   71|      0|        return NULL;
   72|  3.81k|    return &context->plugins[id];
   73|  3.81k|}
plugin.c:configure_interface:
  304|    762|{
  305|    762|    krb5_error_code ret;
  306|    762|    struct plugin_interface *interface = &context->plugins[id];
  307|    762|    char **modstrs = NULL, **enable = NULL, **disable = NULL;
  308|       |
  309|    762|    if (interface->configured)
  ------------------
  |  Branch (309:9): [True: 0, False: 762]
  ------------------
  310|      0|        return 0;
  311|       |
  312|       |    /* Detect consistency errors when plugin interfaces are added. */
  313|    762|    assert(sizeof(interface_names) / sizeof(*interface_names) ==
  ------------------
  |  Branch (313:5): [True: 0, Folded]
  |  Branch (313:5): [True: 762, Folded]
  ------------------
  314|    762|           PLUGIN_NUM_INTERFACES);
  315|       |
  316|       |    /* Get profile variables for this interface. */
  317|    762|    ret = get_profile_var(context, id, KRB5_CONF_MODULE, &modstrs);
  ------------------
  |  |  280|    762|#define KRB5_CONF_MODULE                       "module"
  ------------------
  318|    762|    if (ret)
  ------------------
  |  Branch (318:9): [True: 0, False: 762]
  ------------------
  319|      0|        goto cleanup;
  320|    762|    ret = get_profile_var(context, id, KRB5_CONF_DISABLE, &disable);
  ------------------
  |  |  206|    762|#define KRB5_CONF_DISABLE                      "disable"
  ------------------
  321|    762|    if (ret)
  ------------------
  |  Branch (321:9): [True: 0, False: 762]
  ------------------
  322|      0|        goto cleanup;
  323|    762|    ret = get_profile_var(context, id, KRB5_CONF_ENABLE_ONLY, &enable);
  ------------------
  |  |  217|    762|#define KRB5_CONF_ENABLE_ONLY                  "enable_only"
  ------------------
  324|    762|    if (ret)
  ------------------
  |  Branch (324:9): [True: 0, False: 762]
  ------------------
  325|      0|        goto cleanup;
  326|       |
  327|       |    /* Create the full list of dynamic and built-in modules. */
  328|    762|    if (modstrs != NULL) {
  ------------------
  |  Branch (328:9): [True: 0, False: 762]
  ------------------
  329|      0|        ret = make_full_list(context, modstrs, &interface->modules);
  330|      0|        if (ret)
  ------------------
  |  Branch (330:13): [True: 0, False: 0]
  ------------------
  331|      0|            goto cleanup;
  332|      0|    }
  333|       |
  334|       |    /* Remove disabled modules. */
  335|    762|    if (disable != NULL)
  ------------------
  |  Branch (335:9): [True: 0, False: 762]
  ------------------
  336|      0|        remove_disabled_modules(interface->modules, disable);
  337|       |
  338|       |    /* Filter and re-order the list according to enable-modules. */
  339|    762|    if (enable != NULL)
  ------------------
  |  Branch (339:9): [True: 0, False: 762]
  ------------------
  340|      0|        filter_enabled_modules(interface->modules, enable);
  341|       |
  342|    762|cleanup:
  343|    762|    profile_free_list(modstrs);
  344|    762|    profile_free_list(enable);
  345|    762|    profile_free_list(disable);
  346|    762|    return ret;
  347|    762|}
plugin.c:get_profile_var:
  192|  2.28k|{
  193|  2.28k|    krb5_error_code ret;
  194|  2.28k|    const char *path[4];
  195|       |
  196|  2.28k|    *out = NULL;
  197|  2.28k|    path[0] = KRB5_CONF_PLUGINS;
  ------------------
  |  |  285|  2.28k|#define KRB5_CONF_PLUGINS                      "plugins"
  ------------------
  198|  2.28k|    path[1] = interface_names[id];
  199|  2.28k|    path[2] = varname;
  200|  2.28k|    path[3] = NULL;
  201|  2.28k|    ret = profile_get_values(context->profile, path, out);
  202|  2.28k|    return (ret == PROF_NO_RELATION) ? 0 : ret;
  ------------------
  |  |  309|  2.28k|#define PROF_NO_RELATION                         (-1429577725L)
  ------------------
  |  Branch (202:12): [True: 2.28k, False: 0]
  ------------------
  203|  2.28k|}
plugin.c:make_plugin_mapping:
  104|  3.04k|{
  105|  3.04k|    krb5_error_code ret;
  106|  3.04k|    struct plugin_mapping *map = NULL;
  107|       |
  108|       |    /* Create the mapping entry. */
  109|  3.04k|    map = k5alloc(sizeof(*map), &ret);
  110|  3.04k|    if (map == NULL)
  ------------------
  |  Branch (110:9): [True: 0, False: 3.04k]
  ------------------
  111|      0|        return ret;
  112|       |
  113|  3.04k|    map->modname = k5memdup0(name, namelen, &ret);
  114|  3.04k|    if (map->modname == NULL)
  ------------------
  |  Branch (114:9): [True: 0, False: 3.04k]
  ------------------
  115|      0|        goto oom;
  116|  3.04k|    if (path != NULL) {
  ------------------
  |  Branch (116:9): [True: 0, False: 3.04k]
  ------------------
  117|      0|        if (k5_path_join(context->plugin_base_dir, path, &map->dyn_path))
  ------------------
  |  Branch (117:13): [True: 0, False: 0]
  ------------------
  118|      0|            goto oom;
  119|      0|    }
  120|  3.04k|    map->module = module;
  121|  3.04k|    *map_out = map;
  122|  3.04k|    return 0;
  123|       |
  124|      0|oom:
  125|      0|    free_plugin_mapping(map);
  126|       |    return ENOMEM;
  127|  3.04k|}
plugin.c:free_plugin_mapping:
   78|  3.04k|{
   79|  3.04k|    if (map == NULL)
  ------------------
  |  Branch (79:9): [True: 0, False: 3.04k]
  ------------------
   80|      0|        return;
   81|  3.04k|    free(map->modname);
   82|  3.04k|    free(map->dyn_path);
   83|  3.04k|    if (map->dyn_handle != NULL)
  ------------------
  |  Branch (83:9): [True: 0, False: 3.04k]
  ------------------
   84|      0|        krb5int_close_plugin(map->dyn_handle);
   85|  3.04k|    free(map);
   86|  3.04k|}
plugin.c:load_if_needed:
  354|  3.04k|{
  355|  3.04k|    krb5_error_code ret;
  356|  3.04k|    char *symname = NULL;
  357|  3.04k|    struct plugin_file_handle *handle = NULL;
  358|  3.04k|    void (*initvt_fn)(void);
  359|       |
  360|  3.04k|    if (map->module != NULL || map->dyn_path == NULL)
  ------------------
  |  Branch (360:9): [True: 3.04k, False: 0]
  |  Branch (360:32): [True: 0, False: 0]
  ------------------
  361|  3.04k|        return;
  362|      0|    if (asprintf(&symname, "%s_%s_initvt", iname, map->modname) < 0)
  ------------------
  |  Branch (362:9): [True: 0, False: 0]
  ------------------
  363|      0|        return;
  364|       |
  365|      0|    ret = krb5int_open_plugin(map->dyn_path, &handle, &context->err);
  366|      0|    if (ret) {
  ------------------
  |  Branch (366:9): [True: 0, False: 0]
  ------------------
  367|      0|        TRACE_PLUGIN_LOAD_FAIL(context, map->modname, ret);
  ------------------
  |  |  306|      0|    TRACE(c, "Error loading plugin module {str}: {kerr}", modname, err)
  |  |  ------------------
  |  |  |  |  100|      0|    do { if (ctx->trace_callback != NULL)                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  101|      0|            krb5int_trace(ctx, __VA_ARGS__); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:55): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  368|      0|        goto err;
  369|      0|    }
  370|       |
  371|      0|    ret = krb5int_get_plugin_func(handle, symname, &initvt_fn, &context->err);
  372|      0|    if (ret) {
  ------------------
  |  Branch (372:9): [True: 0, False: 0]
  ------------------
  373|      0|        TRACE_PLUGIN_LOOKUP_FAIL(context, map->modname, ret);
  ------------------
  |  |  308|      0|    TRACE(c, "Error initializing module {str}: {kerr}", modname, err)
  |  |  ------------------
  |  |  |  |  100|      0|    do { if (ctx->trace_callback != NULL)                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  101|      0|            krb5int_trace(ctx, __VA_ARGS__); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:55): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  374|      0|        goto err;
  375|      0|    }
  376|       |
  377|      0|    free(symname);
  378|      0|    map->dyn_handle = handle;
  379|      0|    map->module = (krb5_plugin_initvt_fn)initvt_fn;
  380|      0|    return;
  381|       |
  382|      0|err:
  383|       |    /* Clean up, and also null out map->dyn_path so we don't try again. */
  384|      0|    if (handle != NULL)
  ------------------
  |  Branch (384:9): [True: 0, False: 0]
  ------------------
  385|      0|        krb5int_close_plugin(handle);
  386|      0|    free(symname);
  387|      0|    free(map->dyn_path);
  388|       |    map->dyn_path = NULL;
  389|      0|}
plugin.c:register_module:
  138|  3.04k|{
  139|  3.04k|    struct plugin_mapping **list;
  140|  3.04k|    size_t count;
  141|       |
  142|       |    /* Allocate list space for another element and a terminator. */
  143|  3.04k|    list = interface->modules;
  144|  7.62k|    for (count = 0; list != NULL && list[count] != NULL; count++);
  ------------------
  |  Branch (144:21): [True: 6.85k, False: 762]
  |  Branch (144:37): [True: 4.57k, False: 2.28k]
  ------------------
  145|  3.04k|    list = realloc(interface->modules, (count + 2) * sizeof(*list));
  146|  3.04k|    if (list == NULL)
  ------------------
  |  Branch (146:9): [True: 0, False: 3.04k]
  ------------------
  147|      0|        return ENOMEM;
  148|  3.04k|    list[count] = list[count + 1] = NULL;
  149|  3.04k|    interface->modules = list;
  150|       |
  151|       |    /* Create a new mapping structure and add it to the list. */
  152|  3.04k|    return make_plugin_mapping(context, modname, strlen(modname), dyn_path,
  153|  3.04k|                               module, &list[count]);
  154|  3.04k|}
plugin.c:free_mapping_list:
   90|  11.7k|{
   91|  11.7k|    struct plugin_mapping **mp;
   92|       |
   93|  14.8k|    for (mp = list; mp != NULL && *mp != NULL; mp++)
  ------------------
  |  Branch (93:21): [True: 3.81k, False: 11.0k]
  |  Branch (93:35): [True: 3.04k, False: 762]
  ------------------
   94|  3.04k|        free_plugin_mapping(*mp);
   95|  11.7k|    free(list);
   96|  11.7k|}

krb5int_initialize_library:
   59|    906|{
   60|    906|    return CALL_INIT_FUNCTION(krb5int_lib_init);
  ------------------
  |  |  291|    906|        k5_call_init_function(& JOIN__2(NAME, once))
  |  |  ------------------
  |  |  |  |  255|    906|        (__extension__ ({                                               \
  |  |  |  |  256|    906|                k5_init_t *k5int_i = (I);                               \
  |  |  |  |  257|    906|                int k5int_err = k5_once(&k5int_i->once, k5int_i->fn);   \
  |  |  |  |  258|    906|                (k5int_err                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (258:18): [True: 0, False: 906]
  |  |  |  |  ------------------
  |  |  |  |  259|    906|                 ? k5int_err                                            \
  |  |  |  |  260|    906|                 : (assert(k5int_i->did_run != 0), k5int_i->error));    \
  |  |  |  |  261|    906|            }))
  |  |  ------------------
  ------------------
  |  Branch (60:12): [True: 0, False: 906]
  |  Branch (60:12): [True: 906, False: 0]
  ------------------
   61|    906|}
krb5_libinit.c:krb5int_lib_init:
   24|      1|{
   25|      1|    int err;
   26|       |
   27|      1|    k5_set_error_info_callout_fn(error_message);
   28|       |
   29|       |#ifdef SHOW_INITFINI_FUNCS
   30|       |    printf("krb5int_lib_init\n");
   31|       |#endif
   32|       |
   33|      1|    add_error_table(&et_krb5_error_table);
   34|      1|    add_error_table(&et_k5e1_error_table);
   35|      1|    add_error_table(&et_kv5m_error_table);
   36|      1|    add_error_table(&et_kdb5_error_table);
   37|      1|    add_error_table(&et_asn1_error_table);
   38|      1|    add_error_table(&et_k524_error_table);
   39|       |
   40|      1|    bindtextdomain(KRB5_TEXTDOMAIN, LOCALEDIR);
  ------------------
  |  | 1068|      1|#define KRB5_TEXTDOMAIN "mit-krb5"
  ------------------
   41|       |
   42|      1|#ifndef LEAN_CLIENT
   43|      1|    err = krb5int_kt_initialize();
   44|      1|    if (err)
  ------------------
  |  Branch (44:9): [True: 0, False: 1]
  ------------------
   45|      0|        return err;
   46|      1|#endif /* LEAN_CLIENT */
   47|      1|    err = krb5int_cc_initialize();
   48|      1|    if (err)
  ------------------
  |  Branch (48:9): [True: 0, False: 1]
  ------------------
   49|      0|        return err;
   50|      1|    err = k5_mutex_finish_init(&krb5int_us_time_mutex);
   51|      1|    if (err)
  ------------------
  |  Branch (51:9): [True: 0, False: 1]
  ------------------
   52|      0|        return err;
   53|       |
   54|      1|    return 0;
   55|      1|}

k5_expand_path_tokens:
  432|    906|{
  433|       |    return k5_expand_path_tokens_extra(context, path_in, path_out, NULL);
  434|    906|}
k5_expand_path_tokens_extra:
  454|    906|{
  455|    906|    krb5_error_code ret;
  456|    906|    struct k5buf buf;
  457|    906|    const char *tok_begin, *tok_end;
  458|    906|    char *tok_val, **extra_tokens = NULL, *path;
  459|    906|    const char *path_left;
  460|    906|    size_t nargs = 0, i;
  461|    906|    va_list ap;
  462|       |
  463|    906|    *path_out = NULL;
  464|       |
  465|    906|    k5_buf_init_dynamic(&buf);
  466|       |
  467|       |    /* Count extra tokens. */
  468|    906|    va_start(ap, path_out);
  469|    906|    while (va_arg(ap, const char *) != NULL)
  ------------------
  |  Branch (469:12): [True: 0, False: 906]
  ------------------
  470|      0|        nargs++;
  471|    906|    va_end(ap);
  472|    906|    if (nargs % 2 != 0)
  ------------------
  |  Branch (472:9): [True: 0, False: 906]
  ------------------
  473|      0|        return EINVAL;
  474|       |
  475|       |    /* Get extra tokens. */
  476|    906|    if (nargs > 0) {
  ------------------
  |  Branch (476:9): [True: 0, False: 906]
  ------------------
  477|      0|        extra_tokens = k5calloc(nargs + 1, sizeof(char *), &ret);
  478|      0|        if (extra_tokens == NULL)
  ------------------
  |  Branch (478:13): [True: 0, False: 0]
  ------------------
  479|      0|            goto cleanup;
  480|      0|        va_start(ap, path_out);
  481|      0|        for (i = 0; i < nargs; i++) {
  ------------------
  |  Branch (481:21): [True: 0, False: 0]
  ------------------
  482|      0|            extra_tokens[i] = strdup(va_arg(ap, const char *));
  483|      0|            if (extra_tokens[i] == NULL) {
  ------------------
  |  Branch (483:17): [True: 0, False: 0]
  ------------------
  484|      0|                ret = ENOMEM;
  485|      0|                va_end(ap);
  486|      0|                goto cleanup;
  487|      0|            }
  488|      0|        }
  489|      0|        va_end(ap);
  490|      0|    }
  491|       |
  492|    906|    path_left = path_in;
  493|    906|    while (TRUE) {
  ------------------
  |  |  167|    906|#define TRUE    1
  |  |  ------------------
  |  |  |  Branch (167:17): [True: 906, Folded]
  |  |  ------------------
  ------------------
  494|       |        /* Find the next token in path_left and add the literal text up to it.
  495|       |         * If there are no more tokens, we can finish up. */
  496|    906|        tok_begin = strstr(path_left, "%{");
  497|    906|        if (tok_begin == NULL) {
  ------------------
  |  Branch (497:13): [True: 906, False: 0]
  ------------------
  498|    906|            k5_buf_add(&buf, path_left);
  499|    906|            break;
  500|    906|        }
  501|      0|        k5_buf_add_len(&buf, path_left, tok_begin - path_left);
  502|       |
  503|       |        /* Find the end of this token. */
  504|      0|        tok_end = strchr(tok_begin, '}');
  505|      0|        if (tok_end == NULL) {
  ------------------
  |  Branch (505:13): [True: 0, False: 0]
  ------------------
  506|      0|            ret = EINVAL;
  507|      0|            k5_setmsg(context, ret, _("variable missing }"));
  ------------------
  |  | 2414|      0|#define k5_setmsg krb5_set_error_message
  ------------------
                          k5_setmsg(context, ret, _("variable missing }"));
  ------------------
  |  | 1069|      0|#define _(s) dgettext(KRB5_TEXTDOMAIN, s)
  ------------------
  508|      0|            goto cleanup;
  509|      0|        }
  510|       |
  511|       |        /* Expand this token and add its value. */
  512|      0|        ret = expand_token(context, tok_begin, tok_end, extra_tokens,
  513|      0|                           &tok_val);
  514|      0|        if (ret)
  ------------------
  |  Branch (514:13): [True: 0, False: 0]
  ------------------
  515|      0|            goto cleanup;
  516|      0|        k5_buf_add(&buf, tok_val);
  517|      0|        free(tok_val);
  518|      0|        path_left = tok_end + 1;
  519|      0|    }
  520|       |
  521|    906|    path = k5_buf_cstring(&buf);
  522|    906|    if (path == NULL) {
  ------------------
  |  Branch (522:9): [True: 0, False: 906]
  ------------------
  523|      0|        ret = ENOMEM;
  524|      0|        goto cleanup;
  525|      0|    }
  526|       |
  527|       |#ifdef _WIN32
  528|       |    /* Also deal with slashes. */
  529|       |    {
  530|       |        char *p;
  531|       |        for (p = path; *p != '\0'; p++) {
  532|       |            if (*p == '/')
  533|       |                *p = '\\';
  534|       |        }
  535|       |    }
  536|       |#endif
  537|    906|    *path_out = path;
  538|    906|    memset(&buf, 0, sizeof(buf));
  539|    906|    ret = 0;
  540|       |
  541|    906|cleanup:
  542|    906|    k5_buf_free(&buf);
  543|    906|    free_extra_tokens(extra_tokens);
  544|    906|    return ret;
  545|    906|}
expand_path.c:free_extra_tokens:
  438|    906|{
  439|    906|    char **p;
  440|       |
  441|    906|    for (p = extra_tokens; p != NULL && *p != NULL; p++)
  ------------------
  |  Branch (441:28): [True: 0, False: 906]
  |  Branch (441:41): [True: 0, False: 0]
  ------------------
  442|      0|        free(*p);
  443|    906|    free(extra_tokens);
  444|    906|}

krb5_get_default_realm:
  498|    762|{
  499|    762|    krb5_error_code ret;
  500|       |
  501|    762|    *realm_out = NULL;
  502|       |
  503|    762|    if (context == NULL || context->magic != KV5M_CONTEXT)
  ------------------
  |  | 9072|    762|#define KV5M_CONTEXT                             (-1760647388L)
  ------------------
  |  Branch (503:9): [True: 0, False: 762]
  |  Branch (503:28): [True: 0, False: 762]
  ------------------
  504|      0|        return KV5M_CONTEXT;
  ------------------
  |  | 9072|      0|#define KV5M_CONTEXT                             (-1760647388L)
  ------------------
  505|       |
  506|    762|    if (context->default_realm == NULL) {
  ------------------
  |  Branch (506:9): [True: 762, False: 0]
  ------------------
  507|    762|        ret = get_default_realm(context, &context->default_realm);
  508|    762|        if (ret)
  ------------------
  |  Branch (508:13): [True: 762, False: 0]
  ------------------
  509|    762|            return ret;
  510|    762|    }
  511|      0|    *realm_out = strdup(context->default_realm);
  512|      0|    return (*realm_out == NULL) ? ENOMEM : 0;
  ------------------
  |  Branch (512:12): [True: 0, False: 0]
  ------------------
  513|    762|}
k5_hostrealm_free_context:
  544|    906|{
  545|    906|    free_handles(context, context->hostrealm_handles);
  546|       |    context->hostrealm_handles = NULL;
  547|    906|}
hostrealm.c:load_hostrealm_modules:
   99|    762|{
  100|    762|    krb5_error_code ret;
  101|    762|    struct hostrealm_module_handle **list = NULL, *handle;
  102|    762|    krb5_plugin_initvt_fn *modules = NULL, *mod;
  103|    762|    size_t count;
  104|       |
  105|    762|    ret = get_modules(context, &modules);
  106|    762|    if (ret != 0)
  ------------------
  |  Branch (106:9): [True: 0, False: 762]
  ------------------
  107|      0|        goto cleanup;
  108|       |
  109|       |    /* Allocate a large enough list of handles. */
  110|  3.81k|    for (count = 0; modules[count] != NULL; count++);
  ------------------
  |  Branch (110:21): [True: 3.04k, False: 762]
  ------------------
  111|    762|    list = k5alloc((count + 1) * sizeof(*list), &ret);
  112|    762|    if (list == NULL)
  ------------------
  |  Branch (112:9): [True: 0, False: 762]
  ------------------
  113|      0|        goto cleanup;
  114|       |
  115|       |    /* Initialize each module, ignoring ones that fail. */
  116|    762|    count = 0;
  117|  3.81k|    for (mod = modules; *mod != NULL; mod++) {
  ------------------
  |  Branch (117:25): [True: 3.04k, False: 762]
  ------------------
  118|  3.04k|        handle = k5alloc(sizeof(*handle), &ret);
  119|  3.04k|        if (handle == NULL)
  ------------------
  |  Branch (119:13): [True: 0, False: 3.04k]
  ------------------
  120|      0|            goto cleanup;
  121|  3.04k|        ret = (*mod)(context, 1, 1, (krb5_plugin_vtable)&handle->vt);
  122|  3.04k|        if (ret != 0) {
  ------------------
  |  Branch (122:13): [True: 0, False: 3.04k]
  ------------------
  123|      0|            TRACE_HOSTREALM_VTINIT_FAIL(context, ret);
  ------------------
  |  |  214|      0|    TRACE(c, "hostrealm module failed to init vtable: {kerr}", ret)
  |  |  ------------------
  |  |  |  |  100|      0|    do { if (ctx->trace_callback != NULL)                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  101|      0|            krb5int_trace(ctx, __VA_ARGS__); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:55): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  124|      0|            free(handle);
  125|      0|            continue;
  126|      0|        }
  127|       |
  128|  3.04k|        handle->data = NULL;
  129|  3.04k|        if (handle->vt.init != NULL) {
  ------------------
  |  Branch (129:13): [True: 0, False: 3.04k]
  ------------------
  130|      0|            ret = handle->vt.init(context, &handle->data);
  131|      0|            if (ret != 0) {
  ------------------
  |  Branch (131:17): [True: 0, False: 0]
  ------------------
  132|      0|                TRACE_HOSTREALM_INIT_FAIL(context, handle->vt.name, ret);
  ------------------
  |  |  216|      0|    TRACE(c, "hostrealm module {str} failed to init: {kerr}", name, ret)
  |  |  ------------------
  |  |  |  |  100|      0|    do { if (ctx->trace_callback != NULL)                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  101|      0|            krb5int_trace(ctx, __VA_ARGS__); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:55): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  133|      0|                free(handle);
  134|      0|                continue;
  135|      0|            }
  136|      0|        }
  137|  3.04k|        list[count++] = handle;
  138|  3.04k|        list[count] = NULL;
  139|  3.04k|    }
  140|    762|    list[count] = NULL;
  141|       |
  142|    762|    ret = 0;
  143|    762|    context->hostrealm_handles = list;
  144|    762|    list = NULL;
  145|       |
  146|    762|cleanup:
  147|    762|    k5_plugin_free_modules(context, modules);
  148|    762|    free_handles(context, list);
  149|    762|    return ret;
  150|    762|}
hostrealm.c:get_modules:
   71|    762|{
   72|    762|    krb5_error_code ret;
   73|    762|    const int intf = PLUGIN_INTERFACE_HOSTREALM;
  ------------------
  |  | 1142|    762|#define PLUGIN_INTERFACE_HOSTREALM   6
  ------------------
   74|       |
   75|    762|    *modules_out = NULL;
   76|       |
   77|       |    /* Register built-in modules. */
   78|    762|    ret = k5_plugin_register(context, intf, "registry",
   79|    762|                             hostrealm_registry_initvt);
   80|    762|    if (ret)
  ------------------
  |  Branch (80:9): [True: 0, False: 762]
  ------------------
   81|      0|        return ret;
   82|    762|    ret = k5_plugin_register(context, intf, "profile",
   83|    762|                             hostrealm_profile_initvt);
   84|    762|    if (ret)
  ------------------
  |  Branch (84:9): [True: 0, False: 762]
  ------------------
   85|      0|        return ret;
   86|    762|    ret = k5_plugin_register(context, intf, "dns", hostrealm_dns_initvt);
   87|    762|    if (ret)
  ------------------
  |  Branch (87:9): [True: 0, False: 762]
  ------------------
   88|      0|        return ret;
   89|    762|    ret = k5_plugin_register(context, intf, "domain", hostrealm_domain_initvt);
   90|    762|    if (ret)
  ------------------
  |  Branch (90:9): [True: 0, False: 762]
  ------------------
   91|      0|        return ret;
   92|       |
   93|    762|    return k5_plugin_load_all(context, intf, modules_out);
   94|    762|}
hostrealm.c:get_default_realm:
  463|    762|{
  464|    762|    krb5_error_code ret;
  465|    762|    struct hostrealm_module_handle **hp;
  466|    762|    char **realms;
  467|       |
  468|    762|    *realm_out = NULL;
  469|    762|    if (context->hostrealm_handles == NULL) {
  ------------------
  |  Branch (469:9): [True: 762, False: 0]
  ------------------
  470|    762|        ret = load_hostrealm_modules(context);
  471|    762|        if (ret)
  ------------------
  |  Branch (471:13): [True: 0, False: 762]
  ------------------
  472|      0|            return ret;
  473|    762|    }
  474|       |
  475|       |    /* Give each module a chance to determine the default realm. */
  476|  3.81k|    for (hp = context->hostrealm_handles; *hp != NULL; hp++) {
  ------------------
  |  Branch (476:43): [True: 3.04k, False: 762]
  ------------------
  477|  3.04k|        ret = default_realm(context, *hp, &realms);
  478|  3.04k|        if (ret == 0) {
  ------------------
  |  Branch (478:13): [True: 0, False: 3.04k]
  ------------------
  479|      0|            if (*realms == NULL) {
  ------------------
  |  Branch (479:17): [True: 0, False: 0]
  ------------------
  480|      0|                ret = KRB5_CONFIG_NODEFREALM;
  ------------------
  |  | 8877|      0|#define KRB5_CONFIG_NODEFREALM                   (-1765328160L)
  ------------------
  481|      0|            } else {
  482|      0|                *realm_out = strdup(realms[0]);
  483|      0|                if (*realm_out == NULL)
  ------------------
  |  Branch (483:21): [True: 0, False: 0]
  ------------------
  484|      0|                    ret = ENOMEM;
  485|      0|            }
  486|      0|            free_list(context, *hp, realms);
  487|      0|            return ret;
  488|  3.04k|        } else if (ret != KRB5_PLUGIN_NO_HANDLE) {
  ------------------
  |  | 8902|  3.04k|#define KRB5_PLUGIN_NO_HANDLE                    (-1765328135L)
  ------------------
  |  Branch (488:20): [True: 0, False: 3.04k]
  ------------------
  489|      0|            return ret;
  490|      0|        }
  491|  3.04k|    }
  492|       |
  493|    762|    return KRB5_CONFIG_NODEFREALM;
  ------------------
  |  | 8877|    762|#define KRB5_CONFIG_NODEFREALM                   (-1765328160L)
  ------------------
  494|    762|}
hostrealm.c:default_realm:
  176|  3.04k|{
  177|  3.04k|    if (h->vt.default_realm == NULL)
  ------------------
  |  Branch (177:9): [True: 762, False: 2.28k]
  ------------------
  178|    762|        return KRB5_PLUGIN_NO_HANDLE;
  ------------------
  |  | 8902|    762|#define KRB5_PLUGIN_NO_HANDLE                    (-1765328135L)
  ------------------
  179|  2.28k|    return h->vt.default_realm(context, h->data, realms_out);
  180|  3.04k|}
hostrealm.c:free_handles:
   53|  1.66k|{
   54|  1.66k|    struct hostrealm_module_handle *h, **hp;
   55|       |
   56|  1.66k|    if (handles == NULL)
  ------------------
  |  Branch (56:9): [True: 906, False: 762]
  ------------------
   57|    906|        return;
   58|  3.81k|    for (hp = handles; *hp != NULL; hp++) {
  ------------------
  |  Branch (58:24): [True: 3.04k, False: 762]
  ------------------
   59|  3.04k|        h = *hp;
   60|  3.04k|        if (h->vt.fini != NULL)
  ------------------
  |  Branch (60:13): [True: 0, False: 3.04k]
  ------------------
   61|      0|            h->vt.fini(context, h->data);
   62|  3.04k|        free(h);
   63|  3.04k|    }
   64|    762|    free(handles);
   65|    762|}

hostrealm_dns_initvt:
  121|    762|{
  122|    762|    krb5_hostrealm_vtable vt = (krb5_hostrealm_vtable)vtable;
  123|       |
  124|    762|    vt->name = "dns";
  125|    762|    vt->fallback_realm = dns_fallback_realm;
  126|    762|    vt->default_realm = dns_default_realm;
  127|    762|    vt->free_list = dns_free_realmlist;
  128|    762|    return 0;
  129|    762|}
hostrealm_dns.c:dns_default_realm:
   85|    762|{
   86|    762|    krb5_error_code ret;
   87|    762|    char *localhost, *realm;
   88|       |
   89|    762|    *realms_out = NULL;
   90|    762|    if (!_krb5_use_dns_realm(context))
  ------------------
  |  Branch (90:9): [True: 762, False: 0]
  ------------------
   91|    762|        return KRB5_PLUGIN_NO_HANDLE;
  ------------------
  |  | 8902|    762|#define KRB5_PLUGIN_NO_HANDLE                    (-1765328135L)
  ------------------
   92|       |
   93|      0|    ret = krb5int_get_fq_local_hostname(&localhost);
   94|      0|    if (ret)
  ------------------
  |  Branch (94:9): [True: 0, False: 0]
  ------------------
   95|      0|        return ret;
   96|       |
   97|       |    /* If we don't find a TXT record for localhost or any parent, look for a
   98|       |     * global record. */
   99|      0|    realm = txt_lookup(context, localhost);
  100|      0|    free(localhost);
  101|      0|    if (realm == NULL)
  ------------------
  |  Branch (101:9): [True: 0, False: 0]
  ------------------
  102|      0|        (void)k5_try_realm_txt_rr(context, "_kerberos", NULL, &realm);
  103|       |
  104|      0|    if (realm == NULL)
  ------------------
  |  Branch (104:9): [True: 0, False: 0]
  ------------------
  105|      0|        return KRB5_PLUGIN_NO_HANDLE;
  ------------------
  |  | 8902|      0|#define KRB5_PLUGIN_NO_HANDLE                    (-1765328135L)
  ------------------
  106|      0|    ret = k5_make_realmlist(realm, realms_out);
  107|      0|    free(realm);
  108|      0|    return ret;
  109|      0|}

hostrealm_domain_initvt:
  121|    762|{
  122|    762|    krb5_hostrealm_vtable vt = (krb5_hostrealm_vtable)vtable;
  123|       |
  124|    762|    vt->name = "domain";
  125|    762|    vt->fallback_realm = domain_fallback_realm;
  126|    762|    vt->free_list = domain_free_realmlist;
  127|    762|    return 0;
  128|    762|}

hostrealm_profile_initvt:
  109|    762|{
  110|    762|    krb5_hostrealm_vtable vt = (krb5_hostrealm_vtable)vtable;
  111|       |
  112|    762|    vt->name = "profile";
  113|    762|    vt->host_realm = profile_host_realm;
  114|    762|    vt->default_realm = profile_default_realm;
  115|    762|    vt->free_list = profile_free_realmlist;
  116|    762|    return 0;
  117|    762|}
hostrealm_profile.c:profile_default_realm:
   83|    762|{
   84|    762|    krb5_error_code ret;
   85|    762|    char *prof_realm;
   86|       |
   87|    762|    *realms_out = NULL;
   88|    762|    ret = profile_get_string(context->profile, KRB5_CONF_LIBDEFAULTS,
  ------------------
  |  |  271|    762|#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
  ------------------
   89|    762|                             KRB5_CONF_DEFAULT_REALM, NULL, NULL, &prof_realm);
  ------------------
  |  |  202|    762|#define KRB5_CONF_DEFAULT_REALM                "default_realm"
  ------------------
   90|    762|    if (ret)
  ------------------
  |  Branch (90:9): [True: 0, False: 762]
  ------------------
   91|      0|        return ret;
   92|    762|    if (prof_realm == NULL)
  ------------------
  |  Branch (92:9): [True: 762, False: 0]
  ------------------
   93|    762|        return KRB5_PLUGIN_NO_HANDLE;
  ------------------
  |  | 8902|    762|#define KRB5_PLUGIN_NO_HANDLE                    (-1765328135L)
  ------------------
   94|      0|    ret = k5_make_realmlist(prof_realm, realms_out);
   95|      0|    profile_release_string(prof_realm);
   96|      0|    return ret;
   97|    762|}

hostrealm_registry_initvt:
  128|    762|{
  129|    762|    krb5_hostrealm_vtable vt = (krb5_hostrealm_vtable)vtable;
  130|       |
  131|    762|    vt->name = "registry";
  132|    762|    vt->default_realm = registry_default_realm;
  133|    762|    vt->free_list = registry_free_realmlist;
  134|    762|    return 0;
  135|    762|}
hostrealm_registry.c:registry_default_realm:
  113|    762|{
  114|    762|        return KRB5_PLUGIN_NO_HANDLE;
  ------------------
  |  | 8902|    762|#define KRB5_PLUGIN_NO_HANDLE                    (-1765328135L)
  ------------------
  115|    762|}

k5_os_init_context:
  415|    906|{
  416|    906|    krb5_os_context os_ctx;
  417|    906|    krb5_error_code    retval = 0;
  418|       |#ifdef _WIN32
  419|       |    WORD wVersionRequested;
  420|       |    WSADATA wsaData;
  421|       |#endif /* _WIN32 */
  422|       |
  423|    906|    os_ctx = &ctx->os_context;
  424|    906|    os_ctx->magic = KV5M_OS_CONTEXT;
  ------------------
  |  | 9073|    906|#define KV5M_OS_CONTEXT                          (-1760647387L)
  ------------------
  425|    906|    os_ctx->time_offset = 0;
  426|    906|    os_ctx->usec_offset = 0;
  427|    906|    os_ctx->os_flags = 0;
  428|    906|    os_ctx->default_ccname = 0;
  429|       |
  430|    906|    PLUGIN_DIR_INIT(&ctx->libkrb5_plugins);
  ------------------
  |  |   86|    906|#define PLUGIN_DIR_INIT(P) ((P)->files = NULL)
  ------------------
  431|    906|    ctx->preauth_context = NULL;
  432|       |
  433|       |    /* Use the profile we were handed, or create one from config files. */
  434|    906|    if (profile)
  ------------------
  |  Branch (434:9): [True: 0, False: 906]
  ------------------
  435|      0|        retval = profile_copy(profile, &ctx->profile);
  436|    906|    else
  437|    906|        retval = os_init_paths(ctx, (flags & KRB5_INIT_CONTEXT_KDC) != 0);
  ------------------
  |  | 2861|    906|#define KRB5_INIT_CONTEXT_KDC    0x2 /**< Use KDC configuration if available */
  ------------------
  438|    906|    if (retval)
  ------------------
  |  Branch (438:9): [True: 0, False: 906]
  ------------------
  439|      0|        return retval;
  440|       |
  441|       |#ifdef _WIN32
  442|       |    /* We initialize winsock to version 1.1 but
  443|       |     * we do not care if we succeed or fail.
  444|       |     */
  445|       |    wVersionRequested = 0x0101;
  446|       |    WSAStartup (wVersionRequested, &wsaData);
  447|       |#endif /* _WIN32 */
  448|       |
  449|    906|    return 0;
  450|    906|}
k5_os_free_context:
  492|    906|{
  493|    906|    krb5_os_context os_ctx;
  494|       |
  495|    906|    os_ctx = &ctx->os_context;
  496|       |
  497|    906|    if (os_ctx->default_ccname) {
  ------------------
  |  Branch (497:9): [True: 0, False: 906]
  ------------------
  498|      0|        free(os_ctx->default_ccname);
  499|      0|        os_ctx->default_ccname = 0;
  500|      0|    }
  501|       |
  502|    906|    os_ctx->magic = 0;
  503|       |
  504|    906|    if (ctx->profile) {
  ------------------
  |  Branch (504:9): [True: 906, False: 0]
  ------------------
  505|    906|        profile_abandon(ctx->profile);
  506|    906|        ctx->profile = 0;
  507|    906|    }
  508|       |
  509|    906|    if (ctx->preauth_context) {
  ------------------
  |  Branch (509:9): [True: 0, False: 906]
  ------------------
  510|      0|        k5_free_preauth_context(ctx);
  511|      0|        ctx->preauth_context = NULL;
  512|      0|    }
  513|    906|    krb5int_close_plugin_dirs (&ctx->libkrb5_plugins);
  514|       |
  515|       |#ifdef _WIN32
  516|       |    WSACleanup();
  517|       |#endif /* _WIN32 */
  518|    906|}
init_os_ctx.c:os_init_paths:
  375|    906|{
  376|    906|    krb5_error_code    retval = 0;
  377|    906|    profile_filespec_t *files = 0;
  378|    906|    krb5_boolean secure = ctx->profile_secure;
  379|       |
  380|    906|    retval = os_get_default_config_files(&files, secure);
  381|       |
  382|    906|    if (retval == 0 && kdc)
  ------------------
  |  Branch (382:9): [True: 906, False: 0]
  |  Branch (382:24): [True: 0, False: 906]
  ------------------
  383|      0|        retval = add_kdc_config_file(&files);
  384|       |
  385|    906|    if (!retval) {
  ------------------
  |  Branch (385:9): [True: 906, False: 0]
  ------------------
  386|    906|        retval = profile_init_flags((const_profile_filespec_t *) files,
  387|    906|                                    PROFILE_INIT_ALLOW_MODULE, &ctx->profile);
  ------------------
  |  |   27|    906|#define PROFILE_INIT_ALLOW_MODULE       0x0001  /* Allow module declaration */
  ------------------
  388|       |
  389|       |        /* If none of the filenames can be opened, use an empty profile. */
  390|    906|        if (retval == ENOENT)
  ------------------
  |  Branch (390:13): [True: 906, False: 0]
  ------------------
  391|    906|            retval = profile_init(NULL, &ctx->profile);
  392|    906|    }
  393|       |
  394|    906|    if (files)
  ------------------
  |  Branch (394:9): [True: 906, False: 0]
  ------------------
  395|    906|        free_filespecs(files);
  396|       |
  397|    906|    if (retval)
  ------------------
  |  Branch (397:9): [True: 0, False: 906]
  ------------------
  398|      0|        ctx->profile = 0;
  399|       |
  400|    906|    if (retval == ENOENT)
  ------------------
  |  Branch (400:9): [True: 0, False: 906]
  ------------------
  401|      0|        return KRB5_CONFIG_CANTOPEN;
  ------------------
  |  | 8788|      0|#define KRB5_CONFIG_CANTOPEN                     (-1765328249L)
  ------------------
  402|       |
  403|    906|    if ((retval == PROF_SECTION_NOTOP) ||
  ------------------
  |  |  319|    906|#define PROF_SECTION_NOTOP                       (-1429577715L)
  ------------------
  |  Branch (403:9): [True: 0, False: 906]
  ------------------
  404|    906|        (retval == PROF_SECTION_SYNTAX) ||
  ------------------
  |  |  320|    906|#define PROF_SECTION_SYNTAX                      (-1429577714L)
  ------------------
  |  Branch (404:9): [True: 0, False: 906]
  ------------------
  405|    906|        (retval == PROF_RELATION_SYNTAX) ||
  ------------------
  |  |  321|    906|#define PROF_RELATION_SYNTAX                     (-1429577713L)
  ------------------
  |  Branch (405:9): [True: 0, False: 906]
  ------------------
  406|    906|        (retval == PROF_EXTRA_CBRACE) ||
  ------------------
  |  |  322|    906|#define PROF_EXTRA_CBRACE                        (-1429577712L)
  ------------------
  |  Branch (406:9): [True: 0, False: 906]
  ------------------
  407|    906|        (retval == PROF_MISSING_OBRACE))
  ------------------
  |  |  323|    906|#define PROF_MISSING_OBRACE                      (-1429577711L)
  ------------------
  |  Branch (407:9): [True: 0, False: 906]
  ------------------
  408|      0|        return KRB5_CONFIG_BADFORMAT;
  ------------------
  |  | 8789|      0|#define KRB5_CONFIG_BADFORMAT                    (-1765328248L)
  ------------------
  409|       |
  410|    906|    return retval;
  411|    906|}
init_os_ctx.c:os_get_default_config_files:
  238|    906|{
  239|    906|    profile_filespec_t* files;
  240|       |#if defined(_WIN32)
  241|       |    krb5_error_code retval = 0;
  242|       |    char *name = 0;
  243|       |
  244|       |    if (!secure) {
  245|       |        char *env = secure_getenv("KRB5_CONFIG");
  246|       |        if (env) {
  247|       |            name = strdup(env);
  248|       |            if (!name) return ENOMEM;
  249|       |        }
  250|       |    }
  251|       |    if (!name && !secure) {
  252|       |        /* HKCU */
  253|       |        retval = get_from_registry(&name, HKEY_CURRENT_USER);
  254|       |        if (retval) return retval;
  255|       |    }
  256|       |    if (!name) {
  257|       |        /* HKLM */
  258|       |        retval = get_from_registry(&name, HKEY_LOCAL_MACHINE);
  259|       |        if (retval) return retval;
  260|       |    }
  261|       |
  262|       |    if (!name && !secure) {
  263|       |        retval = get_from_known_folder(CSIDL_APPDATA, &name);
  264|       |        if (retval) return retval;
  265|       |    }
  266|       |
  267|       |    if (!name) {
  268|       |        retval = get_from_known_folder(CSIDL_COMMON_APPDATA, &name);
  269|       |        if (retval) return retval;
  270|       |    }
  271|       |
  272|       |    if (!name && !secure) {
  273|       |        /* module dir */
  274|       |        retval = get_from_module_dir(&name);
  275|       |        if (retval) return retval;
  276|       |    }
  277|       |    if (!name) {
  278|       |        /* windows dir */
  279|       |        retval = get_from_windows_dir(&name);
  280|       |    }
  281|       |    if (retval)
  282|       |        return retval;
  283|       |    if (!name)
  284|       |        return KRB5_CONFIG_CANTOPEN; /* should never happen */
  285|       |
  286|       |    files = malloc(2 * sizeof(char *));
  287|       |    if (!files)
  288|       |        return ENOMEM;
  289|       |    files[0] = name;
  290|       |    files[1] = 0;
  291|       |#else /* !_WIN32 */
  292|    906|    char* filepath = 0;
  293|    906|    int n_entries, i;
  294|    906|    unsigned int ent_len;
  295|    906|    const char *s, *t;
  296|       |
  297|    906|    if (secure) {
  ------------------
  |  Branch (297:9): [True: 0, False: 906]
  ------------------
  298|      0|        filepath = DEFAULT_SECURE_PROFILE_PATH;
  ------------------
  |  |   53|      0|#define DEFAULT_SECURE_PROFILE_PATH     "/etc/krb5.conf:/usr/local/etc/krb5.conf"
  ------------------
  299|    906|    } else {
  300|    906|        filepath = secure_getenv("KRB5_CONFIG");
  301|    906|        if (!filepath) filepath = DEFAULT_PROFILE_PATH;
  ------------------
  |  |   54|    906|#define DEFAULT_PROFILE_PATH        DEFAULT_SECURE_PROFILE_PATH
  |  |  ------------------
  |  |  |  |   53|    906|#define DEFAULT_SECURE_PROFILE_PATH     "/etc/krb5.conf:/usr/local/etc/krb5.conf"
  |  |  ------------------
  ------------------
  |  Branch (301:13): [True: 906, False: 0]
  ------------------
  302|    906|    }
  303|       |
  304|       |    /* count the distinct filename components */
  305|  36.2k|    for(s = filepath, n_entries = 1; *s; s++) {
  ------------------
  |  Branch (305:38): [True: 35.3k, False: 906]
  ------------------
  306|  35.3k|        if (*s == ':')
  ------------------
  |  Branch (306:13): [True: 906, False: 34.4k]
  ------------------
  307|    906|            n_entries++;
  308|  35.3k|    }
  309|       |
  310|       |    /* the array is NULL terminated */
  311|    906|    files = (char**) malloc((n_entries+1) * sizeof(char*));
  312|    906|    if (files == 0)
  ------------------
  |  Branch (312:9): [True: 0, False: 906]
  ------------------
  313|      0|        return ENOMEM;
  314|       |
  315|       |    /* measure, copy, and skip each one */
  316|  1.81k|    for(s = filepath, i=0; (t = strchr(s, ':')) || (t=s+strlen(s)); s=t+1, i++) {
  ------------------
  |  Branch (316:28): [True: 906, False: 906]
  |  Branch (316:52): [True: 906, False: 0]
  ------------------
  317|  1.81k|        ent_len = t-s;
  318|  1.81k|        files[i] = (char*) malloc(ent_len + 1);
  319|  1.81k|        if (files[i] == 0) {
  ------------------
  |  Branch (319:13): [True: 0, False: 1.81k]
  ------------------
  320|       |            /* if malloc fails, free the ones that worked */
  321|      0|            while(--i >= 0) free(files[i]);
  ------------------
  |  Branch (321:19): [True: 0, False: 0]
  ------------------
  322|      0|            free(files);
  323|      0|            return ENOMEM;
  324|      0|        }
  325|  1.81k|        strncpy(files[i], s, ent_len);
  326|  1.81k|        files[i][ent_len] = 0;
  327|  1.81k|        if (*t == 0) {
  ------------------
  |  Branch (327:13): [True: 906, False: 906]
  ------------------
  328|    906|            i++;
  329|    906|            break;
  330|    906|        }
  331|  1.81k|    }
  332|       |    /* cap the array */
  333|    906|    files[i] = 0;
  334|    906|#endif /* !_WIN32 */
  335|    906|    *pfiles = (profile_filespec_t *)files;
  336|    906|    return 0;
  337|    906|}
init_os_ctx.c:free_filespecs:
  223|    906|{
  224|    906|    char **cp;
  225|       |
  226|    906|    if (files == 0)
  ------------------
  |  Branch (226:9): [True: 0, False: 906]
  ------------------
  227|      0|        return;
  228|       |
  229|  2.71k|    for (cp = files; *cp; cp++)
  ------------------
  |  Branch (229:22): [True: 1.81k, False: 906]
  ------------------
  230|  1.81k|        free(*cp);
  231|    906|    free(files);
  232|    906|}

k5_localauth_free_context:
  440|    906|{
  441|    906|    free_handles(context, context->localauth_handles);
  442|       |    context->localauth_handles = NULL;
  443|    906|}
localauth.c:free_handles:
   52|    906|{
   53|    906|    struct localauth_module_handle *h, **hp;
   54|       |
   55|    906|    if (handles == NULL)
  ------------------
  |  Branch (55:9): [True: 906, False: 0]
  ------------------
   56|    906|        return;
   57|      0|    for (hp = handles; *hp != NULL; hp++) {
  ------------------
  |  Branch (57:24): [True: 0, False: 0]
  ------------------
   58|      0|        h = *hp;
   59|      0|        if (h->vt.fini != NULL)
  ------------------
  |  Branch (59:13): [True: 0, False: 0]
  ------------------
   60|      0|            h->vt.fini(context, h->data);
   61|      0|        free(h);
   62|      0|    }
   63|      0|    free(handles);
   64|      0|}

_krb5_use_dns_realm:
   96|    762|{
   97|    762|    return maybe_use_dns(context, KRB5_CONF_DNS_LOOKUP_REALM,
  ------------------
  |  |  214|    762|#define KRB5_CONF_DNS_LOOKUP_REALM             "dns_lookup_realm"
  ------------------
   98|    762|                         DEFAULT_LOOKUP_REALM);
  ------------------
  |  |   47|    762|#define DEFAULT_LOOKUP_REALM 0
  ------------------
   99|    762|}
locate_kdc.c:maybe_use_dns:
   53|    762|{
   54|    762|    krb5_error_code code;
   55|    762|    char * value = NULL;
   56|    762|    int use_dns = 0;
   57|       |
   58|    762|    code = profile_get_string(context->profile, KRB5_CONF_LIBDEFAULTS,
  ------------------
  |  |  271|    762|#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
  ------------------
   59|    762|                              name, 0, 0, &value);
   60|    762|    if (value == 0 && code == 0) {
  ------------------
  |  Branch (60:9): [True: 762, False: 0]
  |  Branch (60:23): [True: 762, False: 0]
  ------------------
   61|    762|        code = profile_get_string(context->profile, KRB5_CONF_LIBDEFAULTS,
  ------------------
  |  |  271|    762|#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
  ------------------
   62|    762|                                  KRB5_CONF_DNS_FALLBACK, 0, 0, &value);
  ------------------
  |  |  212|    762|#define KRB5_CONF_DNS_FALLBACK                 "dns_fallback"
  ------------------
   63|    762|    }
   64|    762|    if (code)
  ------------------
  |  Branch (64:9): [True: 0, False: 762]
  ------------------
   65|      0|        return defalt;
   66|       |
   67|    762|    if (value == 0)
  ------------------
  |  Branch (67:9): [True: 762, False: 0]
  ------------------
   68|    762|        return defalt;
   69|       |
   70|      0|    use_dns = _krb5_conf_boolean(value);
   71|      0|    profile_release_string(value);
   72|      0|    return use_dns;
   73|    762|}

k5_init_trace:
  386|    906|{
  387|    906|    const char *filename;
  388|       |
  389|    906|    filename = secure_getenv("KRB5_TRACE");
  390|    906|    if (filename)
  ------------------
  |  Branch (390:9): [True: 0, False: 906]
  ------------------
  391|      0|        (void) krb5_set_trace_filename(context, filename);
  392|    906|}

LLVMFuzzerTestOneInput:
  138|    935|{
  139|    935|    krb5_error_code ret;
  140|    935|    char *data_in;
  141|       |
  142|    935|    if (size < kMinInputLength || size > kMaxInputLength)
  ------------------
  |  |   46|  1.87k|#define kMinInputLength 2
  ------------------
                  if (size < kMinInputLength || size > kMaxInputLength)
  ------------------
  |  |   47|    934|#define kMaxInputLength 256
  ------------------
  |  Branch (142:9): [True: 1, False: 934]
  |  Branch (142:35): [True: 28, False: 906]
  ------------------
  143|     29|        return 0;
  144|       |
  145|    906|    data_in = k5memdup0(data, size, &ret);
  146|    906|    if (data_in == NULL)
  ------------------
  |  Branch (146:9): [True: 0, False: 906]
  ------------------
  147|      0|        return 0;
  148|       |
  149|    906|    fuzz_base64(data_in, size);
  150|    906|    fuzz_hashtab(data_in, size);
  151|    906|    fuzz_hex(data_in, size);
  152|    906|    fuzz_name(data_in, size);
  153|    906|    fuzz_parse_host(data_in, size);
  154|    906|    fuzz_utf8(data_in, size);
  155|       |
  156|    906|    free(data_in);
  157|       |
  158|    906|    return 0;
  159|    906|}
fuzz_util.c:fuzz_base64:
   53|    906|{
   54|    906|    size_t len;
   55|       |
   56|    906|    free(k5_base64_encode(data_in, size));
   57|    906|    free(k5_base64_decode(data_in, &len));
   58|    906|}
fuzz_util.c:fuzz_hashtab:
   62|    906|{
   63|    906|    int st;
   64|    906|    struct k5_hashtab *ht;
   65|       |
   66|    906|    k5_hashtab_create(NULL, 4, &ht);
   67|    906|    if (ht == NULL)
  ------------------
  |  Branch (67:9): [True: 0, False: 906]
  ------------------
   68|      0|        return;
   69|       |
   70|    906|    k5_hashtab_add(ht, data_in, size, &st);
   71|       |
   72|    906|    k5_hashtab_free(ht);
   73|    906|}
fuzz_util.c:fuzz_hex:
   77|    906|{
   78|    906|    char *hex;
   79|    906|    uint8_t *bytes;
   80|    906|    size_t len;
   81|       |
   82|    906|    if (k5_hex_encode(data_in, size, 0, &hex) == 0)
  ------------------
  |  Branch (82:9): [True: 906, False: 0]
  ------------------
   83|    906|        free(hex);
   84|       |
   85|    906|    if (k5_hex_encode(data_in, size, 1, &hex) == 0)
  ------------------
  |  Branch (85:9): [True: 906, False: 0]
  ------------------
   86|    906|        free(hex);
   87|       |
   88|    906|    if (k5_hex_decode(data_in, &bytes, &len) == 0)
  ------------------
  |  Branch (88:9): [True: 96, False: 810]
  ------------------
   89|     96|        free(bytes);
   90|    906|}
fuzz_util.c:fuzz_name:
   94|    906|{
   95|    906|    krb5_context context;
   96|    906|    krb5_principal fuzzing;
   97|       |
   98|    906|    if (krb5_init_context(&context) != 0)
  ------------------
  |  Branch (98:9): [True: 0, False: 906]
  ------------------
   99|      0|        return;
  100|       |
  101|    906|    krb5_parse_name(context, data_in, &fuzzing);
  102|       |
  103|    906|    krb5_free_principal(context, fuzzing);
  104|    906|    krb5_free_context(context);
  105|    906|}
fuzz_util.c:fuzz_parse_host:
  109|    906|{
  110|    906|    char *host_out = NULL;
  111|    906|    int port_out = -1;
  112|       |
  113|    906|    if (k5_parse_host_string(data_in, 1, &host_out, &port_out) == 0)
  ------------------
  |  Branch (113:9): [True: 747, False: 159]
  ------------------
  114|    747|        free(host_out);
  115|    906|}
fuzz_util.c:fuzz_utf8:
  119|    906|{
  120|    906|    krb5_ucs4 u = 0;
  121|    906|    char *utf8;
  122|    906|    uint8_t *utf16;
  123|    906|    size_t utf16len;
  124|       |
  125|    906|    krb5int_utf8_to_ucs4(data_in, &u);
  126|       |
  127|    906|    k5_utf8_to_utf16le(data_in, &utf16, &utf16len);
  128|    906|    if (utf16 != NULL)
  ------------------
  |  Branch (128:9): [True: 536, False: 370]
  ------------------
  129|    536|        free(utf16);
  130|       |
  131|    906|    k5_utf16le_to_utf8((const uint8_t *)data_in, size, &utf8);
  132|    906|    if (utf8 != NULL)
  ------------------
  |  Branch (132:9): [True: 607, False: 299]
  ------------------
  133|    607|        free(utf8);
  134|    906|}

add_error_table:
  254|      7|{
  255|      7|    struct et_list *e;
  256|       |
  257|      7|    if (CALL_INIT_FUNCTION(com_err_initialize))
  ------------------
  |  |  291|      7|        k5_call_init_function(& JOIN__2(NAME, once))
  |  |  ------------------
  |  |  |  |  255|      7|        (__extension__ ({                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (255:9): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  256|      7|                k5_init_t *k5int_i = (I);                               \
  |  |  |  |  257|      7|                int k5int_err = k5_once(&k5int_i->once, k5int_i->fn);   \
  |  |  |  |  258|      7|                (k5int_err                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (258:18): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  259|      7|                 ? k5int_err                                            \
  |  |  |  |  260|      7|                 : (assert(k5int_i->did_run != 0), k5int_i->error));    \
  |  |  |  |  261|      7|            }))
  |  |  ------------------
  ------------------
  |  Branch (257:9): [True: 0, False: 7]
  |  Branch (257:9): [True: 7, False: 0]
  ------------------
  258|      0|        return 0;
  259|       |
  260|      7|    e = malloc(sizeof(struct et_list));
  261|      7|    if (e == NULL)
  ------------------
  |  Branch (261:9): [True: 0, False: 7]
  ------------------
  262|      0|        return ENOMEM;
  263|       |
  264|      7|    e->table = et;
  265|       |
  266|      7|    k5_mutex_lock(&et_list_lock);
  267|      7|    e->next = et_list;
  268|      7|    et_list = e;
  269|       |
  270|       |    /* If there are two strings at the end of the table, they are a text domain
  271|       |     * and locale dir, and we are supposed to call bindtextdomain. */
  272|      7|    if (et->msgs[et->n_msgs] != NULL && et->msgs[et->n_msgs + 1] != NULL)
  ------------------
  |  Branch (272:9): [True: 7, False: 0]
  |  Branch (272:41): [True: 0, False: 7]
  ------------------
  273|      0|        bindtextdomain(et->msgs[et->n_msgs], et->msgs[et->n_msgs + 1]);
  274|       |
  275|      7|    k5_mutex_unlock(&et_list_lock);
  276|      7|    return 0;
  277|      7|}
error_message.c:com_err_initialize:
   35|      1|{
   36|      1|    int err;
   37|       |#ifdef SHOW_INITFINI_FUNCS
   38|       |    printf("com_err_initialize\n");
   39|       |#endif
   40|      1|    terminated = 0;
   41|      1|    err = k5_mutex_finish_init(&et_list_lock);
   42|      1|    if (err)
  ------------------
  |  Branch (42:9): [True: 0, False: 1]
  ------------------
   43|      0|        return err;
   44|      1|    err = k5_mutex_finish_init(&com_err_hook_lock);
   45|      1|    if (err)
  ------------------
  |  Branch (45:9): [True: 0, False: 1]
  ------------------
   46|      0|        return err;
   47|      1|    err = k5_key_register(K5_KEY_COM_ERR, free);
  ------------------
  |  |  413|      1|#define k5_key_register krb5int_key_register
  ------------------
   48|      1|    if (err)
  ------------------
  |  Branch (48:9): [True: 0, False: 1]
  ------------------
   49|      0|        return err;
   50|      1|    return 0;
   51|      1|}

profile_make_prf_data:
  140|  1.81k|{
  141|  1.81k|    prf_data_t d;
  142|  1.81k|    size_t len, flen, slen;
  143|  1.81k|    char *fcopy;
  144|       |
  145|  1.81k|    flen = strlen(filename);
  146|  1.81k|    slen = offsetof(struct _prf_data_t, filespec);
  147|  1.81k|    len = slen + flen + 1;
  148|  1.81k|    if (len < sizeof(struct _prf_data_t))
  ------------------
  |  Branch (148:9): [True: 906, False: 906]
  ------------------
  149|    906|        len = sizeof(struct _prf_data_t);
  150|  1.81k|    d = malloc(len);
  151|  1.81k|    if (d == NULL)
  ------------------
  |  Branch (151:9): [True: 0, False: 1.81k]
  ------------------
  152|      0|        return NULL;
  153|  1.81k|    memset(d, 0, len);
  154|  1.81k|    fcopy = (char *) d + slen;
  155|  1.81k|    assert(fcopy == d->filespec);
  ------------------
  |  Branch (155:5): [True: 0, False: 1.81k]
  |  Branch (155:5): [True: 1.81k, False: 0]
  ------------------
  156|  1.81k|    strlcpy(fcopy, filename, flen + 1);
  ------------------
  |  |  866|  1.81k|#define strlcpy krb5int_strlcpy
  ------------------
  157|  1.81k|    d->refcount = 1;
  158|  1.81k|    d->magic = PROF_MAGIC_FILE_DATA;
  ------------------
  |  |  336|  1.81k|#define PROF_MAGIC_FILE_DATA                     (-1429577698L)
  ------------------
  159|  1.81k|    d->root = NULL;
  160|  1.81k|    d->next = NULL;
  161|  1.81k|    d->fslen = flen;
  162|  1.81k|    if (k5_mutex_init(&d->lock) != 0) {
  ------------------
  |  Branch (162:9): [True: 0, False: 1.81k]
  ------------------
  163|      0|        free(d);
  164|      0|        return NULL;
  165|      0|    }
  166|  1.81k|    return d;
  167|  1.81k|}
profile_open_file:
  171|  1.81k|{
  172|  1.81k|    prf_file_t      prf;
  173|  1.81k|    errcode_t       retval;
  174|  1.81k|    char            *home_env = 0;
  175|  1.81k|    prf_data_t      data;
  176|  1.81k|    char            *expanded_filename;
  177|       |
  178|  1.81k|    retval = CALL_INIT_FUNCTION(profile_library_initializer);
  ------------------
  |  |  291|  1.81k|        k5_call_init_function(& JOIN__2(NAME, once))
  |  |  ------------------
  |  |  |  |  255|  1.81k|        (__extension__ ({                                               \
  |  |  |  |  256|  1.81k|                k5_init_t *k5int_i = (I);                               \
  |  |  |  |  257|  1.81k|                int k5int_err = k5_once(&k5int_i->once, k5int_i->fn);   \
  |  |  |  |  258|  1.81k|                (k5int_err                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (258:18): [True: 0, False: 1.81k]
  |  |  |  |  ------------------
  |  |  |  |  259|  1.81k|                 ? k5int_err                                            \
  |  |  |  |  260|  1.81k|                 : (assert(k5int_i->did_run != 0), k5int_i->error));    \
  |  |  |  |  261|  1.81k|            }))
  |  |  ------------------
  ------------------
  |  Branch (178:14): [True: 0, False: 1.81k]
  |  Branch (178:14): [True: 1.81k, False: 0]
  ------------------
  179|  1.81k|    if (retval)
  ------------------
  |  Branch (179:9): [True: 0, False: 1.81k]
  ------------------
  180|      0|        return retval;
  181|       |
  182|  1.81k|    prf = malloc(sizeof(struct _prf_file_t));
  183|  1.81k|    if (!prf)
  ------------------
  |  Branch (183:9): [True: 0, False: 1.81k]
  ------------------
  184|      0|        return ENOMEM;
  185|  1.81k|    memset(prf, 0, sizeof(struct _prf_file_t));
  186|  1.81k|    prf->magic = PROF_MAGIC_FILE;
  ------------------
  |  |  331|  1.81k|#define PROF_MAGIC_FILE                          (-1429577703L)
  ------------------
  187|       |
  188|  1.81k|    if (filespec[0] == '~' && filespec[1] == '/') {
  ------------------
  |  Branch (188:9): [True: 0, False: 1.81k]
  |  Branch (188:31): [True: 0, False: 0]
  ------------------
  189|      0|        home_env = secure_getenv("HOME");
  190|      0|#ifdef HAVE_PWD_H
  191|      0|        if (home_env == NULL) {
  ------------------
  |  Branch (191:13): [True: 0, False: 0]
  ------------------
  192|      0|            uid_t uid;
  193|      0|            struct passwd *pw, pwx;
  194|      0|            char pwbuf[BUFSIZ];
  195|       |
  196|      0|            uid = getuid();
  197|      0|            if (!k5_getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf), &pw)
  ------------------
  |  |  802|      0|        (getpwuid_r(UID,REC,BUF,BUFSIZE,OUT) == 0       \
  |  |  ------------------
  |  |  |  Branch (802:10): [True: 0, False: 0]
  |  |  ------------------
  |  |  803|      0|         ? (*(OUT) == NULL ? -1 : 0) : -1)
  |  |  ------------------
  |  |  |  Branch (803:13): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (197:17): [True: 0, False: 0]
  ------------------
  198|      0|                && pw != NULL && pw->pw_dir[0] != 0)
  ------------------
  |  Branch (198:20): [True: 0, False: 0]
  |  Branch (198:34): [True: 0, False: 0]
  ------------------
  199|      0|                home_env = pw->pw_dir;
  200|      0|        }
  201|      0|#endif
  202|      0|    }
  203|  1.81k|    if (home_env) {
  ------------------
  |  Branch (203:9): [True: 0, False: 1.81k]
  ------------------
  204|      0|        if (asprintf(&expanded_filename, "%s%s", home_env,
  ------------------
  |  Branch (204:13): [True: 0, False: 0]
  ------------------
  205|      0|                     filespec + 1) < 0)
  206|      0|            expanded_filename = 0;
  207|      0|    } else
  208|  1.81k|        expanded_filename = strdup(filespec);
  209|  1.81k|    if (expanded_filename == 0) {
  ------------------
  |  Branch (209:9): [True: 0, False: 1.81k]
  ------------------
  210|      0|        free(prf);
  211|      0|        return ENOMEM;
  212|      0|    }
  213|       |
  214|  1.81k|    k5_mutex_lock(&g_shared_trees_mutex);
  ------------------
  |  |   44|  1.81k|#define g_shared_trees_mutex    (krb5int_profile_shared_data.mutex)
  ------------------
  215|  1.81k|    for (data = g_shared_trees; data; data = data->next) {
  ------------------
  |  |   43|  1.81k|#define g_shared_trees          (krb5int_profile_shared_data.trees)
  ------------------
  |  Branch (215:33): [True: 0, False: 1.81k]
  ------------------
  216|      0|        if (!strcmp(data->filespec, expanded_filename)
  ------------------
  |  Branch (216:13): [True: 0, False: 0]
  ------------------
  217|       |            /* Check that current uid has read access.  */
  218|      0|            && r_access(data->filespec))
  ------------------
  |  Branch (218:16): [True: 0, False: 0]
  ------------------
  219|      0|            break;
  220|      0|    }
  221|  1.81k|    if (data) {
  ------------------
  |  Branch (221:9): [True: 0, False: 1.81k]
  ------------------
  222|      0|        data->refcount++;
  223|      0|        k5_mutex_unlock(&g_shared_trees_mutex);
  ------------------
  |  |   44|      0|#define g_shared_trees_mutex    (krb5int_profile_shared_data.mutex)
  ------------------
  224|      0|        k5_mutex_lock(&data->lock);
  225|      0|        data->last_stat = 0;    /* Make sure to stat when updating. */
  226|      0|        retval = profile_update_file_data_locked(data, NULL);
  227|      0|        k5_mutex_unlock(&data->lock);
  228|      0|        free(expanded_filename);
  229|      0|        if (retval) {
  ------------------
  |  Branch (229:13): [True: 0, False: 0]
  ------------------
  230|      0|            profile_dereference_data(data);
  231|      0|            free(prf);
  232|      0|            return retval;
  233|      0|        }
  234|      0|        prf->data = data;
  235|      0|        *ret_prof = prf;
  236|      0|        return 0;
  237|      0|    }
  238|  1.81k|    k5_mutex_unlock(&g_shared_trees_mutex);
  ------------------
  |  |   44|  1.81k|#define g_shared_trees_mutex    (krb5int_profile_shared_data.mutex)
  ------------------
  239|  1.81k|    data = profile_make_prf_data(expanded_filename);
  240|  1.81k|    if (data == NULL) {
  ------------------
  |  Branch (240:9): [True: 0, False: 1.81k]
  ------------------
  241|      0|        free(prf);
  242|      0|        free(expanded_filename);
  243|      0|        return ENOMEM;
  244|      0|    }
  245|  1.81k|    free(expanded_filename);
  246|  1.81k|    prf->data = data;
  247|       |
  248|  1.81k|    retval = profile_update_file(prf, ret_modspec);
  ------------------
  |  |  220|  1.81k|#define profile_update_file(P, M) profile_update_file_data((P)->data, M)
  ------------------
  249|  1.81k|    if (retval) {
  ------------------
  |  Branch (249:9): [True: 1.81k, False: 0]
  ------------------
  250|  1.81k|        profile_close_file(prf);
  251|  1.81k|        return retval;
  252|  1.81k|    }
  253|       |
  254|      0|    k5_mutex_lock(&g_shared_trees_mutex);
  ------------------
  |  |   44|      0|#define g_shared_trees_mutex    (krb5int_profile_shared_data.mutex)
  ------------------
  255|      0|    data->flags |= PROFILE_FILE_SHARED;
  ------------------
  |  |   78|      0|#define PROFILE_FILE_SHARED		0x0004
  ------------------
  256|      0|    data->next = g_shared_trees;
  ------------------
  |  |   43|      0|#define g_shared_trees          (krb5int_profile_shared_data.trees)
  ------------------
  257|      0|    g_shared_trees = data;
  ------------------
  |  |   43|      0|#define g_shared_trees          (krb5int_profile_shared_data.trees)
  ------------------
  258|      0|    k5_mutex_unlock(&g_shared_trees_mutex);
  ------------------
  |  |   44|      0|#define g_shared_trees_mutex    (krb5int_profile_shared_data.mutex)
  ------------------
  259|       |
  260|      0|    *ret_prof = prf;
  261|      0|    return 0;
  262|  1.81k|}
profile_update_file_data_locked:
  296|  1.81k|{
  297|  1.81k|    errcode_t retval;
  298|  1.81k|#ifdef HAVE_STAT
  299|  1.81k|    struct stat st;
  300|  1.81k|    unsigned long frac;
  301|  1.81k|    time_t now;
  302|  1.81k|#endif
  303|  1.81k|    FILE *f;
  304|  1.81k|    int isdir = 0;
  305|       |
  306|       |    /* Don't reload if the backing file isn't a regular file. */
  307|  1.81k|    if ((data->flags & PROFILE_FILE_NO_RELOAD) && data->root != NULL)
  ------------------
  |  |   76|  1.81k|#define PROFILE_FILE_NO_RELOAD		0x0001
  ------------------
  |  Branch (307:9): [True: 0, False: 1.81k]
  |  Branch (307:51): [True: 0, False: 0]
  ------------------
  308|      0|        return 0;
  309|       |    /* Don't reload a modified data object, as the modifications may be
  310|       |     * important for this object's use. */
  311|  1.81k|    if (data->flags & PROFILE_FILE_DIRTY)
  ------------------
  |  |   77|  1.81k|#define PROFILE_FILE_DIRTY		0x0002
  ------------------
  |  Branch (311:9): [True: 0, False: 1.81k]
  ------------------
  312|      0|        return 0;
  313|       |
  314|  1.81k|#ifdef HAVE_STAT
  315|  1.81k|    now = time(0);
  316|  1.81k|    if (now == data->last_stat && data->root != NULL) {
  ------------------
  |  Branch (316:9): [True: 0, False: 1.81k]
  |  Branch (316:35): [True: 0, False: 0]
  ------------------
  317|      0|        return 0;
  318|      0|    }
  319|  1.81k|    if (stat(data->filespec, &st)) {
  ------------------
  |  Branch (319:9): [True: 1.81k, False: 0]
  ------------------
  320|  1.81k|        return errno;
  321|  1.81k|    }
  322|      0|    data->last_stat = now;
  323|       |#if defined HAVE_STRUCT_STAT_ST_MTIMENSEC
  324|       |    frac = st.st_mtimensec;
  325|       |#elif defined HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
  326|       |    frac = st.st_mtimespec.tv_nsec;
  327|       |#elif defined HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
  328|       |    frac = st.st_mtim.tv_nsec;
  329|       |#else
  330|       |    frac = 0;
  331|       |#endif
  332|      0|    if (st.st_mtime == data->timestamp
  ------------------
  |  Branch (332:9): [True: 0, False: 0]
  ------------------
  333|      0|        && frac == data->frac_ts
  ------------------
  |  Branch (333:12): [True: 0, False: 0]
  ------------------
  334|      0|        && data->root != NULL) {
  ------------------
  |  Branch (334:12): [True: 0, False: 0]
  ------------------
  335|      0|        return 0;
  336|      0|    }
  337|      0|    if (data->root) {
  ------------------
  |  Branch (337:9): [True: 0, False: 0]
  ------------------
  338|      0|        profile_free_node(data->root);
  339|      0|        data->root = 0;
  340|      0|    }
  341|       |
  342|       |    /* Only try to reload regular files, not devices such as pipes. */
  343|      0|    if ((st.st_mode & S_IFMT) != S_IFREG)
  ------------------
  |  Branch (343:9): [True: 0, False: 0]
  ------------------
  344|      0|        data->flags |= PROFILE_FILE_NO_RELOAD;
  ------------------
  |  |   76|      0|#define PROFILE_FILE_NO_RELOAD		0x0001
  ------------------
  345|       |#else
  346|       |    /*
  347|       |     * If we don't have the stat() call, assume that our in-core
  348|       |     * memory image is correct.  That is, we won't reread the
  349|       |     * profile file if it changes.
  350|       |     */
  351|       |    if (data->root) {
  352|       |        return 0;
  353|       |    }
  354|       |#endif
  355|       |
  356|      0|#ifdef HAVE_STAT
  357|      0|    isdir = S_ISDIR(st.st_mode);
  358|      0|#endif
  359|      0|    if (!isdir) {
  ------------------
  |  Branch (359:9): [True: 0, False: 0]
  ------------------
  360|      0|        errno = 0;
  361|      0|        f = fopen(data->filespec, "r");
  362|      0|        if (f == NULL)
  ------------------
  |  Branch (362:13): [True: 0, False: 0]
  ------------------
  363|      0|            return (errno != 0) ? errno : ENOENT;
  ------------------
  |  Branch (363:20): [True: 0, False: 0]
  ------------------
  364|      0|        set_cloexec_file(f);
  ------------------
  |  |  842|      0|#define set_cloexec_file(F)     set_cloexec_fd(fileno(F))
  |  |  ------------------
  |  |  |  |  835|      0|#  define set_cloexec_fd(FD)    ((void)fcntl((FD), F_SETFD, FD_CLOEXEC))
  |  |  ------------------
  ------------------
  365|      0|    }
  366|       |
  367|      0|    data->upd_serial++;
  368|       |
  369|      0|    if (isdir) {
  ------------------
  |  Branch (369:9): [True: 0, False: 0]
  ------------------
  370|      0|        retval = profile_process_directory(data->filespec, &data->root);
  371|      0|    } else {
  372|      0|        retval = profile_parse_file(f, &data->root, ret_modspec);
  373|      0|        (void)fclose(f);
  374|      0|    }
  375|      0|    if (retval) {
  ------------------
  |  Branch (375:9): [True: 0, False: 0]
  ------------------
  376|      0|        return retval;
  377|      0|    }
  378|      0|    assert(data->root != NULL);
  ------------------
  |  Branch (378:5): [True: 0, False: 0]
  |  Branch (378:5): [True: 0, False: 0]
  ------------------
  379|      0|#ifdef HAVE_STAT
  380|      0|    data->timestamp = st.st_mtime;
  381|      0|    data->frac_ts = frac;
  382|      0|#endif
  383|      0|    return 0;
  384|      0|}
profile_update_file_data:
  387|  1.81k|{
  388|  1.81k|    errcode_t retval;
  389|       |
  390|  1.81k|    k5_mutex_lock(&data->lock);
  391|  1.81k|    retval = profile_update_file_data_locked(data, ret_modspec);
  392|  1.81k|    k5_mutex_unlock(&data->lock);
  393|  1.81k|    return retval;
  394|  1.81k|}
profile_flush_file_data:
  499|  1.81k|{
  500|  1.81k|    errcode_t       retval = 0;
  501|       |
  502|  1.81k|    if (!data || data->magic != PROF_MAGIC_FILE_DATA)
  ------------------
  |  |  336|  1.81k|#define PROF_MAGIC_FILE_DATA                     (-1429577698L)
  ------------------
  |  Branch (502:9): [True: 0, False: 1.81k]
  |  Branch (502:18): [True: 0, False: 1.81k]
  ------------------
  503|      0|        return PROF_MAGIC_FILE_DATA;
  ------------------
  |  |  336|      0|#define PROF_MAGIC_FILE_DATA                     (-1429577698L)
  ------------------
  504|       |
  505|       |    /* Do nothing if this data object has no backing file. */
  506|  1.81k|    if (*data->filespec == '\0')
  ------------------
  |  Branch (506:9): [True: 0, False: 1.81k]
  ------------------
  507|      0|        return 0;
  508|       |
  509|  1.81k|    k5_mutex_lock(&data->lock);
  510|       |
  511|  1.81k|    if ((data->flags & PROFILE_FILE_DIRTY) == 0) {
  ------------------
  |  |   77|  1.81k|#define PROFILE_FILE_DIRTY		0x0002
  ------------------
  |  Branch (511:9): [True: 1.81k, False: 0]
  ------------------
  512|  1.81k|        k5_mutex_unlock(&data->lock);
  513|  1.81k|        return 0;
  514|  1.81k|    }
  515|       |
  516|      0|    retval = write_data_to_file(data, data->filespec, 0);
  517|      0|    data->flags &= ~PROFILE_FILE_DIRTY;
  ------------------
  |  |   77|      0|#define PROFILE_FILE_DIRTY		0x0002
  ------------------
  518|      0|    k5_mutex_unlock(&data->lock);
  519|      0|    return retval;
  520|  1.81k|}
profile_dereference_data:
  538|  1.81k|{
  539|  1.81k|    k5_mutex_lock(&g_shared_trees_mutex);
  ------------------
  |  |   44|  1.81k|#define g_shared_trees_mutex    (krb5int_profile_shared_data.mutex)
  ------------------
  540|  1.81k|    profile_dereference_data_locked(data);
  541|  1.81k|    k5_mutex_unlock(&g_shared_trees_mutex);
  ------------------
  |  |   44|  1.81k|#define g_shared_trees_mutex    (krb5int_profile_shared_data.mutex)
  ------------------
  542|  1.81k|}
profile_dereference_data_locked:
  544|  1.81k|{
  545|  1.81k|    data->refcount--;
  546|  1.81k|    if (data->refcount == 0)
  ------------------
  |  Branch (546:9): [True: 1.81k, False: 0]
  ------------------
  547|  1.81k|        profile_free_file_data(data);
  548|  1.81k|}
profile_free_file:
  598|  1.81k|{
  599|  1.81k|    profile_dereference_data(prf->data);
  600|  1.81k|    free(prf);
  601|  1.81k|}
profile_close_file:
  632|  1.81k|{
  633|  1.81k|    errcode_t       retval;
  634|       |
  635|  1.81k|    retval = profile_flush_file(prf);
  ------------------
  |  |  227|  1.81k|#define profile_flush_file(P) (((P) && (P)->magic == PROF_MAGIC_FILE) ? profile_flush_file_data((P)->data) : PROF_MAGIC_FILE)
  |  |  ------------------
  |  |  |  |  331|  1.81k|#define PROF_MAGIC_FILE                          (-1429577703L)
  |  |  ------------------
  |  |               #define profile_flush_file(P) (((P) && (P)->magic == PROF_MAGIC_FILE) ? profile_flush_file_data((P)->data) : PROF_MAGIC_FILE)
  |  |  ------------------
  |  |  |  |  331|      0|#define PROF_MAGIC_FILE                          (-1429577703L)
  |  |  ------------------
  |  |  |  Branch (227:33): [True: 1.81k, False: 0]
  |  |  |  Branch (227:40): [True: 1.81k, False: 0]
  |  |  ------------------
  ------------------
  636|  1.81k|    if (retval)
  ------------------
  |  Branch (636:9): [True: 0, False: 1.81k]
  ------------------
  637|      0|        return retval;
  638|  1.81k|    profile_free_file(prf);
  639|  1.81k|    return 0;
  640|  1.81k|}
prof_file.c:profile_library_initializer:
   55|      1|{
   56|       |#ifdef SHOW_INITFINI_FUNCS
   57|       |    printf("profile_library_initializer\n");
   58|       |#endif
   59|      1|    add_error_table(&et_prof_error_table);
   60|       |
   61|      1|    return k5_mutex_finish_init(&g_shared_trees_mutex);
  ------------------
  |  |   44|      1|#define g_shared_trees_mutex    (krb5int_profile_shared_data.mutex)
  ------------------
   62|      1|}
prof_file.c:profile_free_file_data:
  605|  1.81k|{
  606|  1.81k|    if (data->flags & PROFILE_FILE_SHARED) {
  ------------------
  |  |   78|  1.81k|#define PROFILE_FILE_SHARED		0x0004
  ------------------
  |  Branch (606:9): [True: 0, False: 1.81k]
  ------------------
  607|       |        /* Remove from linked list.  */
  608|      0|        if (g_shared_trees == data)
  ------------------
  |  |   43|      0|#define g_shared_trees          (krb5int_profile_shared_data.trees)
  ------------------
  |  Branch (608:13): [True: 0, False: 0]
  ------------------
  609|      0|            g_shared_trees = data->next;
  ------------------
  |  |   43|      0|#define g_shared_trees          (krb5int_profile_shared_data.trees)
  ------------------
  610|      0|        else {
  611|      0|            prf_data_t prev, next;
  612|      0|            prev = g_shared_trees;
  ------------------
  |  |   43|      0|#define g_shared_trees          (krb5int_profile_shared_data.trees)
  ------------------
  613|      0|            next = prev->next;
  614|      0|            while (next) {
  ------------------
  |  Branch (614:20): [True: 0, False: 0]
  ------------------
  615|      0|                if (next == data) {
  ------------------
  |  Branch (615:21): [True: 0, False: 0]
  ------------------
  616|      0|                    prev->next = next->next;
  617|      0|                    break;
  618|      0|                }
  619|      0|                prev = next;
  620|      0|                next = next->next;
  621|      0|            }
  622|      0|        }
  623|      0|    }
  624|  1.81k|    if (data->root)
  ------------------
  |  Branch (624:9): [True: 0, False: 1.81k]
  ------------------
  625|      0|        profile_free_node(data->root);
  626|  1.81k|    data->magic = 0;
  627|  1.81k|    k5_mutex_destroy(&data->lock);
  ------------------
  |  |  365|  1.81k|    (k5_os_mutex_destroy(M))
  ------------------
  628|  1.81k|    free(data);
  629|  1.81k|}

profile_free_list:
  120|  2.28k|{
  121|  2.28k|    char        **cp;
  122|       |
  123|  2.28k|    if (list == 0)
  ------------------
  |  Branch (123:9): [True: 2.28k, False: 0]
  ------------------
  124|  2.28k|        return;
  125|       |
  126|      0|    for (cp = list; *cp; cp++)
  ------------------
  |  Branch (126:21): [True: 0, False: 0]
  ------------------
  127|      0|        free(*cp);
  128|      0|    free(list);
  129|      0|}
profile_get_values:
  158|  2.28k|{
  159|  2.28k|    errcode_t               retval;
  160|  2.28k|    void                    *state = NULL;
  161|  2.28k|    char                    *value;
  162|  2.28k|    struct profile_string_list values;
  163|       |
  164|  2.28k|    *ret_values = NULL;
  165|  2.28k|    if (!profile)
  ------------------
  |  Branch (165:9): [True: 0, False: 2.28k]
  ------------------
  166|      0|        return PROF_NO_PROFILE;
  ------------------
  |  |  330|      0|#define PROF_NO_PROFILE                          (-1429577704L)
  ------------------
  167|  2.28k|    if (profile->vt)
  ------------------
  |  Branch (167:9): [True: 0, False: 2.28k]
  ------------------
  168|      0|        return get_values_vt(profile, names, ret_values);
  169|       |
  170|  2.28k|    if ((retval = profile_node_iterator_create(profile, names,
  ------------------
  |  Branch (170:9): [True: 0, False: 2.28k]
  ------------------
  171|  2.28k|                                               PROFILE_ITER_RELATIONS_ONLY,
  ------------------
  |  |  108|  2.28k|#define PROFILE_ITER_RELATIONS_ONLY	0x0004
  ------------------
  172|  2.28k|                                               &state)))
  173|      0|        return retval;
  174|       |
  175|  2.28k|    retval = init_list(&values);
  176|  2.28k|    if (retval)
  ------------------
  |  Branch (176:9): [True: 0, False: 2.28k]
  ------------------
  177|      0|        goto cleanup;
  178|       |
  179|  2.28k|    do {
  180|  2.28k|        if ((retval = profile_node_iterator(&state, 0, 0, &value)))
  ------------------
  |  Branch (180:13): [True: 0, False: 2.28k]
  ------------------
  181|      0|            goto cleanup;
  182|  2.28k|        if (value)
  ------------------
  |  Branch (182:13): [True: 0, False: 2.28k]
  ------------------
  183|      0|            add_to_list(&values, value);
  184|  2.28k|    } while (state);
  ------------------
  |  Branch (184:14): [True: 0, False: 2.28k]
  ------------------
  185|       |
  186|  2.28k|    if (values.num == 0) {
  ------------------
  |  Branch (186:9): [True: 2.28k, False: 0]
  ------------------
  187|  2.28k|        retval = PROF_NO_RELATION;
  ------------------
  |  |  309|  2.28k|#define PROF_NO_RELATION                         (-1429577725L)
  ------------------
  188|  2.28k|        goto cleanup;
  189|  2.28k|    }
  190|       |
  191|  2.28k|cleanup:
  192|  2.28k|    end_list(&values, retval ? NULL : ret_values);
  ------------------
  |  Branch (192:23): [True: 2.28k, False: 0]
  ------------------
  193|  2.28k|    profile_node_iterator_free(&state);
  194|  2.28k|    return retval;
  195|  2.28k|}
profile_get_value:
  221|  14.0k|{
  222|  14.0k|    errcode_t               retval;
  223|  14.0k|    void                    *state;
  224|  14.0k|    char                    *value;
  225|       |
  226|  14.0k|    *ret_value = NULL;
  227|  14.0k|    if (!profile)
  ------------------
  |  Branch (227:9): [True: 0, False: 14.0k]
  ------------------
  228|      0|        return PROF_NO_PROFILE;
  ------------------
  |  |  330|      0|#define PROF_NO_PROFILE                          (-1429577704L)
  ------------------
  229|  14.0k|    if (profile->vt)
  ------------------
  |  Branch (229:9): [True: 0, False: 14.0k]
  ------------------
  230|      0|        return get_value_vt(profile, names, ret_value);
  231|       |
  232|  14.0k|    retval = profile_iterator_create(profile, names,
  233|  14.0k|                                     PROFILE_ITER_RELATIONS_ONLY, &state);
  ------------------
  |  |  108|  14.0k|#define PROFILE_ITER_RELATIONS_ONLY	0x0004
  ------------------
  234|  14.0k|    if (retval)
  ------------------
  |  Branch (234:9): [True: 0, False: 14.0k]
  ------------------
  235|      0|        return retval;
  236|       |
  237|  14.0k|    retval = profile_iterator(&state, NULL, &value);
  238|  14.0k|    if (retval)
  ------------------
  |  Branch (238:9): [True: 0, False: 14.0k]
  ------------------
  239|      0|        goto cleanup;
  240|       |
  241|  14.0k|    if (value)
  ------------------
  |  Branch (241:9): [True: 0, False: 14.0k]
  ------------------
  242|      0|        *ret_value = value;
  243|  14.0k|    else
  244|  14.0k|        retval = PROF_NO_RELATION;
  ------------------
  |  |  309|  14.0k|#define PROF_NO_RELATION                         (-1429577725L)
  ------------------
  245|       |
  246|  14.0k|cleanup:
  247|  14.0k|    profile_iterator_free(&state);
  248|  14.0k|    return retval;
  249|  14.0k|}
profile_get_string:
  255|  5.00k|{
  256|  5.00k|    char            *value;
  257|  5.00k|    errcode_t       retval;
  258|  5.00k|    const char      *names[4];
  259|       |
  260|  5.00k|    if (profile) {
  ------------------
  |  Branch (260:9): [True: 5.00k, False: 0]
  ------------------
  261|  5.00k|        names[0] = name;
  262|  5.00k|        names[1] = subname;
  263|  5.00k|        names[2] = subsubname;
  264|  5.00k|        names[3] = 0;
  265|  5.00k|        retval = profile_get_value(profile, names, &value);
  266|  5.00k|        if (retval == 0) {
  ------------------
  |  Branch (266:13): [True: 0, False: 5.00k]
  ------------------
  267|      0|            *ret_string = value;
  268|      0|            return 0;
  269|  5.00k|        } else if (retval != PROF_NO_SECTION && retval != PROF_NO_RELATION)
  ------------------
  |  |  308|  10.0k|#define PROF_NO_SECTION                          (-1429577726L)
  ------------------
                      } else if (retval != PROF_NO_SECTION && retval != PROF_NO_RELATION)
  ------------------
  |  |  309|  5.00k|#define PROF_NO_RELATION                         (-1429577725L)
  ------------------
  |  Branch (269:20): [True: 5.00k, False: 0]
  |  Branch (269:49): [True: 0, False: 5.00k]
  ------------------
  270|      0|            return retval;
  271|  5.00k|    }
  272|       |
  273|  5.00k|    if (def_val) {
  ------------------
  |  Branch (273:9): [True: 906, False: 4.09k]
  ------------------
  274|    906|        *ret_string = strdup(def_val);
  275|    906|        if (*ret_string == NULL)
  ------------------
  |  Branch (275:13): [True: 0, False: 906]
  ------------------
  276|      0|            return ENOMEM;
  277|    906|    } else
  278|  4.09k|        *ret_string = NULL;
  279|  5.00k|    return 0;
  280|  5.00k|}
profile_get_integer:
  311|  3.62k|{
  312|  3.62k|    char            *value;
  313|  3.62k|    errcode_t       retval;
  314|  3.62k|    const char      *names[4];
  315|       |
  316|  3.62k|    *ret_int = def_val;
  317|  3.62k|    if (profile == 0)
  ------------------
  |  Branch (317:9): [True: 0, False: 3.62k]
  ------------------
  318|      0|        return 0;
  319|       |
  320|  3.62k|    names[0] = name;
  321|  3.62k|    names[1] = subname;
  322|  3.62k|    names[2] = subsubname;
  323|  3.62k|    names[3] = 0;
  324|  3.62k|    retval = profile_get_value(profile, names, &value);
  325|  3.62k|    if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) {
  ------------------
  |  |  308|  7.24k|#define PROF_NO_SECTION                          (-1429577726L)
  ------------------
                  if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) {
  ------------------
  |  |  309|  3.62k|#define PROF_NO_RELATION                         (-1429577725L)
  ------------------
  |  Branch (325:9): [True: 0, False: 3.62k]
  |  Branch (325:38): [True: 3.62k, False: 0]
  ------------------
  326|  3.62k|        *ret_int = def_val;
  327|  3.62k|        return 0;
  328|  3.62k|    } else if (retval)
  ------------------
  |  Branch (328:16): [True: 0, False: 0]
  ------------------
  329|      0|        return retval;
  330|       |
  331|      0|    retval = parse_int(value, ret_int);
  332|      0|    free(value);
  333|      0|    return retval;
  334|  3.62k|}
profile_get_boolean:
  374|  5.43k|{
  375|  5.43k|    char            *value;
  376|  5.43k|    errcode_t       retval;
  377|  5.43k|    const char      *names[4];
  378|       |
  379|  5.43k|    if (profile == 0) {
  ------------------
  |  Branch (379:9): [True: 0, False: 5.43k]
  ------------------
  380|      0|        *ret_boolean = def_val;
  381|      0|        return 0;
  382|      0|    }
  383|       |
  384|  5.43k|    names[0] = name;
  385|  5.43k|    names[1] = subname;
  386|  5.43k|    names[2] = subsubname;
  387|  5.43k|    names[3] = 0;
  388|  5.43k|    retval = profile_get_value(profile, names, &value);
  389|  5.43k|    if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) {
  ------------------
  |  |  308|  10.8k|#define PROF_NO_SECTION                          (-1429577726L)
  ------------------
                  if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) {
  ------------------
  |  |  309|  5.43k|#define PROF_NO_RELATION                         (-1429577725L)
  ------------------
  |  Branch (389:9): [True: 0, False: 5.43k]
  |  Branch (389:38): [True: 5.43k, False: 0]
  ------------------
  390|  5.43k|        *ret_boolean = def_val;
  391|  5.43k|        return 0;
  392|  5.43k|    } else if (retval)
  ------------------
  |  Branch (392:16): [True: 0, False: 0]
  ------------------
  393|      0|        return retval;
  394|       |
  395|      0|    retval = profile_parse_boolean(value, ret_boolean);
  396|      0|    free(value);
  397|      0|    return retval;
  398|  5.43k|}
profile_iterator_create:
  485|  14.0k|{
  486|  14.0k|    struct profile_iterator *iter;
  487|  14.0k|    errcode_t retval;
  488|       |
  489|  14.0k|    *ret_iter = NULL;
  490|  14.0k|    if (!profile)
  ------------------
  |  Branch (490:9): [True: 0, False: 14.0k]
  ------------------
  491|      0|        return PROF_NO_PROFILE;
  ------------------
  |  |  330|      0|#define PROF_NO_PROFILE                          (-1429577704L)
  ------------------
  492|       |
  493|  14.0k|    iter = malloc(sizeof(*iter));
  494|  14.0k|    if (iter == NULL)
  ------------------
  |  Branch (494:9): [True: 0, False: 14.0k]
  ------------------
  495|      0|        return ENOMEM;
  496|  14.0k|    iter->magic = PROF_MAGIC_ITERATOR;
  ------------------
  |  |  315|  14.0k|#define PROF_MAGIC_ITERATOR                      (-1429577719L)
  ------------------
  497|  14.0k|    iter->profile = profile;
  498|       |
  499|       |    /* Create the underlying iterator representation using the vtable or the
  500|       |     * built-in node iterator. */
  501|  14.0k|    if (profile->vt) {
  ------------------
  |  Branch (501:9): [True: 0, False: 14.0k]
  ------------------
  502|      0|        if (!profile->vt->iterator_create)
  ------------------
  |  Branch (502:13): [True: 0, False: 0]
  ------------------
  503|      0|            retval = PROF_UNSUPPORTED;
  ------------------
  |  |  339|      0|#define PROF_UNSUPPORTED                         (-1429577695L)
  ------------------
  504|      0|        else
  505|      0|            retval = profile->vt->iterator_create(profile->cbdata, names,
  506|      0|                                                  flags, &iter->idata);
  507|  14.0k|    } else {
  508|  14.0k|        retval = profile_node_iterator_create(profile, names, flags,
  509|  14.0k|                                              &iter->idata);
  510|  14.0k|    }
  511|  14.0k|    if (retval) {
  ------------------
  |  Branch (511:9): [True: 0, False: 14.0k]
  ------------------
  512|      0|        free(iter);
  513|      0|        return retval;
  514|      0|    }
  515|       |
  516|  14.0k|    *ret_iter = iter;
  517|  14.0k|    return 0;
  518|  14.0k|}
profile_iterator_free:
  522|  14.0k|{
  523|  14.0k|    struct profile_iterator *iter;
  524|  14.0k|    profile_t profile;
  525|       |
  526|  14.0k|    if (!iter_p)
  ------------------
  |  Branch (526:9): [True: 0, False: 14.0k]
  ------------------
  527|      0|        return;
  528|  14.0k|    iter = *iter_p;
  529|  14.0k|    if (!iter || iter->magic != PROF_MAGIC_ITERATOR)
  ------------------
  |  |  315|      0|#define PROF_MAGIC_ITERATOR                      (-1429577719L)
  ------------------
  |  Branch (529:9): [True: 14.0k, False: 0]
  |  Branch (529:18): [True: 0, False: 0]
  ------------------
  530|  14.0k|        return;
  531|      0|    profile = iter->profile;
  532|      0|    if (profile->vt)
  ------------------
  |  Branch (532:9): [True: 0, False: 0]
  ------------------
  533|      0|        profile->vt->iterator_free(profile->cbdata, iter->idata);
  534|      0|    else
  535|      0|        profile_node_iterator_free(&iter->idata);
  536|      0|    free(iter);
  537|       |    *iter_p = NULL;
  538|      0|}
profile_iterator:
  571|  14.0k|{
  572|  14.0k|    char *name, *value;
  573|  14.0k|    errcode_t       retval;
  574|  14.0k|    struct profile_iterator *iter = *iter_p;
  575|  14.0k|    profile_t profile;
  576|       |
  577|  14.0k|    if (ret_name)
  ------------------
  |  Branch (577:9): [True: 0, False: 14.0k]
  ------------------
  578|      0|        *ret_name = NULL;
  579|  14.0k|    if (ret_value)
  ------------------
  |  Branch (579:9): [True: 14.0k, False: 0]
  ------------------
  580|  14.0k|        *ret_value = NULL;
  581|  14.0k|    if (iter == NULL || iter->magic != PROF_MAGIC_ITERATOR)
  ------------------
  |  |  315|  14.0k|#define PROF_MAGIC_ITERATOR                      (-1429577719L)
  ------------------
  |  Branch (581:9): [True: 0, False: 14.0k]
  |  Branch (581:25): [True: 0, False: 14.0k]
  ------------------
  582|      0|        return PROF_MAGIC_ITERATOR;
  ------------------
  |  |  315|      0|#define PROF_MAGIC_ITERATOR                      (-1429577719L)
  ------------------
  583|  14.0k|    profile = iter->profile;
  584|       |
  585|  14.0k|    if (profile->vt) {
  ------------------
  |  Branch (585:9): [True: 0, False: 14.0k]
  ------------------
  586|      0|        retval = profile->vt->iterator(profile->cbdata, iter->idata, &name,
  587|      0|                                       &value);
  588|      0|        if (retval)
  ------------------
  |  Branch (588:13): [True: 0, False: 0]
  ------------------
  589|      0|            return retval;
  590|      0|        if (name == NULL) {
  ------------------
  |  Branch (590:13): [True: 0, False: 0]
  ------------------
  591|      0|            profile->vt->iterator_free(profile->cbdata, iter->idata);
  592|      0|            free(iter);
  593|      0|            *iter_p = NULL;
  594|      0|        }
  595|      0|        retval = set_results(name, value, ret_name, ret_value);
  596|      0|        if (name)
  ------------------
  |  Branch (596:13): [True: 0, False: 0]
  ------------------
  597|      0|            profile->vt->free_string(profile->cbdata, name);
  598|      0|        if (value)
  ------------------
  |  Branch (598:13): [True: 0, False: 0]
  ------------------
  599|      0|            profile->vt->free_string(profile->cbdata, value);
  600|      0|        return retval;
  601|      0|    }
  602|       |
  603|  14.0k|    retval = profile_node_iterator(&iter->idata, 0, &name, &value);
  604|  14.0k|    if (iter->idata == NULL) {
  ------------------
  |  Branch (604:9): [True: 14.0k, False: 0]
  ------------------
  605|  14.0k|        free(iter);
  606|  14.0k|        *iter_p = NULL;
  607|  14.0k|    }
  608|  14.0k|    if (retval)
  ------------------
  |  Branch (608:9): [True: 0, False: 14.0k]
  ------------------
  609|      0|        return retval;
  610|  14.0k|    return set_results(name, value, ret_name, ret_value);
  611|  14.0k|}
profile_release_string:
  615|  1.81k|{
  616|  1.81k|    free(str);
  617|  1.81k|}
prof_get.c:init_list:
   40|  2.28k|{
   41|  2.28k|    list->num = 0;
   42|  2.28k|    list->max = 10;
   43|  2.28k|    list->list = malloc(list->max * sizeof(char *));
   44|  2.28k|    if (list->list == 0)
  ------------------
  |  Branch (44:9): [True: 0, False: 2.28k]
  ------------------
   45|      0|        return ENOMEM;
   46|  2.28k|    list->list[0] = 0;
   47|  2.28k|    return 0;
   48|  2.28k|}
prof_get.c:end_list:
   55|  2.28k|{
   56|  2.28k|    char    **cp;
   57|       |
   58|  2.28k|    if (list == 0)
  ------------------
  |  Branch (58:9): [True: 0, False: 2.28k]
  ------------------
   59|      0|        return;
   60|       |
   61|  2.28k|    if (ret_list) {
  ------------------
  |  Branch (61:9): [True: 0, False: 2.28k]
  ------------------
   62|      0|        *ret_list = list->list;
   63|      0|        return;
   64|  2.28k|    } else {
   65|  2.28k|        for (cp = list->list; cp && *cp; cp++)
  ------------------
  |  Branch (65:31): [True: 2.28k, False: 0]
  |  Branch (65:37): [True: 0, False: 2.28k]
  ------------------
   66|      0|            free(*cp);
   67|  2.28k|        free(list->list);
   68|  2.28k|    }
   69|  2.28k|    list->num = list->max = 0;
   70|  2.28k|    list->list = 0;
   71|  2.28k|}
prof_get.c:set_results:
  545|  14.0k|{
  546|  14.0k|    char *name_copy = NULL, *value_copy = NULL;
  547|       |
  548|  14.0k|    if (ret_name && name) {
  ------------------
  |  Branch (548:9): [True: 0, False: 14.0k]
  |  Branch (548:21): [True: 0, False: 0]
  ------------------
  549|      0|        name_copy = strdup(name);
  550|      0|        if (name_copy == NULL)
  ------------------
  |  Branch (550:13): [True: 0, False: 0]
  ------------------
  551|      0|            goto oom;
  552|      0|    }
  553|  14.0k|    if (ret_value && value) {
  ------------------
  |  Branch (553:9): [True: 14.0k, False: 0]
  |  Branch (553:22): [True: 0, False: 14.0k]
  ------------------
  554|      0|        value_copy = strdup(value);
  555|      0|        if (value_copy == NULL)
  ------------------
  |  Branch (555:13): [True: 0, False: 0]
  ------------------
  556|      0|            goto oom;
  557|      0|    }
  558|  14.0k|    if (ret_name)
  ------------------
  |  Branch (558:9): [True: 0, False: 14.0k]
  ------------------
  559|      0|        *ret_name = name_copy;
  560|  14.0k|    if (ret_value)
  ------------------
  |  Branch (560:9): [True: 14.0k, False: 0]
  ------------------
  561|  14.0k|        *ret_value = value_copy;
  562|  14.0k|    return 0;
  563|      0|oom:
  564|      0|    free(name_copy);
  565|      0|    free(value_copy);
  566|       |    return ENOMEM;
  567|  14.0k|}

profile_init_flags:
  167|  1.81k|{
  168|  1.81k|    const_profile_filespec_t *fs;
  169|  1.81k|    profile_t profile;
  170|  1.81k|    prf_file_t  new_file, last = 0;
  171|  1.81k|    errcode_t retval = 0, access_retval = 0;
  172|  1.81k|    char *modspec = NULL, **modspec_arg;
  173|       |
  174|  1.81k|    profile = malloc(sizeof(struct _profile_t));
  175|  1.81k|    if (!profile)
  ------------------
  |  Branch (175:9): [True: 0, False: 1.81k]
  ------------------
  176|      0|        return ENOMEM;
  177|  1.81k|    memset(profile, 0, sizeof(struct _profile_t));
  178|  1.81k|    profile->magic = PROF_MAGIC_PROFILE;
  ------------------
  |  |  324|  1.81k|#define PROF_MAGIC_PROFILE                       (-1429577710L)
  ------------------
  179|       |
  180|       |    /*
  181|       |     * If the filenames list is not specified or empty, return an empty
  182|       |     * profile.
  183|       |     */
  184|  1.81k|    if ( files && !PROFILE_LAST_FILESPEC(*files) ) {
  ------------------
  |  |  116|    906|#define	PROFILE_LAST_FILESPEC(x) (((x) == NULL) || ((x)[0] == '\0'))
  |  |  ------------------
  |  |  |  Branch (116:35): [True: 0, False: 906]
  |  |  |  Branch (116:52): [True: 0, False: 906]
  |  |  ------------------
  ------------------
  |  Branch (184:10): [True: 906, False: 906]
  ------------------
  185|  2.71k|        for (fs = files; !PROFILE_LAST_FILESPEC(*fs); fs++) {
  ------------------
  |  |  116|  2.71k|#define	PROFILE_LAST_FILESPEC(x) (((x) == NULL) || ((x)[0] == '\0'))
  |  |  ------------------
  |  |  |  Branch (116:35): [True: 906, False: 1.81k]
  |  |  |  Branch (116:52): [True: 0, False: 1.81k]
  |  |  ------------------
  ------------------
  186|       |            /* Allow a module declaration if it is permitted by flags and this
  187|       |             * is the first file parsed. */
  188|  1.81k|            modspec_arg = ((flags & PROFILE_INIT_ALLOW_MODULE) && !last) ?
  ------------------
  |  |   27|  1.81k|#define PROFILE_INIT_ALLOW_MODULE       0x0001  /* Allow module declaration */
  ------------------
  |  Branch (188:28): [True: 1.81k, False: 0]
  |  Branch (188:67): [True: 1.81k, False: 0]
  ------------------
  189|  1.81k|                &modspec : NULL;
  190|  1.81k|            retval = profile_open_file(*fs, &new_file, modspec_arg);
  191|  1.81k|            if (retval == PROF_MODULE && modspec) {
  ------------------
  |  |  341|  3.62k|#define PROF_MODULE                              (-1429577693L)
  ------------------
  |  Branch (191:17): [True: 0, False: 1.81k]
  |  Branch (191:42): [True: 0, False: 0]
  ------------------
  192|       |                /* Stop parsing files and load a dynamic module instead. */
  193|      0|                free(profile);
  194|      0|                retval = init_load_module(modspec, ret_profile);
  195|      0|                free(modspec);
  196|      0|                return retval;
  197|      0|            }
  198|       |            /* if this file is missing, skip to the next */
  199|  1.81k|            if (retval == ENOENT) {
  ------------------
  |  Branch (199:17): [True: 1.81k, False: 0]
  ------------------
  200|  1.81k|                continue;
  201|  1.81k|            }
  202|       |            /* If we can't read this file, remember it but keep going. */
  203|      0|            if (retval == EACCES || retval == EPERM) {
  ------------------
  |  Branch (203:17): [True: 0, False: 0]
  |  Branch (203:37): [True: 0, False: 0]
  ------------------
  204|      0|                access_retval = retval;
  205|      0|                continue;
  206|      0|            }
  207|      0|            if (retval) {
  ------------------
  |  Branch (207:17): [True: 0, False: 0]
  ------------------
  208|      0|                profile_release(profile);
  209|      0|                return retval;
  210|      0|            }
  211|      0|            if (last)
  ------------------
  |  Branch (211:17): [True: 0, False: 0]
  ------------------
  212|      0|                last->next = new_file;
  213|      0|            else
  214|      0|                profile->first_file = new_file;
  215|      0|            last = new_file;
  216|      0|        }
  217|       |        /*
  218|       |         * If last is still null after the loop, then all the files were
  219|       |         * missing or unreadable, so return the appropriate error.
  220|       |         */
  221|    906|        if (!last) {
  ------------------
  |  Branch (221:13): [True: 906, False: 0]
  ------------------
  222|    906|            profile_release(profile);
  223|    906|            return access_retval ? access_retval : ENOENT;
  ------------------
  |  Branch (223:20): [True: 0, False: 906]
  ------------------
  224|    906|        }
  225|    906|    }
  226|       |
  227|    906|    *ret_profile = profile;
  228|    906|    return 0;
  229|  1.81k|}
profile_init:
  233|    906|{
  234|    906|    return profile_init_flags(files, 0, ret_profile);
  235|    906|}
profile_abandon:
  474|    906|{
  475|    906|    prf_file_t      p, next;
  476|       |
  477|    906|    if (!profile || profile->magic != PROF_MAGIC_PROFILE)
  ------------------
  |  |  324|    906|#define PROF_MAGIC_PROFILE                       (-1429577710L)
  ------------------
  |  Branch (477:9): [True: 0, False: 906]
  |  Branch (477:21): [True: 0, False: 906]
  ------------------
  478|      0|        return;
  479|       |
  480|    906|    if (profile->vt) {
  ------------------
  |  Branch (480:9): [True: 0, False: 906]
  ------------------
  481|      0|        if (profile->vt->cleanup)
  ------------------
  |  Branch (481:13): [True: 0, False: 0]
  ------------------
  482|      0|            profile->vt->cleanup(profile->cbdata);
  483|      0|        if (profile->lib_handle) {
  ------------------
  |  Branch (483:13): [True: 0, False: 0]
  ------------------
  484|       |            /* Decrement the refcount on the handle and maybe free it. */
  485|      0|            k5_mutex_lock(&profile->lib_handle->lock);
  486|      0|            if (--profile->lib_handle->refcount == 0) {
  ------------------
  |  Branch (486:17): [True: 0, False: 0]
  ------------------
  487|      0|                krb5int_close_plugin(profile->lib_handle->plugin_handle);
  488|      0|                k5_mutex_unlock(&profile->lib_handle->lock);
  489|      0|                k5_mutex_destroy(&profile->lib_handle->lock);
  ------------------
  |  |  365|      0|    (k5_os_mutex_destroy(M))
  ------------------
  490|      0|                free(profile->lib_handle);
  491|      0|            } else
  492|      0|                k5_mutex_unlock(&profile->lib_handle->lock);
  493|      0|        }
  494|      0|        free(profile->vt);
  495|    906|    } else {
  496|    906|        for (p = profile->first_file; p; p = next) {
  ------------------
  |  Branch (496:39): [True: 0, False: 906]
  ------------------
  497|      0|            next = p->next;
  498|      0|            profile_free_file(p);
  499|      0|        }
  500|    906|    }
  501|    906|    profile->magic = 0;
  502|    906|    free(profile);
  503|    906|}
profile_release:
  507|    906|{
  508|    906|    prf_file_t      p, next;
  509|       |
  510|    906|    if (!profile || profile->magic != PROF_MAGIC_PROFILE)
  ------------------
  |  |  324|    906|#define PROF_MAGIC_PROFILE                       (-1429577710L)
  ------------------
  |  Branch (510:9): [True: 0, False: 906]
  |  Branch (510:21): [True: 0, False: 906]
  ------------------
  511|      0|        return;
  512|       |
  513|    906|    if (profile->vt) {
  ------------------
  |  Branch (513:9): [True: 0, False: 906]
  ------------------
  514|       |        /* Flush the profile and then delegate to profile_abandon. */
  515|      0|        if (profile->vt->flush)
  ------------------
  |  Branch (515:13): [True: 0, False: 0]
  ------------------
  516|      0|            profile->vt->flush(profile->cbdata);
  517|      0|        profile_abandon(profile);
  518|      0|        return;
  519|    906|    } else {
  520|    906|        for (p = profile->first_file; p; p = next) {
  ------------------
  |  Branch (520:39): [True: 0, False: 906]
  ------------------
  521|      0|            next = p->next;
  522|      0|            profile_close_file(p);
  523|      0|        }
  524|    906|    }
  525|    906|    profile->magic = 0;
  526|    906|    free(profile);
  527|    906|}

profile_node_iterator_create:
  466|  16.3k|{
  467|  16.3k|    struct profile_node_iterator *iter;
  468|  16.3k|    int     done_idx = 0;
  469|       |
  470|  16.3k|    if (profile == 0)
  ------------------
  |  Branch (470:9): [True: 0, False: 16.3k]
  ------------------
  471|      0|        return PROF_NO_PROFILE;
  ------------------
  |  |  330|      0|#define PROF_NO_PROFILE                          (-1429577704L)
  ------------------
  472|  16.3k|    if (profile->magic != PROF_MAGIC_PROFILE)
  ------------------
  |  |  324|  16.3k|#define PROF_MAGIC_PROFILE                       (-1429577710L)
  ------------------
  |  Branch (472:9): [True: 0, False: 16.3k]
  ------------------
  473|      0|        return PROF_MAGIC_PROFILE;
  ------------------
  |  |  324|      0|#define PROF_MAGIC_PROFILE                       (-1429577710L)
  ------------------
  474|  16.3k|    if (!names)
  ------------------
  |  Branch (474:9): [True: 0, False: 16.3k]
  ------------------
  475|      0|        return PROF_BAD_NAMESET;
  ------------------
  |  |  329|      0|#define PROF_BAD_NAMESET                         (-1429577705L)
  ------------------
  476|  16.3k|    if (!(flags & PROFILE_ITER_LIST_SECTION)) {
  ------------------
  |  |  106|  16.3k|#define PROFILE_ITER_LIST_SECTION	0x0001
  ------------------
  |  Branch (476:9): [True: 16.3k, False: 0]
  ------------------
  477|  16.3k|        if (!names[0])
  ------------------
  |  Branch (477:13): [True: 0, False: 16.3k]
  ------------------
  478|      0|            return PROF_BAD_NAMESET;
  ------------------
  |  |  329|      0|#define PROF_BAD_NAMESET                         (-1429577705L)
  ------------------
  479|  16.3k|        done_idx = 1;
  480|  16.3k|    }
  481|       |
  482|  16.3k|    iter = malloc(sizeof(*iter));
  483|  16.3k|    if (iter == NULL)
  ------------------
  |  Branch (483:9): [True: 0, False: 16.3k]
  ------------------
  484|      0|        return ENOMEM;
  485|       |
  486|  16.3k|    iter->magic = PROF_MAGIC_NODE_ITERATOR;
  ------------------
  |  |  340|  16.3k|#define PROF_MAGIC_NODE_ITERATOR                 (-1429577694L)
  ------------------
  487|  16.3k|    iter->names = names;
  488|  16.3k|    iter->flags = flags;
  489|  16.3k|    iter->file = profile->first_file;
  490|  16.3k|    iter->done_idx = done_idx;
  491|  16.3k|    iter->node = 0;
  492|  16.3k|    iter->num = 0;
  493|  16.3k|    *ret_iter = iter;
  494|  16.3k|    return 0;
  495|  16.3k|}
profile_node_iterator_free:
  498|  18.6k|{
  499|  18.6k|    struct profile_node_iterator *iter;
  500|       |
  501|  18.6k|    if (!iter_p)
  ------------------
  |  Branch (501:9): [True: 0, False: 18.6k]
  ------------------
  502|      0|        return;
  503|  18.6k|    iter = *iter_p;
  504|  18.6k|    if (!iter || iter->magic != PROF_MAGIC_NODE_ITERATOR)
  ------------------
  |  |  340|  16.3k|#define PROF_MAGIC_NODE_ITERATOR                 (-1429577694L)
  ------------------
  |  Branch (504:9): [True: 2.28k, False: 16.3k]
  |  Branch (504:18): [True: 0, False: 16.3k]
  ------------------
  505|  2.28k|        return;
  506|  16.3k|    free(iter);
  507|  16.3k|    *iter_p = 0;
  508|  16.3k|}
profile_node_iterator:
  520|  16.3k|{
  521|  16.3k|    struct profile_node_iterator    *iter = *iter_p;
  522|  16.3k|    struct profile_node             *section, *p;
  523|  16.3k|    const char                      *const *cpp;
  524|  16.3k|    errcode_t                       retval;
  525|  16.3k|    int                             skip_num = 0;
  526|       |
  527|  16.3k|    if (!iter || iter->magic != PROF_MAGIC_NODE_ITERATOR)
  ------------------
  |  |  340|  16.3k|#define PROF_MAGIC_NODE_ITERATOR                 (-1429577694L)
  ------------------
  |  Branch (527:9): [True: 0, False: 16.3k]
  |  Branch (527:18): [True: 0, False: 16.3k]
  ------------------
  528|      0|        return PROF_MAGIC_NODE_ITERATOR;
  ------------------
  |  |  340|      0|#define PROF_MAGIC_NODE_ITERATOR                 (-1429577694L)
  ------------------
  529|  16.3k|    if (iter->file && iter->file->magic != PROF_MAGIC_FILE)
  ------------------
  |  |  331|      0|#define PROF_MAGIC_FILE                          (-1429577703L)
  ------------------
  |  Branch (529:9): [True: 0, False: 16.3k]
  |  Branch (529:23): [True: 0, False: 0]
  ------------------
  530|      0|        return PROF_MAGIC_FILE;
  ------------------
  |  |  331|      0|#define PROF_MAGIC_FILE                          (-1429577703L)
  ------------------
  531|  16.3k|    if (iter->file && iter->file->data->magic != PROF_MAGIC_FILE_DATA)
  ------------------
  |  |  336|      0|#define PROF_MAGIC_FILE_DATA                     (-1429577698L)
  ------------------
  |  Branch (531:9): [True: 0, False: 16.3k]
  |  Branch (531:23): [True: 0, False: 0]
  ------------------
  532|      0|        return PROF_MAGIC_FILE_DATA;
  ------------------
  |  |  336|      0|#define PROF_MAGIC_FILE_DATA                     (-1429577698L)
  ------------------
  533|       |    /*
  534|       |     * If the file has changed, then the node pointer is invalid,
  535|       |     * so we'll have search the file again looking for it.
  536|       |     */
  537|  16.3k|    if (iter->file)
  ------------------
  |  Branch (537:9): [True: 0, False: 16.3k]
  ------------------
  538|      0|        k5_mutex_lock(&iter->file->data->lock);
  539|  16.3k|    if (iter->node && (iter->file->data->upd_serial != iter->file_serial)) {
  ------------------
  |  Branch (539:9): [True: 0, False: 16.3k]
  |  Branch (539:23): [True: 0, False: 0]
  ------------------
  540|      0|        iter->flags &= ~PROFILE_ITER_FINAL_SEEN;
  ------------------
  |  |  110|      0|#define PROFILE_ITER_FINAL_SEEN		0x0100
  ------------------
  541|      0|        skip_num = iter->num;
  542|      0|        iter->node = 0;
  543|      0|    }
  544|  16.3k|    if (iter->node && iter->node->magic != PROF_MAGIC_NODE) {
  ------------------
  |  |  307|      0|#define PROF_MAGIC_NODE                          (-1429577727L)
  ------------------
  |  Branch (544:9): [True: 0, False: 16.3k]
  |  Branch (544:23): [True: 0, False: 0]
  ------------------
  545|      0|        if (iter->file)
  ------------------
  |  Branch (545:13): [True: 0, False: 0]
  ------------------
  546|      0|            k5_mutex_unlock(&iter->file->data->lock);
  547|      0|        return PROF_MAGIC_NODE;
  ------------------
  |  |  307|      0|#define PROF_MAGIC_NODE                          (-1429577727L)
  ------------------
  548|      0|    }
  549|  16.3k|get_new_file:
  550|  16.3k|    if (iter->node == 0) {
  ------------------
  |  Branch (550:9): [True: 16.3k, False: 0]
  ------------------
  551|  16.3k|        if (iter->file == 0 ||
  ------------------
  |  Branch (551:13): [True: 16.3k, False: 0]
  ------------------
  552|  16.3k|            (iter->flags & PROFILE_ITER_FINAL_SEEN)) {
  ------------------
  |  |  110|      0|#define PROFILE_ITER_FINAL_SEEN		0x0100
  ------------------
  |  Branch (552:13): [True: 0, False: 0]
  ------------------
  553|  16.3k|            if (iter->file)
  ------------------
  |  Branch (553:17): [True: 0, False: 16.3k]
  ------------------
  554|      0|                k5_mutex_unlock(&iter->file->data->lock);
  555|  16.3k|            profile_node_iterator_free(iter_p);
  556|  16.3k|            if (ret_node)
  ------------------
  |  Branch (556:17): [True: 0, False: 16.3k]
  ------------------
  557|      0|                *ret_node = 0;
  558|  16.3k|            if (ret_name)
  ------------------
  |  Branch (558:17): [True: 14.0k, False: 2.28k]
  ------------------
  559|  14.0k|                *ret_name = 0;
  560|  16.3k|            if (ret_value)
  ------------------
  |  Branch (560:17): [True: 16.3k, False: 0]
  ------------------
  561|  16.3k|                *ret_value =0;
  562|  16.3k|            return 0;
  563|  16.3k|        }
  564|      0|        if ((retval = profile_update_file_locked(iter->file, NULL))) {
  ------------------
  |  |  223|      0|#define profile_update_file_locked(P, M) profile_update_file_data_locked((P)->data, M)
  ------------------
  |  Branch (564:13): [True: 0, False: 0]
  ------------------
  565|      0|            k5_mutex_unlock(&iter->file->data->lock);
  566|      0|            if (retval == ENOENT || retval == EACCES) {
  ------------------
  |  Branch (566:17): [True: 0, False: 0]
  |  Branch (566:37): [True: 0, False: 0]
  ------------------
  567|       |                /* XXX memory leak? */
  568|      0|                iter->file = iter->file->next;
  569|      0|                if (iter->file)
  ------------------
  |  Branch (569:21): [True: 0, False: 0]
  ------------------
  570|      0|                    k5_mutex_lock(&iter->file->data->lock);
  571|      0|                skip_num = 0;
  572|      0|                retval = 0;
  573|      0|                goto get_new_file;
  574|      0|            } else {
  575|      0|                profile_node_iterator_free(iter_p);
  576|      0|                return retval;
  577|      0|            }
  578|      0|        }
  579|      0|        iter->file_serial = iter->file->data->upd_serial;
  580|       |        /*
  581|       |         * Find the section to list if we are a LIST_SECTION,
  582|       |         * or find the containing section if not.
  583|       |         */
  584|      0|        section = iter->file->data->root;
  585|      0|        assert(section != NULL);
  ------------------
  |  Branch (585:9): [True: 0, False: 0]
  |  Branch (585:9): [True: 0, False: 0]
  ------------------
  586|      0|        for (cpp = iter->names; cpp[iter->done_idx]; cpp++) {
  ------------------
  |  Branch (586:33): [True: 0, False: 0]
  ------------------
  587|      0|            for (p=section->first_child; p; p = p->next) {
  ------------------
  |  Branch (587:42): [True: 0, False: 0]
  ------------------
  588|      0|                if (!strcmp(p->name, *cpp) && !p->value && !p->deleted)
  ------------------
  |  Branch (588:21): [True: 0, False: 0]
  |  Branch (588:47): [True: 0, False: 0]
  |  Branch (588:60): [True: 0, False: 0]
  ------------------
  589|      0|                    break;
  590|      0|            }
  591|      0|            if (!p) {
  ------------------
  |  Branch (591:17): [True: 0, False: 0]
  ------------------
  592|      0|                section = 0;
  593|      0|                break;
  594|      0|            }
  595|      0|            section = p;
  596|      0|            if (p->final)
  ------------------
  |  Branch (596:17): [True: 0, False: 0]
  ------------------
  597|      0|                iter->flags |= PROFILE_ITER_FINAL_SEEN;
  ------------------
  |  |  110|      0|#define PROFILE_ITER_FINAL_SEEN		0x0100
  ------------------
  598|      0|        }
  599|      0|        if (!section) {
  ------------------
  |  Branch (599:13): [True: 0, False: 0]
  ------------------
  600|      0|            k5_mutex_unlock(&iter->file->data->lock);
  601|      0|            iter->file = iter->file->next;
  602|      0|            if (iter->file)
  ------------------
  |  Branch (602:17): [True: 0, False: 0]
  ------------------
  603|      0|                k5_mutex_lock(&iter->file->data->lock);
  604|      0|            skip_num = 0;
  605|      0|            goto get_new_file;
  606|      0|        }
  607|      0|        iter->name = *cpp;
  608|      0|        iter->node = section->first_child;
  609|      0|    }
  610|       |    /*
  611|       |     * OK, now we know iter->node is set up correctly.  Let's do
  612|       |     * the search.
  613|       |     */
  614|      0|    for (p = iter->node; p; p = p->next) {
  ------------------
  |  Branch (614:26): [True: 0, False: 0]
  ------------------
  615|      0|        if (iter->name && strcmp(p->name, iter->name))
  ------------------
  |  Branch (615:13): [True: 0, False: 0]
  |  Branch (615:27): [True: 0, False: 0]
  ------------------
  616|      0|            continue;
  617|      0|        if ((iter->flags & PROFILE_ITER_SECTIONS_ONLY) &&
  ------------------
  |  |  107|      0|#define PROFILE_ITER_SECTIONS_ONLY	0x0002
  ------------------
  |  Branch (617:13): [True: 0, False: 0]
  ------------------
  618|      0|            p->value)
  ------------------
  |  Branch (618:13): [True: 0, False: 0]
  ------------------
  619|      0|            continue;
  620|      0|        if ((iter->flags & PROFILE_ITER_RELATIONS_ONLY) &&
  ------------------
  |  |  108|      0|#define PROFILE_ITER_RELATIONS_ONLY	0x0004
  ------------------
  |  Branch (620:13): [True: 0, False: 0]
  ------------------
  621|      0|            !p->value)
  ------------------
  |  Branch (621:13): [True: 0, False: 0]
  ------------------
  622|      0|            continue;
  623|      0|        if (skip_num > 0) {
  ------------------
  |  Branch (623:13): [True: 0, False: 0]
  ------------------
  624|      0|            skip_num--;
  625|      0|            continue;
  626|      0|        }
  627|      0|        if (p->deleted)
  ------------------
  |  Branch (627:13): [True: 0, False: 0]
  ------------------
  628|      0|            continue;
  629|      0|        if (p->final)
  ------------------
  |  Branch (629:13): [True: 0, False: 0]
  ------------------
  630|      0|            iter->flags |= PROFILE_ITER_FINAL_SEEN;
  ------------------
  |  |  110|      0|#define PROFILE_ITER_FINAL_SEEN		0x0100
  ------------------
  631|      0|        break;
  632|      0|    }
  633|      0|    iter->num++;
  634|      0|    if (!p) {
  ------------------
  |  Branch (634:9): [True: 0, False: 0]
  ------------------
  635|      0|        k5_mutex_unlock(&iter->file->data->lock);
  636|      0|        iter->file = iter->file->next;
  637|      0|        if (iter->file)
  ------------------
  |  Branch (637:13): [True: 0, False: 0]
  ------------------
  638|      0|            k5_mutex_lock(&iter->file->data->lock);
  639|      0|        iter->node = 0;
  640|      0|        skip_num = 0;
  641|      0|        goto get_new_file;
  642|      0|    }
  643|      0|    k5_mutex_unlock(&iter->file->data->lock);
  644|      0|    if ((iter->node = p->next) == NULL)
  ------------------
  |  Branch (644:9): [True: 0, False: 0]
  ------------------
  645|      0|        iter->file = iter->file->next;
  646|      0|    if (ret_node)
  ------------------
  |  Branch (646:9): [True: 0, False: 0]
  ------------------
  647|      0|        *ret_node = p;
  648|      0|    if (ret_name)
  ------------------
  |  Branch (648:9): [True: 0, False: 0]
  ------------------
  649|      0|        *ret_name = p->name;
  650|      0|    if (ret_value)
  ------------------
  |  Branch (650:9): [True: 0, False: 0]
  ------------------
  651|      0|        *ret_value = p->value;
  652|      0|    return 0;
  653|      0|}

k5_base64_encode:
   44|    906|{
   45|    906|    char *s, *p;
   46|    906|    size_t i;
   47|    906|    unsigned int c;
   48|    906|    const unsigned char *q;
   49|       |
   50|    906|    if (len > SIZE_MAX / 4)
  ------------------
  |  Branch (50:9): [True: 0, False: 906]
  ------------------
   51|      0|        return NULL;
   52|       |
   53|    906|    p = s = malloc(len * 4 / 3 + 4);
   54|    906|    if (p == NULL)
  ------------------
  |  Branch (54:9): [True: 0, False: 906]
  ------------------
   55|      0|        return NULL;
   56|    906|    q = (const unsigned char *)data;
   57|       |
   58|  8.17k|    for (i = 0; i < len;) {
  ------------------
  |  Branch (58:17): [True: 7.26k, False: 906]
  ------------------
   59|  7.26k|        c = q[i++];
   60|  7.26k|        c *= 256;
   61|  7.26k|        if (i < len)
  ------------------
  |  Branch (61:13): [True: 6.95k, False: 309]
  ------------------
   62|  6.95k|            c += q[i];
   63|  7.26k|        i++;
   64|  7.26k|        c *= 256;
   65|  7.26k|        if (i < len)
  ------------------
  |  Branch (65:13): [True: 6.54k, False: 722]
  ------------------
   66|  6.54k|            c += q[i];
   67|  7.26k|        i++;
   68|  7.26k|        p[0] = base64_chars[(c & 0x00fc0000) >> 18];
   69|  7.26k|        p[1] = base64_chars[(c & 0x0003f000) >> 12];
   70|  7.26k|        p[2] = base64_chars[(c & 0x00000fc0) >> 6];
   71|  7.26k|        p[3] = base64_chars[(c & 0x0000003f) >> 0];
   72|  7.26k|        if (i > len)
  ------------------
  |  Branch (72:13): [True: 722, False: 6.54k]
  ------------------
   73|    722|            p[3] = '=';
   74|  7.26k|        if (i > len + 1)
  ------------------
  |  Branch (74:13): [True: 309, False: 6.95k]
  ------------------
   75|    309|            p[2] = '=';
   76|  7.26k|        p += 4;
   77|  7.26k|    }
   78|    906|    *p = '\0';
   79|    906|    return s;
   80|    906|}
k5_base64_decode:
  112|    906|{
  113|    906|    unsigned char *data, *q;
  114|    906|    unsigned int val, marker;
  115|    906|    size_t len;
  116|       |
  117|    906|    *len_out = SIZE_MAX;
  118|       |
  119|       |    /* Allocate the output buffer. */
  120|    906|    len = strlen(str);
  121|    906|    if (len % 4)
  ------------------
  |  Branch (121:9): [True: 506, False: 400]
  ------------------
  122|    506|        return NULL;
  123|    400|    q = data = malloc(len / 4 * 3);
  124|    400|    if (data == NULL) {
  ------------------
  |  Branch (124:9): [True: 0, False: 400]
  ------------------
  125|      0|        *len_out = 0;
  126|      0|        return NULL;
  127|      0|    }
  128|       |
  129|       |    /* Decode the string. */
  130|  1.33k|    for (; *str != '\0'; str += 4) {
  ------------------
  |  Branch (130:12): [True: 1.19k, False: 141]
  ------------------
  131|  1.19k|        val = decode_token(str);
  132|  1.19k|        if (val == DECODE_ERROR) {
  ------------------
  |  |   82|  1.19k|#define DECODE_ERROR 0xffffffff
  ------------------
  |  Branch (132:13): [True: 259, False: 939]
  ------------------
  133|    259|            free(data);
  134|    259|            return NULL;
  135|    259|        }
  136|    939|        marker = (val >> 24) & 0xff;
  137|    939|        *q++ = (val >> 16) & 0xff;
  138|    939|        if (marker < 2)
  ------------------
  |  Branch (138:13): [True: 761, False: 178]
  ------------------
  139|    761|            *q++ = (val >> 8) & 0xff;
  140|    939|        if (marker < 1)
  ------------------
  |  Branch (140:13): [True: 733, False: 206]
  ------------------
  141|    733|            *q++ = val & 0xff;
  142|    939|    }
  143|    141|    *len_out = q - data;
  144|    141|    return data;
  145|    400|}
base64.c:decode_token:
   87|  1.19k|{
   88|  1.19k|    int i, marker = 0;
   89|  1.19k|    unsigned int val = 0;
   90|  1.19k|    const char *p;
   91|       |
   92|  5.09k|    for (i = 0; i < 4; i++) {
  ------------------
  |  Branch (92:17): [True: 4.15k, False: 945]
  ------------------
   93|  4.15k|        val *= 64;
   94|  4.15k|        if (token[i] == '=') {
  ------------------
  |  Branch (94:13): [True: 412, False: 3.73k]
  ------------------
   95|    412|            marker++;
   96|  3.73k|        } else if (marker > 0) {
  ------------------
  |  Branch (96:20): [True: 3, False: 3.73k]
  ------------------
   97|      3|            return DECODE_ERROR;
  ------------------
  |  |   82|      3|#define DECODE_ERROR 0xffffffff
  ------------------
   98|  3.73k|        } else {
   99|  3.73k|            p = strchr(base64_chars, token[i]);
  100|  3.73k|            if (p == NULL)
  ------------------
  |  Branch (100:17): [True: 250, False: 3.48k]
  ------------------
  101|    250|                return DECODE_ERROR;
  ------------------
  |  |   82|    250|#define DECODE_ERROR 0xffffffff
  ------------------
  102|  3.48k|            val += p - base64_chars;
  103|  3.48k|        }
  104|  4.15k|    }
  105|    945|    if (marker > 2)
  ------------------
  |  Branch (105:9): [True: 6, False: 939]
  ------------------
  106|      6|        return DECODE_ERROR;
  ------------------
  |  |   82|      6|#define DECODE_ERROR 0xffffffff
  ------------------
  107|    939|    return (marker << 24) | val;
  108|    945|}

krb5int_err_init:
   31|      1|{
   32|      1|    return k5_mutex_finish_init(&krb5int_error_info_support_mutex);
   33|      1|}
k5_free_error:
  103|    906|{
  104|    906|    if (msg != oom_msg)
  ------------------
  |  Branch (104:9): [True: 906, False: 0]
  ------------------
  105|    906|        free((char *)msg);
  106|    906|}
k5_clear_error:
  110|    906|{
  111|    906|    k5_free_error(ep, ep->msg);
  112|       |    ep->msg = NULL;
  113|    906|}
k5_set_error_info_callout_fn:
  117|      1|{
  118|      1|    initialize();
  ------------------
  |  |   34|      1|#define initialize()    krb5int_call_thread_support_init()
  ------------------
  119|      1|    lock();
  ------------------
  |  |   35|      1|#define lock()          k5_mutex_lock(&krb5int_error_info_support_mutex)
  ------------------
  120|      1|    fptr = f;
  121|      1|    unlock();
  ------------------
  |  |   36|      1|#define unlock()        k5_mutex_unlock(&krb5int_error_info_support_mutex)
  ------------------
  122|      1|}

k5_hashtab_create:
  127|    906|{
  128|    906|    struct k5_hashtab *ht;
  129|       |
  130|    906|    *ht_out = NULL;
  131|       |
  132|    906|    ht = malloc(sizeof(*ht));
  133|    906|    if (ht == NULL)
  ------------------
  |  Branch (133:9): [True: 0, False: 906]
  ------------------
  134|      0|        return ENOMEM;
  135|       |
  136|    906|    if (seed != NULL) {
  ------------------
  |  Branch (136:9): [True: 0, False: 906]
  ------------------
  137|      0|        ht->k0 = load_64_le(seed);
  138|      0|        ht->k1 = load_64_le(seed + 8);
  139|    906|    } else {
  140|    906|        ht->k0 = ht->k1 = 0;
  141|    906|    }
  142|    906|    ht->nbuckets = (initial_buckets > 0) ? initial_buckets : 64;
  ------------------
  |  Branch (142:20): [True: 906, False: 0]
  ------------------
  143|    906|    ht->nentries = 0;
  144|    906|    ht->buckets = calloc(ht->nbuckets, sizeof(*ht->buckets));
  145|    906|    if (ht->buckets == NULL) {
  ------------------
  |  Branch (145:9): [True: 0, False: 906]
  ------------------
  146|      0|        free(ht);
  147|      0|        return ENOMEM;
  148|      0|    }
  149|       |
  150|    906|    *ht_out = ht;
  151|    906|    return 0;
  152|    906|}
k5_hashtab_free:
  156|    906|{
  157|    906|    size_t i;
  158|    906|    struct entry *ent;
  159|       |
  160|  4.53k|    for (i = 0; i < ht->nbuckets; i++) {
  ------------------
  |  Branch (160:17): [True: 3.62k, False: 906]
  ------------------
  161|  4.53k|        while (!K5_SLIST_EMPTY(&ht->buckets[i])) {
  ------------------
  |  |  226|  4.53k|#define	K5_SLIST_EMPTY(head)	((head)->slh_first == NULL)
  ------------------
  |  Branch (161:16): [True: 906, False: 3.62k]
  ------------------
  162|    906|            ent = K5_SLIST_FIRST(&ht->buckets[i]);
  ------------------
  |  |  227|    906|#define	K5_SLIST_FIRST(head)	((head)->slh_first)
  ------------------
  163|    906|            K5_SLIST_REMOVE_HEAD(&ht->buckets[i], next);
  ------------------
  |  |  193|    906|#define	K5_SLIST_REMOVE_HEAD(head, field) do {				\
  |  |  194|    906|	(head)->slh_first = (head)->slh_first->field.sle_next;		\
  |  |  195|    906|} while (/*CONSTCOND*/0)
  |  |  ------------------
  |  |  |  Branch (195:23): [Folded, False: 906]
  |  |  ------------------
  ------------------
  164|    906|            free(ent);
  165|    906|        }
  166|  3.62k|    }
  167|    906|    free(ht->buckets);
  168|    906|    free(ht);
  169|    906|}
k5_hashtab_add:
  200|    906|{
  201|    906|    size_t i;
  202|    906|    struct entry *ent;
  203|       |
  204|    906|    if (ht->nentries == ht->nbuckets) {
  ------------------
  |  Branch (204:9): [True: 0, False: 906]
  ------------------
  205|      0|        if (resize_table(ht) != 0)
  ------------------
  |  Branch (205:13): [True: 0, False: 0]
  ------------------
  206|      0|            return ENOMEM;
  207|      0|    }
  208|       |
  209|    906|    ent = malloc(sizeof(*ent));
  210|    906|    if (ent == NULL)
  ------------------
  |  Branch (210:9): [True: 0, False: 906]
  ------------------
  211|      0|        return ENOMEM;
  212|    906|    ent->key = key;
  213|    906|    ent->klen = klen;
  214|    906|    ent->val = val;
  215|       |
  216|    906|    i = siphash24(key, klen, ht->k0, ht->k1) % ht->nbuckets;
  217|    906|    K5_SLIST_INSERT_HEAD(&ht->buckets[i], ent, next);
  ------------------
  |  |  188|    906|#define	K5_SLIST_INSERT_HEAD(head, elm, field) do {			\
  |  |  189|    906|	(elm)->field.sle_next = (head)->slh_first;			\
  |  |  190|    906|	(head)->slh_first = (elm);					\
  |  |  191|    906|} while (/*CONSTCOND*/0)
  |  |  ------------------
  |  |  |  Branch (191:23): [Folded, False: 906]
  |  |  ------------------
  ------------------
  218|       |
  219|    906|    ht->nentries++;
  220|    906|    return 0;
  221|    906|}
fuzz_util.c:siphash24:
   78|    906|{
   79|    906|    uint64_t v0 = k0 ^ 0x736F6D6570736575;
   80|    906|    uint64_t v1 = k1 ^ 0x646F72616E646F6D;
   81|    906|    uint64_t v2 = k0 ^ 0x6C7967656E657261;
   82|    906|    uint64_t v3 = k1 ^ 0x7465646279746573;
   83|    906|    uint64_t mi;
   84|    906|    const uint8_t *p, *end = data + (len - len % 8);
   85|    906|    uint8_t last[8] = { 0 };
   86|       |
   87|       |    /* Process each full 8-byte chunk of data. */
   88|  3.17k|    for (p = data; p < end; p += 8) {
  ------------------
  |  Branch (88:20): [True: 2.27k, False: 906]
  ------------------
   89|  2.27k|        mi = load_64_le(p);
   90|  2.27k|        v3 ^= mi;
   91|  2.27k|        sipround(&v0, &v1, &v2, &v3);
   92|  2.27k|        sipround(&v0, &v1, &v2, &v3);
   93|  2.27k|        v0 ^= mi;
   94|  2.27k|    }
   95|       |
   96|       |    /* Process the last 0-7 bytes followed by the length mod 256. */
   97|    906|    if (len % 8 > 0)
  ------------------
  |  Branch (97:9): [True: 741, False: 165]
  ------------------
   98|    741|        memcpy(last, end, len % 8);
   99|    906|    last[7] = len & 0xFF;
  100|    906|    mi = load_64_le(last);
  101|    906|    v3 ^= mi;
  102|    906|    sipround(&v0, &v1, &v2, &v3);
  103|    906|    sipround(&v0, &v1, &v2, &v3);
  104|    906|    v0 ^= mi;
  105|       |
  106|       |    /* Finalize. */
  107|    906|    v2 ^= 0xFF;
  108|    906|    sipround(&v0, &v1, &v2, &v3);
  109|    906|    sipround(&v0, &v1, &v2, &v3);
  110|    906|    sipround(&v0, &v1, &v2, &v3);
  111|    906|    sipround(&v0, &v1, &v2, &v3);
  112|    906|    return v0 ^ v1 ^ v2 ^ v3;
  113|    906|}
fuzz_util.c:sipround:
   61|  9.98k|{
   62|  9.98k|    *v0 += *v1;
   63|  9.98k|    *v2 += *v3;
   64|  9.98k|    *v1 = rotl64(*v1, 13) ^ *v0;
   65|  9.98k|    *v3 = rotl64(*v3, 16) ^ *v2;
   66|  9.98k|    *v0 = rotl64(*v0, 32);
   67|  9.98k|    *v2 += *v1;
   68|  9.98k|    *v0 += *v3;
   69|  9.98k|    *v1 = rotl64(*v1, 17) ^ *v2;
   70|  9.98k|    *v3 = rotl64(*v3, 21) ^ *v0;
   71|  9.98k|    *v2 = rotl64(*v2, 32);
   72|  9.98k|}
fuzz_util.c:rotl64:
   55|  59.8k|{
   56|  59.8k|    return (x << r) | (x >> (64 - r));
   57|  59.8k|}

k5_hex_encode:
   51|  1.81k|{
   52|  1.81k|    size_t i;
   53|  1.81k|    const uint8_t *p = bytes;
   54|  1.81k|    char *hex;
   55|       |
   56|  1.81k|    *hex_out = NULL;
   57|       |
   58|  1.81k|    hex = malloc(len * 2 + 1);
   59|  1.81k|    if (hex == NULL)
  ------------------
  |  Branch (59:9): [True: 0, False: 1.81k]
  ------------------
   60|      0|        return ENOMEM;
   61|       |
   62|  43.3k|    for (i = 0; i < len; i++) {
  ------------------
  |  Branch (62:17): [True: 41.5k, False: 1.81k]
  ------------------
   63|  41.5k|        hex[i * 2] = hex_digit(p[i] >> 4, uppercase);
   64|  41.5k|        hex[i * 2 + 1] = hex_digit(p[i] & 0xF, uppercase);
   65|  41.5k|    }
   66|  1.81k|    hex[len * 2] = '\0';
   67|       |
   68|  1.81k|    *hex_out = hex;
   69|  1.81k|    return 0;
   70|  1.81k|}
k5_hex_decode:
   87|    906|{
   88|    906|    size_t hexlen, i;
   89|    906|    int h1, h2;
   90|    906|    uint8_t *bytes;
   91|       |
   92|    906|    *bytes_out = NULL;
   93|    906|    *len_out = 0;
   94|       |
   95|    906|    hexlen = strlen(hex);
   96|    906|    if (hexlen % 2 != 0)
  ------------------
  |  Branch (96:9): [True: 250, False: 656]
  ------------------
   97|    250|        return EINVAL;
   98|    656|    bytes = malloc(hexlen / 2 + 1);
   99|    656|    if (bytes == NULL)
  ------------------
  |  Branch (99:9): [True: 0, False: 656]
  ------------------
  100|      0|        return ENOMEM;
  101|       |
  102|  1.85k|    for (i = 0; i < hexlen / 2; i++) {
  ------------------
  |  Branch (102:17): [True: 1.76k, False: 96]
  ------------------
  103|  1.76k|        h1 = decode_hexchar(hex[i * 2]);
  104|  1.76k|        h2 = decode_hexchar(hex[i * 2 + 1]);
  105|  1.76k|        if (h1 == -1 || h2 == -1) {
  ------------------
  |  Branch (105:13): [True: 513, False: 1.25k]
  |  Branch (105:25): [True: 47, False: 1.20k]
  ------------------
  106|    560|            free(bytes);
  107|    560|            return EINVAL;
  108|    560|        }
  109|  1.20k|        bytes[i] = h1 * 16 + h2;
  110|  1.20k|    }
  111|     96|    bytes[i] = 0;
  112|       |
  113|     96|    *bytes_out = bytes;
  114|     96|    *len_out = hexlen / 2;
  115|     96|    return 0;
  116|    656|}
hex.c:hex_digit:
   39|  83.0k|{
   40|  83.0k|    assert(bval <= 0xF);
  ------------------
  |  Branch (40:5): [True: 0, False: 83.0k]
  |  Branch (40:5): [True: 83.0k, False: 0]
  ------------------
   41|  83.0k|    if (bval < 10)
  ------------------
  |  Branch (41:9): [True: 53.4k, False: 29.6k]
  ------------------
   42|  53.4k|        return '0' + bval;
   43|  29.6k|    else if (uppercase)
  ------------------
  |  Branch (43:14): [True: 14.8k, False: 14.8k]
  ------------------
   44|  14.8k|        return 'A' + (bval - 10);
   45|  14.8k|    else
   46|  14.8k|        return 'a' + (bval - 10);
   47|  83.0k|}
hex.c:decode_hexchar:
   75|  3.52k|{
   76|  3.52k|    if (isdigit(c))
  ------------------
  |  Branch (76:9): [True: 957, False: 2.56k]
  ------------------
   77|    957|        return c - '0';
   78|  2.56k|    if (c >= 'A' && c <= 'F')
  ------------------
  |  Branch (78:9): [True: 2.27k, False: 296]
  |  Branch (78:21): [True: 961, False: 1.31k]
  ------------------
   79|    961|        return c - 'A' + 10;
   80|  1.60k|    if (c >= 'a' && c <= 'f')
  ------------------
  |  Branch (80:9): [True: 1.17k, False: 430]
  |  Branch (80:21): [True: 582, False: 596]
  ------------------
   81|    582|        return c - 'a' + 10;
   82|  1.02k|    return -1;
   83|  1.60k|}

krb5int_init_fac:
   61|      1|{
   62|      1|    return k5_mutex_finish_init(&krb5int_fac.lock);
   63|      1|}

k5_buf_init_dynamic:
  125|  2.48k|{
  126|  2.48k|    buf->buftype = K5BUF_DYNAMIC;
  127|  2.48k|    buf->space = 128;
  128|  2.48k|    buf->data = malloc(buf->space);
  129|  2.48k|    if (buf->data == NULL) {
  ------------------
  |  Branch (129:9): [True: 0, False: 2.48k]
  ------------------
  130|      0|        set_error(buf);
  131|      0|        return;
  132|      0|    }
  133|  2.48k|    buf->len = 0;
  134|  2.48k|}
k5_buf_init_dynamic_zap:
  138|    906|{
  139|    906|    k5_buf_init_dynamic(buf);
  140|    906|    if (buf->buftype == K5BUF_DYNAMIC)
  ------------------
  |  Branch (140:9): [True: 906, False: 0]
  ------------------
  141|    906|        buf->buftype = K5BUF_DYNAMIC_ZAP;
  142|    906|}
k5_buf_add:
  146|    906|{
  147|    906|    k5_buf_add_len(buf, data, strlen(data));
  148|    906|}
k5_buf_add_len:
  152|    906|{
  153|    906|    if (!ensure_space(buf, len))
  ------------------
  |  Branch (153:9): [True: 0, False: 906]
  ------------------
  154|      0|        return;
  155|    906|    if (len > 0)
  ------------------
  |  Branch (155:9): [True: 906, False: 0]
  ------------------
  156|    906|        memcpy(endptr(buf), data, len);
  157|    906|    buf->len += len;
  158|    906|}
k5_buf_cstring:
  234|  1.51k|{
  235|  1.51k|    if (!ensure_space(buf, 1))
  ------------------
  |  Branch (235:9): [True: 0, False: 1.51k]
  ------------------
  236|      0|        return NULL;
  237|  1.51k|    *endptr(buf) = '\0';
  238|  1.51k|    return buf->data;
  239|  1.51k|}
k5_buf_get_space:
  243|  19.1k|{
  244|  19.1k|    if (!ensure_space(buf, len))
  ------------------
  |  Branch (244:9): [True: 0, False: 19.1k]
  ------------------
  245|      0|        return NULL;
  246|  19.1k|    buf->len += len;
  247|  19.1k|    return endptr(buf) - len;
  248|  19.1k|}
k5_buf_free:
  267|  1.33k|{
  268|  1.33k|    if (buf->buftype == K5BUF_ERROR)
  ------------------
  |  Branch (268:9): [True: 906, False: 432]
  ------------------
  269|    906|        return;
  270|  1.33k|    assert(buf->buftype == K5BUF_DYNAMIC || buf->buftype == K5BUF_DYNAMIC_ZAP);
  ------------------
  |  Branch (270:5): [True: 432, False: 0]
  |  Branch (270:5): [True: 0, False: 0]
  |  Branch (270:5): [True: 62, False: 370]
  |  Branch (270:5): [True: 370, False: 0]
  ------------------
  271|    432|    if (buf->buftype == K5BUF_DYNAMIC_ZAP)
  ------------------
  |  Branch (271:9): [True: 370, False: 62]
  ------------------
  272|    370|        zap(buf->data, buf->len);
  ------------------
  |  | 1009|    370|# define zap(ptr, len) explicit_bzero(ptr, len)
  ------------------
  273|    432|    free(buf->data);
  274|    432|    set_error(buf);
  275|    432|}
k5buf.c:set_error:
   57|    432|{
   58|    432|    buf->buftype = K5BUF_ERROR;
   59|       |    buf->data = NULL;
   60|    432|    buf->space = buf->len = 0;
   61|    432|}
k5buf.c:ensure_space:
   70|  21.5k|{
   71|  21.5k|    size_t new_space;
   72|  21.5k|    char *new_data;
   73|       |
   74|  21.5k|    if (buf->buftype == K5BUF_ERROR)
  ------------------
  |  Branch (74:9): [True: 0, False: 21.5k]
  ------------------
   75|      0|        return 0;
   76|  21.5k|    if (buf->space - buf->len >= len) /* Enough room already. */
  ------------------
  |  Branch (76:9): [True: 21.4k, False: 126]
  ------------------
   77|  21.4k|        return 1;
   78|    126|    if (buf->buftype == K5BUF_FIXED) /* Can't resize a fixed buffer. */
  ------------------
  |  Branch (78:9): [True: 0, False: 126]
  ------------------
   79|      0|        goto error_exit;
   80|    126|    assert(buf->buftype == K5BUF_DYNAMIC || buf->buftype == K5BUF_DYNAMIC_ZAP);
  ------------------
  |  Branch (80:5): [True: 126, False: 0]
  |  Branch (80:5): [True: 0, False: 0]
  |  Branch (80:5): [True: 63, False: 63]
  |  Branch (80:5): [True: 63, False: 0]
  ------------------
   81|    126|    new_space = buf->space * 2;
   82|    126|    while (new_space - buf->len < len) {
  ------------------
  |  Branch (82:12): [True: 0, False: 126]
  ------------------
   83|      0|        if (new_space > SIZE_MAX / 2)
  ------------------
  |  Branch (83:13): [True: 0, False: 0]
  ------------------
   84|      0|            goto error_exit;
   85|      0|        new_space *= 2;
   86|      0|    }
   87|    126|    if (buf->buftype == K5BUF_DYNAMIC_ZAP) {
  ------------------
  |  Branch (87:9): [True: 63, False: 63]
  ------------------
   88|       |        /* realloc() could leave behind a partial copy of sensitive data. */
   89|     63|        new_data = malloc(new_space);
   90|     63|        if (new_data == NULL)
  ------------------
  |  Branch (90:13): [True: 0, False: 63]
  ------------------
   91|      0|            goto error_exit;
   92|     63|        memcpy(new_data, buf->data, buf->len);
   93|     63|        zap(buf->data, buf->len);
  ------------------
  |  | 1009|     63|# define zap(ptr, len) explicit_bzero(ptr, len)
  ------------------
   94|     63|        free(buf->data);
   95|     63|    } else {
   96|     63|        new_data = realloc(buf->data, new_space);
   97|     63|        if (new_data == NULL)
  ------------------
  |  Branch (97:13): [True: 0, False: 63]
  ------------------
   98|      0|            goto error_exit;
   99|     63|    }
  100|    126|    buf->data = new_data;
  101|    126|    buf->space = new_space;
  102|    126|    return 1;
  103|       |
  104|      0|error_exit:
  105|      0|    if (buf->buftype == K5BUF_DYNAMIC_ZAP)
  ------------------
  |  Branch (105:9): [True: 0, False: 0]
  ------------------
  106|      0|        zap(buf->data, buf->len);
  ------------------
  |  | 1009|      0|# define zap(ptr, len) explicit_bzero(ptr, len)
  ------------------
  107|      0|    if (buf->buftype == K5BUF_DYNAMIC_ZAP || buf->buftype == K5BUF_DYNAMIC)
  ------------------
  |  Branch (107:9): [True: 0, False: 0]
  |  Branch (107:46): [True: 0, False: 0]
  ------------------
  108|      0|        free(buf->data);
  109|      0|    set_error(buf);
  110|      0|    return 0;
  111|    126|}
k5buf.c:endptr:
   51|  21.5k|{
   52|  21.5k|    return (char *)buf->data + buf->len;
   53|  21.5k|}

krb5int_close_plugin_dirs:
  466|    906|{
  467|    906|    size_t i;
  468|       |
  469|    906|    if (dirhandle->files != NULL) {
  ------------------
  |  Branch (469:9): [True: 0, False: 906]
  ------------------
  470|      0|        for (i = 0; dirhandle->files[i] != NULL; i++) {
  ------------------
  |  Branch (470:21): [True: 0, False: 0]
  ------------------
  471|      0|            krb5int_close_plugin (dirhandle->files[i]);
  472|      0|        }
  473|      0|        free (dirhandle->files);
  474|       |        dirhandle->files = NULL;
  475|      0|    }
  476|    906|}

krb5int_strlcpy:
   31|  1.81k|{
   32|  1.81k|	char *d = dst;
   33|  1.81k|	const char *s = src;
   34|  1.81k|	size_t n = siz;
   35|       |
   36|       |	/* Copy as many bytes as will fit */
   37|  1.81k|	if (n != 0) {
  ------------------
  |  Branch (37:6): [True: 1.81k, False: 0]
  ------------------
   38|  36.2k|		while (--n != 0) {
  ------------------
  |  Branch (38:10): [True: 34.4k, False: 1.81k]
  ------------------
   39|  34.4k|			if ((*d++ = *s++) == '\0')
  ------------------
  |  Branch (39:8): [True: 0, False: 34.4k]
  ------------------
   40|      0|				break;
   41|  34.4k|		}
   42|  1.81k|	}
   43|       |
   44|       |	/* Not enough room in dst, add NUL and traverse rest of src */
   45|  1.81k|	if (n == 0) {
  ------------------
  |  Branch (45:6): [True: 1.81k, False: 0]
  ------------------
   46|  1.81k|		if (siz != 0)
  ------------------
  |  Branch (46:7): [True: 1.81k, False: 0]
  ------------------
   47|  1.81k|			*d = '\0';		/* NUL-terminate dst */
   48|  1.81k|		while (*s++)
  ------------------
  |  Branch (48:10): [True: 0, False: 1.81k]
  ------------------
   49|      0|			;
   50|  1.81k|	}
   51|       |
   52|  1.81k|	return(s - src - 1);	/* count does not include NUL */
   53|  1.81k|}

krb5int_pthread_loaded:
  139|  20.8k|{
  140|  20.8k|    int x = flag_pthread_loaded;
  141|  20.8k|    if (x != -1)
  ------------------
  |  Branch (141:9): [True: 20.8k, False: 1]
  ------------------
  142|  20.8k|        return x;
  143|      1|    if (&pthread_getspecific == 0
  ------------------
  |  Branch (143:9): [True: 0, False: 1]
  ------------------
  144|      1|        || &pthread_setspecific == 0
  ------------------
  |  Branch (144:12): [True: 0, False: 1]
  ------------------
  145|      1|        || &pthread_key_create == 0
  ------------------
  |  Branch (145:12): [True: 0, False: 1]
  ------------------
  146|      1|        || &pthread_key_delete == 0
  ------------------
  |  Branch (146:12): [True: 0, False: 1]
  ------------------
  147|      1|        || &pthread_once == 0
  ------------------
  |  Branch (147:12): [True: 0, False: 1]
  ------------------
  148|      1|        || &pthread_mutex_lock == 0
  ------------------
  |  Branch (148:12): [True: 0, False: 1]
  ------------------
  149|      1|        || &pthread_mutex_unlock == 0
  ------------------
  |  Branch (149:12): [True: 0, False: 1]
  ------------------
  150|      1|        || &pthread_mutex_destroy == 0
  ------------------
  |  Branch (150:12): [True: 0, False: 1]
  ------------------
  151|      1|        || &pthread_mutex_init == 0
  ------------------
  |  Branch (151:12): [True: 0, False: 1]
  ------------------
  152|      1|        || &pthread_self == 0
  ------------------
  |  Branch (152:12): [True: 0, False: 1]
  ------------------
  153|       |        /* Any program that's really multithreaded will have to be
  154|       |           able to create threads.  */
  155|      1|        || &pthread_create == 0
  ------------------
  |  Branch (155:12): [True: 0, False: 1]
  ------------------
  156|      1|        || &pthread_join == 0
  ------------------
  |  Branch (156:12): [True: 0, False: 1]
  ------------------
  157|       |        /* Okay, all the interesting functions -- or stubs for them --
  158|       |           seem to be present.  If we call pthread_once, does it
  159|       |           actually seem to cause the indicated function to get called
  160|       |           exactly one time?  */
  161|      1|        || pthread_once(&loaded_test_once, loaded_test_aux) != 0
  ------------------
  |  Branch (161:12): [True: 0, False: 1]
  ------------------
  162|      1|        || pthread_once(&loaded_test_once, loaded_test_aux) != 0
  ------------------
  |  Branch (162:12): [True: 0, False: 1]
  ------------------
  163|       |        /* This catches cases where pthread_once does nothing, and
  164|       |           never causes the function to get called.  That's a pretty
  165|       |           clear violation of the POSIX spec, but hey, it happens.  */
  166|      1|        || flag_pthread_loaded < 0) {
  ------------------
  |  Branch (166:12): [True: 0, False: 1]
  ------------------
  167|      0|        flag_pthread_loaded = 0;
  168|      0|        return 0;
  169|      0|    }
  170|       |    /* If we wanted to be super-paranoid, we could try testing whether
  171|       |       pthread_get/setspecific work, too.  I don't know -- so far --
  172|       |       of any system with non-functional stubs for those.  */
  173|      1|    return flag_pthread_loaded;
  174|      1|}
krb5int_key_register:
  326|      1|{
  327|      1|    int err;
  328|       |
  329|      1|    err = CALL_INIT_FUNCTION(krb5int_thread_support_init);
  ------------------
  |  |  291|      1|        k5_call_init_function(& JOIN__2(NAME, once))
  |  |  ------------------
  |  |  |  |  255|      1|        (__extension__ ({                                               \
  |  |  |  |  256|      1|                k5_init_t *k5int_i = (I);                               \
  |  |  |  |  257|      1|                int k5int_err = k5_once(&k5int_i->once, k5int_i->fn);   \
  |  |  |  |  258|      1|                (k5int_err                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (258:18): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  259|      1|                 ? k5int_err                                            \
  |  |  |  |  260|      1|                 : (assert(k5int_i->did_run != 0), k5int_i->error));    \
  |  |  |  |  261|      1|            }))
  |  |  ------------------
  ------------------
  |  Branch (329:11): [True: 0, False: 1]
  |  Branch (329:11): [True: 1, False: 0]
  ------------------
  330|      1|    if (err)
  ------------------
  |  Branch (330:9): [True: 0, False: 1]
  ------------------
  331|      0|        return err;
  332|       |
  333|       |#ifndef ENABLE_THREADS
  334|       |
  335|       |    assert(destructors_set[keynum] == 0);
  336|       |    destructors[keynum] = destructor;
  337|       |    destructors_set[keynum] = 1;
  338|       |
  339|       |#elif defined(_WIN32)
  340|       |
  341|       |    /* XXX: This can raise EXCEPTION_POSSIBLE_DEADLOCK.  */
  342|       |    EnterCriticalSection(&key_lock);
  343|       |    assert(destructors_set[keynum] == 0);
  344|       |    destructors_set[keynum] = 1;
  345|       |    destructors[keynum] = destructor;
  346|       |    LeaveCriticalSection(&key_lock);
  347|       |
  348|       |#else /* POSIX */
  349|       |
  350|      1|    k5_mutex_lock(&key_lock);
  351|      1|    assert(destructors_set[keynum] == 0);
  ------------------
  |  Branch (351:5): [True: 0, False: 1]
  |  Branch (351:5): [True: 1, False: 0]
  ------------------
  352|      1|    destructors_set[keynum] = 1;
  353|      1|    destructors[keynum] = destructor;
  354|      1|    k5_mutex_unlock(&key_lock);
  355|       |
  356|      1|#endif
  357|      1|    return 0;
  358|      1|}
krb5int_call_thread_support_init:
  398|      1|{
  399|      1|    return CALL_INIT_FUNCTION(krb5int_thread_support_init);
  ------------------
  |  |  291|      1|        k5_call_init_function(& JOIN__2(NAME, once))
  |  |  ------------------
  |  |  |  |  255|      1|        (__extension__ ({                                               \
  |  |  |  |  256|      1|                k5_init_t *k5int_i = (I);                               \
  |  |  |  |  257|      1|                int k5int_err = k5_once(&k5int_i->once, k5int_i->fn);   \
  |  |  |  |  258|      1|                (k5int_err                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (258:18): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  259|      1|                 ? k5int_err                                            \
  |  |  |  |  260|      1|                 : (assert(k5int_i->did_run != 0), k5int_i->error));    \
  |  |  |  |  261|      1|            }))
  |  |  ------------------
  ------------------
  |  Branch (399:12): [True: 0, False: 1]
  |  Branch (399:12): [True: 1, False: 0]
  ------------------
  400|      1|}
k5_os_mutex_init:
  522|  1.81k|{
  523|  1.81k|    if (krb5int_pthread_loaded())
  ------------------
  |  Branch (523:9): [True: 1.81k, False: 0]
  ------------------
  524|  1.81k|        return pthread_mutex_init(m, 0);
  525|      0|    else
  526|      0|        return 0;
  527|  1.81k|}
k5_os_mutex_destroy:
  531|  1.81k|{
  532|  1.81k|    if (krb5int_pthread_loaded())
  ------------------
  |  Branch (532:9): [True: 1.81k, False: 0]
  ------------------
  533|  1.81k|        return pthread_mutex_destroy(m);
  534|      0|    else
  535|      0|        return 0;
  536|  1.81k|}
k5_os_mutex_lock:
  540|  7.25k|{
  541|  7.25k|    if (krb5int_pthread_loaded())
  ------------------
  |  Branch (541:9): [True: 7.25k, False: 0]
  ------------------
  542|  7.25k|        return pthread_mutex_lock(m);
  543|      0|    else
  544|      0|        return 0;
  545|  7.25k|}
k5_os_mutex_unlock:
  549|  7.25k|{
  550|  7.25k|    if (krb5int_pthread_loaded())
  ------------------
  |  Branch (550:9): [True: 7.25k, False: 0]
  ------------------
  551|  7.25k|        return pthread_mutex_unlock(m);
  552|      0|    else
  553|      0|        return 0;
  554|  7.25k|}
k5_once:
  558|  2.72k|{
  559|  2.72k|    if (krb5int_pthread_loaded())
  ------------------
  |  Branch (559:9): [True: 2.72k, False: 0]
  ------------------
  560|  2.72k|        return pthread_once(&once->o, fn);
  561|      0|    else
  562|      0|        return k5_os_nothread_once(&once->n, fn);
  ------------------
  |  |  191|      0|    (*(O) == 3 ? 0                                              \
  |  |  ------------------
  |  |  |  Branch (191:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  192|      0|     : *(O) == 2 ? (*(O) = 4, (F)(), *(O) = 3, 0)               \
  |  |  ------------------
  |  |  |  Branch (192:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  193|      0|     : (assert(*(O) != 4), assert(*(O) == 2 || *(O) == 3), 0))
  ------------------
  |  Branch (562:16): [True: 0, False: 0]
  |  Branch (562:16): [True: 0, False: 0]
  |  Branch (562:16): [True: 0, False: 0]
  |  Branch (562:16): [True: 0, False: 0]
  |  Branch (562:16): [True: 0, False: 0]
  |  Branch (562:16): [True: 0, False: 0]
  ------------------
  563|  2.72k|}
threads.c:loaded_test_aux:
  130|      1|{
  131|      1|    if (flag_pthread_loaded == -1)
  ------------------
  |  Branch (131:9): [True: 1, False: 0]
  ------------------
  132|      1|        flag_pthread_loaded = 1;
  133|      0|    else
  134|       |        /* Could we have been called twice?  */
  135|      0|        flag_pthread_loaded = 0;
  136|      1|}
threads.c:krb5int_thread_support_init:
  405|      1|{
  406|      1|    int err;
  407|       |
  408|       |#ifdef SHOW_INITFINI_FUNCS
  409|       |    printf("krb5int_thread_support_init\n");
  410|       |#endif
  411|       |
  412|       |#ifndef ENABLE_THREADS
  413|       |
  414|       |    /* Nothing to do for TLS initialization.  */
  415|       |
  416|       |#elif defined(_WIN32)
  417|       |
  418|       |    tls_idx = TlsAlloc();
  419|       |    /* XXX This can raise an exception if memory is low!  */
  420|       |    InitializeCriticalSection(&key_lock);
  421|       |
  422|       |#else /* POSIX */
  423|       |
  424|      1|    err = k5_mutex_finish_init(&key_lock);
  425|      1|    if (err)
  ------------------
  |  Branch (425:9): [True: 0, False: 1]
  ------------------
  426|      0|        return err;
  427|      1|    if (K5_PTHREADS_LOADED) {
  ------------------
  |  |  127|      1|# define K5_PTHREADS_LOADED     (krb5int_pthread_loaded())
  |  |  ------------------
  |  |  |  Branch (127:33): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  428|      1|        err = pthread_key_create(&key, thread_termination);
  429|      1|        if (err)
  ------------------
  |  Branch (429:13): [True: 0, False: 1]
  ------------------
  430|      0|            return err;
  431|      1|    }
  432|       |
  433|      1|#endif
  434|       |
  435|      1|    err = krb5int_init_fac();
  436|      1|    if (err)
  ------------------
  |  Branch (436:9): [True: 0, False: 1]
  ------------------
  437|      0|        return err;
  438|       |
  439|      1|    err = krb5int_err_init();
  440|      1|    if (err)
  ------------------
  |  Branch (440:9): [True: 0, False: 1]
  ------------------
  441|      0|        return err;
  442|       |
  443|      1|    return 0;
  444|      1|}

krb5int_utf8_to_ucs4:
  103|    906|{
  104|    906|    const unsigned char *c = (const unsigned char *) p;
  105|    906|    krb5_ucs4 ch;
  106|    906|    int len, i;
  107|    906|    static unsigned char mask[] = {
  108|    906|        0, 0x7f, 0x1f, 0x0f, 0x07 };
  109|       |
  110|    906|    *out = 0;
  111|    906|    len = KRB5_UTF8_CHARLEN2(p, len);
  ------------------
  |  |  109|    906|#define KRB5_UTF8_CHARLEN2(p, l) (                                      \
  |  |  110|    906|        ((l = KRB5_UTF8_CHARLEN(p)) < 3 ||                              \
  |  |  ------------------
  |  |  |  |  102|    906|#define KRB5_UTF8_CHARLEN(p) (KRB5_UTF8_ISASCII(p) ? 1 :                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|    906|#define KRB5_UTF8_ISASCII(p) (!(KRB5_UTF8_BV(p) & 0x80))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  100|    906|#define KRB5_UTF8_BV(p) (*(const unsigned char *)(p))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:30): [True: 611, False: 295]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  103|    906|                              krb5int_utf8_lentab[KRB5_UTF8_BV(p) ^ 0x80])
  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    295|#define KRB5_UTF8_BV(p) (*(const unsigned char *)(p))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (110:10): [True: 768, False: 138]
  |  |  ------------------
  |  |  111|    906|         (krb5int_utf8_mintab[KRB5_UTF8_BV(p) & 0x1f] & (p)[1])) ?      \
  |  |  ------------------
  |  |  |  |  100|    138|#define KRB5_UTF8_BV(p) (*(const unsigned char *)(p))
  |  |  ------------------
  |  |  |  Branch (111:10): [True: 133, False: 5]
  |  |  ------------------
  |  |  112|    906|        l : 0)
  ------------------
  112|       |
  113|    906|    if (len == 0)
  ------------------
  |  Branch (113:9): [True: 117, False: 789]
  ------------------
  114|    117|        return -1;
  115|       |
  116|    789|    ch = c[0] & mask[len];
  117|       |
  118|  1.09k|    for (i = 1; i < len; i++) {
  ------------------
  |  Branch (118:17): [True: 348, False: 745]
  ------------------
  119|    348|        if ((c[i] & 0xc0) != 0x80)
  ------------------
  |  Branch (119:13): [True: 44, False: 304]
  ------------------
  120|     44|            return -1;
  121|       |
  122|    304|        ch <<= 6;
  123|    304|        ch |= c[i] & 0x3f;
  124|    304|    }
  125|       |
  126|    745|    if (ch > 0x10ffff)
  ------------------
  |  Branch (126:9): [True: 3, False: 742]
  ------------------
  127|      3|        return -1;
  128|       |
  129|    742|    *out = ch;
  130|    742|    return 0;
  131|    745|}
krb5int_ucs4_to_utf8:
  135|  13.3k|{
  136|  13.3k|    size_t len = 0;
  137|  13.3k|    unsigned char *p = (unsigned char *) buf;
  138|       |
  139|       |    /* not a valid Unicode character */
  140|  13.3k|    if (c > 0x10ffff)
  ------------------
  |  Branch (140:9): [True: 0, False: 13.3k]
  ------------------
  141|      0|        return 0;
  142|       |
  143|       |    /* Just return length, don't convert */
  144|  13.3k|    if (buf == NULL) {
  ------------------
  |  Branch (144:9): [True: 6.65k, False: 6.65k]
  ------------------
  145|  6.65k|        if (c < 0x80) return 1;
  ------------------
  |  Branch (145:13): [True: 274, False: 6.38k]
  ------------------
  146|  6.38k|        else if (c < 0x800) return 2;
  ------------------
  |  Branch (146:18): [True: 282, False: 6.10k]
  ------------------
  147|  6.10k|        else if (c < 0x10000) return 3;
  ------------------
  |  Branch (147:18): [True: 5.99k, False: 103]
  ------------------
  148|    103|        else return 4;
  149|  6.65k|    }
  150|       |
  151|  6.65k|    if (c < 0x80) {
  ------------------
  |  Branch (151:9): [True: 274, False: 6.38k]
  ------------------
  152|    274|        p[len++] = c;
  153|  6.38k|    } else if (c < 0x800) {
  ------------------
  |  Branch (153:16): [True: 282, False: 6.10k]
  ------------------
  154|    282|        p[len++] = 0xc0 | ( c >> 6 );
  155|    282|        p[len++] = 0x80 | ( c & 0x3f );
  156|  6.10k|    } else if (c < 0x10000) {
  ------------------
  |  Branch (156:16): [True: 5.99k, False: 103]
  ------------------
  157|  5.99k|        p[len++] = 0xe0 | ( c >> 12 );
  158|  5.99k|        p[len++] = 0x80 | ( (c >> 6) & 0x3f );
  159|  5.99k|        p[len++] = 0x80 | ( c & 0x3f );
  160|  5.99k|    } else /* if (c < 0x110000) */ {
  161|    103|        p[len++] = 0xf0 | ( c >> 18 );
  162|    103|        p[len++] = 0x80 | ( (c >> 12) & 0x3f );
  163|    103|        p[len++] = 0x80 | ( (c >> 6) & 0x3f );
  164|    103|        p[len++] = 0x80 | ( c & 0x3f );
  165|    103|    }
  166|       |
  167|  6.65k|    return len;
  168|  13.3k|}

k5_utf8_to_utf16le:
   93|    906|{
   94|    906|    struct k5buf buf;
   95|    906|    krb5_ucs4 ch;
   96|    906|    size_t chlen, i;
   97|       |
   98|    906|    *utf16_out = NULL;
   99|    906|    *nbytes_out = 0;
  100|       |
  101|       |    /* UTF-16 conversion is used for RC4 string-to-key, so treat this data as
  102|       |     * sensitive. */
  103|    906|    k5_buf_init_dynamic_zap(&buf);
  104|       |
  105|       |    /* Examine next UTF-8 character. */
  106|  13.1k|    while (*utf8 != '\0') {
  ------------------
  |  Branch (106:12): [True: 12.6k, False: 536]
  ------------------
  107|       |        /* Get UTF-8 sequence length from first byte. */
  108|  12.6k|        chlen = KRB5_UTF8_CHARLEN2(utf8, chlen);
  ------------------
  |  |  109|  12.6k|#define KRB5_UTF8_CHARLEN2(p, l) (                                      \
  |  |  110|  12.6k|        ((l = KRB5_UTF8_CHARLEN(p)) < 3 ||                              \
  |  |  ------------------
  |  |  |  |  102|  12.6k|#define KRB5_UTF8_CHARLEN(p) (KRB5_UTF8_ISASCII(p) ? 1 :                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|  12.6k|#define KRB5_UTF8_ISASCII(p) (!(KRB5_UTF8_BV(p) & 0x80))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  100|  12.6k|#define KRB5_UTF8_BV(p) (*(const unsigned char *)(p))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:30): [True: 11.5k, False: 1.13k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  103|  12.6k|                              krb5int_utf8_lentab[KRB5_UTF8_BV(p) ^ 0x80])
  |  |  |  |  ------------------
  |  |  |  |  |  |  100|  1.13k|#define KRB5_UTF8_BV(p) (*(const unsigned char *)(p))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (110:10): [True: 12.2k, False: 437]
  |  |  ------------------
  |  |  111|  12.6k|         (krb5int_utf8_mintab[KRB5_UTF8_BV(p) & 0x1f] & (p)[1])) ?      \
  |  |  ------------------
  |  |  |  |  100|    437|#define KRB5_UTF8_BV(p) (*(const unsigned char *)(p))
  |  |  ------------------
  |  |  |  Branch (111:10): [True: 421, False: 16]
  |  |  ------------------
  |  |  112|  12.6k|        l : 0)
  ------------------
  109|  12.6k|        if (chlen == 0)
  ------------------
  |  Branch (109:13): [True: 238, False: 12.4k]
  ------------------
  110|    238|            goto invalid;
  111|       |
  112|       |        /* First byte minus length tag */
  113|  12.4k|        ch = (krb5_ucs4)(utf8[0] & mask[chlen]);
  114|       |
  115|  13.8k|        for (i = 1; i < chlen; i++) {
  ------------------
  |  Branch (115:21): [True: 1.49k, False: 12.3k]
  ------------------
  116|       |            /* Subsequent bytes must start with 10. */
  117|  1.49k|            if ((utf8[i] & 0xc0) != 0x80)
  ------------------
  |  Branch (117:17): [True: 115, False: 1.38k]
  ------------------
  118|    115|                goto invalid;
  119|       |
  120|       |            /* 6 bits of data in each subsequent byte */
  121|  1.38k|            ch <<= 6;
  122|  1.38k|            ch |= (krb5_ucs4)(utf8[i] & 0x3f);
  123|  1.38k|        }
  124|  12.3k|        if (!IS_VALID_UNICODE(ch))
  ------------------
  |  |   78|  12.3k|#define IS_VALID_UNICODE(c) ((c) <= 0x10FFFF && !IS_SURROGATE(c))
  |  |  ------------------
  |  |  |  |   77|  12.2k|#define IS_SURROGATE(c) ((c) >= 0xD800 && (c) <= 0xDFFF)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (77:26): [True: 357, False: 11.9k]
  |  |  |  |  |  Branch (77:43): [True: 14, False: 343]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (78:30): [True: 12.2k, False: 3]
  |  |  ------------------
  ------------------
  125|     17|            goto invalid;
  126|       |
  127|       |        /* Characters in the basic multilingual plane are encoded using two
  128|       |         * bytes; other characters are encoded using four bytes. */
  129|  12.2k|        if (IS_BMP(ch)) {
  ------------------
  |  |   82|  12.2k|#define IS_BMP(c) ((c) <= 0xFFFF && !IS_SURROGATE(c))
  |  |  ------------------
  |  |  |  |   77|  12.0k|#define IS_SURROGATE(c) ((c) >= 0xD800 && (c) <= 0xDFFF)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (77:26): [True: 151, False: 11.9k]
  |  |  |  |  |  Branch (77:43): [True: 0, False: 151]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (82:20): [True: 12.0k, False: 192]
  |  |  ------------------
  ------------------
  130|  12.0k|            k5_buf_add_uint16_le(&buf, ch);
  131|  12.0k|        } else {
  132|       |            /* 0x10000 is subtracted from ch; then the high ten bits plus
  133|       |             * 0xD800 and the low ten bits plus 0xDC00 are the surrogates. */
  134|    192|            k5_buf_add_uint16_le(&buf, HIGH_SURROGATE(ch));
  ------------------
  |  |   87|    192|#define HIGH_SURROGATE(c) (0xD800 | (((c) - BASE) >> 10))
  |  |  ------------------
  |  |  |  |   86|    192|#define BASE 0x10000
  |  |  ------------------
  ------------------
  135|    192|            k5_buf_add_uint16_le(&buf, LOW_SURROGATE(ch));
  ------------------
  |  |   88|    192|#define LOW_SURROGATE(c) (0xDC00 | (((c) - BASE) & 0x3FF))
  |  |  ------------------
  |  |  |  |   86|    192|#define BASE 0x10000
  |  |  ------------------
  ------------------
  136|    192|        }
  137|       |
  138|       |        /* Move to next UTF-8 character. */
  139|  12.2k|        utf8 += chlen;
  140|  12.2k|    }
  141|       |
  142|    536|    *utf16_out = buf.data;
  143|    536|    *nbytes_out = buf.len;
  144|    536|    return 0;
  145|       |
  146|    370|invalid:
  147|    370|    k5_buf_free(&buf);
  148|       |    return EINVAL;
  149|    906|}
k5_utf16le_to_utf8:
  153|    906|{
  154|    906|    struct k5buf buf;
  155|    906|    struct k5input in;
  156|    906|    uint16_t ch1, ch2;
  157|    906|    krb5_ucs4 ch;
  158|    906|    size_t chlen;
  159|    906|    void *p;
  160|       |
  161|    906|    *utf8_out = NULL;
  162|       |
  163|    906|    if (nbytes % 2 != 0)
  ------------------
  |  Branch (163:9): [True: 237, False: 669]
  ------------------
  164|    237|        return EINVAL;
  165|       |
  166|    669|    k5_buf_init_dynamic(&buf);
  167|    669|    k5_input_init(&in, utf16bytes, nbytes);
  168|  7.32k|    while (!in.status && in.len > 0) {
  ------------------
  |  Branch (168:12): [True: 7.32k, False: 0]
  |  Branch (168:26): [True: 6.71k, False: 607]
  ------------------
  169|       |        /* Get the next character or high surrogate.  A low surrogate without a
  170|       |         * preceding high surrogate is invalid. */
  171|  6.71k|        ch1 = k5_input_get_uint16_le(&in);
  172|  6.71k|        if (IS_LOW_SURROGATE(ch1))
  ------------------
  |  |   73|  6.71k|#define IS_LOW_SURROGATE(c) ((c) >= 0xDC00 && (c) <= 0xDFFF)
  |  |  ------------------
  |  |  |  Branch (73:30): [True: 570, False: 6.14k]
  |  |  |  Branch (73:47): [True: 13, False: 557]
  |  |  ------------------
  ------------------
  173|     13|            goto invalid;
  174|  6.70k|        if (IS_HIGH_SURROGATE(ch1)) {
  ------------------
  |  |   70|  6.70k|#define IS_HIGH_SURROGATE(c) ((c) >= 0xD800 && (c) <= 0xDBFF)
  |  |  ------------------
  |  |  |  Branch (70:31): [True: 709, False: 5.99k]
  |  |  |  Branch (70:48): [True: 152, False: 557]
  |  |  ------------------
  ------------------
  175|       |            /* Get the low surrogate and combine the pair. */
  176|    152|            ch2 = k5_input_get_uint16_le(&in);
  177|    152|            if (!IS_LOW_SURROGATE(ch2))
  ------------------
  |  |   73|    152|#define IS_LOW_SURROGATE(c) ((c) >= 0xDC00 && (c) <= 0xDFFF)
  |  |  ------------------
  |  |  |  Branch (73:30): [True: 108, False: 44]
  |  |  |  Branch (73:47): [True: 103, False: 5]
  |  |  ------------------
  ------------------
  178|     49|                goto invalid;
  179|    103|            ch = COMPOSE(ch1, ch2);
  ------------------
  |  |   89|    103|#define COMPOSE(c1, c2) (BASE + ((((c1) & 0x3FF) << 10) | ((c2) & 0x3FF)))
  |  |  ------------------
  |  |  |  |   86|    103|#define BASE 0x10000
  |  |  ------------------
  ------------------
  180|  6.55k|        } else {
  181|  6.55k|            ch = ch1;
  182|  6.55k|        }
  183|       |
  184|  6.65k|        chlen = krb5int_ucs4_to_utf8(ch, NULL);
  185|  6.65k|        p = k5_buf_get_space(&buf, chlen);
  186|  6.65k|        if (p == NULL)
  ------------------
  |  Branch (186:13): [True: 0, False: 6.65k]
  ------------------
  187|      0|            return ENOMEM;
  188|  6.65k|        (void)krb5int_ucs4_to_utf8(ch, p);
  189|  6.65k|    }
  190|       |
  191|    607|    if (in.status)
  ------------------
  |  Branch (191:9): [True: 0, False: 607]
  ------------------
  192|      0|        goto invalid;
  193|       |
  194|    607|    *utf8_out = k5_buf_cstring(&buf);
  195|    607|    return (*utf8_out == NULL) ? ENOMEM : 0;
  ------------------
  |  Branch (195:12): [True: 0, False: 607]
  ------------------
  196|       |
  197|     62|invalid:
  198|     62|    k5_buf_free(&buf);
  199|       |    return EINVAL;
  200|    607|}

