c2i_ASN1_INTEGER:
  282|  38.0k|{
  283|  38.0k|    ASN1_INTEGER *ret = NULL;
  284|  38.0k|    size_t r;
  285|  38.0k|    int neg;
  286|       |
  287|  38.0k|    r = c2i_ibuf(NULL, NULL, *pp, len);
  288|       |
  289|  38.0k|    if (r == 0)
  ------------------
  |  Branch (289:9): [True: 1.41k, False: 36.5k]
  ------------------
  290|  1.41k|        return NULL;
  291|       |
  292|  36.5k|    if ((a == NULL) || ((*a) == NULL)) {
  ------------------
  |  Branch (292:9): [True: 0, False: 36.5k]
  |  Branch (292:24): [True: 36.5k, False: 0]
  ------------------
  293|  36.5k|        ret = ASN1_INTEGER_new();
  294|  36.5k|        if (ret == NULL)
  ------------------
  |  Branch (294:13): [True: 0, False: 36.5k]
  ------------------
  295|      0|            return NULL;
  296|  36.5k|        ret->type = V_ASN1_INTEGER;
  ------------------
  |  |   52|  36.5k|# define V_ASN1_INTEGER                  2
  ------------------
  297|  36.5k|    } else
  298|      0|        ret = *a;
  299|       |
  300|  36.5k|    if (ASN1_STRING_set(ret, NULL, r) == 0)
  ------------------
  |  Branch (300:9): [True: 0, False: 36.5k]
  ------------------
  301|      0|        goto err;
  302|       |
  303|  36.5k|    c2i_ibuf(ret->data, &neg, *pp, len);
  304|       |
  305|  36.5k|    if (neg)
  ------------------
  |  Branch (305:9): [True: 32.3k, False: 4.25k]
  ------------------
  306|  32.3k|        ret->type |= V_ASN1_NEG;
  ------------------
  |  |   85|  32.3k|# define V_ASN1_NEG                      0x100
  ------------------
  307|       |
  308|  36.5k|    *pp += len;
  309|  36.5k|    if (a != NULL)
  ------------------
  |  Branch (309:9): [True: 36.5k, False: 0]
  ------------------
  310|  36.5k|        (*a) = ret;
  311|  36.5k|    return ret;
  312|      0| err:
  313|      0|    ASN1err(ASN1_F_C2I_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  314|      0|    if ((a == NULL) || (*a != ret))
  ------------------
  |  Branch (314:9): [True: 0, False: 0]
  |  Branch (314:24): [True: 0, False: 0]
  ------------------
  315|      0|        ASN1_INTEGER_free(ret);
  316|      0|    return NULL;
  317|  36.5k|}
a_int.c:twos_complement:
   78|  2.57k|{
   79|  2.57k|    unsigned int carry = pad & 1;
   80|       |
   81|       |    /* Begin at the end of the encoding */
   82|  2.57k|    dst += len;
   83|  2.57k|    src += len;
   84|       |    /* two's complement value: ~value + 1 */
   85|  4.52M|    while (len-- != 0) {
  ------------------
  |  Branch (85:12): [True: 4.52M, False: 2.57k]
  ------------------
   86|  4.52M|        *(--dst) = (unsigned char)(carry += *(--src) ^ pad);
   87|  4.52M|        carry >>= 8;
   88|  4.52M|    }
   89|  2.57k|}
a_int.c:c2i_ibuf:
  150|  74.5k|{
  151|  74.5k|    int neg, pad;
  152|       |    /* Zero content length is illegal */
  153|  74.5k|    if (plen == 0) {
  ------------------
  |  Branch (153:9): [True: 1.10k, False: 73.4k]
  ------------------
  154|  1.10k|        ASN1err(ASN1_F_C2I_IBUF, ASN1_R_ILLEGAL_ZERO_CONTENT);
  ------------------
  |  |  111|  1.10k|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|  1.10k|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  155|  1.10k|        return 0;
  156|  1.10k|    }
  157|  73.4k|    neg = p[0] & 0x80;
  158|  73.4k|    if (pneg)
  ------------------
  |  Branch (158:9): [True: 36.5k, False: 36.8k]
  ------------------
  159|  36.5k|        *pneg = neg;
  160|       |    /* Handle common case where length is 1 octet separately */
  161|  73.4k|    if (plen == 1) {
  ------------------
  |  Branch (161:9): [True: 68.0k, False: 5.44k]
  ------------------
  162|  68.0k|        if (b != NULL) {
  ------------------
  |  Branch (162:13): [True: 34.0k, False: 34.0k]
  ------------------
  163|  34.0k|            if (neg)
  ------------------
  |  Branch (163:17): [True: 31.3k, False: 2.71k]
  ------------------
  164|  31.3k|                b[0] = (p[0] ^ 0xFF) + 1;
  165|  2.71k|            else
  166|  2.71k|                b[0] = p[0];
  167|  34.0k|        }
  168|  68.0k|        return 1;
  169|  68.0k|    }
  170|       |
  171|  5.44k|    pad = 0;
  172|  5.44k|    if (p[0] == 0) {
  ------------------
  |  Branch (172:9): [True: 775, False: 4.67k]
  ------------------
  173|    775|        pad = 1;
  174|  4.67k|    } else if (p[0] == 0xFF) {
  ------------------
  |  Branch (174:16): [True: 892, False: 3.78k]
  ------------------
  175|    892|        size_t i;
  176|       |
  177|       |        /*
  178|       |         * Special case [of "one less minimal negative" for given length]:
  179|       |         * if any other bytes non zero it was padded, otherwise not.
  180|       |         */
  181|  5.44M|        for (pad = 0, i = 1; i < plen; i++)
  ------------------
  |  Branch (181:30): [True: 5.44M, False: 892]
  ------------------
  182|  5.44M|            pad |= p[i];
  183|    892|        pad = pad != 0 ? 1 : 0;
  ------------------
  |  Branch (183:15): [True: 722, False: 170]
  ------------------
  184|    892|    }
  185|       |    /* reject illegal padding: first two octets MSB can't match */
  186|  5.44k|    if (pad && (neg == (p[1] & 0x80))) {
  ------------------
  |  Branch (186:9): [True: 1.49k, False: 3.95k]
  |  Branch (186:16): [True: 303, False: 1.19k]
  ------------------
  187|    303|        ASN1err(ASN1_F_C2I_IBUF, ASN1_R_ILLEGAL_PADDING);
  ------------------
  |  |  111|    303|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|    303|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  188|    303|        return 0;
  189|    303|    }
  190|       |
  191|       |    /* skip over pad */
  192|  5.14k|    p += pad;
  193|  5.14k|    plen -= pad;
  194|       |
  195|  5.14k|    if (b != NULL)
  ------------------
  |  Branch (195:9): [True: 2.57k, False: 2.57k]
  ------------------
  196|  2.57k|        twos_complement(b, p, plen, neg ? 0xffU : 0);
  ------------------
  |  Branch (196:37): [True: 1.03k, False: 1.54k]
  ------------------
  197|       |
  198|  5.14k|    return plen;
  199|  5.44k|}

i2t_ASN1_OBJECT:
  181|  10.5k|{
  182|  10.5k|    return OBJ_obj2txt(buf, buf_len, a, 0);
  183|  10.5k|}
i2a_ASN1_OBJECT:
  186|  9.41k|{
  187|  9.41k|    char buf[80], *p = buf;
  188|  9.41k|    int i;
  189|       |
  190|  9.41k|    if ((a == NULL) || (a->data == NULL))
  ------------------
  |  Branch (190:9): [True: 0, False: 9.41k]
  |  Branch (190:24): [True: 0, False: 9.41k]
  ------------------
  191|      0|        return BIO_write(bp, "NULL", 4);
  192|  9.41k|    i = i2t_ASN1_OBJECT(buf, sizeof(buf), a);
  193|  9.41k|    if (i > (int)(sizeof(buf) - 1)) {
  ------------------
  |  Branch (193:9): [True: 1.08k, False: 8.32k]
  ------------------
  194|  1.08k|        if ((p = OPENSSL_malloc(i + 1)) == NULL) {
  ------------------
  |  |  118|  1.08k|        CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  1.08k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  1.08k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  |  Branch (194:13): [True: 0, False: 1.08k]
  ------------------
  195|      0|            ASN1err(ASN1_F_I2A_ASN1_OBJECT, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  196|      0|            return -1;
  197|      0|        }
  198|  1.08k|        i2t_ASN1_OBJECT(p, i + 1, a);
  199|  1.08k|    }
  200|  9.41k|    if (i <= 0) {
  ------------------
  |  Branch (200:9): [True: 750, False: 8.66k]
  ------------------
  201|    750|        i = BIO_write(bp, "<INVALID>", 9);
  202|    750|        i += BIO_dump(bp, (const char *)a->data, a->length);
  203|    750|        return i;
  204|    750|    }
  205|  8.66k|    BIO_write(bp, p, i);
  206|  8.66k|    if (p != buf)
  ------------------
  |  Branch (206:9): [True: 1.08k, False: 7.57k]
  ------------------
  207|  1.08k|        OPENSSL_free(p);
  ------------------
  |  |  128|  1.08k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  1.08k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  1.08k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  208|  8.66k|    return i;
  209|  9.41k|}
d2i_ASN1_OBJECT:
  213|  17.5k|{
  214|  17.5k|    const unsigned char *p;
  215|  17.5k|    long len;
  216|  17.5k|    int tag, xclass;
  217|  17.5k|    int inf, i;
  218|  17.5k|    ASN1_OBJECT *ret = NULL;
  219|  17.5k|    p = *pp;
  220|  17.5k|    inf = ASN1_get_object(&p, &len, &tag, &xclass, length);
  221|  17.5k|    if (inf & 0x80) {
  ------------------
  |  Branch (221:9): [True: 6.26k, False: 11.2k]
  ------------------
  222|  6.26k|        i = ASN1_R_BAD_OBJECT_HEADER;
  ------------------
  |  |  146|  6.26k|# define ASN1_R_BAD_OBJECT_HEADER                         102
  ------------------
  223|  6.26k|        goto err;
  224|  6.26k|    }
  225|       |
  226|  11.2k|    if (tag != V_ASN1_OBJECT) {
  ------------------
  |  |   56|  11.2k|# define V_ASN1_OBJECT                   6
  ------------------
  |  Branch (226:9): [True: 0, False: 11.2k]
  ------------------
  227|      0|        i = ASN1_R_EXPECTING_AN_OBJECT;
  ------------------
  |  |  163|      0|# define ASN1_R_EXPECTING_AN_OBJECT                       116
  ------------------
  228|      0|        goto err;
  229|      0|    }
  230|  11.2k|    ret = c2i_ASN1_OBJECT(a, &p, len);
  231|  11.2k|    if (ret)
  ------------------
  |  Branch (231:9): [True: 9.41k, False: 1.87k]
  ------------------
  232|  9.41k|        *pp = p;
  233|  11.2k|    return ret;
  234|  6.26k| err:
  235|  6.26k|    ASN1err(ASN1_F_D2I_ASN1_OBJECT, i);
  ------------------
  |  |  111|  6.26k|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|  6.26k|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  236|  6.26k|    return NULL;
  237|  11.2k|}
c2i_ASN1_OBJECT:
  241|  11.2k|{
  242|  11.2k|    ASN1_OBJECT *ret = NULL, tobj;
  243|  11.2k|    const unsigned char *p;
  244|  11.2k|    unsigned char *data;
  245|  11.2k|    int i, length;
  246|       |
  247|       |    /*
  248|       |     * Sanity check OID encoding. Need at least one content octet. MSB must
  249|       |     * be clear in the last octet. can't have leading 0x80 in subidentifiers,
  250|       |     * see: X.690 8.19.2
  251|       |     */
  252|  11.2k|    if (len <= 0 || len > INT_MAX || pp == NULL || (p = *pp) == NULL ||
  ------------------
  |  Branch (252:9): [True: 947, False: 10.3k]
  |  Branch (252:21): [True: 0, False: 10.3k]
  |  Branch (252:38): [True: 0, False: 10.3k]
  |  Branch (252:52): [True: 0, False: 10.3k]
  ------------------
  253|  11.2k|        p[len - 1] & 0x80) {
  ------------------
  |  Branch (253:9): [True: 425, False: 9.91k]
  ------------------
  254|  1.37k|        ASN1err(ASN1_F_C2I_ASN1_OBJECT, ASN1_R_INVALID_OBJECT_ENCODING);
  ------------------
  |  |  111|  1.37k|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|  1.37k|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  255|  1.37k|        return NULL;
  256|  1.37k|    }
  257|       |    /* Now 0 < len <= INT_MAX, so the cast is safe. */
  258|  9.91k|    length = (int)len;
  259|       |    /*
  260|       |     * Try to lookup OID in table: these are all valid encodings so if we get
  261|       |     * a match we know the OID is valid.
  262|       |     */
  263|  9.91k|    tobj.nid = NID_undef;
  ------------------
  |  |   14|  9.91k|#define NID_undef                       0
  ------------------
  264|  9.91k|    tobj.data = p;
  265|  9.91k|    tobj.length = length;
  266|  9.91k|    tobj.flags = 0;
  267|  9.91k|    i = OBJ_obj2nid(&tobj);
  268|  9.91k|    if (i != NID_undef) {
  ------------------
  |  |   14|  9.91k|#define NID_undef                       0
  ------------------
  |  Branch (268:9): [True: 3.62k, False: 6.29k]
  ------------------
  269|       |        /*
  270|       |         * Return shared registered OID object: this improves efficiency
  271|       |         * because we don't have to return a dynamically allocated OID
  272|       |         * and NID lookups can use the cached value.
  273|       |         */
  274|  3.62k|        ret = OBJ_nid2obj(i);
  275|  3.62k|        if (a) {
  ------------------
  |  Branch (275:13): [True: 3.62k, False: 0]
  ------------------
  276|  3.62k|            ASN1_OBJECT_free(*a);
  277|  3.62k|            *a = ret;
  278|  3.62k|        }
  279|  3.62k|        *pp += len;
  280|  3.62k|        return ret;
  281|  3.62k|    }
  282|  7.83M|    for (i = 0; i < length; i++, p++) {
  ------------------
  |  Branch (282:17): [True: 7.82M, False: 5.79k]
  ------------------
  283|  7.82M|        if (*p == 0x80 && (!i || !(p[-1] & 0x80))) {
  ------------------
  |  Branch (283:13): [True: 23.2k, False: 7.80M]
  |  Branch (283:28): [True: 267, False: 22.9k]
  |  Branch (283:34): [True: 235, False: 22.7k]
  ------------------
  284|    502|            ASN1err(ASN1_F_C2I_ASN1_OBJECT, ASN1_R_INVALID_OBJECT_ENCODING);
  ------------------
  |  |  111|    502|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|    502|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  285|    502|            return NULL;
  286|    502|        }
  287|  7.82M|    }
  288|       |
  289|  5.79k|    if ((a == NULL) || ((*a) == NULL) ||
  ------------------
  |  Branch (289:9): [True: 0, False: 5.79k]
  |  Branch (289:24): [True: 1.51k, False: 4.28k]
  ------------------
  290|  5.79k|        !((*a)->flags & ASN1_OBJECT_FLAG_DYNAMIC)) {
  ------------------
  |  |   91|  4.28k|# define ASN1_OBJECT_FLAG_DYNAMIC         0x01/* internal use */
  ------------------
  |  Branch (290:9): [True: 938, False: 3.34k]
  ------------------
  291|  2.45k|        if ((ret = ASN1_OBJECT_new()) == NULL)
  ------------------
  |  Branch (291:13): [True: 0, False: 2.45k]
  ------------------
  292|      0|            return NULL;
  293|  3.34k|    } else {
  294|  3.34k|        ret = (*a);
  295|  3.34k|    }
  296|       |
  297|  5.79k|    p = *pp;
  298|       |    /* detach data from object */
  299|  5.79k|    data = (unsigned char *)ret->data;
  300|  5.79k|    ret->data = NULL;
  301|       |    /* once detached we can change it */
  302|  5.79k|    if ((data == NULL) || (ret->length < length)) {
  ------------------
  |  Branch (302:9): [True: 2.45k, False: 3.34k]
  |  Branch (302:27): [True: 365, False: 2.98k]
  ------------------
  303|  2.81k|        ret->length = 0;
  304|  2.81k|        OPENSSL_free(data);
  ------------------
  |  |  128|  2.81k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  2.81k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  2.81k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  305|  2.81k|        data = OPENSSL_malloc(length);
  ------------------
  |  |  118|  2.81k|        CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  2.81k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  2.81k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  306|  2.81k|        if (data == NULL) {
  ------------------
  |  Branch (306:13): [True: 0, False: 2.81k]
  ------------------
  307|      0|            i = ERR_R_MALLOC_FAILURE;
  ------------------
  |  |  199|      0|# define ERR_R_MALLOC_FAILURE                    (1|ERR_R_FATAL)
  |  |  ------------------
  |  |  |  |  198|      0|# define ERR_R_FATAL                             64
  |  |  ------------------
  ------------------
  308|      0|            goto err;
  309|      0|        }
  310|  2.81k|        ret->flags |= ASN1_OBJECT_FLAG_DYNAMIC_DATA;
  ------------------
  |  |   94|  2.81k|# define ASN1_OBJECT_FLAG_DYNAMIC_DATA    0x08/* internal use */
  ------------------
  311|  2.81k|    }
  312|  5.79k|    memcpy(data, p, length);
  313|       |    /* If there are dynamic strings, free them here, and clear the flag */
  314|  5.79k|    if ((ret->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) != 0) {
  ------------------
  |  |   93|  5.79k|# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */
  ------------------
  |  Branch (314:9): [True: 0, False: 5.79k]
  ------------------
  315|      0|        OPENSSL_free((char *)ret->sn);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  316|      0|        OPENSSL_free((char *)ret->ln);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  317|      0|        ret->flags &= ~ASN1_OBJECT_FLAG_DYNAMIC_STRINGS;
  ------------------
  |  |   93|      0|# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */
  ------------------
  318|      0|    }
  319|       |    /* reattach data to object, after which it remains const */
  320|  5.79k|    ret->data = data;
  321|  5.79k|    ret->length = length;
  322|  5.79k|    ret->sn = NULL;
  323|  5.79k|    ret->ln = NULL;
  324|       |    /* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
  325|  5.79k|    p += length;
  326|       |
  327|  5.79k|    if (a != NULL)
  ------------------
  |  Branch (327:9): [True: 5.79k, False: 0]
  ------------------
  328|  5.79k|        (*a) = ret;
  329|  5.79k|    *pp = p;
  330|  5.79k|    return ret;
  331|      0| err:
  332|      0|    ASN1err(ASN1_F_C2I_ASN1_OBJECT, i);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  333|      0|    if ((a == NULL) || (*a != ret))
  ------------------
  |  Branch (333:9): [True: 0, False: 0]
  |  Branch (333:24): [True: 0, False: 0]
  ------------------
  334|      0|        ASN1_OBJECT_free(ret);
  335|      0|    return NULL;
  336|  5.79k|}
ASN1_OBJECT_new:
  339|  2.45k|{
  340|  2.45k|    ASN1_OBJECT *ret;
  341|       |
  342|  2.45k|    ret = OPENSSL_zalloc(sizeof(*ret));
  ------------------
  |  |  120|  2.45k|        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  2.45k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  2.45k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  343|  2.45k|    if (ret == NULL) {
  ------------------
  |  Branch (343:9): [True: 0, False: 2.45k]
  ------------------
  344|      0|        ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  345|      0|        return NULL;
  346|      0|    }
  347|  2.45k|    ret->flags = ASN1_OBJECT_FLAG_DYNAMIC;
  ------------------
  |  |   91|  2.45k|# define ASN1_OBJECT_FLAG_DYNAMIC         0x01/* internal use */
  ------------------
  348|  2.45k|    return ret;
  349|  2.45k|}
ASN1_OBJECT_free:
  352|  11.8k|{
  353|  11.8k|    if (a == NULL)
  ------------------
  |  Branch (353:9): [True: 6.73k, False: 5.13k]
  ------------------
  354|  6.73k|        return;
  355|  5.13k|    if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) {
  ------------------
  |  |   93|  5.13k|# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */
  ------------------
  |  Branch (355:9): [True: 0, False: 5.13k]
  ------------------
  356|      0|#ifndef CONST_STRICT            /* disable purely for compile-time strict
  357|       |                                 * const checking. Doing this on a "real"
  358|       |                                 * compile will cause memory leaks */
  359|      0|        OPENSSL_free((void*)a->sn);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  360|      0|        OPENSSL_free((void*)a->ln);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  361|      0|#endif
  362|      0|        a->sn = a->ln = NULL;
  363|      0|    }
  364|  5.13k|    if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) {
  ------------------
  |  |   94|  5.13k|# define ASN1_OBJECT_FLAG_DYNAMIC_DATA    0x08/* internal use */
  ------------------
  |  Branch (364:9): [True: 2.45k, False: 2.68k]
  ------------------
  365|  2.45k|        OPENSSL_free((void*)a->data);
  ------------------
  |  |  128|  2.45k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  2.45k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  2.45k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  366|  2.45k|        a->data = NULL;
  367|  2.45k|        a->length = 0;
  368|  2.45k|    }
  369|  5.13k|    if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC)
  ------------------
  |  |   91|  5.13k|# define ASN1_OBJECT_FLAG_DYNAMIC         0x01/* internal use */
  ------------------
  |  Branch (369:9): [True: 2.45k, False: 2.68k]
  ------------------
  370|  2.45k|        OPENSSL_free(a);
  ------------------
  |  |  128|  2.45k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  2.45k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  2.45k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  371|  5.13k|}

ERR_load_ASN1_strings:
  344|      2|{
  345|      2|#ifndef OPENSSL_NO_ERR
  346|      2|    if (ERR_func_error_string(ASN1_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (346:9): [True: 2, False: 0]
  ------------------
  347|      2|        ERR_load_strings_const(ASN1_str_functs);
  348|      2|        ERR_load_strings_const(ASN1_str_reasons);
  349|      2|    }
  350|      2|#endif
  351|      2|    return 1;
  352|      2|}

ASN1_get_object:
   46|   135k|{
   47|   135k|    int i, ret;
   48|   135k|    long l;
   49|   135k|    const unsigned char *p = *pp;
   50|   135k|    int tag, xclass, inf;
   51|   135k|    long max = omax;
   52|       |
   53|   135k|    if (!max)
  ------------------
  |  Branch (53:9): [True: 0, False: 135k]
  ------------------
   54|      0|        goto err;
   55|   135k|    ret = (*p & V_ASN1_CONSTRUCTED);
  ------------------
  |  |   40|   135k|# define V_ASN1_CONSTRUCTED              0x20
  ------------------
   56|   135k|    xclass = (*p & V_ASN1_PRIVATE);
  ------------------
  |  |   38|   135k|# define V_ASN1_PRIVATE                  0xc0
  ------------------
   57|   135k|    i = *p & V_ASN1_PRIMITIVE_TAG;
  ------------------
  |  |   41|   135k|# define V_ASN1_PRIMITIVE_TAG            0x1f
  ------------------
   58|   135k|    if (i == V_ASN1_PRIMITIVE_TAG) { /* high-tag */
  ------------------
  |  |   41|   135k|# define V_ASN1_PRIMITIVE_TAG            0x1f
  ------------------
  |  Branch (58:9): [True: 2.02k, False: 133k]
  ------------------
   59|  2.02k|        p++;
   60|  2.02k|        if (--max == 0)
  ------------------
  |  Branch (60:13): [True: 8, False: 2.01k]
  ------------------
   61|      8|            goto err;
   62|  2.01k|        l = 0;
   63|  3.35k|        while (*p & 0x80) {
  ------------------
  |  Branch (63:16): [True: 1.36k, False: 1.99k]
  ------------------
   64|  1.36k|            l <<= 7L;
   65|  1.36k|            l |= *(p++) & 0x7f;
   66|  1.36k|            if (--max == 0)
  ------------------
  |  Branch (66:17): [True: 13, False: 1.35k]
  ------------------
   67|     13|                goto err;
   68|  1.35k|            if (l > (INT_MAX >> 7L))
  ------------------
  |  Branch (68:17): [True: 13, False: 1.34k]
  ------------------
   69|     13|                goto err;
   70|  1.35k|        }
   71|  1.99k|        l <<= 7L;
   72|  1.99k|        l |= *(p++) & 0x7f;
   73|  1.99k|        tag = (int)l;
   74|  1.99k|        if (--max == 0)
  ------------------
  |  Branch (74:13): [True: 6, False: 1.98k]
  ------------------
   75|      6|            goto err;
   76|   133k|    } else {
   77|   133k|        tag = i;
   78|   133k|        p++;
   79|   133k|        if (--max == 0)
  ------------------
  |  Branch (79:13): [True: 82, False: 133k]
  ------------------
   80|     82|            goto err;
   81|   133k|    }
   82|   135k|    *ptag = tag;
   83|   135k|    *pclass = xclass;
   84|   135k|    if (!asn1_get_length(&p, &inf, plength, max))
  ------------------
  |  Branch (84:9): [True: 7.05k, False: 128k]
  ------------------
   85|  7.05k|        goto err;
   86|       |
   87|   128k|    if (inf && !(ret & V_ASN1_CONSTRUCTED))
  ------------------
  |  |   40|  4.52k|# define V_ASN1_CONSTRUCTED              0x20
  ------------------
  |  Branch (87:9): [True: 4.52k, False: 124k]
  |  Branch (87:16): [True: 3, False: 4.52k]
  ------------------
   88|      3|        goto err;
   89|       |
   90|   128k|    if (*plength > (omax - (p - *pp))) {
  ------------------
  |  Branch (90:9): [True: 184, False: 128k]
  ------------------
   91|    184|        ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_TOO_LONG);
  ------------------
  |  |  111|    184|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|    184|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   92|       |        /*
   93|       |         * Set this so that even if things are not long enough the values are
   94|       |         * set correctly
   95|       |         */
   96|    184|        ret |= 0x80;
   97|    184|    }
   98|   128k|    *pp = p;
   99|   128k|    return ret | inf;
  100|  7.17k| err:
  101|  7.17k|    ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_HEADER_TOO_LONG);
  ------------------
  |  |  111|  7.17k|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|  7.17k|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  102|  7.17k|    return 0x80;
  103|   128k|}
ASN1_STRING_set:
  272|  38.4k|{
  273|  38.4k|    unsigned char *c;
  274|  38.4k|    const char *data = _data;
  275|  38.4k|    size_t len;
  276|       |
  277|  38.4k|    if (len_in < 0) {
  ------------------
  |  Branch (277:9): [True: 0, False: 38.4k]
  ------------------
  278|      0|        if (data == NULL)
  ------------------
  |  Branch (278:13): [True: 0, False: 0]
  ------------------
  279|      0|            return 0;
  280|      0|        len = strlen(data);
  281|  38.4k|    } else {
  282|  38.4k|        len = (size_t)len_in;
  283|  38.4k|    }
  284|       |    /*
  285|       |     * Verify that the length fits within an integer for assignment to
  286|       |     * str->length below.  The additional 1 is subtracted to allow for the
  287|       |     * '\0' terminator even though this isn't strictly necessary.
  288|       |     */
  289|  38.4k|    if (len > INT_MAX - 1) {
  ------------------
  |  Branch (289:9): [True: 0, False: 38.4k]
  ------------------
  290|      0|        ASN1err(0, ASN1_R_TOO_LARGE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  291|      0|        return 0;
  292|      0|    }
  293|  38.4k|    if ((size_t)str->length <= len || str->data == NULL) {
  ------------------
  |  Branch (293:9): [True: 38.4k, False: 0]
  |  Branch (293:39): [True: 0, False: 0]
  ------------------
  294|  38.4k|        c = str->data;
  295|  38.4k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  296|       |        /* No NUL terminator in fuzzing builds */
  297|  38.4k|        str->data = OPENSSL_realloc(c, len != 0 ? len : 1);
  ------------------
  |  |  122|  76.9k|        CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  38.4k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  38.4k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  |  |  |  Branch (122:30): [True: 37.6k, False: 853]
  |  |  ------------------
  ------------------
  298|       |#else
  299|       |        str->data = OPENSSL_realloc(c, len + 1);
  300|       |#endif
  301|  38.4k|        if (str->data == NULL) {
  ------------------
  |  Branch (301:13): [True: 0, False: 38.4k]
  ------------------
  302|      0|            ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  303|      0|            str->data = c;
  304|      0|            return 0;
  305|      0|        }
  306|  38.4k|    }
  307|  38.4k|    str->length = len;
  308|  38.4k|    if (data != NULL) {
  ------------------
  |  Branch (308:9): [True: 1.89k, False: 36.5k]
  ------------------
  309|  1.89k|        memcpy(str->data, data, len);
  310|  1.89k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  311|       |        /* Set the unused byte to something non NUL and printable. */
  312|  1.89k|        if (len == 0)
  ------------------
  |  Branch (312:13): [True: 853, False: 1.04k]
  ------------------
  313|    853|            str->data[len] = '~';
  314|       |#else
  315|       |        /*
  316|       |         * Add a NUL terminator. This should not be necessary - but we add it as
  317|       |         * a safety precaution
  318|       |         */
  319|       |        str->data[len] = '\0';
  320|       |#endif
  321|  1.89k|    }
  322|  38.4k|    return 1;
  323|  38.4k|}
ASN1_STRING_type_new:
  338|  38.4k|{
  339|  38.4k|    ASN1_STRING *ret;
  340|       |
  341|  38.4k|    ret = OPENSSL_zalloc(sizeof(*ret));
  ------------------
  |  |  120|  38.4k|        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  38.4k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  38.4k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  342|  38.4k|    if (ret == NULL) {
  ------------------
  |  Branch (342:9): [True: 0, False: 38.4k]
  ------------------
  343|      0|        ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  344|      0|        return NULL;
  345|      0|    }
  346|  38.4k|    ret->type = type;
  347|  38.4k|    return ret;
  348|  38.4k|}
asn1_string_embed_free:
  351|  38.4k|{
  352|  38.4k|    if (a == NULL)
  ------------------
  |  Branch (352:9): [True: 0, False: 38.4k]
  ------------------
  353|      0|        return;
  354|  38.4k|    if (!(a->flags & ASN1_STRING_FLAG_NDEF))
  ------------------
  |  |  127|  38.4k|# define ASN1_STRING_FLAG_NDEF 0x010
  ------------------
  |  Branch (354:9): [True: 38.4k, False: 0]
  ------------------
  355|  38.4k|        OPENSSL_free(a->data);
  ------------------
  |  |  128|  38.4k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  38.4k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  38.4k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  356|  38.4k|    if (embed == 0)
  ------------------
  |  Branch (356:9): [True: 38.4k, False: 0]
  ------------------
  357|  38.4k|        OPENSSL_free(a);
  ------------------
  |  |  128|  38.4k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  38.4k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  38.4k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  358|  38.4k|}
ASN1_STRING_free:
  361|  65.2k|{
  362|  65.2k|    if (a == NULL)
  ------------------
  |  Branch (362:9): [True: 26.7k, False: 38.4k]
  ------------------
  363|  26.7k|        return;
  364|  38.4k|    asn1_string_embed_free(a, a->flags & ASN1_STRING_FLAG_EMBED);
  ------------------
  |  |  142|  38.4k|# define ASN1_STRING_FLAG_EMBED 0x080
  ------------------
  365|  38.4k|}
asn1_lib.c:asn1_get_length:
  114|   135k|{
  115|   135k|    const unsigned char *p = *pp;
  116|   135k|    unsigned long ret = 0;
  117|   135k|    int i;
  118|       |
  119|   135k|    if (max-- < 1)
  ------------------
  |  Branch (119:9): [True: 0, False: 135k]
  ------------------
  120|      0|        return 0;
  121|   135k|    if (*p == 0x80) {
  ------------------
  |  Branch (121:9): [True: 4.52k, False: 131k]
  ------------------
  122|  4.52k|        *inf = 1;
  123|  4.52k|        p++;
  124|   131k|    } else {
  125|   131k|        *inf = 0;
  126|   131k|        i = *p & 0x7f;
  127|   131k|        if (*p++ & 0x80) {
  ------------------
  |  Branch (127:13): [True: 21.9k, False: 109k]
  ------------------
  128|  21.9k|            if (max < i + 1)
  ------------------
  |  Branch (128:17): [True: 6.94k, False: 14.9k]
  ------------------
  129|  6.94k|                return 0;
  130|       |            /* Skip leading zeroes */
  131|  22.3k|            while (i > 0 && *p == 0) {
  ------------------
  |  Branch (131:20): [True: 15.3k, False: 6.96k]
  |  Branch (131:29): [True: 7.31k, False: 8.02k]
  ------------------
  132|  7.31k|                p++;
  133|  7.31k|                i--;
  134|  7.31k|            }
  135|  14.9k|            if (i > (int)sizeof(long))
  ------------------
  |  Branch (135:17): [True: 40, False: 14.9k]
  ------------------
  136|     40|                return 0;
  137|  25.9k|            while (i > 0) {
  ------------------
  |  Branch (137:20): [True: 11.0k, False: 14.9k]
  ------------------
  138|  11.0k|                ret <<= 8;
  139|  11.0k|                ret |= *p++;
  140|  11.0k|                i--;
  141|  11.0k|            }
  142|  14.9k|            if (ret > LONG_MAX)
  ------------------
  |  Branch (142:17): [True: 65, False: 14.8k]
  ------------------
  143|     65|                return 0;
  144|  14.9k|        } else
  145|   109k|            ret = i;
  146|   131k|    }
  147|   128k|    *pp = p;
  148|   128k|    *rl = (long)ret;
  149|   128k|    return 1;
  150|   135k|}

ASN1_parse_dump:
   65|  2.58k|{
   66|  2.58k|    return asn1_parse2(bp, &pp, len, 0, 0, indent, dump);
   67|  2.58k|}
ASN1_tag2str:
  354|  71.8k|{
  355|  71.8k|    static const char *const tag2str[] = {
  356|       |        /* 0-4 */
  357|  71.8k|        "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING",
  358|       |        /* 5-9 */
  359|  71.8k|        "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL",
  360|       |        /* 10-13 */
  361|  71.8k|        "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>",
  362|       |        /* 15-17 */
  363|  71.8k|        "<ASN1 14>", "<ASN1 15>", "SEQUENCE", "SET",
  364|       |        /* 18-20 */
  365|  71.8k|        "NUMERICSTRING", "PRINTABLESTRING", "T61STRING",
  366|       |        /* 21-24 */
  367|  71.8k|        "VIDEOTEXSTRING", "IA5STRING", "UTCTIME", "GENERALIZEDTIME",
  368|       |        /* 25-27 */
  369|  71.8k|        "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING",
  370|       |        /* 28-30 */
  371|  71.8k|        "UNIVERSALSTRING", "<ASN1 29>", "BMPSTRING"
  372|  71.8k|    };
  373|       |
  374|  71.8k|    if ((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED))
  ------------------
  |  |   86|  71.8k|# define V_ASN1_NEG_INTEGER              (2 | V_ASN1_NEG)
  |  |  ------------------
  |  |  |  |   85|  71.8k|# define V_ASN1_NEG                      0x100
  |  |  ------------------
  ------------------
                  if ((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED))
  ------------------
  |  |   87|  71.8k|# define V_ASN1_NEG_ENUMERATED           (10 | V_ASN1_NEG)
  |  |  ------------------
  |  |  |  |   85|  71.8k|# define V_ASN1_NEG                      0x100
  |  |  ------------------
  ------------------
  |  Branch (374:9): [True: 0, False: 71.8k]
  |  Branch (374:40): [True: 0, False: 71.8k]
  ------------------
  375|      0|        tag &= ~0x100;
  376|       |
  377|  71.8k|    if (tag < 0 || tag > 30)
  ------------------
  |  Branch (377:9): [True: 0, False: 71.8k]
  |  Branch (377:20): [True: 0, False: 71.8k]
  ------------------
  378|      0|        return "(unknown)";
  379|  71.8k|    return tag2str[tag];
  380|  71.8k|}
asn1_par.c:asn1_parse2:
   71|  8.24k|{
   72|  8.24k|    const unsigned char *p, *ep, *tot, *op, *opp;
   73|  8.24k|    long len;
   74|  8.24k|    int tag, xclass, ret = 0;
   75|  8.24k|    int nl, hl, j, r;
   76|  8.24k|    ASN1_OBJECT *o = NULL;
   77|  8.24k|    ASN1_OCTET_STRING *os = NULL;
   78|  8.24k|    ASN1_INTEGER *ai = NULL;
   79|  8.24k|    ASN1_ENUMERATED *ae = NULL;
   80|       |    /* ASN1_BMPSTRING *bmp=NULL; */
   81|  8.24k|    int dump_indent, dump_cont = 0;
   82|       |
   83|  8.24k|    if (depth > ASN1_PARSE_MAXDEPTH) {
  ------------------
  |  |   17|  8.24k|#define ASN1_PARSE_MAXDEPTH 128
  ------------------
  |  Branch (83:9): [True: 1, False: 8.24k]
  ------------------
   84|      1|        BIO_puts(bp, "BAD RECURSION DEPTH\n");
   85|      1|        return 0;
   86|      1|    }
   87|       |
   88|  8.24k|    dump_indent = 6;            /* Because we know BIO_dump_indent() */
   89|  8.24k|    p = *pp;
   90|  8.24k|    tot = p + length;
   91|  83.7k|    while (length > 0) {
  ------------------
  |  Branch (91:12): [True: 77.7k, False: 6.01k]
  ------------------
   92|  77.7k|        op = p;
   93|  77.7k|        j = ASN1_get_object(&p, &len, &tag, &xclass, length);
   94|  77.7k|        if (j & 0x80) {
  ------------------
  |  Branch (94:13): [True: 442, False: 77.2k]
  ------------------
   95|    442|            if (BIO_write(bp, "Error in encoding\n", 18) <= 0)
  ------------------
  |  Branch (95:17): [True: 0, False: 442]
  ------------------
   96|      0|                goto end;
   97|    442|            ret = 0;
   98|    442|            goto end;
   99|    442|        }
  100|  77.2k|        hl = (p - op);
  101|  77.2k|        length -= hl;
  102|       |        /*
  103|       |         * if j == 0x21 it is a constructed indefinite length object
  104|       |         */
  105|  77.2k|        if (BIO_printf(bp, "%5ld:", (long)offset + (long)(op - *pp))
  ------------------
  |  Branch (105:13): [True: 0, False: 77.2k]
  ------------------
  106|  77.2k|            <= 0)
  107|      0|            goto end;
  108|       |
  109|  77.2k|        if (j != (V_ASN1_CONSTRUCTED | 1)) {
  ------------------
  |  |   40|  77.2k|# define V_ASN1_CONSTRUCTED              0x20
  ------------------
  |  Branch (109:13): [True: 72.7k, False: 4.52k]
  ------------------
  110|  72.7k|            if (BIO_printf(bp, "d=%-2d hl=%ld l=%4ld ",
  ------------------
  |  Branch (110:17): [True: 0, False: 72.7k]
  ------------------
  111|  72.7k|                           depth, (long)hl, len) <= 0)
  112|      0|                goto end;
  113|  72.7k|        } else {
  114|  4.52k|            if (BIO_printf(bp, "d=%-2d hl=%ld l=inf  ", depth, (long)hl) <= 0)
  ------------------
  |  Branch (114:17): [True: 0, False: 4.52k]
  ------------------
  115|      0|                goto end;
  116|  4.52k|        }
  117|  77.2k|        if (!asn1_print_info(bp, tag, xclass, j, (indent) ? depth : 0))
  ------------------
  |  Branch (117:13): [True: 0, False: 77.2k]
  |  Branch (117:50): [True: 0, False: 77.2k]
  ------------------
  118|      0|            goto end;
  119|  77.2k|        if (j & V_ASN1_CONSTRUCTED) {
  ------------------
  |  |   40|  77.2k|# define V_ASN1_CONSTRUCTED              0x20
  ------------------
  |  Branch (119:13): [True: 6.15k, False: 71.1k]
  ------------------
  120|  6.15k|            const unsigned char *sp = p;
  121|       |
  122|  6.15k|            ep = p + len;
  123|  6.15k|            if (BIO_write(bp, "\n", 1) <= 0)
  ------------------
  |  Branch (123:17): [True: 0, False: 6.15k]
  ------------------
  124|      0|                goto end;
  125|  6.15k|            if (len > length) {
  ------------------
  |  Branch (125:17): [True: 0, False: 6.15k]
  ------------------
  126|      0|                BIO_printf(bp, "length is greater than %ld\n", length);
  127|      0|                ret = 0;
  128|      0|                goto end;
  129|      0|            }
  130|  6.15k|            if ((j == 0x21) && (len == 0)) {
  ------------------
  |  Branch (130:17): [True: 4.52k, False: 1.63k]
  |  Branch (130:32): [True: 4.52k, False: 0]
  ------------------
  131|  4.52k|                for (;;) {
  132|  4.52k|                    r = asn1_parse2(bp, &p, (long)(tot - p),
  133|  4.52k|                                    offset + (p - *pp), depth + 1,
  134|  4.52k|                                    indent, dump);
  135|  4.52k|                    if (r == 0) {
  ------------------
  |  Branch (135:25): [True: 727, False: 3.79k]
  ------------------
  136|    727|                        ret = 0;
  137|    727|                        goto end;
  138|    727|                    }
  139|  3.79k|                    if ((r == 2) || (p >= tot)) {
  ------------------
  |  Branch (139:25): [True: 480, False: 3.31k]
  |  Branch (139:37): [True: 3.31k, False: 0]
  ------------------
  140|  3.79k|                        len = p - sp;
  141|  3.79k|                        break;
  142|  3.79k|                    }
  143|  3.79k|                }
  144|  4.52k|            } else {
  145|  1.63k|                long tmp = len;
  146|       |
  147|  2.66k|                while (p < ep) {
  ------------------
  |  Branch (147:24): [True: 1.13k, False: 1.53k]
  ------------------
  148|  1.13k|                    sp = p;
  149|  1.13k|                    r = asn1_parse2(bp, &p, tmp,
  150|  1.13k|                                    offset + (p - *pp), depth + 1,
  151|  1.13k|                                    indent, dump);
  152|  1.13k|                    if (r == 0) {
  ------------------
  |  Branch (152:25): [True: 99, False: 1.03k]
  ------------------
  153|     99|                        ret = 0;
  154|     99|                        goto end;
  155|     99|                    }
  156|  1.03k|                    tmp -= p - sp;
  157|  1.03k|                }
  158|  1.63k|            }
  159|  71.1k|        } else if (xclass != 0) {
  ------------------
  |  Branch (159:20): [True: 2.38k, False: 68.7k]
  ------------------
  160|  2.38k|            p += len;
  161|  2.38k|            if (BIO_write(bp, "\n", 1) <= 0)
  ------------------
  |  Branch (161:17): [True: 0, False: 2.38k]
  ------------------
  162|      0|                goto end;
  163|  68.7k|        } else {
  164|  68.7k|            nl = 0;
  165|  68.7k|            if ((tag == V_ASN1_PRINTABLESTRING) ||
  ------------------
  |  |   65|  68.7k|# define V_ASN1_PRINTABLESTRING          19
  ------------------
  |  Branch (165:17): [True: 233, False: 68.5k]
  ------------------
  166|  68.7k|                (tag == V_ASN1_T61STRING) ||
  ------------------
  |  |   66|  68.5k|# define V_ASN1_T61STRING                20
  ------------------
  |  Branch (166:17): [True: 202, False: 68.3k]
  ------------------
  167|  68.7k|                (tag == V_ASN1_IA5STRING) ||
  ------------------
  |  |   69|  68.3k|# define V_ASN1_IA5STRING                22
  ------------------
  |  Branch (167:17): [True: 336, False: 67.9k]
  ------------------
  168|  68.7k|                (tag == V_ASN1_VISIBLESTRING) ||
  ------------------
  |  |   74|  67.9k|# define V_ASN1_VISIBLESTRING            26/* alias */
  ------------------
  |  Branch (168:17): [True: 201, False: 67.7k]
  ------------------
  169|  68.7k|                (tag == V_ASN1_NUMERICSTRING) ||
  ------------------
  |  |   64|  67.7k|# define V_ASN1_NUMERICSTRING            18 /**/
  ------------------
  |  Branch (169:17): [True: 439, False: 67.3k]
  ------------------
  170|  68.7k|                (tag == V_ASN1_UTF8STRING) ||
  ------------------
  |  |   61|  67.3k|# define V_ASN1_UTF8STRING               12
  ------------------
  |  Branch (170:17): [True: 370, False: 66.9k]
  ------------------
  171|  68.7k|                (tag == V_ASN1_UTCTIME) || (tag == V_ASN1_GENERALIZEDTIME)) {
  ------------------
  |  |   70|  66.9k|# define V_ASN1_UTCTIME                  23
  ------------------
                              (tag == V_ASN1_UTCTIME) || (tag == V_ASN1_GENERALIZEDTIME)) {
  ------------------
  |  |   71|  66.7k|# define V_ASN1_GENERALIZEDTIME          24 /**/
  ------------------
  |  Branch (171:17): [True: 199, False: 66.7k]
  |  Branch (171:44): [True: 231, False: 66.5k]
  ------------------
  172|  2.21k|                if (BIO_write(bp, ":", 1) <= 0)
  ------------------
  |  Branch (172:21): [True: 0, False: 2.21k]
  ------------------
  173|      0|                    goto end;
  174|  2.21k|                if ((len > 0) && BIO_write(bp, (const char *)p, (int)len)
  ------------------
  |  Branch (174:21): [True: 291, False: 1.92k]
  |  Branch (174:34): [True: 0, False: 291]
  ------------------
  175|    291|                    != (int)len)
  176|      0|                    goto end;
  177|  66.5k|            } else if (tag == V_ASN1_OBJECT) {
  ------------------
  |  |   56|  66.5k|# define V_ASN1_OBJECT                   6
  ------------------
  |  Branch (177:24): [True: 17.5k, False: 48.9k]
  ------------------
  178|  17.5k|                opp = op;
  179|  17.5k|                if (d2i_ASN1_OBJECT(&o, &opp, len + hl) != NULL) {
  ------------------
  |  Branch (179:21): [True: 9.41k, False: 8.14k]
  ------------------
  180|  9.41k|                    if (BIO_write(bp, ":", 1) <= 0)
  ------------------
  |  Branch (180:25): [True: 0, False: 9.41k]
  ------------------
  181|      0|                        goto end;
  182|  9.41k|                    i2a_ASN1_OBJECT(bp, o);
  183|  9.41k|                } else {
  184|  8.14k|                    if (BIO_puts(bp, ":BAD OBJECT") <= 0)
  ------------------
  |  Branch (184:25): [True: 0, False: 8.14k]
  ------------------
  185|      0|                        goto end;
  186|  8.14k|                    dump_cont = 1;
  187|  8.14k|                }
  188|  48.9k|            } else if (tag == V_ASN1_BOOLEAN) {
  ------------------
  |  |   51|  48.9k|# define V_ASN1_BOOLEAN                  1 /**/
  ------------------
  |  Branch (188:24): [True: 6.10k, False: 42.8k]
  ------------------
  189|  6.10k|                if (len != 1) {
  ------------------
  |  Branch (189:21): [True: 3.31k, False: 2.79k]
  ------------------
  190|  3.31k|                    if (BIO_puts(bp, ":BAD BOOLEAN") <= 0)
  ------------------
  |  Branch (190:25): [True: 0, False: 3.31k]
  ------------------
  191|      0|                        goto end;
  192|  3.31k|                    dump_cont = 1;
  193|  3.31k|                }
  194|  6.10k|                if (len > 0)
  ------------------
  |  Branch (194:21): [True: 5.63k, False: 472]
  ------------------
  195|  5.63k|                    BIO_printf(bp, ":%u", p[0]);
  196|  42.8k|            } else if (tag == V_ASN1_BMPSTRING) {
  ------------------
  |  |   77|  42.8k|# define V_ASN1_BMPSTRING                30
  ------------------
  |  Branch (196:24): [True: 197, False: 42.6k]
  ------------------
  197|       |                /* do the BMP thang */
  198|  42.6k|            } else if (tag == V_ASN1_OCTET_STRING) {
  ------------------
  |  |   54|  42.6k|# define V_ASN1_OCTET_STRING             4
  ------------------
  |  Branch (198:24): [True: 2.43k, False: 40.2k]
  ------------------
  199|  2.43k|                int i, printable = 1;
  200|       |
  201|  2.43k|                opp = op;
  202|  2.43k|                os = d2i_ASN1_OCTET_STRING(NULL, &opp, len + hl);
  203|  2.43k|                if (os != NULL && os->length > 0) {
  ------------------
  |  Branch (203:21): [True: 1.89k, False: 539]
  |  Branch (203:35): [True: 1.04k, False: 853]
  ------------------
  204|  1.04k|                    opp = os->data;
  205|       |                    /*
  206|       |                     * testing whether the octet string is printable
  207|       |                     */
  208|  3.73k|                    for (i = 0; i < os->length; i++) {
  ------------------
  |  Branch (208:33): [True: 3.32k, False: 418]
  ------------------
  209|  3.32k|                        if (((opp[i] < ' ') &&
  ------------------
  |  Branch (209:30): [True: 1.26k, False: 2.05k]
  ------------------
  210|  3.32k|                             (opp[i] != '\n') &&
  ------------------
  |  Branch (210:30): [True: 1.00k, False: 267]
  ------------------
  211|  3.32k|                             (opp[i] != '\r') &&
  ------------------
  |  Branch (211:30): [True: 641, False: 361]
  ------------------
  212|  3.32k|                             (opp[i] != '\t')) || (opp[i] > '~')) {
  ------------------
  |  Branch (212:30): [True: 370, False: 271]
  |  Branch (212:51): [True: 255, False: 2.69k]
  ------------------
  213|    625|                            printable = 0;
  214|    625|                            break;
  215|    625|                        }
  216|  3.32k|                    }
  217|  1.04k|                    if (printable)
  ------------------
  |  Branch (217:25): [True: 418, False: 625]
  ------------------
  218|       |                        /* printable string */
  219|    418|                    {
  220|    418|                        if (BIO_write(bp, ":", 1) <= 0)
  ------------------
  |  Branch (220:29): [True: 0, False: 418]
  ------------------
  221|      0|                            goto end;
  222|    418|                        if (BIO_write(bp, (const char *)opp, os->length) <= 0)
  ------------------
  |  Branch (222:29): [True: 0, False: 418]
  ------------------
  223|      0|                            goto end;
  224|    625|                    } else if (!dump)
  ------------------
  |  Branch (224:32): [True: 625, False: 0]
  ------------------
  225|       |                        /*
  226|       |                         * not printable => print octet string as hex dump
  227|       |                         */
  228|    625|                    {
  229|    625|                        if (BIO_write(bp, "[HEX DUMP]:", 11) <= 0)
  ------------------
  |  Branch (229:29): [True: 0, False: 625]
  ------------------
  230|      0|                            goto end;
  231|  2.36M|                        for (i = 0; i < os->length; i++) {
  ------------------
  |  Branch (231:37): [True: 2.36M, False: 625]
  ------------------
  232|  2.36M|                            if (BIO_printf(bp, "%02X", opp[i]) <= 0)
  ------------------
  |  Branch (232:33): [True: 0, False: 2.36M]
  ------------------
  233|      0|                                goto end;
  234|  2.36M|                        }
  235|    625|                    } else
  236|       |                        /* print the normal dump */
  237|      0|                    {
  238|      0|                        if (!nl) {
  ------------------
  |  Branch (238:29): [True: 0, False: 0]
  ------------------
  239|      0|                            if (BIO_write(bp, "\n", 1) <= 0)
  ------------------
  |  Branch (239:33): [True: 0, False: 0]
  ------------------
  240|      0|                                goto end;
  241|      0|                        }
  242|      0|                        if (BIO_dump_indent(bp,
  ------------------
  |  Branch (242:29): [True: 0, False: 0]
  ------------------
  243|      0|                                            (const char *)opp,
  244|      0|                                            ((dump == -1 || dump >
  ------------------
  |  Branch (244:47): [True: 0, False: 0]
  |  Branch (244:61): [True: 0, False: 0]
  ------------------
  245|      0|                                              os->
  246|      0|                                              length) ? os->length : dump),
  247|      0|                                            dump_indent) <= 0)
  248|      0|                            goto end;
  249|      0|                        nl = 1;
  250|      0|                    }
  251|  1.04k|                }
  252|  2.43k|                ASN1_OCTET_STRING_free(os);
  253|  2.43k|                os = NULL;
  254|  40.2k|            } else if (tag == V_ASN1_INTEGER) {
  ------------------
  |  |   52|  40.2k|# define V_ASN1_INTEGER                  2
  ------------------
  |  Branch (254:24): [True: 36.6k, False: 3.55k]
  ------------------
  255|  36.6k|                int i;
  256|       |
  257|  36.6k|                opp = op;
  258|  36.6k|                ai = d2i_ASN1_INTEGER(NULL, &opp, len + hl);
  259|  36.6k|                if (ai != NULL) {
  ------------------
  |  Branch (259:21): [True: 35.8k, False: 804]
  ------------------
  260|  35.8k|                    if (BIO_write(bp, ":", 1) <= 0)
  ------------------
  |  Branch (260:25): [True: 0, False: 35.8k]
  ------------------
  261|      0|                        goto end;
  262|  35.8k|                    if (ai->type == V_ASN1_NEG_INTEGER)
  ------------------
  |  |   86|  35.8k|# define V_ASN1_NEG_INTEGER              (2 | V_ASN1_NEG)
  |  |  ------------------
  |  |  |  |   85|  35.8k|# define V_ASN1_NEG                      0x100
  |  |  ------------------
  ------------------
  |  Branch (262:25): [True: 31.9k, False: 3.92k]
  ------------------
  263|  31.9k|                        if (BIO_write(bp, "-", 1) <= 0)
  ------------------
  |  Branch (263:29): [True: 0, False: 31.9k]
  ------------------
  264|      0|                            goto end;
  265|  3.64M|                    for (i = 0; i < ai->length; i++) {
  ------------------
  |  Branch (265:33): [True: 3.61M, False: 35.8k]
  ------------------
  266|  3.61M|                        if (BIO_printf(bp, "%02X", ai->data[i]) <= 0)
  ------------------
  |  Branch (266:29): [True: 0, False: 3.61M]
  ------------------
  267|      0|                            goto end;
  268|  3.61M|                    }
  269|  35.8k|                    if (ai->length == 0) {
  ------------------
  |  Branch (269:25): [True: 0, False: 35.8k]
  ------------------
  270|      0|                        if (BIO_write(bp, "00", 2) <= 0)
  ------------------
  |  Branch (270:29): [True: 0, False: 0]
  ------------------
  271|      0|                            goto end;
  272|      0|                    }
  273|  35.8k|                } else {
  274|    804|                    if (BIO_puts(bp, ":BAD INTEGER") <= 0)
  ------------------
  |  Branch (274:25): [True: 0, False: 804]
  ------------------
  275|      0|                        goto end;
  276|    804|                    dump_cont = 1;
  277|    804|                }
  278|  36.6k|                ASN1_INTEGER_free(ai);
  279|  36.6k|                ai = NULL;
  280|  36.6k|            } else if (tag == V_ASN1_ENUMERATED) {
  ------------------
  |  |   60|  3.55k|# define V_ASN1_ENUMERATED               10
  ------------------
  |  Branch (280:24): [True: 1.43k, False: 2.11k]
  ------------------
  281|  1.43k|                int i;
  282|       |
  283|  1.43k|                opp = op;
  284|  1.43k|                ae = d2i_ASN1_ENUMERATED(NULL, &opp, len + hl);
  285|  1.43k|                if (ae != NULL) {
  ------------------
  |  Branch (285:21): [True: 716, False: 720]
  ------------------
  286|    716|                    if (BIO_write(bp, ":", 1) <= 0)
  ------------------
  |  Branch (286:25): [True: 0, False: 716]
  ------------------
  287|      0|                        goto end;
  288|    716|                    if (ae->type == V_ASN1_NEG_ENUMERATED)
  ------------------
  |  |   87|    716|# define V_ASN1_NEG_ENUMERATED           (10 | V_ASN1_NEG)
  |  |  ------------------
  |  |  |  |   85|    716|# define V_ASN1_NEG                      0x100
  |  |  ------------------
  ------------------
  |  Branch (288:25): [True: 383, False: 333]
  ------------------
  289|    383|                        if (BIO_write(bp, "-", 1) <= 0)
  ------------------
  |  Branch (289:29): [True: 0, False: 383]
  ------------------
  290|      0|                            goto end;
  291|   944k|                    for (i = 0; i < ae->length; i++) {
  ------------------
  |  Branch (291:33): [True: 943k, False: 716]
  ------------------
  292|   943k|                        if (BIO_printf(bp, "%02X", ae->data[i]) <= 0)
  ------------------
  |  Branch (292:29): [True: 0, False: 943k]
  ------------------
  293|      0|                            goto end;
  294|   943k|                    }
  295|    716|                    if (ae->length == 0) {
  ------------------
  |  Branch (295:25): [True: 0, False: 716]
  ------------------
  296|      0|                        if (BIO_write(bp, "00", 2) <= 0)
  ------------------
  |  Branch (296:29): [True: 0, False: 0]
  ------------------
  297|      0|                            goto end;
  298|      0|                    }
  299|    720|                } else {
  300|    720|                    if (BIO_puts(bp, ":BAD ENUMERATED") <= 0)
  ------------------
  |  Branch (300:25): [True: 0, False: 720]
  ------------------
  301|      0|                        goto end;
  302|    720|                    dump_cont = 1;
  303|    720|                }
  304|  1.43k|                ASN1_ENUMERATED_free(ae);
  305|  1.43k|                ae = NULL;
  306|  2.11k|            } else if (len > 0 && dump) {
  ------------------
  |  Branch (306:24): [True: 795, False: 1.31k]
  |  Branch (306:35): [True: 0, False: 795]
  ------------------
  307|      0|                if (!nl) {
  ------------------
  |  Branch (307:21): [True: 0, False: 0]
  ------------------
  308|      0|                    if (BIO_write(bp, "\n", 1) <= 0)
  ------------------
  |  Branch (308:25): [True: 0, False: 0]
  ------------------
  309|      0|                        goto end;
  310|      0|                }
  311|      0|                if (BIO_dump_indent(bp, (const char *)p,
  ------------------
  |  Branch (311:21): [True: 0, False: 0]
  ------------------
  312|      0|                                    ((dump == -1 || dump > len) ? len : dump),
  ------------------
  |  Branch (312:39): [True: 0, False: 0]
  |  Branch (312:53): [True: 0, False: 0]
  ------------------
  313|      0|                                    dump_indent) <= 0)
  314|      0|                    goto end;
  315|      0|                nl = 1;
  316|      0|            }
  317|  68.7k|            if (dump_cont) {
  ------------------
  |  Branch (317:17): [True: 12.9k, False: 55.7k]
  ------------------
  318|  12.9k|                int i;
  319|  12.9k|                const unsigned char *tmp = op + hl;
  320|  12.9k|                if (BIO_puts(bp, ":[") <= 0)
  ------------------
  |  Branch (320:21): [True: 0, False: 12.9k]
  ------------------
  321|      0|                    goto end;
  322|  5.47M|                for (i = 0; i < len; i++) {
  ------------------
  |  Branch (322:29): [True: 5.45M, False: 12.9k]
  ------------------
  323|  5.45M|                    if (BIO_printf(bp, "%02X", tmp[i]) <= 0)
  ------------------
  |  Branch (323:25): [True: 0, False: 5.45M]
  ------------------
  324|      0|                        goto end;
  325|  5.45M|                }
  326|  12.9k|                if (BIO_puts(bp, "]") <= 0)
  ------------------
  |  Branch (326:21): [True: 0, False: 12.9k]
  ------------------
  327|      0|                    goto end;
  328|  12.9k|                dump_cont = 0;
  329|  12.9k|            }
  330|       |
  331|  68.7k|            if (!nl) {
  ------------------
  |  Branch (331:17): [True: 68.7k, False: 0]
  ------------------
  332|  68.7k|                if (BIO_write(bp, "\n", 1) <= 0)
  ------------------
  |  Branch (332:21): [True: 0, False: 68.7k]
  ------------------
  333|      0|                    goto end;
  334|  68.7k|            }
  335|  68.7k|            p += len;
  336|  68.7k|            if ((tag == V_ASN1_EOC) && (xclass == 0)) {
  ------------------
  |  |   50|  68.7k|# define V_ASN1_EOC                      0
  ------------------
  |  Branch (336:17): [True: 967, False: 67.7k]
  |  Branch (336:40): [True: 967, False: 0]
  ------------------
  337|    967|                ret = 2;        /* End of sequence */
  338|    967|                goto end;
  339|    967|            }
  340|  68.7k|        }
  341|  75.4k|        length -= len;
  342|  75.4k|    }
  343|  6.01k|    ret = 1;
  344|  8.24k| end:
  345|  8.24k|    ASN1_OBJECT_free(o);
  346|  8.24k|    ASN1_OCTET_STRING_free(os);
  347|  8.24k|    ASN1_INTEGER_free(ai);
  348|  8.24k|    ASN1_ENUMERATED_free(ae);
  349|  8.24k|    *pp = p;
  350|  8.24k|    return ret;
  351|  6.01k|}
asn1_par.c:asn1_print_info:
   26|  77.2k|{
   27|  77.2k|    static const char fmt[] = "%-18s";
   28|  77.2k|    char str[128];
   29|  77.2k|    const char *p;
   30|       |
   31|  77.2k|    if (constructed & V_ASN1_CONSTRUCTED)
  ------------------
  |  |   40|  77.2k|# define V_ASN1_CONSTRUCTED              0x20
  ------------------
  |  Branch (31:9): [True: 6.15k, False: 71.1k]
  ------------------
   32|  6.15k|        p = "cons: ";
   33|  71.1k|    else
   34|  71.1k|        p = "prim: ";
   35|  77.2k|    if (BIO_write(bp, p, 6) < 6)
  ------------------
  |  Branch (35:9): [True: 0, False: 77.2k]
  ------------------
   36|      0|        goto err;
   37|  77.2k|    BIO_indent(bp, indent, 128);
   38|       |
   39|  77.2k|    p = str;
   40|  77.2k|    if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
  ------------------
  |  |   38|  77.2k|# define V_ASN1_PRIVATE                  0xc0
  ------------------
                  if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
  ------------------
  |  |   38|  77.2k|# define V_ASN1_PRIVATE                  0xc0
  ------------------
  |  Branch (40:9): [True: 1.05k, False: 76.2k]
  ------------------
   41|  1.05k|        BIO_snprintf(str, sizeof(str), "priv [ %d ] ", tag);
   42|  76.2k|    else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
  ------------------
  |  |   37|  76.2k|# define V_ASN1_CONTEXT_SPECIFIC         0x80
  ------------------
                  else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
  ------------------
  |  |   37|  76.2k|# define V_ASN1_CONTEXT_SPECIFIC         0x80
  ------------------
  |  Branch (42:14): [True: 2.22k, False: 73.9k]
  ------------------
   43|  2.22k|        BIO_snprintf(str, sizeof(str), "cont [ %d ]", tag);
   44|  73.9k|    else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
  ------------------
  |  |   36|  73.9k|# define V_ASN1_APPLICATION              0x40
  ------------------
                  else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
  ------------------
  |  |   36|  73.9k|# define V_ASN1_APPLICATION              0x40
  ------------------
  |  Branch (44:14): [True: 1.68k, False: 72.3k]
  ------------------
   45|  1.68k|        BIO_snprintf(str, sizeof(str), "appl [ %d ]", tag);
   46|  72.3k|    else if (tag > 30)
  ------------------
  |  Branch (46:14): [True: 461, False: 71.8k]
  ------------------
   47|    461|        BIO_snprintf(str, sizeof(str), "<ASN1 %d>", tag);
   48|  71.8k|    else
   49|  71.8k|        p = ASN1_tag2str(tag);
   50|       |
   51|  77.2k|    if (BIO_printf(bp, fmt, p) <= 0)
  ------------------
  |  Branch (51:9): [True: 0, False: 77.2k]
  ------------------
   52|      0|        goto err;
   53|  77.2k|    return 1;
   54|      0| err:
   55|      0|    return 0;
   56|  77.2k|}

ASN1_item_d2i:
  108|  40.5k|{
  109|  40.5k|    ASN1_TLC c;
  110|  40.5k|    ASN1_VALUE *ptmpval = NULL;
  111|  40.5k|    if (!pval)
  ------------------
  |  Branch (111:9): [True: 40.5k, False: 0]
  ------------------
  112|  40.5k|        pval = &ptmpval;
  113|  40.5k|    asn1_tlc_clear_nc(&c);
  ------------------
  |  |   96|  40.5k|#define asn1_tlc_clear_nc(c)    (c)->valid = 0
  ------------------
  114|  40.5k|    if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0)
  ------------------
  |  Branch (114:9): [True: 38.4k, False: 2.06k]
  ------------------
  115|  38.4k|        return *pval;
  116|  2.06k|    return NULL;
  117|  40.5k|}
ASN1_item_ex_d2i:
  122|  40.5k|{
  123|  40.5k|    int rv;
  124|  40.5k|    rv = asn1_item_embed_d2i(pval, in, len, it, tag, aclass, opt, ctx, 0);
  125|  40.5k|    if (rv <= 0)
  ------------------
  |  Branch (125:9): [True: 2.06k, False: 38.4k]
  ------------------
  126|  2.06k|        ASN1_item_ex_free(pval, it);
  127|  40.5k|    return rv;
  128|  40.5k|}
tasn_dec.c:asn1_item_embed_d2i:
  139|  40.5k|{
  140|  40.5k|    const ASN1_TEMPLATE *tt, *errtt = NULL;
  141|  40.5k|    const ASN1_EXTERN_FUNCS *ef;
  142|  40.5k|    const ASN1_AUX *aux = it->funcs;
  143|  40.5k|    ASN1_aux_cb *asn1_cb;
  144|  40.5k|    const unsigned char *p = NULL, *q;
  145|  40.5k|    unsigned char oclass;
  146|  40.5k|    char seq_eoc, seq_nolen, cst, isopt;
  147|  40.5k|    long tmplen;
  148|  40.5k|    int i;
  149|  40.5k|    int otag;
  150|  40.5k|    int ret = 0;
  151|  40.5k|    ASN1_VALUE **pchptr;
  152|  40.5k|    if (!pval)
  ------------------
  |  Branch (152:9): [True: 0, False: 40.5k]
  ------------------
  153|      0|        return 0;
  154|  40.5k|    if (aux && aux->asn1_cb)
  ------------------
  |  Branch (154:9): [True: 0, False: 40.5k]
  |  Branch (154:16): [True: 0, False: 0]
  ------------------
  155|      0|        asn1_cb = aux->asn1_cb;
  156|  40.5k|    else
  157|  40.5k|        asn1_cb = 0;
  158|       |
  159|  40.5k|    if (++depth > ASN1_MAX_CONSTRUCTED_NEST) {
  ------------------
  |  |   27|  40.5k|#define ASN1_MAX_CONSTRUCTED_NEST 30
  ------------------
  |  Branch (159:9): [True: 0, False: 40.5k]
  ------------------
  160|      0|        ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_NESTED_TOO_DEEP);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  161|      0|        goto err;
  162|      0|    }
  163|       |
  164|  40.5k|    switch (it->itype) {
  165|  40.5k|    case ASN1_ITYPE_PRIMITIVE:
  ------------------
  |  |  633|  40.5k|# define ASN1_ITYPE_PRIMITIVE            0x0
  ------------------
  |  Branch (165:5): [True: 40.5k, False: 0]
  ------------------
  166|  40.5k|        if (it->templates) {
  ------------------
  |  Branch (166:13): [True: 0, False: 40.5k]
  ------------------
  167|       |            /*
  168|       |             * tagging or OPTIONAL is currently illegal on an item template
  169|       |             * because the flags can't get passed down. In practice this
  170|       |             * isn't a problem: we include the relevant flags from the item
  171|       |             * template in the template itself.
  172|       |             */
  173|      0|            if ((tag != -1) || opt) {
  ------------------
  |  Branch (173:17): [True: 0, False: 0]
  |  Branch (173:32): [True: 0, False: 0]
  ------------------
  174|      0|                ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I,
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  175|      0|                        ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE);
  176|      0|                goto err;
  177|      0|            }
  178|      0|            return asn1_template_ex_d2i(pval, in, len,
  179|      0|                                        it->templates, opt, ctx, depth);
  180|      0|        }
  181|  40.5k|        return asn1_d2i_ex_primitive(pval, in, len, it,
  182|  40.5k|                                     tag, aclass, opt, ctx);
  183|       |
  184|      0|    case ASN1_ITYPE_MSTRING:
  ------------------
  |  |  641|      0|# define ASN1_ITYPE_MSTRING              0x5
  ------------------
  |  Branch (184:5): [True: 0, False: 40.5k]
  ------------------
  185|       |        /*
  186|       |         * It never makes sense for multi-strings to have implicit tagging, so
  187|       |         * if tag != -1, then this looks like an error in the template.
  188|       |         */
  189|      0|        if (tag != -1) {
  ------------------
  |  Branch (189:13): [True: 0, False: 0]
  ------------------
  190|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_BAD_TEMPLATE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  191|      0|            goto err;
  192|      0|        }
  193|       |
  194|      0|        p = *in;
  195|       |        /* Just read in tag and class */
  196|      0|        ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL,
  197|      0|                              &p, len, -1, 0, 1, ctx);
  198|      0|        if (!ret) {
  ------------------
  |  Branch (198:13): [True: 0, False: 0]
  ------------------
  199|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  200|      0|            goto err;
  201|      0|        }
  202|       |
  203|       |        /* Must be UNIVERSAL class */
  204|      0|        if (oclass != V_ASN1_UNIVERSAL) {
  ------------------
  |  |   35|      0|# define V_ASN1_UNIVERSAL                0x00
  ------------------
  |  Branch (204:13): [True: 0, False: 0]
  ------------------
  205|       |            /* If OPTIONAL, assume this is OK */
  206|      0|            if (opt)
  ------------------
  |  Branch (206:17): [True: 0, False: 0]
  ------------------
  207|      0|                return -1;
  208|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_MSTRING_NOT_UNIVERSAL);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  209|      0|            goto err;
  210|      0|        }
  211|       |
  212|       |        /* Check tag matches bit map */
  213|      0|        if (!(ASN1_tag2bit(otag) & it->utype)) {
  ------------------
  |  Branch (213:13): [True: 0, False: 0]
  ------------------
  214|       |            /* If OPTIONAL, assume this is OK */
  215|      0|            if (opt)
  ------------------
  |  Branch (215:17): [True: 0, False: 0]
  ------------------
  216|      0|                return -1;
  217|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_MSTRING_WRONG_TAG);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  218|      0|            goto err;
  219|      0|        }
  220|      0|        return asn1_d2i_ex_primitive(pval, in, len, it, otag, 0, 0, ctx);
  221|       |
  222|      0|    case ASN1_ITYPE_EXTERN:
  ------------------
  |  |  639|      0|# define ASN1_ITYPE_EXTERN               0x4
  ------------------
  |  Branch (222:5): [True: 0, False: 40.5k]
  ------------------
  223|       |        /* Use new style d2i */
  224|      0|        ef = it->funcs;
  225|      0|        return ef->asn1_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx);
  226|       |
  227|      0|    case ASN1_ITYPE_CHOICE:
  ------------------
  |  |  637|      0|# define ASN1_ITYPE_CHOICE               0x2
  ------------------
  |  Branch (227:5): [True: 0, False: 40.5k]
  ------------------
  228|       |        /*
  229|       |         * It never makes sense for CHOICE types to have implicit tagging, so
  230|       |         * if tag != -1, then this looks like an error in the template.
  231|       |         */
  232|      0|        if (tag != -1) {
  ------------------
  |  Branch (232:13): [True: 0, False: 0]
  ------------------
  233|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_BAD_TEMPLATE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  234|      0|            goto err;
  235|      0|        }
  236|       |
  237|      0|        if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
  ------------------
  |  |  760|      0|# define ASN1_OP_D2I_PRE         4
  ------------------
  |  Branch (237:13): [True: 0, False: 0]
  |  Branch (237:24): [True: 0, False: 0]
  ------------------
  238|      0|            goto auxerr;
  239|      0|        if (*pval) {
  ------------------
  |  Branch (239:13): [True: 0, False: 0]
  ------------------
  240|       |            /* Free up and zero CHOICE value if initialised */
  241|      0|            i = asn1_get_choice_selector(pval, it);
  242|      0|            if ((i >= 0) && (i < it->tcount)) {
  ------------------
  |  Branch (242:17): [True: 0, False: 0]
  |  Branch (242:29): [True: 0, False: 0]
  ------------------
  243|      0|                tt = it->templates + i;
  244|      0|                pchptr = asn1_get_field_ptr(pval, tt);
  245|      0|                asn1_template_free(pchptr, tt);
  246|      0|                asn1_set_choice_selector(pval, -1, it);
  247|      0|            }
  248|      0|        } else if (!ASN1_item_ex_new(pval, it)) {
  ------------------
  |  Branch (248:20): [True: 0, False: 0]
  ------------------
  249|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  250|      0|            goto err;
  251|      0|        }
  252|       |        /* CHOICE type, try each possibility in turn */
  253|      0|        p = *in;
  254|      0|        for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
  ------------------
  |  Branch (254:41): [True: 0, False: 0]
  ------------------
  255|      0|            pchptr = asn1_get_field_ptr(pval, tt);
  256|       |            /*
  257|       |             * We mark field as OPTIONAL so its absence can be recognised.
  258|       |             */
  259|      0|            ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx, depth);
  260|       |            /* If field not present, try the next one */
  261|      0|            if (ret == -1)
  ------------------
  |  Branch (261:17): [True: 0, False: 0]
  ------------------
  262|      0|                continue;
  263|       |            /* If positive return, read OK, break loop */
  264|      0|            if (ret > 0)
  ------------------
  |  Branch (264:17): [True: 0, False: 0]
  ------------------
  265|      0|                break;
  266|       |            /*
  267|       |             * Must be an ASN1 parsing error.
  268|       |             * Free up any partial choice value
  269|       |             */
  270|      0|            asn1_template_free(pchptr, tt);
  271|      0|            errtt = tt;
  272|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  273|      0|            goto err;
  274|      0|        }
  275|       |
  276|       |        /* Did we fall off the end without reading anything? */
  277|      0|        if (i == it->tcount) {
  ------------------
  |  Branch (277:13): [True: 0, False: 0]
  ------------------
  278|       |            /* If OPTIONAL, this is OK */
  279|      0|            if (opt) {
  ------------------
  |  Branch (279:17): [True: 0, False: 0]
  ------------------
  280|       |                /* Free and zero it */
  281|      0|                ASN1_item_ex_free(pval, it);
  282|      0|                return -1;
  283|      0|            }
  284|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_NO_MATCHING_CHOICE_TYPE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  285|      0|            goto err;
  286|      0|        }
  287|       |
  288|      0|        asn1_set_choice_selector(pval, i, it);
  289|       |
  290|      0|        if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))
  ------------------
  |  |  761|      0|# define ASN1_OP_D2I_POST        5
  ------------------
  |  Branch (290:13): [True: 0, False: 0]
  |  Branch (290:24): [True: 0, False: 0]
  ------------------
  291|      0|            goto auxerr;
  292|      0|        *in = p;
  293|      0|        return 1;
  294|       |
  295|      0|    case ASN1_ITYPE_NDEF_SEQUENCE:
  ------------------
  |  |  643|      0|# define ASN1_ITYPE_NDEF_SEQUENCE        0x6
  ------------------
  |  Branch (295:5): [True: 0, False: 40.5k]
  ------------------
  296|      0|    case ASN1_ITYPE_SEQUENCE:
  ------------------
  |  |  635|      0|# define ASN1_ITYPE_SEQUENCE             0x1
  ------------------
  |  Branch (296:5): [True: 0, False: 40.5k]
  ------------------
  297|      0|        p = *in;
  298|      0|        tmplen = len;
  299|       |
  300|       |        /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */
  301|      0|        if (tag == -1) {
  ------------------
  |  Branch (301:13): [True: 0, False: 0]
  ------------------
  302|      0|            tag = V_ASN1_SEQUENCE;
  ------------------
  |  |   62|      0|# define V_ASN1_SEQUENCE                 16
  ------------------
  303|      0|            aclass = V_ASN1_UNIVERSAL;
  ------------------
  |  |   35|      0|# define V_ASN1_UNIVERSAL                0x00
  ------------------
  304|      0|        }
  305|       |        /* Get SEQUENCE length and update len, p */
  306|      0|        ret = asn1_check_tlen(&len, NULL, NULL, &seq_eoc, &cst,
  307|      0|                              &p, len, tag, aclass, opt, ctx);
  308|      0|        if (!ret) {
  ------------------
  |  Branch (308:13): [True: 0, False: 0]
  ------------------
  309|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  310|      0|            goto err;
  311|      0|        } else if (ret == -1)
  ------------------
  |  Branch (311:20): [True: 0, False: 0]
  ------------------
  312|      0|            return -1;
  313|      0|        if (aux && (aux->flags & ASN1_AFLG_BROKEN)) {
  ------------------
  |  |  752|      0|# define ASN1_AFLG_BROKEN        4
  ------------------
  |  Branch (313:13): [True: 0, False: 0]
  |  Branch (313:20): [True: 0, False: 0]
  ------------------
  314|      0|            len = tmplen - (p - *in);
  315|      0|            seq_nolen = 1;
  316|      0|        }
  317|       |        /* If indefinite we don't do a length check */
  318|      0|        else
  319|      0|            seq_nolen = seq_eoc;
  320|      0|        if (!cst) {
  ------------------
  |  Branch (320:13): [True: 0, False: 0]
  ------------------
  321|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_SEQUENCE_NOT_CONSTRUCTED);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  322|      0|            goto err;
  323|      0|        }
  324|       |
  325|      0|        if (!*pval && !ASN1_item_ex_new(pval, it)) {
  ------------------
  |  Branch (325:13): [True: 0, False: 0]
  |  Branch (325:23): [True: 0, False: 0]
  ------------------
  326|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  327|      0|            goto err;
  328|      0|        }
  329|       |
  330|      0|        if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
  ------------------
  |  |  760|      0|# define ASN1_OP_D2I_PRE         4
  ------------------
  |  Branch (330:13): [True: 0, False: 0]
  |  Branch (330:24): [True: 0, False: 0]
  ------------------
  331|      0|            goto auxerr;
  332|       |
  333|       |        /* Free up and zero any ADB found */
  334|      0|        for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
  ------------------
  |  Branch (334:41): [True: 0, False: 0]
  ------------------
  335|      0|            if (tt->flags & ASN1_TFLG_ADB_MASK) {
  ------------------
  |  |  562|      0|# define ASN1_TFLG_ADB_MASK      (0x3<<8)
  ------------------
  |  Branch (335:17): [True: 0, False: 0]
  ------------------
  336|      0|                const ASN1_TEMPLATE *seqtt;
  337|      0|                ASN1_VALUE **pseqval;
  338|      0|                seqtt = asn1_do_adb(pval, tt, 0);
  339|      0|                if (seqtt == NULL)
  ------------------
  |  Branch (339:21): [True: 0, False: 0]
  ------------------
  340|      0|                    continue;
  341|      0|                pseqval = asn1_get_field_ptr(pval, seqtt);
  342|      0|                asn1_template_free(pseqval, seqtt);
  343|      0|            }
  344|      0|        }
  345|       |
  346|       |        /* Get each field entry */
  347|      0|        for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
  ------------------
  |  Branch (347:41): [True: 0, False: 0]
  ------------------
  348|      0|            const ASN1_TEMPLATE *seqtt;
  349|      0|            ASN1_VALUE **pseqval;
  350|      0|            seqtt = asn1_do_adb(pval, tt, 1);
  351|      0|            if (seqtt == NULL)
  ------------------
  |  Branch (351:17): [True: 0, False: 0]
  ------------------
  352|      0|                goto err;
  353|      0|            pseqval = asn1_get_field_ptr(pval, seqtt);
  354|       |            /* Have we ran out of data? */
  355|      0|            if (!len)
  ------------------
  |  Branch (355:17): [True: 0, False: 0]
  ------------------
  356|      0|                break;
  357|      0|            q = p;
  358|      0|            if (asn1_check_eoc(&p, len)) {
  ------------------
  |  Branch (358:17): [True: 0, False: 0]
  ------------------
  359|      0|                if (!seq_eoc) {
  ------------------
  |  Branch (359:21): [True: 0, False: 0]
  ------------------
  360|      0|                    ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_UNEXPECTED_EOC);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  361|      0|                    goto err;
  362|      0|                }
  363|      0|                len -= p - q;
  364|      0|                seq_eoc = 0;
  365|      0|                q = p;
  366|      0|                break;
  367|      0|            }
  368|       |            /*
  369|       |             * This determines the OPTIONAL flag value. The field cannot be
  370|       |             * omitted if it is the last of a SEQUENCE and there is still
  371|       |             * data to be read. This isn't strictly necessary but it
  372|       |             * increases efficiency in some cases.
  373|       |             */
  374|      0|            if (i == (it->tcount - 1))
  ------------------
  |  Branch (374:17): [True: 0, False: 0]
  ------------------
  375|      0|                isopt = 0;
  376|      0|            else
  377|      0|                isopt = (char)(seqtt->flags & ASN1_TFLG_OPTIONAL);
  ------------------
  |  |  502|      0|# define ASN1_TFLG_OPTIONAL      (0x1)
  ------------------
  378|       |            /*
  379|       |             * attempt to read in field, allowing each to be OPTIONAL
  380|       |             */
  381|       |
  382|      0|            ret = asn1_template_ex_d2i(pseqval, &p, len, seqtt, isopt, ctx,
  383|      0|                                       depth);
  384|      0|            if (!ret) {
  ------------------
  |  Branch (384:17): [True: 0, False: 0]
  ------------------
  385|      0|                errtt = seqtt;
  386|      0|                goto err;
  387|      0|            } else if (ret == -1) {
  ------------------
  |  Branch (387:24): [True: 0, False: 0]
  ------------------
  388|       |                /*
  389|       |                 * OPTIONAL component absent. Free and zero the field.
  390|       |                 */
  391|      0|                asn1_template_free(pseqval, seqtt);
  392|      0|                continue;
  393|      0|            }
  394|       |            /* Update length */
  395|      0|            len -= p - q;
  396|      0|        }
  397|       |
  398|       |        /* Check for EOC if expecting one */
  399|      0|        if (seq_eoc && !asn1_check_eoc(&p, len)) {
  ------------------
  |  Branch (399:13): [True: 0, False: 0]
  |  Branch (399:24): [True: 0, False: 0]
  ------------------
  400|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_MISSING_EOC);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  401|      0|            goto err;
  402|      0|        }
  403|       |        /* Check all data read */
  404|      0|        if (!seq_nolen && len) {
  ------------------
  |  Branch (404:13): [True: 0, False: 0]
  |  Branch (404:27): [True: 0, False: 0]
  ------------------
  405|      0|            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_SEQUENCE_LENGTH_MISMATCH);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  406|      0|            goto err;
  407|      0|        }
  408|       |
  409|       |        /*
  410|       |         * If we get here we've got no more data in the SEQUENCE, however we
  411|       |         * may not have read all fields so check all remaining are OPTIONAL
  412|       |         * and clear any that are.
  413|       |         */
  414|      0|        for (; i < it->tcount; tt++, i++) {
  ------------------
  |  Branch (414:16): [True: 0, False: 0]
  ------------------
  415|      0|            const ASN1_TEMPLATE *seqtt;
  416|      0|            seqtt = asn1_do_adb(pval, tt, 1);
  417|      0|            if (seqtt == NULL)
  ------------------
  |  Branch (417:17): [True: 0, False: 0]
  ------------------
  418|      0|                goto err;
  419|      0|            if (seqtt->flags & ASN1_TFLG_OPTIONAL) {
  ------------------
  |  |  502|      0|# define ASN1_TFLG_OPTIONAL      (0x1)
  ------------------
  |  Branch (419:17): [True: 0, False: 0]
  ------------------
  420|      0|                ASN1_VALUE **pseqval;
  421|      0|                pseqval = asn1_get_field_ptr(pval, seqtt);
  422|      0|                asn1_template_free(pseqval, seqtt);
  423|      0|            } else {
  424|      0|                errtt = seqtt;
  425|      0|                ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_FIELD_MISSING);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  426|      0|                goto err;
  427|      0|            }
  428|      0|        }
  429|       |        /* Save encoding */
  430|      0|        if (!asn1_enc_save(pval, *in, p - *in, it))
  ------------------
  |  Branch (430:13): [True: 0, False: 0]
  ------------------
  431|      0|            goto auxerr;
  432|      0|        if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))
  ------------------
  |  |  761|      0|# define ASN1_OP_D2I_POST        5
  ------------------
  |  Branch (432:13): [True: 0, False: 0]
  |  Branch (432:24): [True: 0, False: 0]
  ------------------
  433|      0|            goto auxerr;
  434|      0|        *in = p;
  435|      0|        return 1;
  436|       |
  437|      0|    default:
  ------------------
  |  Branch (437:5): [True: 0, False: 40.5k]
  ------------------
  438|      0|        return 0;
  439|  40.5k|    }
  440|      0| auxerr:
  441|      0|    ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_AUX_ERROR);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  442|      0| err:
  443|      0|    if (errtt)
  ------------------
  |  Branch (443:9): [True: 0, False: 0]
  ------------------
  444|      0|        ERR_add_error_data(4, "Field=", errtt->field_name,
  445|      0|                           ", Type=", it->sname);
  446|      0|    else
  447|      0|        ERR_add_error_data(2, "Type=", it->sname);
  448|      0|    return 0;
  449|      0|}
tasn_dec.c:asn1_d2i_ex_primitive:
  663|  40.5k|{
  664|  40.5k|    int ret = 0, utype;
  665|  40.5k|    long plen;
  666|  40.5k|    char cst, inf, free_cont = 0;
  667|  40.5k|    const unsigned char *p;
  668|  40.5k|    BUF_MEM buf = { 0, NULL, 0, 0 };
  669|  40.5k|    const unsigned char *cont = NULL;
  670|  40.5k|    long len;
  671|  40.5k|    if (!pval) {
  ------------------
  |  Branch (671:9): [True: 0, False: 40.5k]
  ------------------
  672|      0|        ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_NULL);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  673|      0|        return 0;               /* Should never happen */
  674|      0|    }
  675|       |
  676|  40.5k|    if (it->itype == ASN1_ITYPE_MSTRING) {
  ------------------
  |  |  641|  40.5k|# define ASN1_ITYPE_MSTRING              0x5
  ------------------
  |  Branch (676:9): [True: 0, False: 40.5k]
  ------------------
  677|      0|        utype = tag;
  678|      0|        tag = -1;
  679|      0|    } else
  680|  40.5k|        utype = it->utype;
  681|       |
  682|  40.5k|    if (utype == V_ASN1_ANY) {
  ------------------
  |  |   46|  40.5k|# define V_ASN1_ANY                      -4/* used in ASN1 template code */
  ------------------
  |  Branch (682:9): [True: 0, False: 40.5k]
  ------------------
  683|       |        /* If type is ANY need to figure out type from tag */
  684|      0|        unsigned char oclass;
  685|      0|        if (tag >= 0) {
  ------------------
  |  Branch (685:13): [True: 0, False: 0]
  ------------------
  686|      0|            ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_TAGGED_ANY);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  687|      0|            return 0;
  688|      0|        }
  689|      0|        if (opt) {
  ------------------
  |  Branch (689:13): [True: 0, False: 0]
  ------------------
  690|      0|            ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE,
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  691|      0|                    ASN1_R_ILLEGAL_OPTIONAL_ANY);
  692|      0|            return 0;
  693|      0|        }
  694|      0|        p = *in;
  695|      0|        ret = asn1_check_tlen(NULL, &utype, &oclass, NULL, NULL,
  696|      0|                              &p, inlen, -1, 0, 0, ctx);
  697|      0|        if (!ret) {
  ------------------
  |  Branch (697:13): [True: 0, False: 0]
  ------------------
  698|      0|            ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  699|      0|            return 0;
  700|      0|        }
  701|      0|        if (oclass != V_ASN1_UNIVERSAL)
  ------------------
  |  |   35|      0|# define V_ASN1_UNIVERSAL                0x00
  ------------------
  |  Branch (701:13): [True: 0, False: 0]
  ------------------
  702|      0|            utype = V_ASN1_OTHER;
  ------------------
  |  |   45|      0|# define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */
  ------------------
  703|      0|    }
  704|  40.5k|    if (tag == -1) {
  ------------------
  |  Branch (704:9): [True: 40.5k, False: 0]
  ------------------
  705|  40.5k|        tag = utype;
  706|  40.5k|        aclass = V_ASN1_UNIVERSAL;
  ------------------
  |  |   35|  40.5k|# define V_ASN1_UNIVERSAL                0x00
  ------------------
  707|  40.5k|    }
  708|  40.5k|    p = *in;
  709|       |    /* Check header */
  710|  40.5k|    ret = asn1_check_tlen(&plen, NULL, NULL, &inf, &cst,
  711|  40.5k|                          &p, inlen, tag, aclass, opt, ctx);
  712|  40.5k|    if (!ret) {
  ------------------
  |  Branch (712:9): [True: 651, False: 39.9k]
  ------------------
  713|    651|        ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR);
  ------------------
  |  |  111|    651|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|    651|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  714|    651|        return 0;
  715|  39.9k|    } else if (ret == -1)
  ------------------
  |  Branch (715:16): [True: 0, False: 39.9k]
  ------------------
  716|      0|        return -1;
  717|  39.9k|    ret = 0;
  718|       |    /* SEQUENCE, SET and "OTHER" are left in encoded form */
  719|  39.9k|    if ((utype == V_ASN1_SEQUENCE)
  ------------------
  |  |   62|  39.9k|# define V_ASN1_SEQUENCE                 16
  ------------------
  |  Branch (719:9): [True: 0, False: 39.9k]
  ------------------
  720|  39.9k|        || (utype == V_ASN1_SET) || (utype == V_ASN1_OTHER)) {
  ------------------
  |  |   63|  39.9k|# define V_ASN1_SET                      17
  ------------------
                      || (utype == V_ASN1_SET) || (utype == V_ASN1_OTHER)) {
  ------------------
  |  |   45|  39.9k|# define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */
  ------------------
  |  Branch (720:12): [True: 0, False: 39.9k]
  |  Branch (720:37): [True: 0, False: 39.9k]
  ------------------
  721|       |        /*
  722|       |         * Clear context cache for type OTHER because the auto clear when we
  723|       |         * have a exact match won't work
  724|       |         */
  725|      0|        if (utype == V_ASN1_OTHER) {
  ------------------
  |  |   45|      0|# define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */
  ------------------
  |  Branch (725:13): [True: 0, False: 0]
  ------------------
  726|      0|            asn1_tlc_clear(ctx);
  ------------------
  |  |   94|      0|#define asn1_tlc_clear(c)       if (c) (c)->valid = 0
  |  |  ------------------
  |  |  |  Branch (94:37): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  727|      0|        }
  728|       |        /* SEQUENCE and SET must be constructed */
  729|      0|        else if (!cst) {
  ------------------
  |  Branch (729:18): [True: 0, False: 0]
  ------------------
  730|      0|            ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE,
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  731|      0|                    ASN1_R_TYPE_NOT_CONSTRUCTED);
  732|      0|            return 0;
  733|      0|        }
  734|       |
  735|      0|        cont = *in;
  736|       |        /* If indefinite length constructed find the real end */
  737|      0|        if (inf) {
  ------------------
  |  Branch (737:13): [True: 0, False: 0]
  ------------------
  738|      0|            if (!asn1_find_end(&p, plen, inf))
  ------------------
  |  Branch (738:17): [True: 0, False: 0]
  ------------------
  739|      0|                goto err;
  740|      0|            len = p - cont;
  741|      0|        } else {
  742|      0|            len = p - cont + plen;
  743|      0|            p += plen;
  744|      0|        }
  745|  39.9k|    } else if (cst) {
  ------------------
  |  Branch (745:16): [True: 0, False: 39.9k]
  ------------------
  746|      0|        if (utype == V_ASN1_NULL || utype == V_ASN1_BOOLEAN
  ------------------
  |  |   55|      0|# define V_ASN1_NULL                     5
  ------------------
                      if (utype == V_ASN1_NULL || utype == V_ASN1_BOOLEAN
  ------------------
  |  |   51|      0|# define V_ASN1_BOOLEAN                  1 /**/
  ------------------
  |  Branch (746:13): [True: 0, False: 0]
  |  Branch (746:37): [True: 0, False: 0]
  ------------------
  747|      0|            || utype == V_ASN1_OBJECT || utype == V_ASN1_INTEGER
  ------------------
  |  |   56|      0|# define V_ASN1_OBJECT                   6
  ------------------
                          || utype == V_ASN1_OBJECT || utype == V_ASN1_INTEGER
  ------------------
  |  |   52|      0|# define V_ASN1_INTEGER                  2
  ------------------
  |  Branch (747:16): [True: 0, False: 0]
  |  Branch (747:42): [True: 0, False: 0]
  ------------------
  748|      0|            || utype == V_ASN1_ENUMERATED) {
  ------------------
  |  |   60|      0|# define V_ASN1_ENUMERATED               10
  ------------------
  |  Branch (748:16): [True: 0, False: 0]
  ------------------
  749|      0|            ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_TYPE_NOT_PRIMITIVE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  750|      0|            return 0;
  751|      0|        }
  752|       |
  753|       |        /* Free any returned 'buf' content */
  754|      0|        free_cont = 1;
  755|       |        /*
  756|       |         * Should really check the internal tags are correct but some things
  757|       |         * may get this wrong. The relevant specs say that constructed string
  758|       |         * types should be OCTET STRINGs internally irrespective of the type.
  759|       |         * So instead just check for UNIVERSAL class and ignore the tag.
  760|       |         */
  761|      0|        if (!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL, 0)) {
  ------------------
  |  |   35|      0|# define V_ASN1_UNIVERSAL                0x00
  ------------------
  |  Branch (761:13): [True: 0, False: 0]
  ------------------
  762|      0|            goto err;
  763|      0|        }
  764|      0|        len = buf.length;
  765|       |        /* Append a final null to string */
  766|      0|        if (!BUF_MEM_grow_clean(&buf, len + 1)) {
  ------------------
  |  Branch (766:13): [True: 0, False: 0]
  ------------------
  767|      0|            ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  768|      0|            goto err;
  769|      0|        }
  770|      0|        buf.data[len] = 0;
  771|      0|        cont = (const unsigned char *)buf.data;
  772|  39.9k|    } else {
  773|  39.9k|        cont = p;
  774|  39.9k|        len = plen;
  775|  39.9k|        p += plen;
  776|  39.9k|    }
  777|       |
  778|       |    /* We now have content length and type: translate into a structure */
  779|       |    /* asn1_ex_c2i may reuse allocated buffer, and so sets free_cont to 0 */
  780|  39.9k|    if (!asn1_ex_c2i(pval, cont, len, utype, &free_cont, it))
  ------------------
  |  Branch (780:9): [True: 1.41k, False: 38.4k]
  ------------------
  781|  1.41k|        goto err;
  782|       |
  783|  38.4k|    *in = p;
  784|  38.4k|    ret = 1;
  785|  39.9k| err:
  786|  39.9k|    if (free_cont)
  ------------------
  |  Branch (786:9): [True: 0, False: 39.9k]
  ------------------
  787|      0|        OPENSSL_free(buf.data);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  788|  39.9k|    return ret;
  789|  38.4k|}
tasn_dec.c:asn1_ex_c2i:
  795|  39.9k|{
  796|  39.9k|    ASN1_VALUE **opval = NULL;
  797|  39.9k|    ASN1_STRING *stmp;
  798|  39.9k|    ASN1_TYPE *typ = NULL;
  799|  39.9k|    int ret = 0;
  800|  39.9k|    const ASN1_PRIMITIVE_FUNCS *pf;
  801|  39.9k|    ASN1_INTEGER **tint;
  802|  39.9k|    pf = it->funcs;
  803|       |
  804|  39.9k|    if (pf && pf->prim_c2i)
  ------------------
  |  Branch (804:9): [True: 0, False: 39.9k]
  |  Branch (804:15): [True: 0, False: 0]
  ------------------
  805|      0|        return pf->prim_c2i(pval, cont, len, utype, free_cont, it);
  806|       |    /* If ANY type clear type and set pointer to internal value */
  807|  39.9k|    if (it->utype == V_ASN1_ANY) {
  ------------------
  |  |   46|  39.9k|# define V_ASN1_ANY                      -4/* used in ASN1 template code */
  ------------------
  |  Branch (807:9): [True: 0, False: 39.9k]
  ------------------
  808|      0|        if (!*pval) {
  ------------------
  |  Branch (808:13): [True: 0, False: 0]
  ------------------
  809|      0|            typ = ASN1_TYPE_new();
  810|      0|            if (typ == NULL)
  ------------------
  |  Branch (810:17): [True: 0, False: 0]
  ------------------
  811|      0|                goto err;
  812|      0|            *pval = (ASN1_VALUE *)typ;
  813|      0|        } else
  814|      0|            typ = (ASN1_TYPE *)*pval;
  815|       |
  816|      0|        if (utype != typ->type)
  ------------------
  |  Branch (816:13): [True: 0, False: 0]
  ------------------
  817|      0|            ASN1_TYPE_set(typ, utype, NULL);
  818|      0|        opval = pval;
  819|      0|        pval = &typ->value.asn1_value;
  820|      0|    }
  821|  39.9k|    switch (utype) {
  822|      0|    case V_ASN1_OBJECT:
  ------------------
  |  |   56|      0|# define V_ASN1_OBJECT                   6
  ------------------
  |  Branch (822:5): [True: 0, False: 39.9k]
  ------------------
  823|      0|        if (!c2i_ASN1_OBJECT((ASN1_OBJECT **)pval, &cont, len))
  ------------------
  |  Branch (823:13): [True: 0, False: 0]
  ------------------
  824|      0|            goto err;
  825|      0|        break;
  826|       |
  827|      0|    case V_ASN1_NULL:
  ------------------
  |  |   55|      0|# define V_ASN1_NULL                     5
  ------------------
  |  Branch (827:5): [True: 0, False: 39.9k]
  ------------------
  828|      0|        if (len) {
  ------------------
  |  Branch (828:13): [True: 0, False: 0]
  ------------------
  829|      0|            ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_NULL_IS_WRONG_LENGTH);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  830|      0|            goto err;
  831|      0|        }
  832|      0|        *pval = (ASN1_VALUE *)1;
  833|      0|        break;
  834|       |
  835|      0|    case V_ASN1_BOOLEAN:
  ------------------
  |  |   51|      0|# define V_ASN1_BOOLEAN                  1 /**/
  ------------------
  |  Branch (835:5): [True: 0, False: 39.9k]
  ------------------
  836|      0|        if (len != 1) {
  ------------------
  |  Branch (836:13): [True: 0, False: 0]
  ------------------
  837|      0|            ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_BOOLEAN_IS_WRONG_LENGTH);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  838|      0|            goto err;
  839|      0|        } else {
  840|      0|            ASN1_BOOLEAN *tbool;
  841|      0|            tbool = (ASN1_BOOLEAN *)pval;
  842|      0|            *tbool = *cont;
  843|      0|        }
  844|      0|        break;
  845|       |
  846|      0|    case V_ASN1_BIT_STRING:
  ------------------
  |  |   53|      0|# define V_ASN1_BIT_STRING               3
  ------------------
  |  Branch (846:5): [True: 0, False: 39.9k]
  ------------------
  847|      0|        if (!c2i_ASN1_BIT_STRING((ASN1_BIT_STRING **)pval, &cont, len))
  ------------------
  |  Branch (847:13): [True: 0, False: 0]
  ------------------
  848|      0|            goto err;
  849|      0|        break;
  850|       |
  851|  36.6k|    case V_ASN1_INTEGER:
  ------------------
  |  |   52|  36.6k|# define V_ASN1_INTEGER                  2
  ------------------
  |  Branch (851:5): [True: 36.6k, False: 3.22k]
  ------------------
  852|  38.0k|    case V_ASN1_ENUMERATED:
  ------------------
  |  |   60|  38.0k|# define V_ASN1_ENUMERATED               10
  ------------------
  |  Branch (852:5): [True: 1.33k, False: 38.5k]
  ------------------
  853|  38.0k|        tint = (ASN1_INTEGER **)pval;
  854|  38.0k|        if (!c2i_ASN1_INTEGER(tint, &cont, len))
  ------------------
  |  Branch (854:13): [True: 1.41k, False: 36.5k]
  ------------------
  855|  1.41k|            goto err;
  856|       |        /* Fixup type to match the expected form */
  857|  36.5k|        (*tint)->type = utype | ((*tint)->type & V_ASN1_NEG);
  ------------------
  |  |   85|  36.5k|# define V_ASN1_NEG                      0x100
  ------------------
  858|  36.5k|        break;
  859|       |
  860|  1.89k|    case V_ASN1_OCTET_STRING:
  ------------------
  |  |   54|  1.89k|# define V_ASN1_OCTET_STRING             4
  ------------------
  |  Branch (860:5): [True: 1.89k, False: 38.0k]
  ------------------
  861|  1.89k|    case V_ASN1_NUMERICSTRING:
  ------------------
  |  |   64|  1.89k|# define V_ASN1_NUMERICSTRING            18 /**/
  ------------------
  |  Branch (861:5): [True: 0, False: 39.9k]
  ------------------
  862|  1.89k|    case V_ASN1_PRINTABLESTRING:
  ------------------
  |  |   65|  1.89k|# define V_ASN1_PRINTABLESTRING          19
  ------------------
  |  Branch (862:5): [True: 0, False: 39.9k]
  ------------------
  863|  1.89k|    case V_ASN1_T61STRING:
  ------------------
  |  |   66|  1.89k|# define V_ASN1_T61STRING                20
  ------------------
  |  Branch (863:5): [True: 0, False: 39.9k]
  ------------------
  864|  1.89k|    case V_ASN1_VIDEOTEXSTRING:
  ------------------
  |  |   68|  1.89k|# define V_ASN1_VIDEOTEXSTRING           21 /**/
  ------------------
  |  Branch (864:5): [True: 0, False: 39.9k]
  ------------------
  865|  1.89k|    case V_ASN1_IA5STRING:
  ------------------
  |  |   69|  1.89k|# define V_ASN1_IA5STRING                22
  ------------------
  |  Branch (865:5): [True: 0, False: 39.9k]
  ------------------
  866|  1.89k|    case V_ASN1_UTCTIME:
  ------------------
  |  |   70|  1.89k|# define V_ASN1_UTCTIME                  23
  ------------------
  |  Branch (866:5): [True: 0, False: 39.9k]
  ------------------
  867|  1.89k|    case V_ASN1_GENERALIZEDTIME:
  ------------------
  |  |   71|  1.89k|# define V_ASN1_GENERALIZEDTIME          24 /**/
  ------------------
  |  Branch (867:5): [True: 0, False: 39.9k]
  ------------------
  868|  1.89k|    case V_ASN1_GRAPHICSTRING:
  ------------------
  |  |   72|  1.89k|# define V_ASN1_GRAPHICSTRING            25 /**/
  ------------------
  |  Branch (868:5): [True: 0, False: 39.9k]
  ------------------
  869|  1.89k|    case V_ASN1_VISIBLESTRING:
  ------------------
  |  |   74|  1.89k|# define V_ASN1_VISIBLESTRING            26/* alias */
  ------------------
  |  Branch (869:5): [True: 0, False: 39.9k]
  ------------------
  870|  1.89k|    case V_ASN1_GENERALSTRING:
  ------------------
  |  |   75|  1.89k|# define V_ASN1_GENERALSTRING            27 /**/
  ------------------
  |  Branch (870:5): [True: 0, False: 39.9k]
  ------------------
  871|  1.89k|    case V_ASN1_UNIVERSALSTRING:
  ------------------
  |  |   76|  1.89k|# define V_ASN1_UNIVERSALSTRING          28 /**/
  ------------------
  |  Branch (871:5): [True: 0, False: 39.9k]
  ------------------
  872|  1.89k|    case V_ASN1_BMPSTRING:
  ------------------
  |  |   77|  1.89k|# define V_ASN1_BMPSTRING                30
  ------------------
  |  Branch (872:5): [True: 0, False: 39.9k]
  ------------------
  873|  1.89k|    case V_ASN1_UTF8STRING:
  ------------------
  |  |   61|  1.89k|# define V_ASN1_UTF8STRING               12
  ------------------
  |  Branch (873:5): [True: 0, False: 39.9k]
  ------------------
  874|  1.89k|    case V_ASN1_OTHER:
  ------------------
  |  |   45|  1.89k|# define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */
  ------------------
  |  Branch (874:5): [True: 0, False: 39.9k]
  ------------------
  875|  1.89k|    case V_ASN1_SET:
  ------------------
  |  |   63|  1.89k|# define V_ASN1_SET                      17
  ------------------
  |  Branch (875:5): [True: 0, False: 39.9k]
  ------------------
  876|  1.89k|    case V_ASN1_SEQUENCE:
  ------------------
  |  |   62|  1.89k|# define V_ASN1_SEQUENCE                 16
  ------------------
  |  Branch (876:5): [True: 0, False: 39.9k]
  ------------------
  877|  1.89k|    default:
  ------------------
  |  Branch (877:5): [True: 0, False: 39.9k]
  ------------------
  878|  1.89k|        if (utype == V_ASN1_BMPSTRING && (len & 1)) {
  ------------------
  |  |   77|  3.79k|# define V_ASN1_BMPSTRING                30
  ------------------
  |  Branch (878:13): [True: 0, False: 1.89k]
  |  Branch (878:42): [True: 0, False: 0]
  ------------------
  879|      0|            ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_BMPSTRING_IS_WRONG_LENGTH);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  880|      0|            goto err;
  881|      0|        }
  882|  1.89k|        if (utype == V_ASN1_UNIVERSALSTRING && (len & 3)) {
  ------------------
  |  |   76|  3.79k|# define V_ASN1_UNIVERSALSTRING          28 /**/
  ------------------
  |  Branch (882:13): [True: 0, False: 1.89k]
  |  Branch (882:48): [True: 0, False: 0]
  ------------------
  883|      0|            ASN1err(ASN1_F_ASN1_EX_C2I,
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  884|      0|                    ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH);
  885|      0|            goto err;
  886|      0|        }
  887|       |        /* All based on ASN1_STRING and handled the same */
  888|  1.89k|        if (!*pval) {
  ------------------
  |  Branch (888:13): [True: 1.89k, False: 0]
  ------------------
  889|  1.89k|            stmp = ASN1_STRING_type_new(utype);
  890|  1.89k|            if (stmp == NULL) {
  ------------------
  |  Branch (890:17): [True: 0, False: 1.89k]
  ------------------
  891|      0|                ASN1err(ASN1_F_ASN1_EX_C2I, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  892|      0|                goto err;
  893|      0|            }
  894|  1.89k|            *pval = (ASN1_VALUE *)stmp;
  895|  1.89k|        } else {
  896|      0|            stmp = (ASN1_STRING *)*pval;
  897|      0|            stmp->type = utype;
  898|      0|        }
  899|       |        /* If we've already allocated a buffer use it */
  900|  1.89k|        if (*free_cont) {
  ------------------
  |  Branch (900:13): [True: 0, False: 1.89k]
  ------------------
  901|      0|            OPENSSL_free(stmp->data);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  902|      0|            stmp->data = (unsigned char *)cont; /* UGLY CAST! RL */
  903|      0|            stmp->length = len;
  904|      0|            *free_cont = 0;
  905|  1.89k|        } else {
  906|  1.89k|            if (!ASN1_STRING_set(stmp, cont, len)) {
  ------------------
  |  Branch (906:17): [True: 0, False: 1.89k]
  ------------------
  907|      0|                ASN1err(ASN1_F_ASN1_EX_C2I, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  908|      0|                ASN1_STRING_free(stmp);
  909|      0|                *pval = NULL;
  910|      0|                goto err;
  911|      0|            }
  912|  1.89k|        }
  913|  1.89k|        break;
  914|  39.9k|    }
  915|       |    /* If ASN1_ANY and NULL type fix up value */
  916|  38.4k|    if (typ && (utype == V_ASN1_NULL))
  ------------------
  |  |   55|      0|# define V_ASN1_NULL                     5
  ------------------
  |  Branch (916:9): [True: 0, False: 38.4k]
  |  Branch (916:16): [True: 0, False: 0]
  ------------------
  917|      0|        typ->value.ptr = NULL;
  918|       |
  919|  38.4k|    ret = 1;
  920|  39.9k| err:
  921|  39.9k|    if (!ret) {
  ------------------
  |  Branch (921:9): [True: 1.41k, False: 38.4k]
  ------------------
  922|  1.41k|        ASN1_TYPE_free(typ);
  923|  1.41k|        if (opval)
  ------------------
  |  Branch (923:13): [True: 0, False: 1.41k]
  ------------------
  924|      0|            *opval = NULL;
  925|  1.41k|    }
  926|  39.9k|    return ret;
  927|  38.4k|}
tasn_dec.c:asn1_check_tlen:
 1101|  40.5k|{
 1102|  40.5k|    int i;
 1103|  40.5k|    int ptag, pclass;
 1104|  40.5k|    long plen;
 1105|  40.5k|    const unsigned char *p, *q;
 1106|  40.5k|    p = *in;
 1107|  40.5k|    q = p;
 1108|       |
 1109|  40.5k|    if (ctx && ctx->valid) {
  ------------------
  |  Branch (1109:9): [True: 40.5k, False: 0]
  |  Branch (1109:16): [True: 0, False: 40.5k]
  ------------------
 1110|      0|        i = ctx->ret;
 1111|      0|        plen = ctx->plen;
 1112|      0|        pclass = ctx->pclass;
 1113|      0|        ptag = ctx->ptag;
 1114|      0|        p += ctx->hdrlen;
 1115|  40.5k|    } else {
 1116|  40.5k|        i = ASN1_get_object(&p, &plen, &ptag, &pclass, len);
 1117|  40.5k|        if (ctx) {
  ------------------
  |  Branch (1117:13): [True: 40.5k, False: 0]
  ------------------
 1118|  40.5k|            ctx->ret = i;
 1119|  40.5k|            ctx->plen = plen;
 1120|  40.5k|            ctx->pclass = pclass;
 1121|  40.5k|            ctx->ptag = ptag;
 1122|  40.5k|            ctx->hdrlen = p - q;
 1123|  40.5k|            ctx->valid = 1;
 1124|       |            /*
 1125|       |             * If definite length, and no error, length + header can't exceed
 1126|       |             * total amount of data available.
 1127|       |             */
 1128|  40.5k|            if (!(i & 0x81) && ((plen + ctx->hdrlen) > len)) {
  ------------------
  |  Branch (1128:17): [True: 39.9k, False: 651]
  |  Branch (1128:32): [True: 0, False: 39.9k]
  ------------------
 1129|      0|                ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_TOO_LONG);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
 1130|      0|                asn1_tlc_clear(ctx);
  ------------------
  |  |   94|      0|#define asn1_tlc_clear(c)       if (c) (c)->valid = 0
  |  |  ------------------
  |  |  |  Branch (94:37): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1131|      0|                return 0;
 1132|      0|            }
 1133|  40.5k|        }
 1134|  40.5k|    }
 1135|       |
 1136|  40.5k|    if (i & 0x80) {
  ------------------
  |  Branch (1136:9): [True: 651, False: 39.9k]
  ------------------
 1137|    651|        ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_BAD_OBJECT_HEADER);
  ------------------
  |  |  111|    651|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|    651|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
 1138|    651|        asn1_tlc_clear(ctx);
  ------------------
  |  |   94|    651|#define asn1_tlc_clear(c)       if (c) (c)->valid = 0
  |  |  ------------------
  |  |  |  Branch (94:37): [True: 651, False: 0]
  |  |  ------------------
  ------------------
 1139|    651|        return 0;
 1140|    651|    }
 1141|  39.9k|    if (exptag >= 0) {
  ------------------
  |  Branch (1141:9): [True: 39.9k, False: 0]
  ------------------
 1142|  39.9k|        if ((exptag != ptag) || (expclass != pclass)) {
  ------------------
  |  Branch (1142:13): [True: 0, False: 39.9k]
  |  Branch (1142:33): [True: 0, False: 39.9k]
  ------------------
 1143|       |            /*
 1144|       |             * If type is OPTIONAL, not an error: indicate missing type.
 1145|       |             */
 1146|      0|            if (opt)
  ------------------
  |  Branch (1146:17): [True: 0, False: 0]
  ------------------
 1147|      0|                return -1;
 1148|      0|            asn1_tlc_clear(ctx);
  ------------------
  |  |   94|      0|#define asn1_tlc_clear(c)       if (c) (c)->valid = 0
  |  |  ------------------
  |  |  |  Branch (94:37): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1149|      0|            ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_WRONG_TAG);
  ------------------
  |  |  111|      0|# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
 1150|      0|            return 0;
 1151|      0|        }
 1152|       |        /*
 1153|       |         * We have a tag and class match: assume we are going to do something
 1154|       |         * with it
 1155|       |         */
 1156|  39.9k|        asn1_tlc_clear(ctx);
  ------------------
  |  |   94|  39.9k|#define asn1_tlc_clear(c)       if (c) (c)->valid = 0
  |  |  ------------------
  |  |  |  Branch (94:37): [True: 39.9k, False: 0]
  |  |  ------------------
  ------------------
 1157|  39.9k|    }
 1158|       |
 1159|  39.9k|    if (i & 1)
  ------------------
  |  Branch (1159:9): [True: 0, False: 39.9k]
  ------------------
 1160|      0|        plen = len - (p - q);
 1161|       |
 1162|  39.9k|    if (inf)
  ------------------
  |  Branch (1162:9): [True: 39.9k, False: 0]
  ------------------
 1163|  39.9k|        *inf = i & 1;
 1164|       |
 1165|  39.9k|    if (cst)
  ------------------
  |  Branch (1165:9): [True: 39.9k, False: 0]
  ------------------
 1166|  39.9k|        *cst = i & V_ASN1_CONSTRUCTED;
  ------------------
  |  |   40|  39.9k|# define V_ASN1_CONSTRUCTED              0x20
  ------------------
 1167|       |
 1168|  39.9k|    if (olen)
  ------------------
  |  Branch (1168:9): [True: 39.9k, False: 0]
  ------------------
 1169|  39.9k|        *olen = plen;
 1170|       |
 1171|  39.9k|    if (oclass)
  ------------------
  |  Branch (1171:9): [True: 0, False: 39.9k]
  ------------------
 1172|      0|        *oclass = pclass;
 1173|       |
 1174|  39.9k|    if (otag)
  ------------------
  |  Branch (1174:9): [True: 0, False: 39.9k]
  ------------------
 1175|      0|        *otag = ptag;
 1176|       |
 1177|  39.9k|    *in = p;
 1178|  39.9k|    return 1;
 1179|  39.9k|}

ASN1_item_free:
   19|  1.41k|{
   20|  1.41k|    asn1_item_embed_free(&val, it, 0);
   21|  1.41k|}
ASN1_item_ex_free:
   24|  2.06k|{
   25|  2.06k|    asn1_item_embed_free(pval, it, 0);
   26|  2.06k|}
asn1_item_embed_free:
   29|  3.47k|{
   30|  3.47k|    const ASN1_TEMPLATE *tt = NULL, *seqtt;
   31|  3.47k|    const ASN1_EXTERN_FUNCS *ef;
   32|  3.47k|    const ASN1_AUX *aux = it->funcs;
   33|  3.47k|    ASN1_aux_cb *asn1_cb;
   34|  3.47k|    int i;
   35|       |
   36|  3.47k|    if (!pval)
  ------------------
  |  Branch (36:9): [True: 0, False: 3.47k]
  ------------------
   37|      0|        return;
   38|  3.47k|    if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval)
  ------------------
  |  |  633|  3.47k|# define ASN1_ITYPE_PRIMITIVE            0x0
  ------------------
  |  Branch (38:9): [True: 0, False: 3.47k]
  |  Branch (38:48): [True: 0, False: 0]
  ------------------
   39|      0|        return;
   40|  3.47k|    if (aux && aux->asn1_cb)
  ------------------
  |  Branch (40:9): [True: 0, False: 3.47k]
  |  Branch (40:16): [True: 0, False: 0]
  ------------------
   41|      0|        asn1_cb = aux->asn1_cb;
   42|  3.47k|    else
   43|  3.47k|        asn1_cb = 0;
   44|       |
   45|  3.47k|    switch (it->itype) {
  ------------------
  |  Branch (45:13): [True: 0, False: 3.47k]
  ------------------
   46|       |
   47|  3.47k|    case ASN1_ITYPE_PRIMITIVE:
  ------------------
  |  |  633|  3.47k|# define ASN1_ITYPE_PRIMITIVE            0x0
  ------------------
  |  Branch (47:5): [True: 3.47k, False: 0]
  ------------------
   48|  3.47k|        if (it->templates)
  ------------------
  |  Branch (48:13): [True: 0, False: 3.47k]
  ------------------
   49|      0|            asn1_template_free(pval, it->templates);
   50|  3.47k|        else
   51|  3.47k|            asn1_primitive_free(pval, it, embed);
   52|  3.47k|        break;
   53|       |
   54|      0|    case ASN1_ITYPE_MSTRING:
  ------------------
  |  |  641|      0|# define ASN1_ITYPE_MSTRING              0x5
  ------------------
  |  Branch (54:5): [True: 0, False: 3.47k]
  ------------------
   55|      0|        asn1_primitive_free(pval, it, embed);
   56|      0|        break;
   57|       |
   58|      0|    case ASN1_ITYPE_CHOICE:
  ------------------
  |  |  637|      0|# define ASN1_ITYPE_CHOICE               0x2
  ------------------
  |  Branch (58:5): [True: 0, False: 3.47k]
  ------------------
   59|      0|        if (asn1_cb) {
  ------------------
  |  Branch (59:13): [True: 0, False: 0]
  ------------------
   60|      0|            i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
  ------------------
  |  |  758|      0|# define ASN1_OP_FREE_PRE        2
  ------------------
   61|      0|            if (i == 2)
  ------------------
  |  Branch (61:17): [True: 0, False: 0]
  ------------------
   62|      0|                return;
   63|      0|        }
   64|      0|        i = asn1_get_choice_selector(pval, it);
   65|      0|        if ((i >= 0) && (i < it->tcount)) {
  ------------------
  |  Branch (65:13): [True: 0, False: 0]
  |  Branch (65:25): [True: 0, False: 0]
  ------------------
   66|      0|            ASN1_VALUE **pchval;
   67|       |
   68|      0|            tt = it->templates + i;
   69|      0|            pchval = asn1_get_field_ptr(pval, tt);
   70|      0|            asn1_template_free(pchval, tt);
   71|      0|        }
   72|      0|        if (asn1_cb)
  ------------------
  |  Branch (72:13): [True: 0, False: 0]
  ------------------
   73|      0|            asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL);
  ------------------
  |  |  759|      0|# define ASN1_OP_FREE_POST       3
  ------------------
   74|      0|        if (embed == 0) {
  ------------------
  |  Branch (74:13): [True: 0, False: 0]
  ------------------
   75|      0|            OPENSSL_free(*pval);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   76|      0|            *pval = NULL;
   77|      0|        }
   78|      0|        break;
   79|       |
   80|      0|    case ASN1_ITYPE_EXTERN:
  ------------------
  |  |  639|      0|# define ASN1_ITYPE_EXTERN               0x4
  ------------------
  |  Branch (80:5): [True: 0, False: 3.47k]
  ------------------
   81|      0|        ef = it->funcs;
   82|      0|        if (ef && ef->asn1_ex_free)
  ------------------
  |  Branch (82:13): [True: 0, False: 0]
  |  Branch (82:19): [True: 0, False: 0]
  ------------------
   83|      0|            ef->asn1_ex_free(pval, it);
   84|      0|        break;
   85|       |
   86|      0|    case ASN1_ITYPE_NDEF_SEQUENCE:
  ------------------
  |  |  643|      0|# define ASN1_ITYPE_NDEF_SEQUENCE        0x6
  ------------------
  |  Branch (86:5): [True: 0, False: 3.47k]
  ------------------
   87|      0|    case ASN1_ITYPE_SEQUENCE:
  ------------------
  |  |  635|      0|# define ASN1_ITYPE_SEQUENCE             0x1
  ------------------
  |  Branch (87:5): [True: 0, False: 3.47k]
  ------------------
   88|      0|        if (asn1_do_lock(pval, -1, it) != 0) /* if error or ref-counter > 0 */
  ------------------
  |  Branch (88:13): [True: 0, False: 0]
  ------------------
   89|      0|            return;
   90|      0|        if (asn1_cb) {
  ------------------
  |  Branch (90:13): [True: 0, False: 0]
  ------------------
   91|      0|            i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
  ------------------
  |  |  758|      0|# define ASN1_OP_FREE_PRE        2
  ------------------
   92|      0|            if (i == 2)
  ------------------
  |  Branch (92:17): [True: 0, False: 0]
  ------------------
   93|      0|                return;
   94|      0|        }
   95|      0|        asn1_enc_free(pval, it);
   96|       |        /*
   97|       |         * If we free up as normal we will invalidate any ANY DEFINED BY
   98|       |         * field and we won't be able to determine the type of the field it
   99|       |         * defines. So free up in reverse order.
  100|       |         */
  101|      0|        tt = it->templates + it->tcount;
  102|      0|        for (i = 0; i < it->tcount; i++) {
  ------------------
  |  Branch (102:21): [True: 0, False: 0]
  ------------------
  103|      0|            ASN1_VALUE **pseqval;
  104|       |
  105|      0|            tt--;
  106|      0|            seqtt = asn1_do_adb(pval, tt, 0);
  107|      0|            if (!seqtt)
  ------------------
  |  Branch (107:17): [True: 0, False: 0]
  ------------------
  108|      0|                continue;
  109|      0|            pseqval = asn1_get_field_ptr(pval, seqtt);
  110|      0|            asn1_template_free(pseqval, seqtt);
  111|      0|        }
  112|      0|        if (asn1_cb)
  ------------------
  |  Branch (112:13): [True: 0, False: 0]
  ------------------
  113|      0|            asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL);
  ------------------
  |  |  759|      0|# define ASN1_OP_FREE_POST       3
  ------------------
  114|      0|        if (embed == 0) {
  ------------------
  |  Branch (114:13): [True: 0, False: 0]
  ------------------
  115|      0|            OPENSSL_free(*pval);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  116|      0|            *pval = NULL;
  117|      0|        }
  118|      0|        break;
  119|  3.47k|    }
  120|  3.47k|}
asn1_primitive_free:
  147|  3.47k|{
  148|  3.47k|    int utype;
  149|       |
  150|       |    /* Special case: if 'it' is a primitive with a free_func, use that. */
  151|  3.47k|    if (it) {
  ------------------
  |  Branch (151:9): [True: 3.47k, False: 0]
  ------------------
  152|  3.47k|        const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
  153|       |
  154|  3.47k|        if (embed) {
  ------------------
  |  Branch (154:13): [True: 0, False: 3.47k]
  ------------------
  155|      0|            if (pf && pf->prim_clear) {
  ------------------
  |  Branch (155:17): [True: 0, False: 0]
  |  Branch (155:23): [True: 0, False: 0]
  ------------------
  156|      0|                pf->prim_clear(pval, it);
  157|      0|                return;
  158|      0|            }
  159|  3.47k|        } else if (pf && pf->prim_free) {
  ------------------
  |  Branch (159:20): [True: 0, False: 3.47k]
  |  Branch (159:26): [True: 0, False: 0]
  ------------------
  160|      0|            pf->prim_free(pval, it);
  161|      0|            return;
  162|      0|        }
  163|  3.47k|    }
  164|       |
  165|       |    /* Special case: if 'it' is NULL, free contents of ASN1_TYPE */
  166|  3.47k|    if (!it) {
  ------------------
  |  Branch (166:9): [True: 0, False: 3.47k]
  ------------------
  167|      0|        ASN1_TYPE *typ = (ASN1_TYPE *)*pval;
  168|       |
  169|      0|        utype = typ->type;
  170|      0|        pval = &typ->value.asn1_value;
  171|      0|        if (!*pval)
  ------------------
  |  Branch (171:13): [True: 0, False: 0]
  ------------------
  172|      0|            return;
  173|  3.47k|    } else if (it->itype == ASN1_ITYPE_MSTRING) {
  ------------------
  |  |  641|  3.47k|# define ASN1_ITYPE_MSTRING              0x5
  ------------------
  |  Branch (173:16): [True: 0, False: 3.47k]
  ------------------
  174|      0|        utype = -1;
  175|      0|        if (!*pval)
  ------------------
  |  Branch (175:13): [True: 0, False: 0]
  ------------------
  176|      0|            return;
  177|  3.47k|    } else {
  178|  3.47k|        utype = it->utype;
  179|  3.47k|        if ((utype != V_ASN1_BOOLEAN) && !*pval)
  ------------------
  |  |   51|  3.47k|# define V_ASN1_BOOLEAN                  1 /**/
  ------------------
  |  Branch (179:13): [True: 3.47k, False: 0]
  |  Branch (179:42): [True: 3.47k, False: 0]
  ------------------
  180|  3.47k|            return;
  181|  3.47k|    }
  182|       |
  183|      0|    switch (utype) {
  184|      0|    case V_ASN1_OBJECT:
  ------------------
  |  |   56|      0|# define V_ASN1_OBJECT                   6
  ------------------
  |  Branch (184:5): [True: 0, False: 0]
  ------------------
  185|      0|        ASN1_OBJECT_free((ASN1_OBJECT *)*pval);
  186|      0|        break;
  187|       |
  188|      0|    case V_ASN1_BOOLEAN:
  ------------------
  |  |   51|      0|# define V_ASN1_BOOLEAN                  1 /**/
  ------------------
  |  Branch (188:5): [True: 0, False: 0]
  ------------------
  189|      0|        if (it)
  ------------------
  |  Branch (189:13): [True: 0, False: 0]
  ------------------
  190|      0|            *(ASN1_BOOLEAN *)pval = it->size;
  191|      0|        else
  192|      0|            *(ASN1_BOOLEAN *)pval = -1;
  193|      0|        return;
  194|       |
  195|      0|    case V_ASN1_NULL:
  ------------------
  |  |   55|      0|# define V_ASN1_NULL                     5
  ------------------
  |  Branch (195:5): [True: 0, False: 0]
  ------------------
  196|      0|        break;
  197|       |
  198|      0|    case V_ASN1_ANY:
  ------------------
  |  |   46|      0|# define V_ASN1_ANY                      -4/* used in ASN1 template code */
  ------------------
  |  Branch (198:5): [True: 0, False: 0]
  ------------------
  199|      0|        asn1_primitive_free(pval, NULL, 0);
  200|      0|        OPENSSL_free(*pval);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  201|      0|        break;
  202|       |
  203|      0|    default:
  ------------------
  |  Branch (203:5): [True: 0, False: 0]
  ------------------
  204|      0|        asn1_string_embed_free((ASN1_STRING *)*pval, embed);
  205|      0|        break;
  206|      0|    }
  207|      0|    *pval = NULL;
  208|      0|}

ASN1_OCTET_STRING_free:
   23|  10.6k|void sname##_free(sname *x) \
   24|  10.6k|{ \
   25|  10.6k|    ASN1_STRING_free(x); \
   26|  10.6k|}
ASN1_INTEGER_new:
   19|  36.5k|sname *sname##_new(void) \
   20|  36.5k|{ \
   21|  36.5k|    return ASN1_STRING_type_new(V_##sname); \
   22|  36.5k|} \
ASN1_INTEGER_free:
   23|  44.9k|void sname##_free(sname *x) \
   24|  44.9k|{ \
   25|  44.9k|    ASN1_STRING_free(x); \
   26|  44.9k|}
ASN1_ENUMERATED_free:
   23|  9.68k|void sname##_free(sname *x) \
   24|  9.68k|{ \
   25|  9.68k|    ASN1_STRING_free(x); \
   26|  9.68k|}

ERR_load_ASYNC_strings:
   43|      2|{
   44|      2|#ifndef OPENSSL_NO_ERR
   45|      2|    if (ERR_func_error_string(ASYNC_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (45:9): [True: 2, False: 0]
  ------------------
   46|      2|        ERR_load_strings_const(ASYNC_str_functs);
   47|      2|        ERR_load_strings_const(ASYNC_str_reasons);
   48|      2|    }
   49|      2|#endif
   50|      2|    return 1;
   51|      2|}

BIO_dump_cb:
   24|    750|{
   25|    750|    return BIO_dump_indent_cb(cb, u, s, len, 0);
   26|    750|}
BIO_dump_indent_cb:
   30|    750|{
   31|    750|    int ret = 0;
   32|    750|    char buf[288 + 1];
   33|    750|    int i, j, rows, n;
   34|    750|    unsigned char ch;
   35|    750|    int dump_width;
   36|       |
   37|    750|    if (indent < 0)
  ------------------
  |  Branch (37:9): [True: 0, False: 750]
  ------------------
   38|      0|        indent = 0;
   39|    750|    else if (indent > 64)
  ------------------
  |  Branch (39:14): [True: 0, False: 750]
  ------------------
   40|      0|        indent = 64;
   41|       |
   42|    750|    dump_width = DUMP_WIDTH_LESS_INDENT(indent);
  ------------------
  |  |   18|    750|#define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH - ((i - (i > 6 ? 6 : i) + 3) / 4))
  |  |  ------------------
  |  |  |  |   17|    750|#define DUMP_WIDTH      16
  |  |  ------------------
  |  |  |  Branch (18:56): [True: 0, False: 750]
  |  |  ------------------
  ------------------
   43|    750|    rows = len / dump_width;
   44|    750|    if ((rows * dump_width) < len)
  ------------------
  |  Branch (44:9): [True: 362, False: 388]
  ------------------
   45|    362|        rows++;
   46|   430k|    for (i = 0; i < rows; i++) {
  ------------------
  |  Branch (46:17): [True: 429k, False: 750]
  ------------------
   47|   429k|        n = BIO_snprintf(buf, sizeof(buf), "%*s%04x - ", indent, "",
   48|   429k|                         i * dump_width);
   49|  7.30M|        for (j = 0; j < dump_width; j++) {
  ------------------
  |  Branch (49:21): [True: 6.87M, False: 429k]
  ------------------
   50|  6.87M|            if (SPACE(buf, n, 3)) {
  ------------------
  |  |   20|  6.87M|#define SPACE(buf, pos, n)   (sizeof(buf) - (pos) > (n))
  |  |  ------------------
  |  |  |  Branch (20:30): [True: 6.87M, False: 0]
  |  |  ------------------
  ------------------
   51|  6.87M|                if (((i * dump_width) + j) >= len) {
  ------------------
  |  Branch (51:21): [True: 2.08k, False: 6.86M]
  ------------------
   52|  2.08k|                    strcpy(buf + n, "   ");
   53|  6.86M|                } else {
   54|  6.86M|                    ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
   55|  6.86M|                    BIO_snprintf(buf + n, 4, "%02x%c", ch,
   56|  6.86M|                                 j == 7 ? '-' : ' ');
  ------------------
  |  Branch (56:34): [True: 429k, False: 6.43M]
  ------------------
   57|  6.86M|                }
   58|  6.87M|                n += 3;
   59|  6.87M|            }
   60|  6.87M|        }
   61|   429k|        if (SPACE(buf, n, 2)) {
  ------------------
  |  |   20|   429k|#define SPACE(buf, pos, n)   (sizeof(buf) - (pos) > (n))
  |  |  ------------------
  |  |  |  Branch (20:30): [True: 429k, False: 0]
  |  |  ------------------
  ------------------
   62|   429k|            strcpy(buf + n, "  ");
   63|   429k|            n += 2;
   64|   429k|        }
   65|  7.29M|        for (j = 0; j < dump_width; j++) {
  ------------------
  |  Branch (65:21): [True: 6.86M, False: 429k]
  ------------------
   66|  6.86M|            if (((i * dump_width) + j) >= len)
  ------------------
  |  Branch (66:17): [True: 362, False: 6.86M]
  ------------------
   67|    362|                break;
   68|  6.86M|            if (SPACE(buf, n, 1)) {
  ------------------
  |  |   20|  6.86M|#define SPACE(buf, pos, n)   (sizeof(buf) - (pos) > (n))
  |  |  ------------------
  |  |  |  Branch (20:30): [True: 6.86M, False: 0]
  |  |  ------------------
  ------------------
   69|  6.86M|                ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
   70|  6.86M|#ifndef CHARSET_EBCDIC
   71|  6.86M|                buf[n++] = ((ch >= ' ') && (ch <= '~')) ? ch : '.';
  ------------------
  |  Branch (71:29): [True: 4.22M, False: 2.64M]
  |  Branch (71:44): [True: 769k, False: 3.45M]
  ------------------
   72|       |#else
   73|       |                buf[n++] = ((ch >= os_toascii[' ']) && (ch <= os_toascii['~']))
   74|       |                           ? os_toebcdic[ch]
   75|       |                           : '.';
   76|       |#endif
   77|  6.86M|                buf[n] = '\0';
   78|  6.86M|            }
   79|  6.86M|        }
   80|   429k|        if (SPACE(buf, n, 1)) {
  ------------------
  |  |   20|   429k|#define SPACE(buf, pos, n)   (sizeof(buf) - (pos) > (n))
  |  |  ------------------
  |  |  |  Branch (20:30): [True: 429k, False: 0]
  |  |  ------------------
  ------------------
   81|   429k|            buf[n++] = '\n';
   82|   429k|            buf[n] = '\0';
   83|   429k|        }
   84|       |        /*
   85|       |         * if this is the last call then update the ddt_dump thing so that we
   86|       |         * will move the selection point in the debug window
   87|       |         */
   88|   429k|        ret += cb((void *)buf, n, u);
   89|   429k|    }
   90|    750|    return ret;
   91|    750|}
BIO_dump:
  116|    750|{
  117|    750|    return BIO_dump_cb(write_bio, bp, s, len);
  118|    750|}
b_dump.c:write_bio:
  111|   429k|{
  112|   429k|    return BIO_write((BIO *)bp, (const char *)data, len);
  113|   429k|}

BIO_printf:
  877|  12.6M|{
  878|  12.6M|    va_list args;
  879|  12.6M|    int ret;
  880|       |
  881|  12.6M|    va_start(args, format);
  882|       |
  883|  12.6M|    ret = BIO_vprintf(bio, format, args);
  884|       |
  885|  12.6M|    va_end(args);
  886|  12.6M|    return ret;
  887|  12.6M|}
BIO_vprintf:
  890|  12.6M|{
  891|  12.6M|    int ret;
  892|  12.6M|    size_t retlen;
  893|  12.6M|    char hugebuf[1024 * 2];     /* Was previously 10k, which is unreasonable
  894|       |                                 * in small-stack environments, like threads
  895|       |                                 * or DOS programs. */
  896|  12.6M|    char *hugebufp = hugebuf;
  897|  12.6M|    size_t hugebufsize = sizeof(hugebuf);
  898|  12.6M|    char *dynbuf = NULL;
  899|  12.6M|    int ignored;
  900|       |
  901|  12.6M|    dynbuf = NULL;
  902|  12.6M|    if (!_dopr(&hugebufp, &dynbuf, &hugebufsize, &retlen, &ignored, format,
  ------------------
  |  Branch (902:9): [True: 0, False: 12.6M]
  ------------------
  903|  12.6M|                args)) {
  904|      0|        OPENSSL_free(dynbuf);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  905|      0|        return -1;
  906|      0|    }
  907|  12.6M|    if (dynbuf) {
  ------------------
  |  Branch (907:9): [True: 0, False: 12.6M]
  ------------------
  908|      0|        ret = BIO_write(bio, dynbuf, (int)retlen);
  909|      0|        OPENSSL_free(dynbuf);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  910|  12.6M|    } else {
  911|  12.6M|        ret = BIO_write(bio, hugebuf, (int)retlen);
  912|  12.6M|    }
  913|  12.6M|    return ret;
  914|  12.6M|}
BIO_snprintf:
  923|  7.40M|{
  924|  7.40M|    va_list args;
  925|  7.40M|    int ret;
  926|       |
  927|  7.40M|    va_start(args, format);
  928|       |
  929|  7.40M|    ret = BIO_vsnprintf(buf, n, format, args);
  930|       |
  931|  7.40M|    va_end(args);
  932|  7.40M|    return ret;
  933|  7.40M|}
BIO_vsnprintf:
  936|  7.40M|{
  937|  7.40M|    size_t retlen;
  938|  7.40M|    int truncated;
  939|       |
  940|  7.40M|    if (!_dopr(&buf, NULL, &n, &retlen, &truncated, format, args))
  ------------------
  |  Branch (940:9): [True: 0, False: 7.40M]
  ------------------
  941|      0|        return -1;
  942|       |
  943|  7.40M|    if (truncated)
  ------------------
  |  Branch (943:9): [True: 0, False: 7.40M]
  ------------------
  944|       |        /*
  945|       |         * In case of truncation, return -1 like traditional snprintf.
  946|       |         * (Current drafts for ISO/IEC 9899 say snprintf should return the
  947|       |         * number of characters that would have been written, had the buffer
  948|       |         * been large enough.)
  949|       |         */
  950|      0|        return -1;
  951|  7.40M|    else
  952|  7.40M|        return (retlen <= INT_MAX) ? (int)retlen : -1;
  ------------------
  |  Branch (952:16): [True: 7.40M, False: 0]
  ------------------
  953|  7.40M|}
b_print.c:_dopr:
   91|  20.0M|{
   92|  20.0M|    char ch;
   93|  20.0M|    int64_t value;
   94|  20.0M|#ifndef OPENSSL_SYS_UEFI
   95|  20.0M|    LDOUBLE fvalue;
  ------------------
  |  |   28|  20.0M|# define LDOUBLE double
  ------------------
   96|  20.0M|#endif
   97|  20.0M|    char *strvalue;
   98|  20.0M|    int min;
   99|  20.0M|    int max;
  100|  20.0M|    int state;
  101|  20.0M|    int flags;
  102|  20.0M|    int cflags;
  103|  20.0M|    size_t currlen;
  104|       |
  105|  20.0M|    state = DP_S_DEFAULT;
  ------------------
  |  |   45|  20.0M|#define DP_S_DEFAULT    0
  ------------------
  106|  20.0M|    flags = currlen = cflags = min = 0;
  107|  20.0M|    max = -1;
  108|  20.0M|    ch = *format++;
  109|       |
  110|   247M|    while (state != DP_S_DONE) {
  ------------------
  |  |   52|   247M|#define DP_S_DONE       7
  ------------------
  |  Branch (110:12): [True: 227M, False: 20.0M]
  ------------------
  111|   227M|        if (ch == '\0' || (buffer == NULL && currlen >= *maxlen))
  ------------------
  |  Branch (111:13): [True: 20.0M, False: 207M]
  |  Branch (111:28): [True: 104M, False: 102M]
  |  Branch (111:46): [True: 0, False: 104M]
  ------------------
  112|  20.0M|            state = DP_S_DONE;
  ------------------
  |  |   52|  20.0M|#define DP_S_DONE       7
  ------------------
  113|       |
  114|   227M|        switch (state) {
  115|  29.7M|        case DP_S_DEFAULT:
  ------------------
  |  |   45|  29.7M|#define DP_S_DEFAULT    0
  ------------------
  |  Branch (115:9): [True: 29.7M, False: 197M]
  ------------------
  116|  29.7M|            if (ch == '%')
  ------------------
  |  Branch (116:17): [True: 27.4M, False: 2.30M]
  ------------------
  117|  27.4M|                state = DP_S_FLAGS;
  ------------------
  |  |   46|  27.4M|#define DP_S_FLAGS      1
  ------------------
  118|  2.30M|            else
  119|  2.30M|                if (!doapr_outch(sbuffer, buffer, &currlen, maxlen, ch))
  ------------------
  |  Branch (119:21): [True: 0, False: 2.30M]
  ------------------
  120|      0|                    return 0;
  121|  29.7M|            ch = *format++;
  122|  29.7M|            break;
  123|  47.3M|        case DP_S_FLAGS:
  ------------------
  |  |   46|  47.3M|#define DP_S_FLAGS      1
  ------------------
  |  Branch (123:9): [True: 47.3M, False: 179M]
  ------------------
  124|  47.3M|            switch (ch) {
  125|   154k|            case '-':
  ------------------
  |  Branch (125:13): [True: 154k, False: 47.1M]
  ------------------
  126|   154k|                flags |= DP_F_MINUS;
  ------------------
  |  |   56|   154k|#define DP_F_MINUS      (1 << 0)
  ------------------
  127|   154k|                ch = *format++;
  128|   154k|                break;
  129|      0|            case '+':
  ------------------
  |  Branch (129:13): [True: 0, False: 47.3M]
  ------------------
  130|      0|                flags |= DP_F_PLUS;
  ------------------
  |  |   58|      0|#define DP_F_PLUS       (1 << 1)
  ------------------
  131|      0|                ch = *format++;
  132|      0|                break;
  133|      0|            case ' ':
  ------------------
  |  Branch (133:13): [True: 0, False: 47.3M]
  ------------------
  134|      0|                flags |= DP_F_SPACE;
  ------------------
  |  |   60|      0|#define DP_F_SPACE      (1 << 2)
  ------------------
  135|      0|                ch = *format++;
  136|      0|                break;
  137|      0|            case '#':
  ------------------
  |  Branch (137:13): [True: 0, False: 47.3M]
  ------------------
  138|      0|                flags |= DP_F_NUM;
  ------------------
  |  |   62|      0|#define DP_F_NUM        (1 << 3)
  ------------------
  139|      0|                ch = *format++;
  140|      0|                break;
  141|  19.6M|            case '0':
  ------------------
  |  Branch (141:13): [True: 19.6M, False: 27.6M]
  ------------------
  142|  19.6M|                flags |= DP_F_ZERO;
  ------------------
  |  |   64|  19.6M|#define DP_F_ZERO       (1 << 4)
  ------------------
  143|  19.6M|                ch = *format++;
  144|  19.6M|                break;
  145|  27.4M|            default:
  ------------------
  |  Branch (145:13): [True: 27.4M, False: 19.8M]
  ------------------
  146|  27.4M|                state = DP_S_MIN;
  ------------------
  |  |   47|  27.4M|#define DP_S_MIN        2
  ------------------
  147|  27.4M|                break;
  148|  47.3M|            }
  149|  47.3M|            break;
  150|  47.5M|        case DP_S_MIN:
  ------------------
  |  |   47|  47.5M|#define DP_S_MIN        2
  ------------------
  |  Branch (150:9): [True: 47.5M, False: 179M]
  ------------------
  151|  47.5M|            if (ossl_isdigit(ch)) {
  ------------------
  |  |   71|  47.5M|# define ossl_isdigit(c)        (ossl_ctype_check((c), CTYPE_MASK_digit))
  |  |  ------------------
  |  |  |  |   26|  47.5M|# define CTYPE_MASK_digit       0x4
  |  |  ------------------
  |  |  |  Branch (71:33): [True: 20.0M, False: 27.4M]
  |  |  ------------------
  ------------------
  152|  20.0M|                min = 10 * min + char_to_int(ch);
  ------------------
  |  |   83|  20.0M|#define char_to_int(p) (p - '0')
  ------------------
  153|  20.0M|                ch = *format++;
  154|  27.4M|            } else if (ch == '*') {
  ------------------
  |  Branch (154:24): [True: 429k, False: 27.0M]
  ------------------
  155|   429k|                min = va_arg(args, int);
  156|   429k|                ch = *format++;
  157|   429k|                state = DP_S_DOT;
  ------------------
  |  |   48|   429k|#define DP_S_DOT        3
  ------------------
  158|   429k|            } else
  159|  27.0M|                state = DP_S_DOT;
  ------------------
  |  |   48|  27.0M|#define DP_S_DOT        3
  ------------------
  160|  47.5M|            break;
  161|  27.4M|        case DP_S_DOT:
  ------------------
  |  |   48|  27.4M|#define DP_S_DOT        3
  ------------------
  |  Branch (161:9): [True: 27.4M, False: 199M]
  ------------------
  162|  27.4M|            if (ch == '.') {
  ------------------
  |  Branch (162:17): [True: 0, False: 27.4M]
  ------------------
  163|      0|                state = DP_S_MAX;
  ------------------
  |  |   49|      0|#define DP_S_MAX        4
  ------------------
  164|      0|                ch = *format++;
  165|      0|            } else
  166|  27.4M|                state = DP_S_MOD;
  ------------------
  |  |   50|  27.4M|#define DP_S_MOD        5
  ------------------
  167|  27.4M|            break;
  168|      0|        case DP_S_MAX:
  ------------------
  |  |   49|      0|#define DP_S_MAX        4
  ------------------
  |  Branch (168:9): [True: 0, False: 227M]
  ------------------
  169|      0|            if (ossl_isdigit(ch)) {
  ------------------
  |  |   71|      0|# define ossl_isdigit(c)        (ossl_ctype_check((c), CTYPE_MASK_digit))
  |  |  ------------------
  |  |  |  |   26|      0|# define CTYPE_MASK_digit       0x4
  |  |  ------------------
  |  |  |  Branch (71:33): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  170|      0|                if (max < 0)
  ------------------
  |  Branch (170:21): [True: 0, False: 0]
  ------------------
  171|      0|                    max = 0;
  172|      0|                max = 10 * max + char_to_int(ch);
  ------------------
  |  |   83|      0|#define char_to_int(p) (p - '0')
  ------------------
  173|      0|                ch = *format++;
  174|      0|            } else if (ch == '*') {
  ------------------
  |  Branch (174:24): [True: 0, False: 0]
  ------------------
  175|      0|                max = va_arg(args, int);
  176|      0|                ch = *format++;
  177|      0|                state = DP_S_MOD;
  ------------------
  |  |   50|      0|#define DP_S_MOD        5
  ------------------
  178|      0|            } else
  179|      0|                state = DP_S_MOD;
  ------------------
  |  |   50|      0|#define DP_S_MOD        5
  ------------------
  180|      0|            break;
  181|  27.4M|        case DP_S_MOD:
  ------------------
  |  |   50|  27.4M|#define DP_S_MOD        5
  ------------------
  |  Branch (181:9): [True: 27.4M, False: 199M]
  ------------------
  182|  27.4M|            switch (ch) {
  183|      0|            case 'h':
  ------------------
  |  Branch (183:13): [True: 0, False: 27.4M]
  ------------------
  184|      0|                cflags = DP_C_SHORT;
  ------------------
  |  |   71|      0|#define DP_C_SHORT      1
  ------------------
  185|      0|                ch = *format++;
  186|      0|                break;
  187|   332k|            case 'l':
  ------------------
  |  Branch (187:13): [True: 332k, False: 27.1M]
  ------------------
  188|   332k|                if (*format == 'l') {
  ------------------
  |  Branch (188:21): [True: 0, False: 332k]
  ------------------
  189|      0|                    cflags = DP_C_LLONG;
  ------------------
  |  |   74|      0|#define DP_C_LLONG      4
  ------------------
  190|      0|                    format++;
  191|      0|                } else
  192|   332k|                    cflags = DP_C_LONG;
  ------------------
  |  |   72|   332k|#define DP_C_LONG       2
  ------------------
  193|   332k|                ch = *format++;
  194|   332k|                break;
  195|      0|            case 'q':
  ------------------
  |  Branch (195:13): [True: 0, False: 27.4M]
  ------------------
  196|      0|            case 'j':
  ------------------
  |  Branch (196:13): [True: 0, False: 27.4M]
  ------------------
  197|      0|                cflags = DP_C_LLONG;
  ------------------
  |  |   74|      0|#define DP_C_LLONG      4
  ------------------
  198|      0|                ch = *format++;
  199|      0|                break;
  200|      0|            case 'L':
  ------------------
  |  Branch (200:13): [True: 0, False: 27.4M]
  ------------------
  201|      0|                cflags = DP_C_LDOUBLE;
  ------------------
  |  |   73|      0|#define DP_C_LDOUBLE    3
  ------------------
  202|      0|                ch = *format++;
  203|      0|                break;
  204|      0|            case 'z':
  ------------------
  |  Branch (204:13): [True: 0, False: 27.4M]
  ------------------
  205|      0|                cflags = DP_C_SIZE;
  ------------------
  |  |   75|      0|#define DP_C_SIZE       5
  ------------------
  206|      0|                ch = *format++;
  207|      0|                break;
  208|  27.1M|            default:
  ------------------
  |  Branch (208:13): [True: 27.1M, False: 332k]
  ------------------
  209|  27.1M|                break;
  210|  27.4M|            }
  211|  27.4M|            state = DP_S_CONV;
  ------------------
  |  |   51|  27.4M|#define DP_S_CONV       6
  ------------------
  212|  27.4M|            break;
  213|  27.4M|        case DP_S_CONV:
  ------------------
  |  |   51|  27.4M|#define DP_S_CONV       6
  ------------------
  |  Branch (213:9): [True: 27.4M, False: 199M]
  ------------------
  214|  27.4M|            switch (ch) {
  215|   310k|            case 'd':
  ------------------
  |  Branch (215:13): [True: 310k, False: 27.1M]
  ------------------
  216|   310k|            case 'i':
  ------------------
  |  Branch (216:13): [True: 0, False: 27.4M]
  ------------------
  217|   310k|                switch (cflags) {
  218|      0|                case DP_C_SHORT:
  ------------------
  |  |   71|      0|#define DP_C_SHORT      1
  ------------------
  |  Branch (218:17): [True: 0, False: 310k]
  ------------------
  219|      0|                    value = (short int)va_arg(args, int);
  220|      0|                    break;
  221|   227k|                case DP_C_LONG:
  ------------------
  |  |   72|   227k|#define DP_C_LONG       2
  ------------------
  |  Branch (221:17): [True: 227k, False: 82.6k]
  ------------------
  222|   227k|                    value = va_arg(args, long int);
  223|   227k|                    break;
  224|      0|                case DP_C_LLONG:
  ------------------
  |  |   74|      0|#define DP_C_LLONG      4
  ------------------
  |  Branch (224:17): [True: 0, False: 310k]
  ------------------
  225|      0|                    value = va_arg(args, int64_t);
  226|      0|                    break;
  227|      0|                case DP_C_SIZE:
  ------------------
  |  |   75|      0|#define DP_C_SIZE       5
  ------------------
  |  Branch (227:17): [True: 0, False: 310k]
  ------------------
  228|      0|                    value = va_arg(args, ossl_ssize_t);
  229|      0|                    break;
  230|  82.6k|                default:
  ------------------
  |  Branch (230:17): [True: 82.6k, False: 227k]
  ------------------
  231|  82.6k|                    value = va_arg(args, int);
  232|  82.6k|                    break;
  233|   310k|                }
  234|   310k|                if (!fmtint(sbuffer, buffer, &currlen, maxlen, value, 10, min,
  ------------------
  |  Branch (234:21): [True: 0, False: 310k]
  ------------------
  235|   310k|                            max, flags))
  236|      0|                    return 0;
  237|   310k|                break;
  238|  12.3M|            case 'X':
  ------------------
  |  Branch (238:13): [True: 12.3M, False: 15.0M]
  ------------------
  239|  12.3M|                flags |= DP_F_UP;
  ------------------
  |  |   66|  12.3M|#define DP_F_UP         (1 << 5)
  ------------------
  240|       |                /* FALLTHROUGH */
  241|  19.6M|            case 'x':
  ------------------
  |  Branch (241:13): [True: 7.29M, False: 20.1M]
  ------------------
  242|  19.6M|            case 'o':
  ------------------
  |  Branch (242:13): [True: 0, False: 27.4M]
  ------------------
  243|  19.7M|            case 'u':
  ------------------
  |  Branch (243:13): [True: 110k, False: 27.3M]
  ------------------
  244|  19.7M|                flags |= DP_F_UNSIGNED;
  ------------------
  |  |   68|  19.7M|#define DP_F_UNSIGNED   (1 << 6)
  ------------------
  245|  19.7M|                switch (cflags) {
  246|      0|                case DP_C_SHORT:
  ------------------
  |  |   71|      0|#define DP_C_SHORT      1
  ------------------
  |  Branch (246:17): [True: 0, False: 19.7M]
  ------------------
  247|      0|                    value = (unsigned short int)va_arg(args, unsigned int);
  248|      0|                    break;
  249|   105k|                case DP_C_LONG:
  ------------------
  |  |   72|   105k|#define DP_C_LONG       2
  ------------------
  |  Branch (249:17): [True: 105k, False: 19.6M]
  ------------------
  250|   105k|                    value = va_arg(args, unsigned long int);
  251|   105k|                    break;
  252|      0|                case DP_C_LLONG:
  ------------------
  |  |   74|      0|#define DP_C_LLONG      4
  ------------------
  |  Branch (252:17): [True: 0, False: 19.7M]
  ------------------
  253|      0|                    value = va_arg(args, uint64_t);
  254|      0|                    break;
  255|      0|                case DP_C_SIZE:
  ------------------
  |  |   75|      0|#define DP_C_SIZE       5
  ------------------
  |  Branch (255:17): [True: 0, False: 19.7M]
  ------------------
  256|      0|                    value = va_arg(args, size_t);
  257|      0|                    break;
  258|  19.6M|                default:
  ------------------
  |  Branch (258:17): [True: 19.6M, False: 105k]
  ------------------
  259|  19.6M|                    value = va_arg(args, unsigned int);
  260|  19.6M|                    break;
  261|  19.7M|                }
  262|  19.7M|                if (!fmtint(sbuffer, buffer, &currlen, maxlen, value,
  ------------------
  |  Branch (262:21): [True: 0, False: 19.7M]
  ------------------
  263|  19.7M|                            ch == 'o' ? 8 : (ch == 'u' ? 10 : 16),
  ------------------
  |  Branch (263:29): [True: 0, False: 19.7M]
  |  Branch (263:46): [True: 110k, False: 19.6M]
  ------------------
  264|  19.7M|                            min, max, flags))
  265|      0|                    return 0;
  266|  19.7M|                break;
  267|  19.7M|#ifndef OPENSSL_SYS_UEFI
  268|  19.7M|            case 'f':
  ------------------
  |  Branch (268:13): [True: 0, False: 27.4M]
  ------------------
  269|      0|                if (cflags == DP_C_LDOUBLE)
  ------------------
  |  |   73|      0|#define DP_C_LDOUBLE    3
  ------------------
  |  Branch (269:21): [True: 0, False: 0]
  ------------------
  270|      0|                    fvalue = va_arg(args, LDOUBLE);
  271|      0|                else
  272|      0|                    fvalue = va_arg(args, double);
  273|      0|                if (!fmtfp(sbuffer, buffer, &currlen, maxlen, fvalue, min, max,
  ------------------
  |  Branch (273:21): [True: 0, False: 0]
  ------------------
  274|      0|                           flags, F_FORMAT))
  ------------------
  |  |   78|      0|#define F_FORMAT        0
  ------------------
  275|      0|                    return 0;
  276|      0|                break;
  277|      0|            case 'E':
  ------------------
  |  Branch (277:13): [True: 0, False: 27.4M]
  ------------------
  278|      0|                flags |= DP_F_UP;
  ------------------
  |  |   66|      0|#define DP_F_UP         (1 << 5)
  ------------------
  279|       |                /* fall thru */
  280|      0|            case 'e':
  ------------------
  |  Branch (280:13): [True: 0, False: 27.4M]
  ------------------
  281|      0|                if (cflags == DP_C_LDOUBLE)
  ------------------
  |  |   73|      0|#define DP_C_LDOUBLE    3
  ------------------
  |  Branch (281:21): [True: 0, False: 0]
  ------------------
  282|      0|                    fvalue = va_arg(args, LDOUBLE);
  283|      0|                else
  284|      0|                    fvalue = va_arg(args, double);
  285|      0|                if (!fmtfp(sbuffer, buffer, &currlen, maxlen, fvalue, min, max,
  ------------------
  |  Branch (285:21): [True: 0, False: 0]
  ------------------
  286|      0|                           flags, E_FORMAT))
  ------------------
  |  |   79|      0|#define E_FORMAT        1
  ------------------
  287|      0|                    return 0;
  288|      0|                break;
  289|      0|            case 'G':
  ------------------
  |  Branch (289:13): [True: 0, False: 27.4M]
  ------------------
  290|      0|                flags |= DP_F_UP;
  ------------------
  |  |   66|      0|#define DP_F_UP         (1 << 5)
  ------------------
  291|       |                /* fall thru */
  292|      0|            case 'g':
  ------------------
  |  Branch (292:13): [True: 0, False: 27.4M]
  ------------------
  293|      0|                if (cflags == DP_C_LDOUBLE)
  ------------------
  |  |   73|      0|#define DP_C_LDOUBLE    3
  ------------------
  |  Branch (293:21): [True: 0, False: 0]
  ------------------
  294|      0|                    fvalue = va_arg(args, LDOUBLE);
  295|      0|                else
  296|      0|                    fvalue = va_arg(args, double);
  297|      0|                if (!fmtfp(sbuffer, buffer, &currlen, maxlen, fvalue, min, max,
  ------------------
  |  Branch (297:21): [True: 0, False: 0]
  ------------------
  298|      0|                           flags, G_FORMAT))
  ------------------
  |  |   80|      0|#define G_FORMAT        2
  ------------------
  299|      0|                    return 0;
  300|      0|                break;
  301|       |#else
  302|       |            case 'f':
  303|       |            case 'E':
  304|       |            case 'e':
  305|       |            case 'G':
  306|       |            case 'g':
  307|       |                /* not implemented for UEFI */
  308|       |                return 0;
  309|       |#endif
  310|  6.86M|            case 'c':
  ------------------
  |  Branch (310:13): [True: 6.86M, False: 20.6M]
  ------------------
  311|  6.86M|                if (!doapr_outch(sbuffer, buffer, &currlen, maxlen,
  ------------------
  |  Branch (311:21): [True: 0, False: 6.86M]
  ------------------
  312|  6.86M|                                 va_arg(args, int)))
  313|      0|                    return 0;
  314|  6.86M|                break;
  315|  6.86M|            case 's':
  ------------------
  |  Branch (315:13): [True: 506k, False: 26.9M]
  ------------------
  316|   506k|                strvalue = va_arg(args, char *);
  317|   506k|                if (max < 0) {
  ------------------
  |  Branch (317:21): [True: 506k, False: 0]
  ------------------
  318|   506k|                    if (buffer)
  ------------------
  |  Branch (318:25): [True: 77.2k, False: 429k]
  ------------------
  319|  77.2k|                        max = INT_MAX;
  320|   429k|                    else
  321|   429k|                        max = *maxlen;
  322|   506k|                }
  323|   506k|                if (!fmtstr(sbuffer, buffer, &currlen, maxlen, strvalue,
  ------------------
  |  Branch (323:21): [True: 0, False: 506k]
  ------------------
  324|   506k|                            flags, min, max))
  325|      0|                    return 0;
  326|   506k|                break;
  327|   506k|            case 'p':
  ------------------
  |  Branch (327:13): [True: 0, False: 27.4M]
  ------------------
  328|      0|                value = (size_t)va_arg(args, void *);
  329|      0|                if (!fmtint(sbuffer, buffer, &currlen, maxlen,
  ------------------
  |  Branch (329:21): [True: 0, False: 0]
  ------------------
  330|      0|                            value, 16, min, max, flags | DP_F_NUM))
  ------------------
  |  |   62|      0|#define DP_F_NUM        (1 << 3)
  ------------------
  331|      0|                    return 0;
  332|      0|                break;
  333|      0|            case 'n':
  ------------------
  |  Branch (333:13): [True: 0, False: 27.4M]
  ------------------
  334|      0|                {
  335|      0|                    int *num;
  336|      0|                    num = va_arg(args, int *);
  337|      0|                    *num = currlen;
  338|      0|                }
  339|      0|                break;
  340|      0|            case '%':
  ------------------
  |  Branch (340:13): [True: 0, False: 27.4M]
  ------------------
  341|      0|                if (!doapr_outch(sbuffer, buffer, &currlen, maxlen, ch))
  ------------------
  |  Branch (341:21): [True: 0, False: 0]
  ------------------
  342|      0|                    return 0;
  343|      0|                break;
  344|      0|            case 'w':
  ------------------
  |  Branch (344:13): [True: 0, False: 27.4M]
  ------------------
  345|       |                /* not supported yet, treat as next char */
  346|      0|                ch = *format++;
  347|      0|                break;
  348|      0|            default:
  ------------------
  |  Branch (348:13): [True: 0, False: 27.4M]
  ------------------
  349|       |                /* unknown, skip */
  350|      0|                break;
  351|  27.4M|            }
  352|  27.4M|            ch = *format++;
  353|  27.4M|            state = DP_S_DEFAULT;
  ------------------
  |  |   45|  27.4M|#define DP_S_DEFAULT    0
  ------------------
  354|  27.4M|            flags = cflags = min = 0;
  355|  27.4M|            max = -1;
  356|  27.4M|            break;
  357|  20.0M|        case DP_S_DONE:
  ------------------
  |  |   52|  20.0M|#define DP_S_DONE       7
  ------------------
  |  Branch (357:9): [True: 20.0M, False: 207M]
  ------------------
  358|  20.0M|            break;
  359|      0|        default:
  ------------------
  |  Branch (359:9): [True: 0, False: 227M]
  ------------------
  360|      0|            break;
  361|   227M|        }
  362|   227M|    }
  363|       |    /*
  364|       |     * We have to truncate if there is no dynamic buffer and we have filled the
  365|       |     * static buffer.
  366|       |     */
  367|  20.0M|    if (buffer == NULL) {
  ------------------
  |  Branch (367:9): [True: 7.40M, False: 12.6M]
  ------------------
  368|  7.40M|        *truncated = (currlen > *maxlen - 1);
  369|  7.40M|        if (*truncated)
  ------------------
  |  Branch (369:13): [True: 0, False: 7.40M]
  ------------------
  370|      0|            currlen = *maxlen - 1;
  371|  7.40M|    }
  372|  20.0M|    if (!doapr_outch(sbuffer, buffer, &currlen, maxlen, '\0'))
  ------------------
  |  Branch (372:9): [True: 0, False: 20.0M]
  ------------------
  373|      0|        return 0;
  374|  20.0M|    *retlen = currlen - 1;
  375|  20.0M|    return 1;
  376|  20.0M|}
b_print.c:doapr_outch:
  830|  72.3M|{
  831|       |    /* If we haven't at least one buffer, someone has done a big booboo */
  832|  72.3M|    if (!ossl_assert(*sbuffer != NULL || buffer != NULL))
  ------------------
  |  |   40|  72.3M|# define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: "#x, \
  |  |  ------------------
  |  |  |  Branch (40:42): [True: 72.3M, False: 0]
  |  |  |  Branch (40:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   41|  72.3M|                                         __FILE__, __LINE__)
  ------------------
  |  Branch (832:9): [True: 0, False: 72.3M]
  ------------------
  833|      0|        return 0;
  834|       |
  835|       |    /* |currlen| must always be <= |*maxlen| */
  836|  72.3M|    if (!ossl_assert(*currlen <= *maxlen))
  ------------------
  |  |   40|  72.3M|# define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: "#x, \
  |  |   41|  72.3M|                                         __FILE__, __LINE__)
  ------------------
  |  Branch (836:9): [True: 0, False: 72.3M]
  ------------------
  837|      0|        return 0;
  838|       |
  839|  72.3M|    if (buffer && *currlen == *maxlen) {
  ------------------
  |  Branch (839:9): [True: 40.5M, False: 31.8M]
  |  Branch (839:19): [True: 0, False: 40.5M]
  ------------------
  840|      0|        if (*maxlen > INT_MAX - BUFFER_INC)
  ------------------
  |  |  825|      0|#define BUFFER_INC  1024
  ------------------
  |  Branch (840:13): [True: 0, False: 0]
  ------------------
  841|      0|            return 0;
  842|       |
  843|      0|        *maxlen += BUFFER_INC;
  ------------------
  |  |  825|      0|#define BUFFER_INC  1024
  ------------------
  844|      0|        if (*buffer == NULL) {
  ------------------
  |  Branch (844:13): [True: 0, False: 0]
  ------------------
  845|      0|            if ((*buffer = OPENSSL_malloc(*maxlen)) == NULL) {
  ------------------
  |  |  118|      0|        CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  |  Branch (845:17): [True: 0, False: 0]
  ------------------
  846|      0|                BIOerr(BIO_F_DOAPR_OUTCH, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  847|      0|                return 0;
  848|      0|            }
  849|      0|            if (*currlen > 0) {
  ------------------
  |  Branch (849:17): [True: 0, False: 0]
  ------------------
  850|      0|                if (!ossl_assert(*sbuffer != NULL))
  ------------------
  |  |   40|      0|# define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: "#x, \
  |  |   41|      0|                                         __FILE__, __LINE__)
  ------------------
  |  Branch (850:21): [True: 0, False: 0]
  ------------------
  851|      0|                    return 0;
  852|      0|                memcpy(*buffer, *sbuffer, *currlen);
  853|      0|            }
  854|      0|            *sbuffer = NULL;
  855|      0|        } else {
  856|      0|            char *tmpbuf;
  857|      0|            tmpbuf = OPENSSL_realloc(*buffer, *maxlen);
  ------------------
  |  |  122|      0|        CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  858|      0|            if (tmpbuf == NULL)
  ------------------
  |  Branch (858:17): [True: 0, False: 0]
  ------------------
  859|      0|                return 0;
  860|      0|            *buffer = tmpbuf;
  861|      0|        }
  862|      0|    }
  863|       |
  864|  72.3M|    if (*currlen < *maxlen) {
  ------------------
  |  Branch (864:9): [True: 72.3M, False: 0]
  ------------------
  865|  72.3M|        if (*sbuffer)
  ------------------
  |  Branch (865:13): [True: 72.3M, False: 0]
  ------------------
  866|  72.3M|            (*sbuffer)[(*currlen)++] = (char)c;
  867|      0|        else
  868|      0|            (*buffer)[(*currlen)++] = (char)c;
  869|  72.3M|    }
  870|       |
  871|  72.3M|    return 1;
  872|  72.3M|}
b_print.c:fmtint:
  435|  20.1M|{
  436|  20.1M|    int signvalue = 0;
  437|  20.1M|    const char *prefix = "";
  438|  20.1M|    uint64_t uvalue;
  439|  20.1M|    char convert[DECIMAL_SIZE(value) + 3];
  440|  20.1M|    int place = 0;
  441|  20.1M|    int spadlen = 0;
  442|  20.1M|    int zpadlen = 0;
  443|  20.1M|    int caps = 0;
  444|       |
  445|  20.1M|    if (max < 0)
  ------------------
  |  Branch (445:9): [True: 20.1M, False: 0]
  ------------------
  446|  20.1M|        max = 0;
  447|  20.1M|    uvalue = value;
  448|  20.1M|    if (!(flags & DP_F_UNSIGNED)) {
  ------------------
  |  |   68|  20.1M|#define DP_F_UNSIGNED   (1 << 6)
  ------------------
  |  Branch (448:9): [True: 310k, False: 19.7M]
  ------------------
  449|   310k|        if (value < 0) {
  ------------------
  |  Branch (449:13): [True: 0, False: 310k]
  ------------------
  450|      0|            signvalue = '-';
  451|      0|            uvalue = 0 - (uint64_t)value;
  452|   310k|        } else if (flags & DP_F_PLUS)
  ------------------
  |  |   58|   310k|#define DP_F_PLUS       (1 << 1)
  ------------------
  |  Branch (452:20): [True: 0, False: 310k]
  ------------------
  453|      0|            signvalue = '+';
  454|   310k|        else if (flags & DP_F_SPACE)
  ------------------
  |  |   60|   310k|#define DP_F_SPACE      (1 << 2)
  ------------------
  |  Branch (454:18): [True: 0, False: 310k]
  ------------------
  455|      0|            signvalue = ' ';
  456|   310k|    }
  457|  20.1M|    if (flags & DP_F_NUM) {
  ------------------
  |  |   62|  20.1M|#define DP_F_NUM        (1 << 3)
  ------------------
  |  Branch (457:9): [True: 0, False: 20.1M]
  ------------------
  458|      0|        if (base == 8)
  ------------------
  |  Branch (458:13): [True: 0, False: 0]
  ------------------
  459|      0|            prefix = "0";
  460|      0|        if (base == 16)
  ------------------
  |  Branch (460:13): [True: 0, False: 0]
  ------------------
  461|      0|            prefix = "0x";
  462|      0|    }
  463|  20.1M|    if (flags & DP_F_UP)
  ------------------
  |  |   66|  20.1M|#define DP_F_UP         (1 << 5)
  ------------------
  |  Branch (463:9): [True: 12.3M, False: 7.71M]
  ------------------
  464|  12.3M|        caps = 1;
  465|  33.8M|    do {
  466|  33.8M|        convert[place++] = (caps ? "0123456789ABCDEF" : "0123456789abcdef")
  ------------------
  |  Branch (466:29): [True: 19.7M, False: 14.0M]
  ------------------
  467|  33.8M|            [uvalue % (unsigned)base];
  468|  33.8M|        uvalue = (uvalue / (unsigned)base);
  469|  33.8M|    } while (uvalue && (place < (int)sizeof(convert)));
  ------------------
  |  Branch (469:14): [True: 13.7M, False: 20.1M]
  |  Branch (469:24): [True: 13.7M, False: 0]
  ------------------
  470|  20.1M|    if (place == sizeof(convert))
  ------------------
  |  Branch (470:9): [True: 0, False: 20.1M]
  ------------------
  471|      0|        place--;
  472|  20.1M|    convert[place] = 0;
  473|       |
  474|  20.1M|    zpadlen = max - place;
  475|  20.1M|    spadlen =
  476|  20.1M|        min - OSSL_MAX(max, place) - (signvalue ? 1 : 0) - strlen(prefix);
  ------------------
  |  |   84|  20.1M|#define OSSL_MAX(p,q) ((p >= q) ? p : q)
  |  |  ------------------
  |  |  |  Branch (84:24): [True: 0, False: 20.1M]
  |  |  ------------------
  ------------------
  |  Branch (476:39): [True: 0, False: 20.1M]
  ------------------
  477|  20.1M|    if (zpadlen < 0)
  ------------------
  |  Branch (477:9): [True: 20.1M, False: 0]
  ------------------
  478|  20.1M|        zpadlen = 0;
  479|  20.1M|    if (spadlen < 0)
  ------------------
  |  Branch (479:9): [True: 466k, False: 19.6M]
  ------------------
  480|   466k|        spadlen = 0;
  481|  20.1M|    if (flags & DP_F_ZERO) {
  ------------------
  |  |   64|  20.1M|#define DP_F_ZERO       (1 << 4)
  ------------------
  |  Branch (481:9): [True: 19.6M, False: 413k]
  ------------------
  482|  19.6M|        zpadlen = OSSL_MAX(zpadlen, spadlen);
  ------------------
  |  |   84|  19.6M|#define OSSL_MAX(p,q) ((p >= q) ? p : q)
  |  |  ------------------
  |  |  |  Branch (84:24): [True: 12.0M, False: 7.62M]
  |  |  ------------------
  ------------------
  483|  19.6M|        spadlen = 0;
  484|  19.6M|    }
  485|  20.1M|    if (flags & DP_F_MINUS)
  ------------------
  |  |   56|  20.1M|#define DP_F_MINUS      (1 << 0)
  ------------------
  |  Branch (485:9): [True: 77.2k, False: 20.0M]
  ------------------
  486|  77.2k|        spadlen = -spadlen;
  487|       |
  488|       |    /* spaces */
  489|  20.3M|    while (spadlen > 0) {
  ------------------
  |  Branch (489:12): [True: 285k, False: 20.1M]
  ------------------
  490|   285k|        if (!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
  ------------------
  |  Branch (490:13): [True: 0, False: 285k]
  ------------------
  491|      0|            return 0;
  492|   285k|        --spadlen;
  493|   285k|    }
  494|       |
  495|       |    /* sign */
  496|  20.1M|    if (signvalue)
  ------------------
  |  Branch (496:9): [True: 0, False: 20.1M]
  ------------------
  497|      0|        if (!doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue))
  ------------------
  |  Branch (497:13): [True: 0, False: 0]
  ------------------
  498|      0|            return 0;
  499|       |
  500|       |    /* prefix */
  501|  20.1M|    while (*prefix) {
  ------------------
  |  Branch (501:12): [True: 0, False: 20.1M]
  ------------------
  502|      0|        if (!doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix))
  ------------------
  |  Branch (502:13): [True: 0, False: 0]
  ------------------
  503|      0|            return 0;
  504|      0|        prefix++;
  505|      0|    }
  506|       |
  507|       |    /* zeros */
  508|  20.1M|    if (zpadlen > 0) {
  ------------------
  |  Branch (508:9): [True: 7.62M, False: 12.4M]
  ------------------
  509|  15.2M|        while (zpadlen > 0) {
  ------------------
  |  Branch (509:16): [True: 7.63M, False: 7.62M]
  ------------------
  510|  7.63M|            if (!doapr_outch(sbuffer, buffer, currlen, maxlen, '0'))
  ------------------
  |  Branch (510:17): [True: 0, False: 7.63M]
  ------------------
  511|      0|                return 0;
  512|  7.63M|            --zpadlen;
  513|  7.63M|        }
  514|  7.62M|    }
  515|       |    /* digits */
  516|  53.9M|    while (place > 0) {
  ------------------
  |  Branch (516:12): [True: 33.8M, False: 20.1M]
  ------------------
  517|  33.8M|        if (!doapr_outch(sbuffer, buffer, currlen, maxlen, convert[--place]))
  ------------------
  |  Branch (517:13): [True: 0, False: 33.8M]
  ------------------
  518|      0|            return 0;
  519|  33.8M|    }
  520|       |
  521|       |    /* left justified spaces */
  522|  20.1M|    while (spadlen < 0) {
  ------------------
  |  Branch (522:12): [True: 44.7k, False: 20.1M]
  ------------------
  523|  44.7k|        if (!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
  ------------------
  |  Branch (523:13): [True: 0, False: 44.7k]
  ------------------
  524|      0|            return 0;
  525|  44.7k|        ++spadlen;
  526|  44.7k|    }
  527|  20.1M|    return 1;
  528|  20.1M|}
b_print.c:fmtstr:
  383|   506k|{
  384|   506k|    int padlen;
  385|   506k|    size_t strln;
  386|   506k|    int cnt = 0;
  387|       |
  388|   506k|    if (value == 0)
  ------------------
  |  Branch (388:9): [True: 0, False: 506k]
  ------------------
  389|      0|        value = "<NULL>";
  390|       |
  391|   506k|    strln = OPENSSL_strnlen(value, max < 0 ? SIZE_MAX : (size_t)max);
  ------------------
  |  Branch (391:36): [True: 0, False: 506k]
  ------------------
  392|       |
  393|   506k|    padlen = min - strln;
  394|   506k|    if (min < 0 || padlen < 0)
  ------------------
  |  Branch (394:9): [True: 0, False: 506k]
  |  Branch (394:20): [True: 196, False: 506k]
  ------------------
  395|    196|        padlen = 0;
  396|   506k|    if (max >= 0) {
  ------------------
  |  Branch (396:9): [True: 506k, False: 0]
  ------------------
  397|       |        /*
  398|       |         * Calculate the maximum output including padding.
  399|       |         * Make sure max doesn't overflow into negativity
  400|       |         */
  401|   506k|        if (max < INT_MAX - padlen)
  ------------------
  |  Branch (401:13): [True: 429k, False: 77.2k]
  ------------------
  402|   429k|            max += padlen;
  403|  77.2k|        else
  404|  77.2k|            max = INT_MAX;
  405|   506k|    }
  406|   506k|    if (flags & DP_F_MINUS)
  ------------------
  |  |   56|   506k|#define DP_F_MINUS      (1 << 0)
  ------------------
  |  Branch (406:9): [True: 77.2k, False: 429k]
  ------------------
  407|  77.2k|        padlen = -padlen;
  408|       |
  409|   506k|    while ((padlen > 0) && (max < 0 || cnt < max)) {
  ------------------
  |  Branch (409:12): [True: 0, False: 506k]
  |  Branch (409:29): [True: 0, False: 0]
  |  Branch (409:40): [True: 0, False: 0]
  ------------------
  410|      0|        if (!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
  ------------------
  |  Branch (410:13): [True: 0, False: 0]
  ------------------
  411|      0|            return 0;
  412|      0|        --padlen;
  413|      0|        ++cnt;
  414|      0|    }
  415|  1.08M|    while (strln > 0 && (max < 0 || cnt < max)) {
  ------------------
  |  Branch (415:12): [True: 574k, False: 506k]
  |  Branch (415:26): [True: 0, False: 574k]
  |  Branch (415:37): [True: 574k, False: 0]
  ------------------
  416|   574k|        if (!doapr_outch(sbuffer, buffer, currlen, maxlen, *value++))
  ------------------
  |  Branch (416:13): [True: 0, False: 574k]
  ------------------
  417|      0|            return 0;
  418|   574k|        --strln;
  419|   574k|        ++cnt;
  420|   574k|    }
  421|  1.32M|    while ((padlen < 0) && (max < 0 || cnt < max)) {
  ------------------
  |  Branch (421:12): [True: 816k, False: 506k]
  |  Branch (421:29): [True: 0, False: 816k]
  |  Branch (421:40): [True: 816k, False: 0]
  ------------------
  422|   816k|        if (!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
  ------------------
  |  Branch (422:13): [True: 0, False: 816k]
  ------------------
  423|      0|            return 0;
  424|   816k|        ++padlen;
  425|   816k|        ++cnt;
  426|   816k|    }
  427|   506k|    return 1;
  428|   506k|}

bio_sock_cleanup_int:
  152|      2|{
  153|       |# ifdef OPENSSL_SYS_WINDOWS
  154|       |    if (wsa_init_done) {
  155|       |        wsa_init_done = 0;
  156|       |        WSACleanup();
  157|       |    }
  158|       |# endif
  159|      2|}

ERR_load_BIO_strings:
  137|      2|{
  138|      2|#ifndef OPENSSL_NO_ERR
  139|      2|    if (ERR_func_error_string(BIO_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (139:9): [True: 2, False: 0]
  ------------------
  140|      2|        ERR_load_strings_const(BIO_str_functs);
  141|      2|        ERR_load_strings_const(BIO_str_reasons);
  142|      2|    }
  143|      2|#endif
  144|      2|    return 1;
  145|      2|}

BIO_new:
   72|      2|{
   73|      2|    BIO *bio = OPENSSL_zalloc(sizeof(*bio));
  ------------------
  |  |  120|      2|        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   74|       |
   75|      2|    if (bio == NULL) {
  ------------------
  |  Branch (75:9): [True: 0, False: 2]
  ------------------
   76|      0|        BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   77|      0|        return NULL;
   78|      0|    }
   79|       |
   80|      2|    bio->method = method;
   81|      2|    bio->shutdown = 1;
   82|      2|    bio->references = 1;
   83|       |
   84|      2|    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data))
  ------------------
  |  |  106|      2|# define CRYPTO_EX_INDEX_BIO             12
  ------------------
  |  Branch (84:9): [True: 0, False: 2]
  ------------------
   85|      0|        goto err;
   86|       |
   87|      2|    bio->lock = CRYPTO_THREAD_lock_new();
   88|      2|    if (bio->lock == NULL) {
  ------------------
  |  Branch (88:9): [True: 0, False: 2]
  ------------------
   89|      0|        BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   90|      0|        CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
  ------------------
  |  |  106|      0|# define CRYPTO_EX_INDEX_BIO             12
  ------------------
   91|      0|        goto err;
   92|      0|    }
   93|       |
   94|      2|    if (method->create != NULL && !method->create(bio)) {
  ------------------
  |  Branch (94:9): [True: 2, False: 0]
  |  Branch (94:35): [True: 0, False: 2]
  ------------------
   95|      0|        BIOerr(BIO_F_BIO_NEW, ERR_R_INIT_FAIL);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   96|      0|        CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
  ------------------
  |  |  106|      0|# define CRYPTO_EX_INDEX_BIO             12
  ------------------
   97|      0|        CRYPTO_THREAD_lock_free(bio->lock);
   98|      0|        goto err;
   99|      0|    }
  100|      2|    if (method->create == NULL)
  ------------------
  |  Branch (100:9): [True: 0, False: 2]
  ------------------
  101|      0|        bio->init = 1;
  102|       |
  103|      2|    return bio;
  104|       |
  105|      0|err:
  106|      0|    OPENSSL_free(bio);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  107|      0|    return NULL;
  108|      2|}
BIO_clear_flags:
  191|      2|{
  192|      2|    b->flags &= ~flags;
  193|      2|}
BIO_write:
  356|  13.2M|{
  357|  13.2M|    size_t written;
  358|  13.2M|    int ret;
  359|       |
  360|  13.2M|    if (dlen < 0)
  ------------------
  |  Branch (360:9): [True: 0, False: 13.2M]
  ------------------
  361|      0|        return 0;
  362|       |
  363|  13.2M|    ret = bio_write_intern(b, data, (size_t)dlen, &written);
  364|       |
  365|  13.2M|    if (ret > 0) {
  ------------------
  |  Branch (365:9): [True: 13.2M, False: 0]
  ------------------
  366|       |        /* *written should always be <= dlen */
  367|  13.2M|        ret = (int)written;
  368|  13.2M|    }
  369|       |
  370|  13.2M|    return ret;
  371|  13.2M|}
BIO_puts:
  388|  38.9k|{
  389|  38.9k|    int ret;
  390|  38.9k|    size_t written = 0;
  391|       |
  392|  38.9k|    if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
  ------------------
  |  Branch (392:9): [True: 0, False: 38.9k]
  |  Branch (392:24): [True: 0, False: 38.9k]
  |  Branch (392:47): [True: 0, False: 38.9k]
  ------------------
  393|      0|        BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  394|      0|        return -2;
  395|      0|    }
  396|       |
  397|  38.9k|    if (b->callback != NULL || b->callback_ex != NULL) {
  ------------------
  |  Branch (397:9): [True: 0, False: 38.9k]
  |  Branch (397:32): [True: 0, False: 38.9k]
  ------------------
  398|      0|        ret = (int)bio_call_callback(b, BIO_CB_PUTS, buf, 0, 0, 0L, 1L, NULL);
  ------------------
  |  |  223|      0|# define BIO_CB_PUTS     0x04
  ------------------
  399|      0|        if (ret <= 0)
  ------------------
  |  Branch (399:13): [True: 0, False: 0]
  ------------------
  400|      0|            return ret;
  401|      0|    }
  402|       |
  403|  38.9k|    if (!b->init) {
  ------------------
  |  Branch (403:9): [True: 0, False: 38.9k]
  ------------------
  404|      0|        BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  405|      0|        return -2;
  406|      0|    }
  407|       |
  408|  38.9k|    ret = b->method->bputs(b, buf);
  409|       |
  410|  38.9k|    if (ret > 0) {
  ------------------
  |  Branch (410:9): [True: 38.9k, False: 0]
  ------------------
  411|  38.9k|        b->num_write += (uint64_t)ret;
  412|  38.9k|        written = ret;
  413|  38.9k|        ret = 1;
  414|  38.9k|    }
  415|       |
  416|  38.9k|    if (b->callback != NULL || b->callback_ex != NULL)
  ------------------
  |  Branch (416:9): [True: 0, False: 38.9k]
  |  Branch (416:32): [True: 0, False: 38.9k]
  ------------------
  417|      0|        ret = (int)bio_call_callback(b, BIO_CB_PUTS | BIO_CB_RETURN, buf, 0, 0,
  ------------------
  |  |  223|      0|# define BIO_CB_PUTS     0x04
  ------------------
                      ret = (int)bio_call_callback(b, BIO_CB_PUTS | BIO_CB_RETURN, buf, 0, 0,
  ------------------
  |  |  231|      0|# define BIO_CB_RETURN   0x80
  ------------------
  418|      0|                                     0L, ret, &written);
  419|       |
  420|  38.9k|    if (ret > 0) {
  ------------------
  |  Branch (420:9): [True: 38.9k, False: 0]
  ------------------
  421|  38.9k|        if (written > INT_MAX) {
  ------------------
  |  Branch (421:13): [True: 0, False: 38.9k]
  ------------------
  422|      0|            BIOerr(BIO_F_BIO_PUTS, BIO_R_LENGTH_TOO_LONG);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  423|      0|            ret = -1;
  424|  38.9k|        } else {
  425|  38.9k|            ret = (int)written;
  426|  38.9k|        }
  427|  38.9k|    }
  428|       |
  429|  38.9k|    return ret;
  430|  38.9k|}
BIO_indent:
  481|  77.2k|{
  482|  77.2k|    if (indent < 0)
  ------------------
  |  Branch (482:9): [True: 0, False: 77.2k]
  ------------------
  483|      0|        indent = 0;
  484|  77.2k|    if (indent > max)
  ------------------
  |  Branch (484:9): [True: 0, False: 77.2k]
  ------------------
  485|      0|        indent = max;
  486|  77.2k|    while (indent--)
  ------------------
  |  Branch (486:12): [True: 0, False: 77.2k]
  ------------------
  487|      0|        if (BIO_puts(b, " ") != 1)
  ------------------
  |  Branch (487:13): [True: 0, False: 0]
  ------------------
  488|      0|            return 0;
  489|  77.2k|    return 1;
  490|  77.2k|}
BIO_ctrl:
  511|      2|{
  512|      2|    long ret;
  513|       |
  514|      2|    if (b == NULL)
  ------------------
  |  Branch (514:9): [True: 0, False: 2]
  ------------------
  515|      0|        return 0;
  516|       |
  517|      2|    if ((b->method == NULL) || (b->method->ctrl == NULL)) {
  ------------------
  |  Branch (517:9): [True: 0, False: 2]
  |  Branch (517:32): [True: 0, False: 2]
  ------------------
  518|      0|        BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  519|      0|        return -2;
  520|      0|    }
  521|       |
  522|      2|    if (b->callback != NULL || b->callback_ex != NULL) {
  ------------------
  |  Branch (522:9): [True: 0, False: 2]
  |  Branch (522:32): [True: 0, False: 2]
  ------------------
  523|      0|        ret = bio_call_callback(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1L, NULL);
  ------------------
  |  |  225|      0|# define BIO_CB_CTRL     0x06
  ------------------
  524|      0|        if (ret <= 0)
  ------------------
  |  Branch (524:13): [True: 0, False: 0]
  ------------------
  525|      0|            return ret;
  526|      0|    }
  527|       |
  528|      2|    ret = b->method->ctrl(b, cmd, larg, parg);
  529|       |
  530|      2|    if (b->callback != NULL || b->callback_ex != NULL)
  ------------------
  |  Branch (530:9): [True: 0, False: 2]
  |  Branch (530:32): [True: 0, False: 2]
  ------------------
  531|      0|        ret = bio_call_callback(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, 0, cmd,
  ------------------
  |  |  225|      0|# define BIO_CB_CTRL     0x06
  ------------------
                      ret = bio_call_callback(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, 0, cmd,
  ------------------
  |  |  231|      0|# define BIO_CB_RETURN   0x80
  ------------------
  532|      0|                                larg, ret, NULL);
  533|       |
  534|      2|    return ret;
  535|      2|}
bio_cleanup:
  778|      2|{
  779|      2|#ifndef OPENSSL_NO_SOCK
  780|      2|    bio_sock_cleanup_int();
  781|      2|    CRYPTO_THREAD_lock_free(bio_lookup_lock);
  782|      2|    bio_lookup_lock = NULL;
  783|      2|#endif
  784|      2|    CRYPTO_THREAD_lock_free(bio_type_lock);
  785|      2|    bio_type_lock = NULL;
  786|      2|}
bio_lib.c:bio_write_intern:
  322|  13.2M|{
  323|  13.2M|    int ret;
  324|       |
  325|  13.2M|    if (b == NULL)
  ------------------
  |  Branch (325:9): [True: 0, False: 13.2M]
  ------------------
  326|      0|        return 0;
  327|       |
  328|  13.2M|    if ((b->method == NULL) || (b->method->bwrite == NULL)) {
  ------------------
  |  Branch (328:9): [True: 0, False: 13.2M]
  |  Branch (328:32): [True: 0, False: 13.2M]
  ------------------
  329|      0|        BIOerr(BIO_F_BIO_WRITE_INTERN, BIO_R_UNSUPPORTED_METHOD);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  330|      0|        return -2;
  331|      0|    }
  332|       |
  333|  13.2M|    if ((b->callback != NULL || b->callback_ex != NULL) &&
  ------------------
  |  Branch (333:10): [True: 0, False: 13.2M]
  |  Branch (333:33): [True: 0, False: 13.2M]
  ------------------
  334|  13.2M|        ((ret = (int)bio_call_callback(b, BIO_CB_WRITE, data, dlen, 0, 0L, 1L,
  ------------------
  |  |  222|      0|# define BIO_CB_WRITE    0x03
  ------------------
  |  Branch (334:9): [True: 0, False: 0]
  ------------------
  335|      0|                                       NULL)) <= 0))
  336|      0|        return ret;
  337|       |
  338|  13.2M|    if (!b->init) {
  ------------------
  |  Branch (338:9): [True: 0, False: 13.2M]
  ------------------
  339|      0|        BIOerr(BIO_F_BIO_WRITE_INTERN, BIO_R_UNINITIALIZED);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  340|      0|        return -2;
  341|      0|    }
  342|       |
  343|  13.2M|    ret = b->method->bwrite(b, data, dlen, written);
  344|       |
  345|  13.2M|    if (ret > 0)
  ------------------
  |  Branch (345:9): [True: 13.2M, False: 0]
  ------------------
  346|  13.2M|        b->num_write += (uint64_t)*written;
  347|       |
  348|  13.2M|    if (b->callback != NULL || b->callback_ex != NULL)
  ------------------
  |  Branch (348:9): [True: 0, False: 13.2M]
  |  Branch (348:32): [True: 0, False: 13.2M]
  ------------------
  349|      0|        ret = (int)bio_call_callback(b, BIO_CB_WRITE | BIO_CB_RETURN, data,
  ------------------
  |  |  222|      0|# define BIO_CB_WRITE    0x03
  ------------------
                      ret = (int)bio_call_callback(b, BIO_CB_WRITE | BIO_CB_RETURN, data,
  ------------------
  |  |  231|      0|# define BIO_CB_RETURN   0x80
  ------------------
  350|      0|                                     dlen, 0, 0L, ret, written);
  351|       |
  352|  13.2M|    return ret;
  353|  13.2M|}

bwrite_conv:
   71|  13.2M|{
   72|  13.2M|    int ret;
   73|       |
   74|  13.2M|    if (datal > INT_MAX)
  ------------------
  |  Branch (74:9): [True: 0, False: 13.2M]
  ------------------
   75|      0|        datal = INT_MAX;
   76|       |
   77|  13.2M|    ret = bio->method->bwrite_old(bio, data, (int)datal);
   78|       |
   79|  13.2M|    if (ret <= 0) {
  ------------------
  |  Branch (79:9): [True: 0, False: 13.2M]
  ------------------
   80|      0|        *written = 0;
   81|      0|        return ret;
   82|      0|    }
   83|       |
   84|  13.2M|    *written = (size_t)ret;
   85|       |
   86|  13.2M|    return 1;
   87|  13.2M|}

BIO_new_file:
   60|      2|{
   61|      2|    BIO  *ret;
   62|      2|    FILE *file = openssl_fopen(filename, mode);
   63|      2|    int fp_flags = BIO_CLOSE;
  ------------------
  |  |   66|      2|# define BIO_CLOSE               0x01
  ------------------
   64|       |
   65|      2|    if (strchr(mode, 'b') == NULL)
  ------------------
  |  Branch (65:9): [True: 2, False: 0]
  ------------------
   66|      2|        fp_flags |= BIO_FP_TEXT;
  ------------------
  |  |  148|      2|# define BIO_FP_TEXT             0x10
  ------------------
   67|       |
   68|      2|    if (file == NULL) {
  ------------------
  |  Branch (68:9): [True: 0, False: 2]
  ------------------
   69|      0|        SYSerr(SYS_F_FOPEN, get_last_sys_error());
  ------------------
  |  |  101|      0|# define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   70|      0|        ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
   71|      0|        if (errno == ENOENT
  ------------------
  |  Branch (71:13): [True: 0, False: 0]
  ------------------
   72|      0|#ifdef ENXIO
   73|      0|            || errno == ENXIO
  ------------------
  |  Branch (73:16): [True: 0, False: 0]
  ------------------
   74|      0|#endif
   75|      0|            )
   76|      0|            BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   77|      0|        else
   78|      0|            BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   79|      0|        return NULL;
   80|      0|    }
   81|      2|    if ((ret = BIO_new(BIO_s_file())) == NULL) {
  ------------------
  |  Branch (81:9): [True: 0, False: 2]
  ------------------
   82|      0|        fclose(file);
   83|      0|        return NULL;
   84|      0|    }
   85|       |
   86|      2|    BIO_clear_flags(ret, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage
  ------------------
  |  |  160|      2|#  define BIO_FLAGS_UPLINK        0
  ------------------
   87|       |                                             * UPLINK */
   88|      2|    BIO_set_fp(ret, file, fp_flags);
  ------------------
  |  |  416|      2|# define BIO_set_fp(b,fp,c)      BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)(fp))
  |  |  ------------------
  |  |  |  |  299|      2|# define BIO_C_SET_FILE_PTR                      106
  |  |  ------------------
  ------------------
   89|      2|    return ret;
   90|      2|}
BIO_s_file:
  106|      2|{
  107|      2|    return &methods_filep;
  108|      2|}
bss_file.c:file_write:
  158|  13.3M|{
  159|  13.3M|    int ret = 0;
  160|       |
  161|  13.3M|    if (b->init && (in != NULL)) {
  ------------------
  |  Branch (161:9): [True: 13.3M, False: 0]
  |  Branch (161:20): [True: 13.3M, False: 0]
  ------------------
  162|  13.3M|        if (b->flags & BIO_FLAGS_UPLINK)
  ------------------
  |  |  160|  13.3M|#  define BIO_FLAGS_UPLINK        0
  ------------------
  |  Branch (162:13): [True: 0, False: 13.3M]
  ------------------
  163|      0|            ret = UP_fwrite(in, (int)inl, 1, b->ptr);
  ------------------
  |  |  163|      0|# define UP_fwrite       fwrite
  ------------------
  164|  13.3M|        else
  165|  13.3M|            ret = fwrite(in, (int)inl, 1, (FILE *)b->ptr);
  166|  13.3M|        if (ret)
  ------------------
  |  Branch (166:13): [True: 13.3M, False: 0]
  ------------------
  167|  13.3M|            ret = inl;
  168|       |        /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */
  169|       |        /*
  170|       |         * according to Tim Hudson <tjh@openssl.org>, the commented out
  171|       |         * version above can cause 'inl' write calls under some stupid stdio
  172|       |         * implementations (VMS)
  173|       |         */
  174|  13.3M|    }
  175|  13.3M|    return ret;
  176|  13.3M|}
bss_file.c:file_puts:
  356|  38.9k|{
  357|  38.9k|    int n, ret;
  358|       |
  359|  38.9k|    n = strlen(str);
  360|  38.9k|    ret = file_write(bp, str, n);
  361|  38.9k|    return ret;
  362|  38.9k|}
bss_file.c:file_ctrl:
  179|      2|{
  180|      2|    long ret = 1;
  181|      2|    FILE *fp = (FILE *)b->ptr;
  182|      2|    FILE **fpp;
  183|      2|    char p[4];
  184|      2|    int st;
  185|       |
  186|      2|    switch (cmd) {
  187|      0|    case BIO_C_FILE_SEEK:
  ------------------
  |  |  321|      0|# define BIO_C_FILE_SEEK                         128
  ------------------
  |  Branch (187:5): [True: 0, False: 2]
  ------------------
  188|      0|    case BIO_CTRL_RESET:
  ------------------
  |  |   71|      0|# define BIO_CTRL_RESET          1/* opt - rewind/zero etc */
  ------------------
  |  Branch (188:5): [True: 0, False: 2]
  ------------------
  189|      0|        if (b->flags & BIO_FLAGS_UPLINK)
  ------------------
  |  |  160|      0|#  define BIO_FLAGS_UPLINK        0
  ------------------
  |  Branch (189:13): [True: 0, False: 0]
  ------------------
  190|      0|            ret = (long)UP_fseek(b->ptr, num, 0);
  ------------------
  |  |  169|      0|# define UP_fseek        fseek
  ------------------
  191|      0|        else
  192|      0|            ret = (long)fseek(fp, num, 0);
  193|      0|        break;
  194|      0|    case BIO_CTRL_EOF:
  ------------------
  |  |   72|      0|# define BIO_CTRL_EOF            2/* opt - are we at the eof */
  ------------------
  |  Branch (194:5): [True: 0, False: 2]
  ------------------
  195|      0|        if (b->flags & BIO_FLAGS_UPLINK)
  ------------------
  |  |  160|      0|#  define BIO_FLAGS_UPLINK        0
  ------------------
  |  Branch (195:13): [True: 0, False: 0]
  ------------------
  196|      0|            ret = (long)UP_feof(fp);
  ------------------
  |  |  165|      0|# define UP_feof         feof
  ------------------
  197|      0|        else
  198|      0|            ret = (long)feof(fp);
  199|      0|        break;
  200|      0|    case BIO_C_FILE_TELL:
  ------------------
  |  |  327|      0|# define BIO_C_FILE_TELL                         133
  ------------------
  |  Branch (200:5): [True: 0, False: 2]
  ------------------
  201|      0|    case BIO_CTRL_INFO:
  ------------------
  |  |   73|      0|# define BIO_CTRL_INFO           3/* opt - extra tit-bits */
  ------------------
  |  Branch (201:5): [True: 0, False: 2]
  ------------------
  202|      0|        if (b->flags & BIO_FLAGS_UPLINK)
  ------------------
  |  |  160|      0|#  define BIO_FLAGS_UPLINK        0
  ------------------
  |  Branch (202:13): [True: 0, False: 0]
  ------------------
  203|      0|            ret = UP_ftell(b->ptr);
  ------------------
  |  |  170|      0|# define UP_ftell        ftell
  ------------------
  204|      0|        else
  205|      0|            ret = ftell(fp);
  206|      0|        break;
  207|      2|    case BIO_C_SET_FILE_PTR:
  ------------------
  |  |  299|      2|# define BIO_C_SET_FILE_PTR                      106
  ------------------
  |  Branch (207:5): [True: 2, False: 0]
  ------------------
  208|      2|        file_free(b);
  209|      2|        b->shutdown = (int)num & BIO_CLOSE;
  ------------------
  |  |   66|      2|# define BIO_CLOSE               0x01
  ------------------
  210|      2|        b->ptr = ptr;
  211|      2|        b->init = 1;
  212|       |# if BIO_FLAGS_UPLINK!=0
  213|       |#  if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)
  214|       |#   define _IOB_ENTRIES 20
  215|       |#  endif
  216|       |        /* Safety net to catch purely internal BIO_set_fp calls */
  217|       |#  if defined(_MSC_VER) && _MSC_VER>=1900
  218|       |        if (ptr == stdin || ptr == stdout || ptr == stderr)
  219|       |            BIO_clear_flags(b, BIO_FLAGS_UPLINK);
  220|       |#  elif defined(_IOB_ENTRIES)
  221|       |        if ((size_t)ptr >= (size_t)stdin &&
  222|       |            (size_t)ptr < (size_t)(stdin + _IOB_ENTRIES))
  223|       |            BIO_clear_flags(b, BIO_FLAGS_UPLINK);
  224|       |#  endif
  225|       |# endif
  226|       |# ifdef UP_fsetmod
  227|       |        if (b->flags & BIO_FLAGS_UPLINK)
  228|       |            UP_fsetmod(b->ptr, (char)((num & BIO_FP_TEXT) ? 't' : 'b'));
  229|       |        else
  230|       |# endif
  231|      2|        {
  232|       |# if defined(OPENSSL_SYS_WINDOWS)
  233|       |            int fd = _fileno((FILE *)ptr);
  234|       |            if (num & BIO_FP_TEXT)
  235|       |                _setmode(fd, _O_TEXT);
  236|       |            else
  237|       |                _setmode(fd, _O_BINARY);
  238|       |# elif defined(OPENSSL_SYS_MSDOS)
  239|       |            int fd = fileno((FILE *)ptr);
  240|       |            /* Set correct text/binary mode */
  241|       |            if (num & BIO_FP_TEXT)
  242|       |                _setmode(fd, _O_TEXT);
  243|       |            /* Dangerous to set stdin/stdout to raw (unless redirected) */
  244|       |            else {
  245|       |                if (fd == STDIN_FILENO || fd == STDOUT_FILENO) {
  246|       |                    if (isatty(fd) <= 0)
  247|       |                        _setmode(fd, _O_BINARY);
  248|       |                } else
  249|       |                    _setmode(fd, _O_BINARY);
  250|       |            }
  251|       |# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
  252|       |            int fd = fileno((FILE *)ptr);
  253|       |            if (!(num & BIO_FP_TEXT))
  254|       |                setmode(fd, O_BINARY);
  255|       |# endif
  256|      2|        }
  257|      2|        break;
  258|      0|    case BIO_C_SET_FILENAME:
  ------------------
  |  |  301|      0|# define BIO_C_SET_FILENAME                      108
  ------------------
  |  Branch (258:5): [True: 0, False: 2]
  ------------------
  259|      0|        file_free(b);
  260|      0|        b->shutdown = (int)num & BIO_CLOSE;
  ------------------
  |  |   66|      0|# define BIO_CLOSE               0x01
  ------------------
  261|      0|        if (num & BIO_FP_APPEND) {
  ------------------
  |  |  147|      0|# define BIO_FP_APPEND           0x08
  ------------------
  |  Branch (261:13): [True: 0, False: 0]
  ------------------
  262|      0|            if (num & BIO_FP_READ)
  ------------------
  |  |  145|      0|# define BIO_FP_READ             0x02
  ------------------
  |  Branch (262:17): [True: 0, False: 0]
  ------------------
  263|      0|                OPENSSL_strlcpy(p, "a+", sizeof(p));
  264|      0|            else
  265|      0|                OPENSSL_strlcpy(p, "a", sizeof(p));
  266|      0|        } else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
  ------------------
  |  |  145|      0|# define BIO_FP_READ             0x02
  ------------------
                      } else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
  ------------------
  |  |  146|      0|# define BIO_FP_WRITE            0x04
  ------------------
  |  Branch (266:20): [True: 0, False: 0]
  |  Branch (266:43): [True: 0, False: 0]
  ------------------
  267|      0|            OPENSSL_strlcpy(p, "r+", sizeof(p));
  268|      0|        else if (num & BIO_FP_WRITE)
  ------------------
  |  |  146|      0|# define BIO_FP_WRITE            0x04
  ------------------
  |  Branch (268:18): [True: 0, False: 0]
  ------------------
  269|      0|            OPENSSL_strlcpy(p, "w", sizeof(p));
  270|      0|        else if (num & BIO_FP_READ)
  ------------------
  |  |  145|      0|# define BIO_FP_READ             0x02
  ------------------
  |  Branch (270:18): [True: 0, False: 0]
  ------------------
  271|      0|            OPENSSL_strlcpy(p, "r", sizeof(p));
  272|      0|        else {
  273|      0|            BIOerr(BIO_F_FILE_CTRL, BIO_R_BAD_FOPEN_MODE);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  274|      0|            ret = 0;
  275|      0|            break;
  276|      0|        }
  277|       |# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
  278|       |        if (!(num & BIO_FP_TEXT))
  279|       |            OPENSSL_strlcat(p, "b", sizeof(p));
  280|       |        else
  281|       |            OPENSSL_strlcat(p, "t", sizeof(p));
  282|       |# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
  283|       |        if (!(num & BIO_FP_TEXT))
  284|       |            OPENSSL_strlcat(p, "b", sizeof(p));
  285|       |# endif
  286|      0|        fp = openssl_fopen(ptr, p);
  287|      0|        if (fp == NULL) {
  ------------------
  |  Branch (287:13): [True: 0, False: 0]
  ------------------
  288|      0|            SYSerr(SYS_F_FOPEN, get_last_sys_error());
  ------------------
  |  |  101|      0|# define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  289|      0|            ERR_add_error_data(5, "fopen('", ptr, "','", p, "')");
  290|      0|            BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  291|      0|            ret = 0;
  292|      0|            break;
  293|      0|        }
  294|      0|        b->ptr = fp;
  295|      0|        b->init = 1;
  296|      0|        BIO_clear_flags(b, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage
  ------------------
  |  |  160|      0|#  define BIO_FLAGS_UPLINK        0
  ------------------
  297|       |                                               * UPLINK */
  298|      0|        break;
  299|      0|    case BIO_C_GET_FILE_PTR:
  ------------------
  |  |  300|      0|# define BIO_C_GET_FILE_PTR                      107
  ------------------
  |  Branch (299:5): [True: 0, False: 2]
  ------------------
  300|       |        /* the ptr parameter is actually a FILE ** in this case. */
  301|      0|        if (ptr != NULL) {
  ------------------
  |  Branch (301:13): [True: 0, False: 0]
  ------------------
  302|      0|            fpp = (FILE **)ptr;
  303|      0|            *fpp = (FILE *)b->ptr;
  304|      0|        }
  305|      0|        break;
  306|      0|    case BIO_CTRL_GET_CLOSE:
  ------------------
  |  |   78|      0|# define BIO_CTRL_GET_CLOSE      8/* man - set the 'close' on free */
  ------------------
  |  Branch (306:5): [True: 0, False: 2]
  ------------------
  307|      0|        ret = (long)b->shutdown;
  308|      0|        break;
  309|      0|    case BIO_CTRL_SET_CLOSE:
  ------------------
  |  |   79|      0|# define BIO_CTRL_SET_CLOSE      9/* man - set the 'close' on free */
  ------------------
  |  Branch (309:5): [True: 0, False: 2]
  ------------------
  310|      0|        b->shutdown = (int)num;
  311|      0|        break;
  312|      0|    case BIO_CTRL_FLUSH:
  ------------------
  |  |   81|      0|# define BIO_CTRL_FLUSH          11/* opt - 'flush' buffered output */
  ------------------
  |  Branch (312:5): [True: 0, False: 2]
  ------------------
  313|      0|        st = b->flags & BIO_FLAGS_UPLINK
  ------------------
  |  |  160|      0|#  define BIO_FLAGS_UPLINK        0
  ------------------
  |  Branch (313:14): [True: 0, False: 0]
  ------------------
  314|      0|                ? UP_fflush(b->ptr) : fflush((FILE *)b->ptr);
  ------------------
  |  |  171|      0|# define UP_fflush       fflush
  ------------------
  315|      0|        if (st == EOF) {
  ------------------
  |  Branch (315:13): [True: 0, False: 0]
  ------------------
  316|      0|            SYSerr(SYS_F_FFLUSH, get_last_sys_error());
  ------------------
  |  |  101|      0|# define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  317|      0|            ERR_add_error_data(1, "fflush()");
  318|      0|            BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);
  ------------------
  |  |  116|      0|# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  319|      0|            ret = 0;
  320|      0|        }
  321|      0|        break;
  322|      0|    case BIO_CTRL_DUP:
  ------------------
  |  |   82|      0|# define BIO_CTRL_DUP            12/* man - extra stuff for 'duped' BIO */
  ------------------
  |  Branch (322:5): [True: 0, False: 2]
  ------------------
  323|      0|        ret = 1;
  324|      0|        break;
  325|       |
  326|      0|    case BIO_CTRL_WPENDING:
  ------------------
  |  |   83|      0|# define BIO_CTRL_WPENDING       13/* opt - number of bytes still to write */
  ------------------
  |  Branch (326:5): [True: 0, False: 2]
  ------------------
  327|      0|    case BIO_CTRL_PENDING:
  ------------------
  |  |   80|      0|# define BIO_CTRL_PENDING        10/* opt - is their more data buffered */
  ------------------
  |  Branch (327:5): [True: 0, False: 2]
  ------------------
  328|      0|    case BIO_CTRL_PUSH:
  ------------------
  |  |   76|      0|# define BIO_CTRL_PUSH           6/* opt - internal, used to signify change */
  ------------------
  |  Branch (328:5): [True: 0, False: 2]
  ------------------
  329|      0|    case BIO_CTRL_POP:
  ------------------
  |  |   77|      0|# define BIO_CTRL_POP            7/* opt - internal, used to signify change */
  ------------------
  |  Branch (329:5): [True: 0, False: 2]
  ------------------
  330|      0|    default:
  ------------------
  |  Branch (330:5): [True: 0, False: 2]
  ------------------
  331|      0|        ret = 0;
  332|      0|        break;
  333|      2|    }
  334|      2|    return ret;
  335|      2|}
bss_file.c:file_new:
  111|      2|{
  112|      2|    bi->init = 0;
  113|      2|    bi->num = 0;
  114|      2|    bi->ptr = NULL;
  115|      2|    bi->flags = BIO_FLAGS_UPLINK; /* default to UPLINK */
  ------------------
  |  |  160|      2|#  define BIO_FLAGS_UPLINK        0
  ------------------
  116|      2|    return 1;
  117|      2|}
bss_file.c:file_free:
  120|      2|{
  121|      2|    if (a == NULL)
  ------------------
  |  Branch (121:9): [True: 0, False: 2]
  ------------------
  122|      0|        return 0;
  123|      2|    if (a->shutdown) {
  ------------------
  |  Branch (123:9): [True: 2, False: 0]
  ------------------
  124|      2|        if ((a->init) && (a->ptr != NULL)) {
  ------------------
  |  Branch (124:13): [True: 0, False: 2]
  |  Branch (124:26): [True: 0, False: 0]
  ------------------
  125|      0|            if (a->flags & BIO_FLAGS_UPLINK)
  ------------------
  |  |  160|      0|#  define BIO_FLAGS_UPLINK        0
  ------------------
  |  Branch (125:17): [True: 0, False: 0]
  ------------------
  126|      0|                UP_fclose(a->ptr);
  ------------------
  |  |  166|      0|# define UP_fclose       fclose
  ------------------
  127|      0|            else
  128|      0|                fclose(a->ptr);
  129|      0|            a->ptr = NULL;
  130|      0|            a->flags = BIO_FLAGS_UPLINK;
  ------------------
  |  |  160|      0|#  define BIO_FLAGS_UPLINK        0
  ------------------
  131|      0|        }
  132|      2|        a->init = 0;
  133|      2|    }
  134|      2|    return 1;
  135|      2|}

bn_div_words:
  196|  65.5k|{
  197|  65.5k|    BN_ULONG ret, waste;
  ------------------
  |  |   31|  65.5k|#  define BN_ULONG        unsigned long
  ------------------
  198|       |
  199|  65.5k| asm("divq      %4":"=a"(ret), "=d"(waste)
  200|  65.5k| :     "a"(l), "d"(h), "r"(d)
  201|  65.5k| :     "cc");
  202|       |
  203|  65.5k|    return ret;
  204|  65.5k|}

ERR_load_BN_strings:
  110|      2|{
  111|      2|#ifndef OPENSSL_NO_ERR
  112|      2|    if (ERR_func_error_string(BN_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (112:9): [True: 2, False: 0]
  ------------------
  113|      2|        ERR_load_strings_const(BN_str_functs);
  114|      2|        ERR_load_strings_const(BN_str_reasons);
  115|      2|    }
  116|      2|#endif
  117|      2|    return 1;
  118|      2|}

BN_num_bits_word:
  100|  17.1k|{
  101|  17.1k|    BN_ULONG x, mask;
  ------------------
  |  |   31|  17.1k|#  define BN_ULONG        unsigned long
  ------------------
  102|  17.1k|    int bits = (l != 0);
  103|       |
  104|  17.1k|#if BN_BITS2 > 32
  105|  17.1k|    x = l >> 32;
  106|  17.1k|    mask = (0 - x) & BN_MASK2;
  ------------------
  |  |   87|  17.1k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  107|  17.1k|    mask = (0 - (mask >> (BN_BITS2 - 1)));
  ------------------
  |  |   48|  17.1k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  17.1k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  108|  17.1k|    bits += 32 & mask;
  109|  17.1k|    l ^= (x ^ l) & mask;
  110|  17.1k|#endif
  111|       |
  112|  17.1k|    x = l >> 16;
  113|  17.1k|    mask = (0 - x) & BN_MASK2;
  ------------------
  |  |   87|  17.1k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  114|  17.1k|    mask = (0 - (mask >> (BN_BITS2 - 1)));
  ------------------
  |  |   48|  17.1k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  17.1k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  115|  17.1k|    bits += 16 & mask;
  116|  17.1k|    l ^= (x ^ l) & mask;
  117|       |
  118|  17.1k|    x = l >> 8;
  119|  17.1k|    mask = (0 - x) & BN_MASK2;
  ------------------
  |  |   87|  17.1k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  120|  17.1k|    mask = (0 - (mask >> (BN_BITS2 - 1)));
  ------------------
  |  |   48|  17.1k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  17.1k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  121|  17.1k|    bits += 8 & mask;
  122|  17.1k|    l ^= (x ^ l) & mask;
  123|       |
  124|  17.1k|    x = l >> 4;
  125|  17.1k|    mask = (0 - x) & BN_MASK2;
  ------------------
  |  |   87|  17.1k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  126|  17.1k|    mask = (0 - (mask >> (BN_BITS2 - 1)));
  ------------------
  |  |   48|  17.1k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  17.1k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  127|  17.1k|    bits += 4 & mask;
  128|  17.1k|    l ^= (x ^ l) & mask;
  129|       |
  130|  17.1k|    x = l >> 2;
  131|  17.1k|    mask = (0 - x) & BN_MASK2;
  ------------------
  |  |   87|  17.1k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  132|  17.1k|    mask = (0 - (mask >> (BN_BITS2 - 1)));
  ------------------
  |  |   48|  17.1k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  17.1k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  133|  17.1k|    bits += 2 & mask;
  134|  17.1k|    l ^= (x ^ l) & mask;
  135|       |
  136|  17.1k|    x = l >> 1;
  137|  17.1k|    mask = (0 - x) & BN_MASK2;
  ------------------
  |  |   87|  17.1k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  138|  17.1k|    mask = (0 - (mask >> (BN_BITS2 - 1)));
  ------------------
  |  |   48|  17.1k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  17.1k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  139|  17.1k|    bits += 1 & mask;
  140|       |
  141|  17.1k|    return bits;
  142|  17.1k|}
BN_num_bits:
  178|  4.72k|{
  179|  4.72k|    int i = a->top - 1;
  180|  4.72k|    bn_check_top(a);
  181|       |
  182|  4.72k|    if (a->flags & BN_FLG_CONSTTIME) {
  ------------------
  |  |   61|  4.72k|# define BN_FLG_CONSTTIME        0x04
  ------------------
  |  Branch (182:9): [True: 0, False: 4.72k]
  ------------------
  183|       |        /*
  184|       |         * We assume that BIGNUMs flagged as CONSTTIME have also been expanded
  185|       |         * so that a->dmax is not leaking secret information.
  186|       |         *
  187|       |         * In other words, it's the caller's responsibility to ensure `a` has
  188|       |         * been preallocated in advance to a public length if we hit this
  189|       |         * branch.
  190|       |         *
  191|       |         */
  192|      0|        return bn_num_bits_consttime(a);
  193|      0|    }
  194|       |
  195|  4.72k|    if (BN_is_zero(a))
  ------------------
  |  Branch (195:9): [True: 0, False: 4.72k]
  ------------------
  196|      0|        return 0;
  197|       |
  198|  4.72k|    return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
  ------------------
  |  |   48|  4.72k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  4.72k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  199|  4.72k|}
BN_free:
  225|  11.6k|{
  226|  11.6k|    if (a == NULL)
  ------------------
  |  Branch (226:9): [True: 4.62k, False: 6.98k]
  ------------------
  227|  4.62k|        return;
  228|  6.98k|    if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
  ------------------
  |  |   53|  6.98k|# define BN_FLG_STATIC_DATA      0x02
  ------------------
  |  Branch (228:9): [True: 6.98k, False: 0]
  ------------------
  229|  6.98k|        bn_free_d(a, 0);
  230|  6.98k|    if (a->flags & BN_FLG_MALLOCED)
  ------------------
  |  |   52|  6.98k|# define BN_FLG_MALLOCED         0x01
  ------------------
  |  Branch (230:9): [True: 6.98k, False: 0]
  ------------------
  231|  6.98k|        OPENSSL_free(a);
  ------------------
  |  |  128|  6.98k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  6.98k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  6.98k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  232|  6.98k|}
BN_new:
  243|  6.98k|{
  244|  6.98k|    BIGNUM *ret;
  245|       |
  246|  6.98k|    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
  ------------------
  |  |  120|  6.98k|        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  6.98k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  6.98k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  |  Branch (246:9): [True: 0, False: 6.98k]
  ------------------
  247|      0|        BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  102|      0|# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  248|      0|        return NULL;
  249|      0|    }
  250|  6.98k|    ret->flags = BN_FLG_MALLOCED;
  ------------------
  |  |   52|  6.98k|# define BN_FLG_MALLOCED         0x01
  ------------------
  251|  6.98k|    bn_check_top(ret);
  252|  6.98k|    return ret;
  253|  6.98k|}
bn_expand2:
  302|  17.5k|{
  303|  17.5k|    if (words > b->dmax) {
  ------------------
  |  Branch (303:9): [True: 17.5k, False: 0]
  ------------------
  304|  17.5k|        BN_ULONG *a = bn_expand_internal(b, words);
  ------------------
  |  |   31|  17.5k|#  define BN_ULONG        unsigned long
  ------------------
  305|  17.5k|        if (!a)
  ------------------
  |  Branch (305:13): [True: 0, False: 17.5k]
  ------------------
  306|      0|            return NULL;
  307|  17.5k|        if (b->d != NULL)
  ------------------
  |  Branch (307:13): [True: 10.5k, False: 6.98k]
  ------------------
  308|  10.5k|            bn_free_d(b, 1);
  309|  17.5k|        b->d = a;
  310|  17.5k|        b->dmax = words;
  311|  17.5k|    }
  312|       |
  313|  17.5k|    return b;
  314|  17.5k|}
BN_dup:
  317|  4.72k|{
  318|  4.72k|    BIGNUM *t;
  319|       |
  320|  4.72k|    if (a == NULL)
  ------------------
  |  Branch (320:9): [True: 0, False: 4.72k]
  ------------------
  321|      0|        return NULL;
  322|  4.72k|    bn_check_top(a);
  323|       |
  324|  4.72k|    t = BN_get_flags(a, BN_FLG_SECURE) ? BN_secure_new() : BN_new();
  ------------------
  |  |   62|  4.72k|# define BN_FLG_SECURE           0x08
  ------------------
  |  Branch (324:9): [True: 0, False: 4.72k]
  ------------------
  325|  4.72k|    if (t == NULL)
  ------------------
  |  Branch (325:9): [True: 0, False: 4.72k]
  ------------------
  326|      0|        return NULL;
  327|  4.72k|    if (!BN_copy(t, a)) {
  ------------------
  |  Branch (327:9): [True: 0, False: 4.72k]
  ------------------
  328|      0|        BN_free(t);
  329|      0|        return NULL;
  330|      0|    }
  331|  4.72k|    bn_check_top(t);
  332|  4.72k|    return t;
  333|  4.72k|}
BN_copy:
  336|  4.72k|{
  337|  4.72k|    int bn_words;
  338|       |
  339|  4.72k|    bn_check_top(b);
  340|       |
  341|  4.72k|    bn_words = BN_get_flags(b, BN_FLG_CONSTTIME) ? b->dmax : b->top;
  ------------------
  |  |   61|  4.72k|# define BN_FLG_CONSTTIME        0x04
  ------------------
  |  Branch (341:16): [True: 0, False: 4.72k]
  ------------------
  342|       |
  343|  4.72k|    if (a == b)
  ------------------
  |  Branch (343:9): [True: 0, False: 4.72k]
  ------------------
  344|      0|        return a;
  345|  4.72k|    if (bn_wexpand(a, bn_words) == NULL)
  ------------------
  |  Branch (345:9): [True: 0, False: 4.72k]
  ------------------
  346|      0|        return NULL;
  347|       |
  348|  4.72k|    if (b->top > 0)
  ------------------
  |  Branch (348:9): [True: 4.72k, False: 0]
  ------------------
  349|  4.72k|        memcpy(a->d, b->d, sizeof(b->d[0]) * bn_words);
  350|       |
  351|  4.72k|    a->neg = b->neg;
  352|  4.72k|    a->top = b->top;
  353|  4.72k|    a->flags |= b->flags & BN_FLG_FIXED_TOP;
  ------------------
  |  |  219|  4.72k|#  define BN_FLG_FIXED_TOP 0
  ------------------
  354|  4.72k|    bn_check_top(a);
  355|  4.72k|    return a;
  356|  4.72k|}
BN_set_word:
  420|  4.72k|{
  421|  4.72k|    bn_check_top(a);
  422|  4.72k|    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
  ------------------
  |  Branch (422:9): [True: 0, False: 4.72k]
  ------------------
  423|      0|        return 0;
  424|  4.72k|    a->neg = 0;
  425|  4.72k|    a->d[0] = w;
  426|  4.72k|    a->top = (w ? 1 : 0);
  ------------------
  |  Branch (426:15): [True: 4.72k, False: 0]
  ------------------
  427|  4.72k|    a->flags &= ~BN_FLG_FIXED_TOP;
  ------------------
  |  |  219|  4.72k|#  define BN_FLG_FIXED_TOP 0
  ------------------
  428|  4.72k|    bn_check_top(a);
  429|  4.72k|    return 1;
  430|  4.72k|}
BN_is_zero:
  904|  58.7k|{
  905|  58.7k|    return a->top == 0;
  906|  58.7k|}
BN_is_negative:
  924|  4.72k|{
  925|  4.72k|    return (a->neg != 0);
  926|  4.72k|}
BN_get_flags:
  970|  68.9k|{
  971|  68.9k|    return b->flags & n;
  972|  68.9k|}
bn_wexpand:
 1000|  53.6k|{
 1001|  53.6k|    return (words <= a->dmax) ? a : bn_expand2(a, words);
  ------------------
  |  Branch (1001:12): [True: 38.4k, False: 15.2k]
  ------------------
 1002|  53.6k|}
bn_correct_top:
 1027|  48.9k|{
 1028|  48.9k|    BN_ULONG *ftl;
  ------------------
  |  |   31|  48.9k|#  define BN_ULONG        unsigned long
  ------------------
 1029|  48.9k|    int tmp_top = a->top;
 1030|       |
 1031|  48.9k|    if (tmp_top > 0) {
  ------------------
  |  Branch (1031:9): [True: 48.9k, False: 0]
  ------------------
 1032|  90.3k|        for (ftl = &(a->d[tmp_top]); tmp_top > 0; tmp_top--) {
  ------------------
  |  Branch (1032:38): [True: 90.3k, False: 0]
  ------------------
 1033|  90.3k|            ftl--;
 1034|  90.3k|            if (*ftl != 0)
  ------------------
  |  Branch (1034:17): [True: 48.9k, False: 41.3k]
  ------------------
 1035|  48.9k|                break;
 1036|  90.3k|        }
 1037|  48.9k|        a->top = tmp_top;
 1038|  48.9k|    }
 1039|  48.9k|    if (a->top == 0)
  ------------------
  |  Branch (1039:9): [True: 0, False: 48.9k]
  ------------------
 1040|      0|        a->neg = 0;
 1041|  48.9k|    a->flags &= ~BN_FLG_FIXED_TOP;
  ------------------
  |  |  219|  48.9k|#  define BN_FLG_FIXED_TOP 0
  ------------------
 1042|  48.9k|    bn_pollute(a);
 1043|  48.9k|}
bn_lib.c:bn_free_d:
  202|  17.5k|{
  203|  17.5k|    if (BN_get_flags(a, BN_FLG_SECURE))
  ------------------
  |  |   62|  17.5k|# define BN_FLG_SECURE           0x08
  ------------------
  |  Branch (203:9): [True: 0, False: 17.5k]
  ------------------
  204|      0|        OPENSSL_secure_clear_free(a->d, a->dmax * sizeof(a->d[0]));
  ------------------
  |  |  142|      0|        CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  205|  17.5k|    else if (clear != 0)
  ------------------
  |  Branch (205:14): [True: 10.5k, False: 6.98k]
  ------------------
  206|  10.5k|        OPENSSL_clear_free(a->d, a->dmax * sizeof(a->d[0]));
  ------------------
  |  |  126|  10.5k|        CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  10.5k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  10.5k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  207|  6.98k|    else
  208|  6.98k|        OPENSSL_free(a->d);
  ------------------
  |  |  128|  6.98k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  6.98k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  6.98k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  209|  17.5k|}
bn_lib.c:bn_expand_internal:
  266|  17.5k|{
  267|  17.5k|    BN_ULONG *a = NULL;
  ------------------
  |  |   31|  17.5k|#  define BN_ULONG        unsigned long
  ------------------
  268|       |
  269|  17.5k|    if (words > (INT_MAX / (4 * BN_BITS2))) {
  ------------------
  |  |   48|  17.5k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  17.5k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  |  Branch (269:9): [True: 0, False: 17.5k]
  ------------------
  270|      0|        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);
  ------------------
  |  |  102|      0|# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  271|      0|        return NULL;
  272|      0|    }
  273|  17.5k|    if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {
  ------------------
  |  |   53|  17.5k|# define BN_FLG_STATIC_DATA      0x02
  ------------------
  |  Branch (273:9): [True: 0, False: 17.5k]
  ------------------
  274|      0|        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
  ------------------
  |  |  102|      0|# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  275|      0|        return NULL;
  276|      0|    }
  277|  17.5k|    if (BN_get_flags(b, BN_FLG_SECURE))
  ------------------
  |  |   62|  17.5k|# define BN_FLG_SECURE           0x08
  ------------------
  |  Branch (277:9): [True: 0, False: 17.5k]
  ------------------
  278|      0|        a = OPENSSL_secure_zalloc(words * sizeof(*a));
  ------------------
  |  |  138|      0|        CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  279|  17.5k|    else
  280|  17.5k|        a = OPENSSL_zalloc(words * sizeof(*a));
  ------------------
  |  |  120|  17.5k|        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  17.5k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  17.5k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  281|  17.5k|    if (a == NULL) {
  ------------------
  |  Branch (281:9): [True: 0, False: 17.5k]
  ------------------
  282|      0|        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  102|      0|# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  283|      0|        return NULL;
  284|      0|    }
  285|       |
  286|  17.5k|    assert(b->top <= words);
  287|  17.5k|    if (b->top > 0)
  ------------------
  |  Branch (287:9): [True: 10.5k, False: 6.98k]
  ------------------
  288|  10.5k|        memcpy(a, b->d, sizeof(*a) * b->top);
  289|       |
  290|  17.5k|    return a;
  291|  17.5k|}

bn_lib.c:bn_expand:
  678|  4.72k|{
  679|  4.72k|    if (bits > (INT_MAX - BN_BITS2 + 1))
  ------------------
  |  |   48|  4.72k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  4.72k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  |  Branch (679:9): [True: 0, False: 4.72k]
  ------------------
  680|      0|        return NULL;
  681|       |
  682|  4.72k|    if (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax)
  ------------------
  |  |   48|  4.72k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  4.72k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
                  if (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax)
  ------------------
  |  |   48|  4.72k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  4.72k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  |  Branch (682:9): [True: 2.46k, False: 2.25k]
  ------------------
  683|  2.46k|        return a;
  684|       |
  685|  2.25k|    return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);
  ------------------
  |  |   48|  2.25k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  2.25k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
                  return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);
  ------------------
  |  |   48|  2.25k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  2.25k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  686|  4.72k|}

BN_bn2dec:
   54|  4.72k|{
   55|  4.72k|    int i = 0, num, ok = 0, n, tbytes;
   56|  4.72k|    char *buf = NULL;
   57|  4.72k|    char *p;
   58|  4.72k|    BIGNUM *t = NULL;
   59|  4.72k|    BN_ULONG *bn_data = NULL, *lp;
  ------------------
  |  |   31|  4.72k|#  define BN_ULONG        unsigned long
  ------------------
   60|  4.72k|    int bn_data_num;
   61|       |
   62|       |    /*-
   63|       |     * get an upper bound for the length of the decimal integer
   64|       |     * num <= (BN_num_bits(a) + 1) * log(2)
   65|       |     *     <= 3 * BN_num_bits(a) * 0.101 + log(2) + 1     (rounding error)
   66|       |     *     <= 3 * BN_num_bits(a) / 10 + 3 * BN_num_bits / 1000 + 1 + 1
   67|       |     */
   68|  4.72k|    i = BN_num_bits(a) * 3;
   69|  4.72k|    num = (i / 10 + i / 1000 + 1) + 1;
   70|  4.72k|    tbytes = num + 3;   /* negative and terminator and one spare? */
   71|  4.72k|    bn_data_num = num / BN_DEC_NUM + 1;
  ------------------
  |  |   92|  4.72k|#  define BN_DEC_NUM      19
  ------------------
   72|  4.72k|    bn_data = OPENSSL_malloc(bn_data_num * sizeof(BN_ULONG));
  ------------------
  |  |  118|  4.72k|        CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  4.72k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  4.72k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   73|  4.72k|    buf = OPENSSL_malloc(tbytes);
  ------------------
  |  |  118|  4.72k|        CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  4.72k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  4.72k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   74|  4.72k|    if (buf == NULL || bn_data == NULL) {
  ------------------
  |  Branch (74:9): [True: 0, False: 4.72k]
  |  Branch (74:24): [True: 0, False: 4.72k]
  ------------------
   75|      0|        BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  102|      0|# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   76|      0|        goto err;
   77|      0|    }
   78|  4.72k|    if ((t = BN_dup(a)) == NULL)
  ------------------
  |  Branch (78:9): [True: 0, False: 4.72k]
  ------------------
   79|      0|        goto err;
   80|       |
   81|  4.72k|    p = buf;
   82|  4.72k|    lp = bn_data;
   83|  4.72k|    if (BN_is_zero(t)) {
  ------------------
  |  Branch (83:9): [True: 0, False: 4.72k]
  ------------------
   84|      0|        *p++ = '0';
   85|      0|        *p++ = '\0';
   86|  4.72k|    } else {
   87|  4.72k|        if (BN_is_negative(t))
  ------------------
  |  Branch (87:13): [True: 0, False: 4.72k]
  ------------------
   88|      0|            *p++ = '-';
   89|       |
   90|  17.1k|        while (!BN_is_zero(t)) {
  ------------------
  |  Branch (90:16): [True: 12.4k, False: 4.72k]
  ------------------
   91|  12.4k|            if (lp - bn_data >= bn_data_num)
  ------------------
  |  Branch (91:17): [True: 0, False: 12.4k]
  ------------------
   92|      0|                goto err;
   93|  12.4k|            *lp = BN_div_word(t, BN_DEC_CONV);
  ------------------
  |  |   91|  12.4k|#  define BN_DEC_CONV     (10000000000000000000UL)
  ------------------
   94|  12.4k|            if (*lp == (BN_ULONG)-1)
  ------------------
  |  Branch (94:17): [True: 0, False: 12.4k]
  ------------------
   95|      0|                goto err;
   96|  12.4k|            lp++;
   97|  12.4k|        }
   98|  4.72k|        lp--;
   99|       |        /*
  100|       |         * We now have a series of blocks, BN_DEC_NUM chars in length, where
  101|       |         * the last one needs truncation. The blocks need to be reversed in
  102|       |         * order.
  103|       |         */
  104|  4.72k|        n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT1, *lp);
  ------------------
  |  |   93|  4.72k|#  define BN_DEC_FMT1     "%lu"
  ------------------
  105|  4.72k|        if (n < 0)
  ------------------
  |  Branch (105:13): [True: 0, False: 4.72k]
  ------------------
  106|      0|            goto err;
  107|  4.72k|        p += n;
  108|  12.4k|        while (lp != bn_data) {
  ------------------
  |  Branch (108:16): [True: 7.72k, False: 4.72k]
  ------------------
  109|  7.72k|            lp--;
  110|  7.72k|            n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT2, *lp);
  ------------------
  |  |   94|  7.72k|#  define BN_DEC_FMT2     "%019lu"
  ------------------
  111|  7.72k|            if (n < 0)
  ------------------
  |  Branch (111:17): [True: 0, False: 7.72k]
  ------------------
  112|      0|                goto err;
  113|  7.72k|            p += n;
  114|  7.72k|        }
  115|  4.72k|    }
  116|  4.72k|    ok = 1;
  117|  4.72k| err:
  118|  4.72k|    OPENSSL_free(bn_data);
  ------------------
  |  |  128|  4.72k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  4.72k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  4.72k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  119|  4.72k|    BN_free(t);
  120|  4.72k|    if (ok)
  ------------------
  |  Branch (120:9): [True: 4.72k, False: 0]
  ------------------
  121|  4.72k|        return buf;
  122|      0|    OPENSSL_free(buf);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  123|      0|    return NULL;
  124|  4.72k|}

BN_lshift:
   82|  48.9k|{
   83|  48.9k|    int ret;
   84|       |
   85|  48.9k|    if (n < 0) {
  ------------------
  |  Branch (85:9): [True: 0, False: 48.9k]
  ------------------
   86|      0|        BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT);
  ------------------
  |  |  102|      0|# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   87|      0|        return 0;
   88|      0|    }
   89|       |
   90|  48.9k|    ret = bn_lshift_fixed_top(r, a, n);
   91|       |
   92|  48.9k|    bn_correct_top(r);
   93|  48.9k|    bn_check_top(r);
   94|       |
   95|  48.9k|    return ret;
   96|  48.9k|}
bn_lshift_fixed_top:
  105|  48.9k|{
  106|  48.9k|    int i, nw;
  107|  48.9k|    unsigned int lb, rb;
  108|  48.9k|    BN_ULONG *t, *f;
  ------------------
  |  |   31|  48.9k|#  define BN_ULONG        unsigned long
  ------------------
  109|  48.9k|    BN_ULONG l, m, rmask = 0;
  ------------------
  |  |   31|  48.9k|#  define BN_ULONG        unsigned long
  ------------------
  110|       |
  111|  48.9k|    assert(n >= 0);
  112|       |
  113|  48.9k|    bn_check_top(r);
  114|  48.9k|    bn_check_top(a);
  115|       |
  116|  48.9k|    nw = n / BN_BITS2;
  ------------------
  |  |   48|  48.9k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  48.9k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  117|  48.9k|    if (bn_wexpand(r, a->top + nw + 1) == NULL)
  ------------------
  |  Branch (117:9): [True: 0, False: 48.9k]
  ------------------
  118|      0|        return 0;
  119|       |
  120|  48.9k|    if (a->top != 0) {
  ------------------
  |  Branch (120:9): [True: 48.9k, False: 0]
  ------------------
  121|  48.9k|        lb = (unsigned int)n % BN_BITS2;
  ------------------
  |  |   48|  48.9k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  48.9k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  122|  48.9k|        rb = BN_BITS2 - lb;
  ------------------
  |  |   48|  48.9k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  48.9k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  123|  48.9k|        rb %= BN_BITS2;            /* say no to undefined behaviour */
  ------------------
  |  |   48|  48.9k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  48.9k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
  124|  48.9k|        rmask = (BN_ULONG)0 - rb;  /* rmask = 0 - (rb != 0) */
  125|  48.9k|        rmask |= rmask >> 8;
  126|  48.9k|        f = &(a->d[0]);
  127|  48.9k|        t = &(r->d[nw]);
  128|  48.9k|        l = f[a->top - 1];
  129|  48.9k|        t[a->top] = (l >> rb) & rmask;
  130|   531k|        for (i = a->top - 1; i > 0; i--) {
  ------------------
  |  Branch (130:30): [True: 482k, False: 48.9k]
  ------------------
  131|   482k|            m = l << lb;
  132|   482k|            l = f[i - 1];
  133|   482k|            t[i] = (m | ((l >> rb) & rmask)) & BN_MASK2;
  ------------------
  |  |   87|   482k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  134|   482k|        }
  135|  48.9k|        t[0] = (l << lb) & BN_MASK2;
  ------------------
  |  |   87|  48.9k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  136|  48.9k|    } else {
  137|       |        /* shouldn't happen, but formally required */
  138|      0|        r->d[nw] = 0;
  139|      0|    }
  140|  48.9k|    if (nw != 0)
  ------------------
  |  Branch (140:9): [True: 0, False: 48.9k]
  ------------------
  141|      0|        memset(r->d, 0, sizeof(*t) * nw);
  142|       |
  143|  48.9k|    r->neg = a->neg;
  144|  48.9k|    r->top = a->top + nw + 1;
  145|  48.9k|    r->flags |= BN_FLG_FIXED_TOP;
  ------------------
  |  |  219|  48.9k|#  define BN_FLG_FIXED_TOP 0
  ------------------
  146|       |
  147|  48.9k|    return 1;
  148|  48.9k|}

BN_div_word:
   62|  12.4k|{
   63|  12.4k|    BN_ULONG ret = 0;
  ------------------
  |  |   31|  12.4k|#  define BN_ULONG        unsigned long
  ------------------
   64|  12.4k|    int i, j;
   65|       |
   66|  12.4k|    bn_check_top(a);
   67|  12.4k|    w &= BN_MASK2;
  ------------------
  |  |   87|  12.4k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
   68|       |
   69|  12.4k|    if (!w)
  ------------------
  |  Branch (69:9): [True: 0, False: 12.4k]
  ------------------
   70|       |        /* actually this an error (division by zero) */
   71|      0|        return (BN_ULONG)-1;
   72|  12.4k|    if (a->top == 0)
  ------------------
  |  Branch (72:9): [True: 0, False: 12.4k]
  ------------------
   73|      0|        return 0;
   74|       |
   75|       |    /* normalize input (so bn_div_words doesn't complain) */
   76|  12.4k|    j = BN_BITS2 - BN_num_bits_word(w);
  ------------------
  |  |   48|  12.4k|# define BN_BITS2       (BN_BYTES * 8)
  |  |  ------------------
  |  |  |  |   32|  12.4k|#  define BN_BYTES        8
  |  |  ------------------
  ------------------
   77|  12.4k|    w <<= j;
   78|  12.4k|    if (!BN_lshift(a, a, j))
  ------------------
  |  Branch (78:9): [True: 0, False: 12.4k]
  ------------------
   79|      0|        return (BN_ULONG)-1;
   80|       |
   81|  78.0k|    for (i = a->top - 1; i >= 0; i--) {
  ------------------
  |  Branch (81:26): [True: 65.5k, False: 12.4k]
  ------------------
   82|  65.5k|        BN_ULONG l, d;
  ------------------
  |  |   31|  65.5k|#  define BN_ULONG        unsigned long
  ------------------
   83|       |
   84|  65.5k|        l = a->d[i];
   85|  65.5k|        d = bn_div_words(ret, l, w);
   86|  65.5k|        ret = (l - ((d * w) & BN_MASK2)) & BN_MASK2;
  ------------------
  |  |   87|  65.5k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
                      ret = (l - ((d * w) & BN_MASK2)) & BN_MASK2;
  ------------------
  |  |   87|  65.5k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
   87|  65.5k|        a->d[i] = d;
   88|  65.5k|    }
   89|  12.4k|    if ((a->top > 0) && (a->d[a->top - 1] == 0))
  ------------------
  |  Branch (89:9): [True: 12.4k, False: 0]
  |  Branch (89:25): [True: 11.9k, False: 456]
  ------------------
   90|  11.9k|        a->top--;
   91|  12.4k|    ret >>= j;
   92|  12.4k|    if (!a->top)
  ------------------
  |  Branch (92:9): [True: 4.72k, False: 7.72k]
  ------------------
   93|  4.72k|        a->neg = 0; /* don't allow negative zero */
   94|  12.4k|    bn_check_top(a);
   95|  12.4k|    return ret;
   96|  12.4k|}
BN_add_word:
   99|  36.5k|{
  100|  36.5k|    BN_ULONG l;
  ------------------
  |  |   31|  36.5k|#  define BN_ULONG        unsigned long
  ------------------
  101|  36.5k|    int i;
  102|       |
  103|  36.5k|    bn_check_top(a);
  104|  36.5k|    w &= BN_MASK2;
  ------------------
  |  |   87|  36.5k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  105|       |
  106|       |    /* degenerate case: w is zero */
  107|  36.5k|    if (!w)
  ------------------
  |  Branch (107:9): [True: 6.35k, False: 30.1k]
  ------------------
  108|  6.35k|        return 1;
  109|       |    /* degenerate case: a is zero */
  110|  30.1k|    if (BN_is_zero(a))
  ------------------
  |  Branch (110:9): [True: 0, False: 30.1k]
  ------------------
  111|      0|        return BN_set_word(a, w);
  112|       |    /* handle 'a' when negative */
  113|  30.1k|    if (a->neg) {
  ------------------
  |  Branch (113:9): [True: 0, False: 30.1k]
  ------------------
  114|      0|        a->neg = 0;
  115|      0|        i = BN_sub_word(a, w);
  116|      0|        if (!BN_is_zero(a))
  ------------------
  |  Branch (116:13): [True: 0, False: 0]
  ------------------
  117|      0|            a->neg = !(a->neg);
  118|      0|        return i;
  119|      0|    }
  120|  60.3k|    for (i = 0; w != 0 && i < a->top; i++) {
  ------------------
  |  Branch (120:17): [True: 30.1k, False: 30.1k]
  |  Branch (120:27): [True: 30.1k, False: 0]
  ------------------
  121|  30.1k|        a->d[i] = l = (a->d[i] + w) & BN_MASK2;
  ------------------
  |  |   87|  30.1k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  122|  30.1k|        w = (w > l) ? 1 : 0;
  ------------------
  |  Branch (122:13): [True: 0, False: 30.1k]
  ------------------
  123|  30.1k|    }
  124|  30.1k|    if (w && i == a->top) {
  ------------------
  |  Branch (124:9): [True: 0, False: 30.1k]
  |  Branch (124:14): [True: 0, False: 0]
  ------------------
  125|      0|        if (bn_wexpand(a, a->top + 1) == NULL)
  ------------------
  |  Branch (125:13): [True: 0, False: 0]
  ------------------
  126|      0|            return 0;
  127|      0|        a->top++;
  128|      0|        a->d[i] = w;
  129|      0|    }
  130|  30.1k|    bn_check_top(a);
  131|  30.1k|    return 1;
  132|  30.1k|}
BN_sub_word:
  135|  1.91k|{
  136|  1.91k|    int i;
  137|       |
  138|  1.91k|    bn_check_top(a);
  139|  1.91k|    w &= BN_MASK2;
  ------------------
  |  |   87|  1.91k|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  140|       |
  141|       |    /* degenerate case: w is zero */
  142|  1.91k|    if (!w)
  ------------------
  |  Branch (142:9): [True: 0, False: 1.91k]
  ------------------
  143|      0|        return 1;
  144|       |    /* degenerate case: a is zero */
  145|  1.91k|    if (BN_is_zero(a)) {
  ------------------
  |  Branch (145:9): [True: 0, False: 1.91k]
  ------------------
  146|      0|        i = BN_set_word(a, w);
  147|      0|        if (i != 0)
  ------------------
  |  Branch (147:13): [True: 0, False: 0]
  ------------------
  148|      0|            BN_set_negative(a, 1);
  149|      0|        return i;
  150|      0|    }
  151|       |    /* handle 'a' when negative */
  152|  1.91k|    if (a->neg) {
  ------------------
  |  Branch (152:9): [True: 0, False: 1.91k]
  ------------------
  153|      0|        a->neg = 0;
  154|      0|        i = BN_add_word(a, w);
  155|      0|        a->neg = 1;
  156|      0|        return i;
  157|      0|    }
  158|       |
  159|  1.91k|    if ((a->top == 1) && (a->d[0] < w)) {
  ------------------
  |  Branch (159:9): [True: 0, False: 1.91k]
  |  Branch (159:26): [True: 0, False: 0]
  ------------------
  160|      0|        a->d[0] = w - a->d[0];
  161|      0|        a->neg = 1;
  162|      0|        return 1;
  163|      0|    }
  164|  1.91k|    i = 0;
  165|  2.59k|    for (;;) {
  166|  2.59k|        if (a->d[i] >= w) {
  ------------------
  |  Branch (166:13): [True: 1.91k, False: 684]
  ------------------
  167|  1.91k|            a->d[i] -= w;
  168|  1.91k|            break;
  169|  1.91k|        } else {
  170|    684|            a->d[i] = (a->d[i] - w) & BN_MASK2;
  ------------------
  |  |   87|    684|#  define BN_MASK2        (0xffffffffffffffffL)
  ------------------
  171|    684|            i++;
  172|    684|            w = 1;
  173|    684|        }
  174|  2.59k|    }
  175|  1.91k|    if ((a->d[i] == 0) && (i == (a->top - 1)))
  ------------------
  |  Branch (175:9): [True: 577, False: 1.33k]
  |  Branch (175:27): [True: 340, False: 237]
  ------------------
  176|    340|        a->top--;
  177|  1.91k|    bn_check_top(a);
  178|  1.91k|    return 1;
  179|  1.91k|}

ERR_load_BUF_strings:
   30|      2|{
   31|      2|#ifndef OPENSSL_NO_ERR
   32|      2|    if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (32:9): [True: 2, False: 0]
  ------------------
   33|      2|        ERR_load_strings_const(BUF_str_functs);
   34|      2|        ERR_load_strings_const(BUF_str_reasons);
   35|      2|    }
   36|      2|#endif
   37|      2|    return 1;
   38|      2|}

ERR_load_CMS_strings:
  291|      2|{
  292|      2|#ifndef OPENSSL_NO_ERR
  293|      2|    if (ERR_func_error_string(CMS_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (293:9): [True: 2, False: 0]
  ------------------
  294|      2|        ERR_load_strings_const(CMS_str_functs);
  295|      2|        ERR_load_strings_const(CMS_str_reasons);
  296|      2|    }
  297|      2|#endif
  298|      2|    return 1;
  299|      2|}

ERR_load_COMP_strings:
   38|      2|{
   39|      2|#ifndef OPENSSL_NO_ERR
   40|      2|    if (ERR_func_error_string(COMP_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (40:9): [True: 2, False: 0]
  ------------------
   41|      2|        ERR_load_strings_const(COMP_str_functs);
   42|      2|        ERR_load_strings_const(COMP_str_reasons);
   43|      2|    }
   44|      2|#endif
   45|      2|    return 1;
   46|      2|}

ERR_load_CONF_strings:
   87|      2|{
   88|      2|#ifndef OPENSSL_NO_ERR
   89|      2|    if (ERR_func_error_string(CONF_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (89:9): [True: 2, False: 0]
  ------------------
   90|      2|        ERR_load_strings_const(CONF_str_functs);
   91|      2|        ERR_load_strings_const(CONF_str_reasons);
   92|      2|    }
   93|      2|#endif
   94|      2|    return 1;
   95|      2|}

CONF_modules_unload:
  360|      2|{
  361|      2|    int i;
  362|      2|    CONF_MODULE *md;
  363|      2|    CONF_modules_finish();
  364|       |    /* unload modules in reverse order */
  365|      2|    for (i = sk_CONF_MODULE_num(supported_modules) - 1; i >= 0; i--) {
  ------------------
  |  Branch (365:57): [True: 0, False: 2]
  ------------------
  366|      0|        md = sk_CONF_MODULE_value(supported_modules, i);
  367|       |        /* If static or in use and 'all' not set ignore it */
  368|      0|        if (((md->links > 0) || !md->dso) && !all)
  ------------------
  |  Branch (368:14): [True: 0, False: 0]
  |  Branch (368:33): [True: 0, False: 0]
  |  Branch (368:46): [True: 0, False: 0]
  ------------------
  369|      0|            continue;
  370|       |        /* Since we're working in reverse this is OK */
  371|      0|        (void)sk_CONF_MODULE_delete(supported_modules, i);
  372|      0|        module_free(md);
  373|      0|    }
  374|      2|    if (sk_CONF_MODULE_num(supported_modules) == 0) {
  ------------------
  |  Branch (374:9): [True: 0, False: 2]
  ------------------
  375|      0|        sk_CONF_MODULE_free(supported_modules);
  376|      0|        supported_modules = NULL;
  377|      0|    }
  378|      2|}
CONF_modules_finish:
  391|      4|{
  392|      4|    CONF_IMODULE *imod;
  393|      4|    while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  ------------------
  |  Branch (393:12): [True: 0, False: 4]
  ------------------
  394|      0|        imod = sk_CONF_IMODULE_pop(initialized_modules);
  395|      0|        module_finish(imod);
  396|      0|    }
  397|      4|    sk_CONF_IMODULE_free(initialized_modules);
  398|      4|    initialized_modules = NULL;
  399|      4|}
conf_modules_free_int:
  427|      2|{
  428|      2|    CONF_modules_finish();
  429|      2|    CONF_modules_unload(1);
  430|      2|}

ERR_load_CRYPTO_strings:
   69|      2|{
   70|      2|#ifndef OPENSSL_NO_ERR
   71|      2|    if (ERR_func_error_string(CRYPTO_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (71:9): [True: 2, False: 0]
  ------------------
   72|      2|        ERR_load_strings_const(CRYPTO_str_functs);
   73|      2|        ERR_load_strings_const(CRYPTO_str_reasons);
   74|      2|    }
   75|      2|#endif
   76|      2|    return 1;
   77|      2|}

OPENSSL_cpuid_setup:
   98|      4|{
   99|      4|    static int trigger = 0;
  100|      4|    IA32CAP OPENSSL_ia32_cpuid(unsigned int *);
  101|      4|    IA32CAP vec;
  102|      4|    const variant_char *env;
  103|       |
  104|      4|    if (trigger)
  ------------------
  |  Branch (104:9): [True: 2, False: 2]
  ------------------
  105|      2|        return;
  106|       |
  107|      2|    trigger = 1;
  108|      2|    if ((env = ossl_getenv("OPENSSL_ia32cap")) != NULL) {
  ------------------
  |  |   49|      2|#   define ossl_getenv getenv
  ------------------
  |  Branch (108:9): [True: 0, False: 2]
  ------------------
  109|      0|        int off = (env[0] == '~') ? 1 : 0;
  ------------------
  |  Branch (109:19): [True: 0, False: 0]
  ------------------
  110|       |
  111|      0|        vec = ossl_strtouint64(env + off);
  112|       |
  113|      0|        if (off) {
  ------------------
  |  Branch (113:13): [True: 0, False: 0]
  ------------------
  114|      0|            IA32CAP mask = vec;
  115|      0|            vec = OPENSSL_ia32_cpuid(OPENSSL_ia32cap_P) & ~mask;
  116|      0|            if (mask & (1<<24)) {
  ------------------
  |  Branch (116:17): [True: 0, False: 0]
  ------------------
  117|       |                /*
  118|       |                 * User disables FXSR bit, mask even other capabilities
  119|       |                 * that operate exclusively on XMM, so we don't have to
  120|       |                 * double-check all the time. We mask PCLMULQDQ, AMD XOP,
  121|       |                 * AES-NI and AVX. Formally speaking we don't have to
  122|       |                 * do it in x86_64 case, but we can safely assume that
  123|       |                 * x86_64 users won't actually flip this flag.
  124|       |                 */
  125|      0|                vec &= ~((IA32CAP)(1<<1|1<<11|1<<25|1<<28) << 32);
  126|      0|            }
  127|      0|        } else if (env[0] == ':') {
  ------------------
  |  Branch (127:20): [True: 0, False: 0]
  ------------------
  128|      0|            vec = OPENSSL_ia32_cpuid(OPENSSL_ia32cap_P);
  129|      0|        }
  130|       |
  131|      0|        if ((env = ossl_strchr(env, ':')) != NULL) {
  ------------------
  |  Branch (131:13): [True: 0, False: 0]
  ------------------
  132|      0|            IA32CAP vecx;
  133|       |
  134|      0|            env++;
  135|      0|            off = (env[0] == '~') ? 1 : 0;
  ------------------
  |  Branch (135:19): [True: 0, False: 0]
  ------------------
  136|      0|            vecx = ossl_strtouint64(env + off);
  137|      0|            if (off) {
  ------------------
  |  Branch (137:17): [True: 0, False: 0]
  ------------------
  138|      0|                OPENSSL_ia32cap_P[2] &= ~(unsigned int)vecx;
  139|      0|                OPENSSL_ia32cap_P[3] &= ~(unsigned int)(vecx >> 32);
  140|      0|            } else {
  141|      0|                OPENSSL_ia32cap_P[2] = (unsigned int)vecx;
  142|      0|                OPENSSL_ia32cap_P[3] = (unsigned int)(vecx >> 32);
  143|      0|            }
  144|      0|        } else {
  145|      0|            OPENSSL_ia32cap_P[2] = 0;
  146|      0|            OPENSSL_ia32cap_P[3] = 0;
  147|      0|        }
  148|      2|    } else {
  149|      2|        vec = OPENSSL_ia32_cpuid(OPENSSL_ia32cap_P);
  150|      2|    }
  151|       |
  152|       |    /*
  153|       |     * |(1<<10) sets a reserved bit to signal that variable
  154|       |     * was initialized already... This is to avoid interference
  155|       |     * with cpuid snippets in ELF .init segment.
  156|       |     */
  157|      2|    OPENSSL_ia32cap_P[0] = (unsigned int)vec | (1 << 10);
  158|      2|    OPENSSL_ia32cap_P[1] = (unsigned int)(vec >> 32);
  159|      2|}

ERR_load_CT_strings:
   88|      2|{
   89|      2|#ifndef OPENSSL_NO_ERR
   90|      2|    if (ERR_func_error_string(CT_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (90:9): [True: 2, False: 0]
  ------------------
   91|      2|        ERR_load_strings_const(CT_str_functs);
   92|      2|        ERR_load_strings_const(CT_str_reasons);
   93|      2|    }
   94|      2|#endif
   95|      2|    return 1;
   96|      2|}

ossl_ctype_check:
  253|  47.5M|{
  254|  47.5M|    const int max = sizeof(ctype_char_map) / sizeof(*ctype_char_map);
  255|  47.5M|    const int a = ossl_toascii(c);
  ------------------
  |  |   53|  47.5M|#  define ossl_toascii(c)       (c)
  ------------------
  256|       |
  257|  47.5M|    return a >= 0 && a < max && (ctype_char_map[a] & mask) != 0;
  ------------------
  |  Branch (257:12): [True: 47.5M, False: 0]
  |  Branch (257:22): [True: 47.5M, False: 0]
  |  Branch (257:33): [True: 20.0M, False: 27.4M]
  ------------------
  258|  47.5M|}

ERR_load_DH_strings:
   94|      2|{
   95|      2|#ifndef OPENSSL_NO_ERR
   96|      2|    if (ERR_func_error_string(DH_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (96:9): [True: 2, False: 0]
  ------------------
   97|      2|        ERR_load_strings_const(DH_str_functs);
   98|      2|        ERR_load_strings_const(DH_str_reasons);
   99|      2|    }
  100|      2|#endif
  101|      2|    return 1;
  102|      2|}

ERR_load_DSA_strings:
   70|      2|{
   71|      2|#ifndef OPENSSL_NO_ERR
   72|      2|    if (ERR_func_error_string(DSA_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (72:9): [True: 2, False: 0]
  ------------------
   73|      2|        ERR_load_strings_const(DSA_str_functs);
   74|      2|        ERR_load_strings_const(DSA_str_reasons);
   75|      2|    }
   76|      2|#endif
   77|      2|    return 1;
   78|      2|}

ERR_load_DSO_strings:
   92|      2|{
   93|      2|#ifndef OPENSSL_NO_ERR
   94|      2|    if (ERR_func_error_string(DSO_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (94:9): [True: 2, False: 0]
  ------------------
   95|      2|        ERR_load_strings_const(DSO_str_functs);
   96|      2|        ERR_load_strings_const(DSO_str_reasons);
   97|      2|    }
   98|      2|#endif
   99|      2|    return 1;
  100|      2|}

ERR_load_EC_strings:
  387|      2|{
  388|      2|#ifndef OPENSSL_NO_ERR
  389|      2|    if (ERR_func_error_string(EC_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (389:9): [True: 2, False: 0]
  ------------------
  390|      2|        ERR_load_strings_const(EC_str_functs);
  391|      2|        ERR_load_strings_const(EC_str_reasons);
  392|      2|    }
  393|      2|#endif
  394|      2|    return 1;
  395|      2|}

ERR_load_ENGINE_strings:
  146|      2|{
  147|      2|#ifndef OPENSSL_NO_ERR
  148|      2|    if (ERR_func_error_string(ENGINE_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (148:9): [True: 2, False: 0]
  ------------------
  149|      2|        ERR_load_strings_const(ENGINE_str_functs);
  150|      2|        ERR_load_strings_const(ENGINE_str_reasons);
  151|      2|    }
  152|      2|#endif
  153|      2|    return 1;
  154|      2|}

engine_cleanup_int:
  169|      2|{
  170|      2|    if (int_cleanup_check(0)) {
  ------------------
  |  Branch (170:9): [True: 0, False: 2]
  ------------------
  171|      0|        sk_ENGINE_CLEANUP_ITEM_pop_free(cleanup_stack,
  172|      0|                                        engine_cleanup_cb_free);
  173|      0|        cleanup_stack = NULL;
  174|      0|    }
  175|      2|    CRYPTO_THREAD_lock_free(global_engine_lock);
  176|      2|    global_engine_lock = NULL;
  177|      2|}
eng_lib.c:int_cleanup_check:
  117|      2|{
  118|      2|    if (cleanup_stack)
  ------------------
  |  Branch (118:9): [True: 0, False: 2]
  ------------------
  119|      0|        return 1;
  120|      2|    if (!create)
  ------------------
  |  Branch (120:9): [True: 2, False: 0]
  ------------------
  121|      2|        return 0;
  122|      0|    cleanup_stack = sk_ENGINE_CLEANUP_ITEM_new_null();
  123|      0|    return (cleanup_stack ? 1 : 0);
  ------------------
  |  Branch (123:13): [True: 0, False: 0]
  ------------------
  124|      2|}

err_cleanup:
  321|      2|{
  322|      2|    if (set_err_thread_local != 0)
  ------------------
  |  Branch (322:9): [True: 2, False: 0]
  ------------------
  323|      2|        CRYPTO_THREAD_cleanup_local(&err_thread_local);
  324|      2|    CRYPTO_THREAD_lock_free(err_string_lock);
  325|      2|    err_string_lock = NULL;
  326|      2|#ifndef OPENSSL_NO_ERR
  327|      2|    lh_ERR_STRING_DATA_free(int_error_hash);
  328|      2|    int_error_hash = NULL;
  329|      2|#endif
  330|      2|}
ERR_load_ERR_strings:
  359|    118|{
  360|    118|#ifndef OPENSSL_NO_ERR
  361|    118|    if (!RUN_ONCE(&err_string_init, do_err_strings_init))
  ------------------
  |  |  119|    118|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 118, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (361:9): [True: 0, False: 118]
  ------------------
  362|      0|        return 0;
  363|       |
  364|    118|    err_load_strings(ERR_str_libraries);
  365|    118|    err_load_strings(ERR_str_reasons);
  366|    118|    err_patch(ERR_LIB_SYS, ERR_str_functs);
  ------------------
  |  |   55|    118|# define ERR_LIB_SYS             2
  ------------------
  367|    118|    err_load_strings(ERR_str_functs);
  368|    118|    build_SYS_str_reasons();
  369|    118|#endif
  370|    118|    return 1;
  371|    118|}
ERR_load_strings_const:
  387|    116|{
  388|    116|#ifndef OPENSSL_NO_ERR
  389|    116|    if (ERR_load_ERR_strings() == 0)
  ------------------
  |  Branch (389:9): [True: 0, False: 116]
  ------------------
  390|      0|        return 0;
  391|    116|    err_load_strings(str);
  392|    116|#endif
  393|       |
  394|    116|    return 1;
  395|    116|}
ERR_put_error:
  424|  18.2k|{
  425|  18.2k|    ERR_STATE *es;
  426|       |
  427|       |#ifdef _OSD_POSIX
  428|       |    /*
  429|       |     * In the BS2000-OSD POSIX subsystem, the compiler generates path names
  430|       |     * in the form "*POSIX(/etc/passwd)". This dirty hack strips them to
  431|       |     * something sensible. @@@ We shouldn't modify a const string, though.
  432|       |     */
  433|       |    if (strncmp(file, "*POSIX(", sizeof("*POSIX(") - 1) == 0) {
  434|       |        char *end;
  435|       |
  436|       |        /* Skip the "*POSIX(" prefix */
  437|       |        file += sizeof("*POSIX(") - 1;
  438|       |        end = &file[strlen(file) - 1];
  439|       |        if (*end == ')')
  440|       |            *end = '\0';
  441|       |        /* Optional: use the basename of the path only. */
  442|       |        if ((end = strrchr(file, '/')) != NULL)
  443|       |            file = &end[1];
  444|       |    }
  445|       |#endif
  446|  18.2k|    es = ERR_get_state();
  447|  18.2k|    if (es == NULL)
  ------------------
  |  Branch (447:9): [True: 0, False: 18.2k]
  ------------------
  448|      0|        return;
  449|       |
  450|  18.2k|    es->top = (es->top + 1) % ERR_NUM_ERRORS;
  ------------------
  |  |   42|  18.2k|# define ERR_NUM_ERRORS  16
  ------------------
  451|  18.2k|    if (es->top == es->bottom)
  ------------------
  |  Branch (451:9): [True: 16.2k, False: 1.96k]
  ------------------
  452|  16.2k|        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
  ------------------
  |  |   42|  16.2k|# define ERR_NUM_ERRORS  16
  ------------------
  453|  18.2k|    es->err_flags[es->top] = 0;
  454|  18.2k|    es->err_buffer[es->top] = ERR_PACK(lib, func, reason);
  ------------------
  |  |  138|  18.2k|# define ERR_PACK(l,f,r) ( \
  |  |  139|  18.2k|        (((unsigned int)(l) & 0x0FF) << 24L) | \
  |  |  140|  18.2k|        (((unsigned int)(f) & 0xFFF) << 12L) | \
  |  |  141|  18.2k|        (((unsigned int)(r) & 0xFFF)       ) )
  ------------------
  455|  18.2k|    es->err_file[es->top] = file;
  456|  18.2k|    es->err_line[es->top] = line;
  457|  18.2k|    err_clear_data(es, es->top);
  ------------------
  |  |  272|  18.2k|        do { \
  |  |  273|  18.2k|            if ((p)->err_data_flags[i] & ERR_TXT_MALLOCED) {\
  |  |  ------------------
  |  |  |  |   36|  18.2k|# define ERR_TXT_MALLOCED        0x01
  |  |  ------------------
  |  |  |  Branch (273:17): [True: 0, False: 18.2k]
  |  |  ------------------
  |  |  274|      0|                OPENSSL_free((p)->err_data[i]); \
  |  |  ------------------
  |  |  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  |  |  ------------------
  |  |  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  275|      0|                (p)->err_data[i] = NULL; \
  |  |  276|      0|            } \
  |  |  277|  18.2k|            (p)->err_data_flags[i] = 0; \
  |  |  278|  18.2k|        } while (0)
  |  |  ------------------
  |  |  |  Branch (278:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
  458|  18.2k|}
ERR_clear_error:
  461|  2.58k|{
  462|  2.58k|    int i;
  463|  2.58k|    ERR_STATE *es;
  464|       |
  465|  2.58k|    es = ERR_get_state();
  466|  2.58k|    if (es == NULL)
  ------------------
  |  Branch (466:9): [True: 0, False: 2.58k]
  ------------------
  467|      0|        return;
  468|       |
  469|  43.9k|    for (i = 0; i < ERR_NUM_ERRORS; i++) {
  ------------------
  |  |   42|  43.9k|# define ERR_NUM_ERRORS  16
  ------------------
  |  Branch (469:17): [True: 41.3k, False: 2.58k]
  ------------------
  470|  41.3k|        err_clear(es, i);
  ------------------
  |  |  281|  41.3k|        do { \
  |  |  282|  41.3k|            err_clear_data(p, i); \
  |  |  ------------------
  |  |  |  |  272|  41.3k|        do { \
  |  |  |  |  273|  41.3k|            if ((p)->err_data_flags[i] & ERR_TXT_MALLOCED) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|  41.3k|# define ERR_TXT_MALLOCED        0x01
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (273:17): [True: 0, False: 41.3k]
  |  |  |  |  ------------------
  |  |  |  |  274|      0|                OPENSSL_free((p)->err_data[i]); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  275|      0|                (p)->err_data[i] = NULL; \
  |  |  |  |  276|      0|            } \
  |  |  |  |  277|  41.3k|            (p)->err_data_flags[i] = 0; \
  |  |  |  |  278|  41.3k|        } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:18): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  283|  41.3k|            (p)->err_flags[i] = 0; \
  |  |  284|  41.3k|            (p)->err_buffer[i] = 0; \
  |  |  285|  41.3k|            (p)->err_file[i] = NULL; \
  |  |  286|  41.3k|            (p)->err_line[i] = -1; \
  |  |  287|  41.3k|        } while (0)
  |  |  ------------------
  |  |  |  Branch (287:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
  471|  41.3k|    }
  472|  2.58k|    es->top = es->bottom = 0;
  473|  2.58k|}
ERR_func_error_string:
  676|     58|{
  677|     58|#ifndef OPENSSL_NO_ERR
  678|     58|    ERR_STRING_DATA d, *p;
  679|     58|    unsigned long l, f;
  680|       |
  681|     58|    if (!RUN_ONCE(&err_string_init, do_err_strings_init)) {
  ------------------
  |  |  119|     58|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 58, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (681:9): [True: 0, False: 58]
  ------------------
  682|      0|        return NULL;
  683|      0|    }
  684|       |
  685|     58|    l = ERR_GET_LIB(e);
  ------------------
  |  |  142|     58|# define ERR_GET_LIB(l)          (int)(((l) >> 24L) & 0x0FFL)
  ------------------
  686|     58|    f = ERR_GET_FUNC(e);
  ------------------
  |  |  143|     58|# define ERR_GET_FUNC(l)         (int)(((l) >> 12L) & 0xFFFL)
  ------------------
  687|     58|    d.error = ERR_PACK(l, f, 0);
  ------------------
  |  |  138|     58|# define ERR_PACK(l,f,r) ( \
  |  |  139|     58|        (((unsigned int)(l) & 0x0FF) << 24L) | \
  |  |  140|     58|        (((unsigned int)(f) & 0xFFF) << 12L) | \
  |  |  141|     58|        (((unsigned int)(r) & 0xFFF)       ) )
  ------------------
  688|     58|    p = int_err_get_item(&d);
  689|     58|    return ((p == NULL) ? NULL : p->string);
  ------------------
  |  Branch (689:13): [True: 58, False: 0]
  ------------------
  690|       |#else
  691|       |    return NULL;
  692|       |#endif
  693|     58|}
err_delete_thread_state:
  720|      2|{
  721|      2|    ERR_STATE *state = CRYPTO_THREAD_get_local(&err_thread_local);
  722|      2|    if (state == NULL)
  ------------------
  |  Branch (722:9): [True: 0, False: 2]
  ------------------
  723|      0|        return;
  724|       |
  725|      2|    CRYPTO_THREAD_set_local(&err_thread_local, NULL);
  726|      2|    ERR_STATE_free(state);
  727|      2|}
ERR_get_state:
  748|  20.8k|{
  749|  20.8k|    ERR_STATE *state;
  750|  20.8k|    int saveerrno = get_last_sys_error();
  ------------------
  |  |   75|  20.8k|# define get_last_sys_error()    errno
  ------------------
  751|       |
  752|  20.8k|    if (!OPENSSL_init_crypto(OPENSSL_INIT_BASE_ONLY, NULL))
  ------------------
  |  |   28|  20.8k|# define OPENSSL_INIT_BASE_ONLY              0x00040000L
  ------------------
  |  Branch (752:9): [True: 0, False: 20.8k]
  ------------------
  753|      0|        return NULL;
  754|       |
  755|  20.8k|    if (!RUN_ONCE(&err_init, err_do_init))
  ------------------
  |  |  119|  20.8k|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 20.8k, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (755:9): [True: 0, False: 20.8k]
  ------------------
  756|      0|        return NULL;
  757|       |
  758|  20.8k|    state = CRYPTO_THREAD_get_local(&err_thread_local);
  759|  20.8k|    if (state == (ERR_STATE*)-1)
  ------------------
  |  Branch (759:9): [True: 0, False: 20.8k]
  ------------------
  760|      0|        return NULL;
  761|       |
  762|  20.8k|    if (state == NULL) {
  ------------------
  |  Branch (762:9): [True: 2, False: 20.8k]
  ------------------
  763|      2|        if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1))
  ------------------
  |  Branch (763:13): [True: 0, False: 2]
  ------------------
  764|      0|            return NULL;
  765|       |
  766|      2|        if ((state = OPENSSL_zalloc(sizeof(*state))) == NULL) {
  ------------------
  |  |  120|      2|        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  |  Branch (766:13): [True: 0, False: 2]
  ------------------
  767|      0|            CRYPTO_THREAD_set_local(&err_thread_local, NULL);
  768|      0|            return NULL;
  769|      0|        }
  770|       |
  771|      2|        if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
  ------------------
  |  |   32|      2|# define OPENSSL_INIT_THREAD_ERR_STATE       0x02
  ------------------
  |  Branch (771:13): [True: 0, False: 2]
  ------------------
  772|      2|                || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
  ------------------
  |  Branch (772:20): [True: 0, False: 2]
  ------------------
  773|      0|            ERR_STATE_free(state);
  774|      0|            CRYPTO_THREAD_set_local(&err_thread_local, NULL);
  775|      0|            return NULL;
  776|      0|        }
  777|       |
  778|       |        /* Ignore failures from these */
  779|      2|        OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
  ------------------
  |  |  357|      2|# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS    0x00000002L
  ------------------
  780|      2|    }
  781|       |
  782|  20.8k|    set_sys_error(saveerrno);
  ------------------
  |  |   77|  20.8k|# define set_sys_error(e)        errno=(e)
  ------------------
  783|  20.8k|    return state;
  784|  20.8k|}
err.c:do_err_strings_init:
  302|      2|{
  303|      2|    if (!OPENSSL_init_crypto(0, NULL))
  ------------------
  |  Branch (303:9): [True: 0, False: 2]
  ------------------
  304|      0|        return 0;
  305|      2|    err_string_lock = CRYPTO_THREAD_lock_new();
  306|      2|    if (err_string_lock == NULL)
  ------------------
  |  Branch (306:9): [True: 0, False: 2]
  ------------------
  307|      0|        return 0;
  308|      2|#ifndef OPENSSL_NO_ERR
  309|      2|    int_error_hash = lh_ERR_STRING_DATA_new(err_string_data_hash,
  310|      2|                                            err_string_data_cmp);
  311|      2|    if (int_error_hash == NULL) {
  ------------------
  |  Branch (311:9): [True: 0, False: 2]
  ------------------
  312|      0|        CRYPTO_THREAD_lock_free(err_string_lock);
  313|      0|        err_string_lock = NULL;
  314|      0|        return 0;
  315|      0|    }
  316|      2|#endif
  317|      2|    return 1;
  318|      2|}
err.c:err_string_data_hash:
  167|  15.2k|{
  168|  15.2k|    unsigned long ret, l;
  169|       |
  170|  15.2k|    l = a->error;
  171|  15.2k|    ret = l ^ ERR_GET_LIB(l) ^ ERR_GET_FUNC(l);
  ------------------
  |  |  142|  15.2k|# define ERR_GET_LIB(l)          (int)(((l) >> 24L) & 0x0FFL)
  ------------------
                  ret = l ^ ERR_GET_LIB(l) ^ ERR_GET_FUNC(l);
  ------------------
  |  |  143|  15.2k|# define ERR_GET_FUNC(l)         (int)(((l) >> 12L) & 0xFFFL)
  ------------------
  172|  15.2k|    return (ret ^ ret % 19 * 13);
  173|  15.2k|}
err.c:err_string_data_cmp:
  177|  10.5k|{
  178|  10.5k|    if (a->error == b->error)
  ------------------
  |  Branch (178:9): [True: 10.3k, False: 246]
  ------------------
  179|  10.3k|        return 0;
  180|    246|    return a->error > b->error ? 1 : -1;
  ------------------
  |  Branch (180:12): [True: 150, False: 96]
  ------------------
  181|  10.5k|}
err.c:err_load_strings:
  348|    472|{
  349|    472|    CRYPTO_THREAD_write_lock(err_string_lock);
  350|  15.6k|    for (; str->error; str++)
  ------------------
  |  Branch (350:12): [True: 15.1k, False: 472]
  ------------------
  351|  15.1k|        (void)lh_ERR_STRING_DATA_insert(int_error_hash,
  352|  15.1k|                                       (ERR_STRING_DATA *)str);
  353|    472|    CRYPTO_THREAD_unlock(err_string_lock);
  354|    472|    return 1;
  355|    472|}
err.c:err_patch:
  337|    118|{
  338|    118|    unsigned long plib = ERR_PACK(lib, 0, 0);
  ------------------
  |  |  138|    118|# define ERR_PACK(l,f,r) ( \
  |  |  139|    118|        (((unsigned int)(l) & 0x0FF) << 24L) | \
  |  |  140|    118|        (((unsigned int)(f) & 0xFFF) << 12L) | \
  |  |  141|    118|        (((unsigned int)(r) & 0xFFF)       ) )
  ------------------
  339|       |
  340|  2.83k|    for (; str->error != 0; str++)
  ------------------
  |  Branch (340:12): [True: 2.71k, False: 118]
  ------------------
  341|  2.71k|        str->error |= plib;
  342|    118|}
err.c:build_SYS_str_reasons:
  210|    118|{
  211|       |    /* OPENSSL_malloc cannot be used here, use static storage instead */
  212|    118|    static char strerror_pool[SPACE_SYS_STR_REASONS];
  213|    118|    char *cur = strerror_pool;
  214|    118|    size_t cnt = 0;
  215|    118|    static int init = 1;
  216|    118|    int i;
  217|    118|    int saveerrno = get_last_sys_error();
  ------------------
  |  |   75|    118|# define get_last_sys_error()    errno
  ------------------
  218|       |
  219|    118|    CRYPTO_THREAD_write_lock(err_string_lock);
  220|    118|    if (!init) {
  ------------------
  |  Branch (220:9): [True: 116, False: 2]
  ------------------
  221|    116|        CRYPTO_THREAD_unlock(err_string_lock);
  222|    116|        return;
  223|    116|    }
  224|       |
  225|    256|    for (i = 1; i <= NUM_SYS_STR_REASONS; i++) {
  ------------------
  |  |  196|    256|# define NUM_SYS_STR_REASONS 127
  ------------------
  |  Branch (225:17): [True: 254, False: 2]
  ------------------
  226|    254|        ERR_STRING_DATA *str = &SYS_str_reasons[i - 1];
  227|       |
  228|    254|        str->error = ERR_PACK(ERR_LIB_SYS, 0, i);
  ------------------
  |  |  138|    254|# define ERR_PACK(l,f,r) ( \
  |  |  139|    254|        (((unsigned int)(l) & 0x0FF) << 24L) | \
  |  |  140|    254|        (((unsigned int)(f) & 0xFFF) << 12L) | \
  |  |  141|    254|        (((unsigned int)(r) & 0xFFF)       ) )
  ------------------
  229|       |        /*
  230|       |         * If we have used up all the space in strerror_pool,
  231|       |         * there's no point in calling openssl_strerror_r()
  232|       |         */
  233|    254|        if (str->string == NULL && cnt < sizeof(strerror_pool)) {
  ------------------
  |  Branch (233:13): [True: 254, False: 0]
  |  Branch (233:36): [True: 254, False: 0]
  ------------------
  234|    254|            if (openssl_strerror_r(i, cur, sizeof(strerror_pool) - cnt)) {
  ------------------
  |  Branch (234:17): [True: 250, False: 4]
  ------------------
  235|    250|                size_t l = strlen(cur);
  236|       |
  237|    250|                str->string = cur;
  238|    250|                cnt += l;
  239|    250|                cur += l;
  240|       |
  241|       |                /*
  242|       |                 * VMS has an unusual quirk of adding spaces at the end of
  243|       |                 * some (most? all?) messages. Lets trim them off.
  244|       |                 */
  245|    250|                while (cur > strerror_pool && ossl_isspace(cur[-1])) {
  ------------------
  |  |   76|    250|# define ossl_isspace(c)        (ossl_ctype_check((c), CTYPE_MASK_space))
  |  |  ------------------
  |  |  |  |   27|    250|# define CTYPE_MASK_space       0x8
  |  |  ------------------
  |  |  |  Branch (76:33): [True: 0, False: 250]
  |  |  ------------------
  ------------------
  |  Branch (245:24): [True: 250, False: 0]
  ------------------
  246|      0|                    cur--;
  247|      0|                    cnt--;
  248|      0|                }
  249|    250|                *cur++ = '\0';
  250|    250|                cnt++;
  251|    250|            }
  252|    254|        }
  253|    254|        if (str->string == NULL)
  ------------------
  |  Branch (253:13): [True: 4, False: 250]
  ------------------
  254|      4|            str->string = "unknown";
  255|    254|    }
  256|       |
  257|       |    /*
  258|       |     * Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, as
  259|       |     * required by ERR_load_strings.
  260|       |     */
  261|       |
  262|      2|    init = 0;
  263|       |
  264|      2|    CRYPTO_THREAD_unlock(err_string_lock);
  265|       |    /* openssl_strerror_r could change errno, but we want to preserve it */
  266|      2|    set_sys_error(saveerrno);
  ------------------
  |  |   77|      2|# define set_sys_error(e)        errno=(e)
  ------------------
  267|      2|    err_load_strings(SYS_str_reasons);
  268|      2|}
err.c:int_err_get_item:
  184|     58|{
  185|     58|    ERR_STRING_DATA *p = NULL;
  186|       |
  187|     58|    CRYPTO_THREAD_read_lock(err_string_lock);
  188|     58|    p = lh_ERR_STRING_DATA_retrieve(int_error_hash, d);
  189|     58|    CRYPTO_THREAD_unlock(err_string_lock);
  190|       |
  191|     58|    return p;
  192|     58|}
err.c:ERR_STATE_free:
  290|      2|{
  291|      2|    int i;
  292|       |
  293|      2|    if (s == NULL)
  ------------------
  |  Branch (293:9): [True: 0, False: 2]
  ------------------
  294|      0|        return;
  295|     34|    for (i = 0; i < ERR_NUM_ERRORS; i++) {
  ------------------
  |  |   42|     34|# define ERR_NUM_ERRORS  16
  ------------------
  |  Branch (295:17): [True: 32, False: 2]
  ------------------
  296|     32|        err_clear_data(s, i);
  ------------------
  |  |  272|     32|        do { \
  |  |  273|     32|            if ((p)->err_data_flags[i] & ERR_TXT_MALLOCED) {\
  |  |  ------------------
  |  |  |  |   36|     32|# define ERR_TXT_MALLOCED        0x01
  |  |  ------------------
  |  |  |  Branch (273:17): [True: 0, False: 32]
  |  |  ------------------
  |  |  274|      0|                OPENSSL_free((p)->err_data[i]); \
  |  |  ------------------
  |  |  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  |  |  ------------------
  |  |  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  275|      0|                (p)->err_data[i] = NULL; \
  |  |  276|      0|            } \
  |  |  277|     32|            (p)->err_data_flags[i] = 0; \
  |  |  278|     32|        } while (0)
  |  |  ------------------
  |  |  |  Branch (278:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
  297|     32|    }
  298|      2|    OPENSSL_free(s);
  ------------------
  |  |  128|      2|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  299|      2|}
err.c:err_do_init:
  742|      2|{
  743|      2|    set_err_thread_local = 1;
  744|      2|    return CRYPTO_THREAD_init_local(&err_thread_local, NULL);
  745|      2|}

err_load_crypto_strings_int:
   43|      2|{
   44|      2|    if (
   45|      2|#ifndef OPENSSL_NO_ERR
   46|      2|        ERR_load_ERR_strings() == 0 ||    /* include error strings for SYSerr */
  ------------------
  |  Branch (46:9): [True: 0, False: 2]
  ------------------
   47|      2|        ERR_load_BN_strings() == 0 ||
  ------------------
  |  Branch (47:9): [True: 0, False: 2]
  ------------------
   48|      2|# ifndef OPENSSL_NO_RSA
   49|      2|        ERR_load_RSA_strings() == 0 ||
  ------------------
  |  Branch (49:9): [True: 0, False: 2]
  ------------------
   50|      2|# endif
   51|      2|# ifndef OPENSSL_NO_DH
   52|      2|        ERR_load_DH_strings() == 0 ||
  ------------------
  |  Branch (52:9): [True: 0, False: 2]
  ------------------
   53|      2|# endif
   54|      2|        ERR_load_EVP_strings() == 0 ||
  ------------------
  |  Branch (54:9): [True: 0, False: 2]
  ------------------
   55|      2|        ERR_load_BUF_strings() == 0 ||
  ------------------
  |  Branch (55:9): [True: 0, False: 2]
  ------------------
   56|      2|        ERR_load_OBJ_strings() == 0 ||
  ------------------
  |  Branch (56:9): [True: 0, False: 2]
  ------------------
   57|      2|        ERR_load_PEM_strings() == 0 ||
  ------------------
  |  Branch (57:9): [True: 0, False: 2]
  ------------------
   58|      2|# ifndef OPENSSL_NO_DSA
   59|      2|        ERR_load_DSA_strings() == 0 ||
  ------------------
  |  Branch (59:9): [True: 0, False: 2]
  ------------------
   60|      2|# endif
   61|      2|        ERR_load_X509_strings() == 0 ||
  ------------------
  |  Branch (61:9): [True: 0, False: 2]
  ------------------
   62|      2|        ERR_load_ASN1_strings() == 0 ||
  ------------------
  |  Branch (62:9): [True: 0, False: 2]
  ------------------
   63|      2|        ERR_load_CONF_strings() == 0 ||
  ------------------
  |  Branch (63:9): [True: 0, False: 2]
  ------------------
   64|      2|        ERR_load_CRYPTO_strings() == 0 ||
  ------------------
  |  Branch (64:9): [True: 0, False: 2]
  ------------------
   65|      2|# ifndef OPENSSL_NO_COMP
   66|      2|        ERR_load_COMP_strings() == 0 ||
  ------------------
  |  Branch (66:9): [True: 0, False: 2]
  ------------------
   67|      2|# endif
   68|      2|# ifndef OPENSSL_NO_EC
   69|      2|        ERR_load_EC_strings() == 0 ||
  ------------------
  |  Branch (69:9): [True: 0, False: 2]
  ------------------
   70|      2|# endif
   71|       |        /* skip ERR_load_SSL_strings() because it is not in this library */
   72|      2|        ERR_load_BIO_strings() == 0 ||
  ------------------
  |  Branch (72:9): [True: 0, False: 2]
  ------------------
   73|      2|        ERR_load_PKCS7_strings() == 0 ||
  ------------------
  |  Branch (73:9): [True: 0, False: 2]
  ------------------
   74|      2|        ERR_load_X509V3_strings() == 0 ||
  ------------------
  |  Branch (74:9): [True: 0, False: 2]
  ------------------
   75|      2|        ERR_load_PKCS12_strings() == 0 ||
  ------------------
  |  Branch (75:9): [True: 0, False: 2]
  ------------------
   76|      2|        ERR_load_RAND_strings() == 0 ||
  ------------------
  |  Branch (76:9): [True: 0, False: 2]
  ------------------
   77|      2|        ERR_load_DSO_strings() == 0 ||
  ------------------
  |  Branch (77:9): [True: 0, False: 2]
  ------------------
   78|      2|# ifndef OPENSSL_NO_TS
   79|      2|        ERR_load_TS_strings() == 0 ||
  ------------------
  |  Branch (79:9): [True: 0, False: 2]
  ------------------
   80|      2|# endif
   81|      2|# ifndef OPENSSL_NO_ENGINE
   82|      2|        ERR_load_ENGINE_strings() == 0 ||
  ------------------
  |  Branch (82:9): [True: 0, False: 2]
  ------------------
   83|      2|# endif
   84|      2|# ifndef OPENSSL_NO_OCSP
   85|      2|        ERR_load_OCSP_strings() == 0 ||
  ------------------
  |  Branch (85:9): [True: 0, False: 2]
  ------------------
   86|      2|# endif
   87|      2|        ERR_load_UI_strings() == 0 ||
  ------------------
  |  Branch (87:9): [True: 0, False: 2]
  ------------------
   88|      2|# ifndef OPENSSL_NO_CMS
   89|      2|        ERR_load_CMS_strings() == 0 ||
  ------------------
  |  Branch (89:9): [True: 0, False: 2]
  ------------------
   90|      2|# endif
   91|      2|# ifndef OPENSSL_NO_CT
   92|      2|        ERR_load_CT_strings() == 0 ||
  ------------------
  |  Branch (92:9): [True: 0, False: 2]
  ------------------
   93|      2|# endif
   94|      2|        ERR_load_ASYNC_strings() == 0 ||
  ------------------
  |  Branch (94:9): [True: 0, False: 2]
  ------------------
   95|      2|#endif
   96|      2|        ERR_load_KDF_strings() == 0 ||
  ------------------
  |  Branch (96:9): [True: 0, False: 2]
  ------------------
   97|      2|        ERR_load_OSSL_STORE_strings() == 0)
  ------------------
  |  Branch (97:9): [True: 0, False: 2]
  ------------------
   98|      0|        return 0;
   99|       |
  100|      2|    return 1;
  101|      2|}

ERR_load_EVP_strings:
  287|      2|{
  288|      2|#ifndef OPENSSL_NO_ERR
  289|      2|    if (ERR_func_error_string(EVP_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (289:9): [True: 2, False: 0]
  ------------------
  290|      2|        ERR_load_strings_const(EVP_str_functs);
  291|      2|        ERR_load_strings_const(EVP_str_reasons);
  292|      2|    }
  293|      2|#endif
  294|      2|    return 1;
  295|      2|}

EVP_PBE_cleanup:
  244|      2|{
  245|      2|    sk_EVP_PBE_CTL_pop_free(pbe_algs, free_evp_pbe_ctl);
  246|      2|    pbe_algs = NULL;
  247|      2|}

evp_cleanup_int:
   81|      2|{
   82|      2|    OBJ_NAME_cleanup(OBJ_NAME_TYPE_CIPHER_METH);
  ------------------
  |  |   20|      2|# define OBJ_NAME_TYPE_CIPHER_METH       0x02
  ------------------
   83|      2|    OBJ_NAME_cleanup(OBJ_NAME_TYPE_MD_METH);
  ------------------
  |  |   19|      2|# define OBJ_NAME_TYPE_MD_METH           0x01
  ------------------
   84|       |    /*
   85|       |     * The above calls will only clean out the contents of the name hash
   86|       |     * table, but not the hash table itself.  The following line does that
   87|       |     * part.  -- Richard Levitte
   88|       |     */
   89|      2|    OBJ_NAME_cleanup(-1);
   90|       |
   91|      2|    EVP_PBE_cleanup();
   92|      2|    OBJ_sigid_free();
   93|       |
   94|      2|    evp_app_cleanup_int();
   95|      2|}

evp_app_cleanup_int:
  317|      2|{
  318|      2|    if (app_pkey_methods != NULL)
  ------------------
  |  Branch (318:9): [True: 0, False: 2]
  ------------------
  319|      0|        sk_EVP_PKEY_METHOD_pop_free(app_pkey_methods, EVP_PKEY_meth_free);
  320|      2|}

crypto_cleanup_all_ex_data_int:
   94|      2|{
   95|      2|    int i;
   96|       |
   97|     34|    for (i = 0; i < CRYPTO_EX_INDEX__COUNT; ++i) {
  ------------------
  |  |  110|     34|# define CRYPTO_EX_INDEX__COUNT          16
  ------------------
  |  Branch (97:17): [True: 32, False: 2]
  ------------------
   98|     32|        EX_CALLBACKS *ip = &ex_data[i];
   99|       |
  100|     32|        sk_EX_CALLBACK_pop_free(ip->meth, cleanup_cb);
  101|     32|        ip->meth = NULL;
  102|     32|    }
  103|       |
  104|      2|    CRYPTO_THREAD_lock_free(ex_data_lock);
  105|      2|    ex_data_lock = NULL;
  106|      2|}
CRYPTO_free_ex_index:
  131|      2|{
  132|      2|    EX_CALLBACKS *ip = get_and_lock(class_index);
  133|      2|    EX_CALLBACK *a;
  134|      2|    int toret = 0;
  135|       |
  136|      2|    if (ip == NULL)
  ------------------
  |  Branch (136:9): [True: 0, False: 2]
  ------------------
  137|      0|        return 0;
  138|      2|    if (idx < 0 || idx >= sk_EX_CALLBACK_num(ip->meth))
  ------------------
  |  Branch (138:9): [True: 2, False: 0]
  |  Branch (138:20): [True: 0, False: 0]
  ------------------
  139|      2|        goto err;
  140|      0|    a = sk_EX_CALLBACK_value(ip->meth, idx);
  141|      0|    if (a == NULL)
  ------------------
  |  Branch (141:9): [True: 0, False: 0]
  ------------------
  142|      0|        goto err;
  143|      0|    a->new_func = dummy_new;
  144|      0|    a->dup_func = dummy_dup;
  145|      0|    a->free_func = dummy_free;
  146|      0|    toret = 1;
  147|      2|err:
  148|      2|    CRYPTO_THREAD_unlock(ex_data_lock);
  149|      2|    return toret;
  150|      0|}
CRYPTO_new_ex_data:
  209|      2|{
  210|      2|    int mx, i;
  211|      2|    void *ptr;
  212|      2|    EX_CALLBACK **storage = NULL;
  213|      2|    EX_CALLBACK *stack[10];
  214|      2|    EX_CALLBACKS *ip = get_and_lock(class_index);
  215|       |
  216|      2|    if (ip == NULL)
  ------------------
  |  Branch (216:9): [True: 0, False: 2]
  ------------------
  217|      0|        return 0;
  218|       |
  219|      2|    ad->sk = NULL;
  220|       |
  221|      2|    mx = sk_EX_CALLBACK_num(ip->meth);
  222|      2|    if (mx > 0) {
  ------------------
  |  Branch (222:9): [True: 0, False: 2]
  ------------------
  223|      0|        if (mx < (int)OSSL_NELEM(stack))
  ------------------
  |  |   13|      0|# define OSSL_NELEM(x)    (sizeof(x)/sizeof((x)[0]))
  ------------------
  |  Branch (223:13): [True: 0, False: 0]
  ------------------
  224|      0|            storage = stack;
  225|      0|        else
  226|      0|            storage = OPENSSL_malloc(sizeof(*storage) * mx);
  ------------------
  |  |  118|      0|        CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  227|      0|        if (storage != NULL)
  ------------------
  |  Branch (227:13): [True: 0, False: 0]
  ------------------
  228|      0|            for (i = 0; i < mx; i++)
  ------------------
  |  Branch (228:25): [True: 0, False: 0]
  ------------------
  229|      0|                storage[i] = sk_EX_CALLBACK_value(ip->meth, i);
  230|      0|    }
  231|      2|    CRYPTO_THREAD_unlock(ex_data_lock);
  232|       |
  233|      2|    if (mx > 0 && storage == NULL) {
  ------------------
  |  Branch (233:9): [True: 0, False: 2]
  |  Branch (233:19): [True: 0, False: 0]
  ------------------
  234|      0|        CRYPTOerr(CRYPTO_F_CRYPTO_NEW_EX_DATA, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  113|      0|# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  235|      0|        return 0;
  236|      0|    }
  237|      2|    for (i = 0; i < mx; i++) {
  ------------------
  |  Branch (237:17): [True: 0, False: 2]
  ------------------
  238|      0|        if (storage[i] != NULL && storage[i]->new_func != NULL) {
  ------------------
  |  Branch (238:13): [True: 0, False: 0]
  |  Branch (238:35): [True: 0, False: 0]
  ------------------
  239|      0|            ptr = CRYPTO_get_ex_data(ad, i);
  240|      0|            storage[i]->new_func(obj, ptr, ad, i,
  241|      0|                                 storage[i]->argl, storage[i]->argp);
  242|      0|        }
  243|      0|    }
  244|      2|    if (storage != stack)
  ------------------
  |  Branch (244:9): [True: 2, False: 0]
  ------------------
  245|      2|        OPENSSL_free(storage);
  ------------------
  |  |  128|      2|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  246|      2|    return 1;
  247|      2|}
ex_data.c:get_and_lock:
   51|      4|{
   52|      4|    EX_CALLBACKS *ip;
   53|       |
   54|      4|    if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {
  ------------------
  |  |  110|      4|# define CRYPTO_EX_INDEX__COUNT          16
  ------------------
  |  Branch (54:9): [True: 0, False: 4]
  |  Branch (54:28): [True: 0, False: 4]
  ------------------
   55|      0|        CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);
  ------------------
  |  |  113|      0|# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   56|      0|        return NULL;
   57|      0|    }
   58|       |
   59|      4|    if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
  ------------------
  |  |  119|      4|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 4, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (59:9): [True: 0, False: 4]
  ------------------
   60|      0|        CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
  ------------------
  |  |  113|      0|# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
   61|      0|        return NULL;
   62|      0|    }
   63|       |
   64|      4|    if (ex_data_lock == NULL) {
  ------------------
  |  Branch (64:9): [True: 0, False: 4]
  ------------------
   65|       |        /*
   66|       |         * This can happen in normal operation when using CRYPTO_mem_leaks().
   67|       |         * The CRYPTO_mem_leaks() function calls OPENSSL_cleanup() which cleans
   68|       |         * up the locks. Subsequently the BIO that CRYPTO_mem_leaks() uses gets
   69|       |         * freed, which also attempts to free the ex_data. However
   70|       |         * CRYPTO_mem_leaks() ensures that the ex_data is freed early (i.e.
   71|       |         * before OPENSSL_cleanup() is called), so if we get here we can safely
   72|       |         * ignore this operation. We just treat it as an error.
   73|       |         */
   74|      0|         return NULL;
   75|      0|    }
   76|       |
   77|      4|    ip = &ex_data[class_index];
   78|      4|    CRYPTO_THREAD_write_lock(ex_data_lock);
   79|      4|    return ip;
   80|      4|}
ex_data.c:do_ex_data_init:
   39|      2|{
   40|      2|    if (!OPENSSL_init_crypto(0, NULL))
  ------------------
  |  Branch (40:9): [True: 0, False: 2]
  ------------------
   41|      0|        return 0;
   42|      2|    ex_data_lock = CRYPTO_THREAD_lock_new();
   43|      2|    return ex_data_lock != NULL;
   44|      2|}

ossl_init_thread_start:
  458|      2|{
  459|      2|    struct thread_local_inits_st *locals;
  460|       |
  461|      2|    if (!OPENSSL_init_crypto(0, NULL))
  ------------------
  |  Branch (461:9): [True: 0, False: 2]
  ------------------
  462|      0|        return 0;
  463|       |
  464|      2|    locals = ossl_init_get_thread_local(1);
  465|       |
  466|      2|    if (locals == NULL)
  ------------------
  |  Branch (466:9): [True: 0, False: 2]
  ------------------
  467|      0|        return 0;
  468|       |
  469|      2|    if (opts & OPENSSL_INIT_THREAD_ASYNC) {
  ------------------
  |  |   31|      2|# define OPENSSL_INIT_THREAD_ASYNC           0x01
  ------------------
  |  Branch (469:9): [True: 0, False: 2]
  ------------------
  470|       |#ifdef OPENSSL_INIT_DEBUG
  471|       |        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "
  472|       |                        "marking thread for async\n");
  473|       |#endif
  474|      0|        locals->async = 1;
  475|      0|    }
  476|       |
  477|      2|    if (opts & OPENSSL_INIT_THREAD_ERR_STATE) {
  ------------------
  |  |   32|      2|# define OPENSSL_INIT_THREAD_ERR_STATE       0x02
  ------------------
  |  Branch (477:9): [True: 2, False: 0]
  ------------------
  478|       |#ifdef OPENSSL_INIT_DEBUG
  479|       |        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "
  480|       |                        "marking thread for err_state\n");
  481|       |#endif
  482|      2|        locals->err_state = 1;
  483|      2|    }
  484|       |
  485|      2|    if (opts & OPENSSL_INIT_THREAD_RAND) {
  ------------------
  |  |   33|      2|# define OPENSSL_INIT_THREAD_RAND            0x04
  ------------------
  |  Branch (485:9): [True: 0, False: 2]
  ------------------
  486|       |#ifdef OPENSSL_INIT_DEBUG
  487|       |        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "
  488|       |                        "marking thread for rand\n");
  489|       |#endif
  490|      0|        locals->rand = 1;
  491|      0|    }
  492|       |
  493|      2|    return 1;
  494|      2|}
OPENSSL_cleanup:
  497|      2|{
  498|      2|    OPENSSL_INIT_STOP *currhandler, *lasthandler;
  499|      2|    CRYPTO_THREAD_LOCAL key;
  500|       |
  501|       |    /* If we've not been inited then no need to deinit */
  502|      2|    if (!base_inited)
  ------------------
  |  Branch (502:9): [True: 0, False: 2]
  ------------------
  503|      0|        return;
  504|       |
  505|       |    /* Might be explicitly called and also by atexit */
  506|      2|    if (stopped)
  ------------------
  |  Branch (506:9): [True: 0, False: 2]
  ------------------
  507|      0|        return;
  508|      2|    stopped = 1;
  509|       |
  510|       |    /*
  511|       |     * Thread stop may not get automatically called by the thread library for
  512|       |     * the very last thread in some situations, so call it directly.
  513|       |     */
  514|      2|    ossl_init_thread_stop(ossl_init_get_thread_local(0));
  515|       |
  516|      2|    currhandler = stop_handlers;
  517|      2|    while (currhandler != NULL) {
  ------------------
  |  Branch (517:12): [True: 0, False: 2]
  ------------------
  518|      0|        currhandler->handler();
  519|      0|        lasthandler = currhandler;
  520|      0|        currhandler = currhandler->next;
  521|      0|        OPENSSL_free(lasthandler);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  522|      0|    }
  523|      2|    stop_handlers = NULL;
  524|       |
  525|      2|    CRYPTO_THREAD_lock_free(init_lock);
  526|      2|    init_lock = NULL;
  527|       |
  528|       |    /*
  529|       |     * We assume we are single-threaded for this function, i.e. no race
  530|       |     * conditions for the various "*_inited" vars below.
  531|       |     */
  532|       |
  533|      2|#ifndef OPENSSL_NO_COMP
  534|      2|    if (zlib_inited) {
  ------------------
  |  Branch (534:9): [True: 0, False: 2]
  ------------------
  535|       |#ifdef OPENSSL_INIT_DEBUG
  536|       |        fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  537|       |                        "comp_zlib_cleanup_int()\n");
  538|       |#endif
  539|      0|        comp_zlib_cleanup_int();
  540|      0|    }
  541|      2|#endif
  542|       |
  543|      2|    if (async_inited) {
  ------------------
  |  Branch (543:9): [True: 0, False: 2]
  ------------------
  544|       |# ifdef OPENSSL_INIT_DEBUG
  545|       |        fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  546|       |                        "async_deinit()\n");
  547|       |# endif
  548|      0|        async_deinit();
  549|      0|    }
  550|       |
  551|      2|    key = destructor_key.value;
  552|      2|    destructor_key.sane = -1;
  553|      2|    CRYPTO_THREAD_cleanup_local(&key);
  554|       |
  555|       |#ifdef OPENSSL_INIT_DEBUG
  556|       |    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  557|       |                    "rand_cleanup_int()\n");
  558|       |    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  559|       |                    "conf_modules_free_int()\n");
  560|       |#ifndef OPENSSL_NO_ENGINE
  561|       |    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  562|       |                    "engine_cleanup_int()\n");
  563|       |#endif
  564|       |    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  565|       |                    "crypto_cleanup_all_ex_data_int()\n");
  566|       |    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  567|       |                    "bio_sock_cleanup_int()\n");
  568|       |    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  569|       |                    "bio_cleanup()\n");
  570|       |    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  571|       |                    "evp_cleanup_int()\n");
  572|       |    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  573|       |                    "obj_cleanup_int()\n");
  574|       |    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
  575|       |                    "err_cleanup()\n");
  576|       |#endif
  577|       |    /*
  578|       |     * Note that cleanup order is important:
  579|       |     * - rand_cleanup_int could call an ENGINE's RAND cleanup function so
  580|       |     * must be called before engine_cleanup_int()
  581|       |     * - ENGINEs use CRYPTO_EX_DATA and therefore, must be cleaned up
  582|       |     * before the ex data handlers are wiped in CRYPTO_cleanup_all_ex_data().
  583|       |     * - conf_modules_free_int() can end up in ENGINE code so must be called
  584|       |     * before engine_cleanup_int()
  585|       |     * - ENGINEs and additional EVP algorithms might use added OIDs names so
  586|       |     * obj_cleanup_int() must be called last
  587|       |     */
  588|      2|    rand_cleanup_int();
  589|      2|    rand_drbg_cleanup_int();
  590|      2|    conf_modules_free_int();
  591|      2|#ifndef OPENSSL_NO_ENGINE
  592|      2|    engine_cleanup_int();
  593|      2|#endif
  594|      2|    ossl_store_cleanup_int();
  595|      2|    crypto_cleanup_all_ex_data_int();
  596|      2|    bio_cleanup();
  597|      2|    evp_cleanup_int();
  598|      2|    obj_cleanup_int();
  599|      2|    err_cleanup();
  600|       |
  601|      2|    CRYPTO_secure_malloc_done();
  602|       |
  603|      2|    base_inited = 0;
  604|      2|}
OPENSSL_init_crypto:
  612|  20.8k|{
  613|  20.8k|    if (stopped) {
  ------------------
  |  Branch (613:9): [True: 0, False: 20.8k]
  ------------------
  614|      0|        if (!(opts & OPENSSL_INIT_BASE_ONLY))
  ------------------
  |  |   28|      0|# define OPENSSL_INIT_BASE_ONLY              0x00040000L
  ------------------
  |  Branch (614:13): [True: 0, False: 0]
  ------------------
  615|      0|            CRYPTOerr(CRYPTO_F_OPENSSL_INIT_CRYPTO, ERR_R_INIT_FAIL);
  ------------------
  |  |  113|      0|# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  616|      0|        return 0;
  617|      0|    }
  618|       |
  619|       |    /*
  620|       |     * When the caller specifies OPENSSL_INIT_BASE_ONLY, that should be the
  621|       |     * *only* option specified.  With that option we return immediately after
  622|       |     * doing the requested limited initialization.  Note that
  623|       |     * err_shelve_state() called by us via ossl_init_load_crypto_nodelete()
  624|       |     * re-enters OPENSSL_init_crypto() with OPENSSL_INIT_BASE_ONLY, but with
  625|       |     * base already initialized this is a harmless NOOP.
  626|       |     *
  627|       |     * If we remain the only caller of err_shelve_state() the recursion should
  628|       |     * perhaps be removed, but if in doubt, it can be left in place.
  629|       |     */
  630|  20.8k|    if (!RUN_ONCE(&base, ossl_init_base))
  ------------------
  |  |  119|  20.8k|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 20.8k, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (630:9): [True: 0, False: 20.8k]
  ------------------
  631|      0|        return 0;
  632|  20.8k|    if (opts & OPENSSL_INIT_BASE_ONLY)
  ------------------
  |  |   28|  20.8k|# define OPENSSL_INIT_BASE_ONLY              0x00040000L
  ------------------
  |  Branch (632:9): [True: 20.8k, False: 10]
  ------------------
  633|  20.8k|        return 1;
  634|       |
  635|       |    /*
  636|       |     * Now we don't always set up exit handlers, the INIT_BASE_ONLY calls
  637|       |     * should not have the side-effect of setting up exit handlers, and
  638|       |     * therefore, this code block is below the INIT_BASE_ONLY-conditioned early
  639|       |     * return above.
  640|       |     */
  641|     10|    if ((opts & OPENSSL_INIT_NO_ATEXIT) != 0) {
  ------------------
  |  |  375|     10|# define OPENSSL_INIT_NO_ATEXIT              0x00080000L
  ------------------
  |  Branch (641:9): [True: 0, False: 10]
  ------------------
  642|      0|        if (!RUN_ONCE_ALT(&register_atexit, ossl_init_no_register_atexit,
  ------------------
  |  |  137|      0|    (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (137:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (642:13): [True: 0, False: 0]
  ------------------
  643|      0|                          ossl_init_register_atexit))
  644|      0|            return 0;
  645|     10|    } else if (!RUN_ONCE(&register_atexit, ossl_init_register_atexit)) {
  ------------------
  |  |  119|     10|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 10, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (645:16): [True: 0, False: 10]
  ------------------
  646|      0|        return 0;
  647|      0|    }
  648|       |
  649|     10|    if (!RUN_ONCE(&load_crypto_nodelete, ossl_init_load_crypto_nodelete))
  ------------------
  |  |  119|     10|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 10, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (649:9): [True: 0, False: 10]
  ------------------
  650|      0|        return 0;
  651|       |
  652|     10|    if ((opts & OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS)
  ------------------
  |  |  356|     10|# define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x00000001L
  ------------------
  |  Branch (652:9): [True: 0, False: 10]
  ------------------
  653|     10|            && !RUN_ONCE_ALT(&load_crypto_strings,
  ------------------
  |  |  137|      0|    (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (137:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (653:16): [True: 0, False: 0]
  ------------------
  654|     10|                             ossl_init_no_load_crypto_strings,
  655|     10|                             ossl_init_load_crypto_strings))
  656|      0|        return 0;
  657|       |
  658|     10|    if ((opts & OPENSSL_INIT_LOAD_CRYPTO_STRINGS)
  ------------------
  |  |  357|     10|# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS    0x00000002L
  ------------------
  |  Branch (658:9): [True: 4, False: 6]
  ------------------
  659|     10|            && !RUN_ONCE(&load_crypto_strings, ossl_init_load_crypto_strings))
  ------------------
  |  |  119|      4|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 4, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (659:16): [True: 0, False: 4]
  ------------------
  660|      0|        return 0;
  661|       |
  662|     10|    if ((opts & OPENSSL_INIT_NO_ADD_ALL_CIPHERS)
  ------------------
  |  |  360|     10|# define OPENSSL_INIT_NO_ADD_ALL_CIPHERS     0x00000010L
  ------------------
  |  Branch (662:9): [True: 0, False: 10]
  ------------------
  663|     10|            && !RUN_ONCE_ALT(&add_all_ciphers, ossl_init_no_add_all_ciphers,
  ------------------
  |  |  137|      0|    (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (137:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (663:16): [True: 0, False: 0]
  ------------------
  664|     10|                             ossl_init_add_all_ciphers))
  665|      0|        return 0;
  666|       |
  667|     10|    if ((opts & OPENSSL_INIT_ADD_ALL_CIPHERS)
  ------------------
  |  |  358|     10|# define OPENSSL_INIT_ADD_ALL_CIPHERS        0x00000004L
  ------------------
  |  Branch (667:9): [True: 0, False: 10]
  ------------------
  668|     10|            && !RUN_ONCE(&add_all_ciphers, ossl_init_add_all_ciphers))
  ------------------
  |  |  119|      0|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (668:16): [True: 0, False: 0]
  ------------------
  669|      0|        return 0;
  670|       |
  671|     10|    if ((opts & OPENSSL_INIT_NO_ADD_ALL_DIGESTS)
  ------------------
  |  |  361|     10|# define OPENSSL_INIT_NO_ADD_ALL_DIGESTS     0x00000020L
  ------------------
  |  Branch (671:9): [True: 0, False: 10]
  ------------------
  672|     10|            && !RUN_ONCE_ALT(&add_all_digests, ossl_init_no_add_all_digests,
  ------------------
  |  |  137|      0|    (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (137:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (672:16): [True: 0, False: 0]
  ------------------
  673|     10|                             ossl_init_add_all_digests))
  674|      0|        return 0;
  675|       |
  676|     10|    if ((opts & OPENSSL_INIT_ADD_ALL_DIGESTS)
  ------------------
  |  |  359|     10|# define OPENSSL_INIT_ADD_ALL_DIGESTS        0x00000008L
  ------------------
  |  Branch (676:9): [True: 0, False: 10]
  ------------------
  677|     10|            && !RUN_ONCE(&add_all_digests, ossl_init_add_all_digests))
  ------------------
  |  |  119|      0|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (677:16): [True: 0, False: 0]
  ------------------
  678|      0|        return 0;
  679|       |
  680|     10|    if ((opts & OPENSSL_INIT_ATFORK)
  ------------------
  |  |  373|     10|# define OPENSSL_INIT_ATFORK                 0x00020000L
  ------------------
  |  Branch (680:9): [True: 0, False: 10]
  ------------------
  681|     10|            && !openssl_init_fork_handlers())
  ------------------
  |  Branch (681:16): [True: 0, False: 0]
  ------------------
  682|      0|        return 0;
  683|       |
  684|     10|    if ((opts & OPENSSL_INIT_NO_LOAD_CONFIG)
  ------------------
  |  |  363|     10|# define OPENSSL_INIT_NO_LOAD_CONFIG         0x00000080L
  ------------------
  |  Branch (684:9): [True: 0, False: 10]
  ------------------
  685|     10|            && !RUN_ONCE_ALT(&config, ossl_init_no_config, ossl_init_config))
  ------------------
  |  |  137|      0|    (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (137:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (685:16): [True: 0, False: 0]
  ------------------
  686|      0|        return 0;
  687|       |
  688|     10|    if (opts & OPENSSL_INIT_LOAD_CONFIG) {
  ------------------
  |  |  362|     10|# define OPENSSL_INIT_LOAD_CONFIG            0x00000040L
  ------------------
  |  Branch (688:9): [True: 0, False: 10]
  ------------------
  689|      0|        int ret;
  690|      0|        CRYPTO_THREAD_write_lock(init_lock);
  691|      0|        conf_settings = settings;
  692|      0|        ret = RUN_ONCE(&config, ossl_init_config);
  ------------------
  |  |  119|      0|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  693|      0|        conf_settings = NULL;
  694|      0|        CRYPTO_THREAD_unlock(init_lock);
  695|      0|        if (ret <= 0)
  ------------------
  |  Branch (695:13): [True: 0, False: 0]
  ------------------
  696|      0|            return 0;
  697|      0|    }
  698|       |
  699|     10|    if ((opts & OPENSSL_INIT_ASYNC)
  ------------------
  |  |  364|     10|# define OPENSSL_INIT_ASYNC                  0x00000100L
  ------------------
  |  Branch (699:9): [True: 0, False: 10]
  ------------------
  700|     10|            && !RUN_ONCE(&async, ossl_init_async))
  ------------------
  |  |  119|      0|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (700:16): [True: 0, False: 0]
  ------------------
  701|      0|        return 0;
  702|       |
  703|     10|#ifndef OPENSSL_NO_ENGINE
  704|     10|    if ((opts & OPENSSL_INIT_ENGINE_OPENSSL)
  ------------------
  |  |  367|     10|# define OPENSSL_INIT_ENGINE_OPENSSL         0x00000800L
  ------------------
  |  Branch (704:9): [True: 0, False: 10]
  ------------------
  705|     10|            && !RUN_ONCE(&engine_openssl, ossl_init_engine_openssl))
  ------------------
  |  |  119|      0|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (705:16): [True: 0, False: 0]
  ------------------
  706|      0|        return 0;
  707|       |# if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_DEVCRYPTOENG)
  708|       |    if ((opts & OPENSSL_INIT_ENGINE_CRYPTODEV)
  709|       |            && !RUN_ONCE(&engine_devcrypto, ossl_init_engine_devcrypto))
  710|       |        return 0;
  711|       |# endif
  712|     10|# ifndef OPENSSL_NO_RDRAND
  713|     10|    if ((opts & OPENSSL_INIT_ENGINE_RDRAND)
  ------------------
  |  |  365|     10|# define OPENSSL_INIT_ENGINE_RDRAND          0x00000200L
  ------------------
  |  Branch (713:9): [True: 0, False: 10]
  ------------------
  714|     10|            && !RUN_ONCE(&engine_rdrand, ossl_init_engine_rdrand))
  ------------------
  |  |  119|      0|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (714:16): [True: 0, False: 0]
  ------------------
  715|      0|        return 0;
  716|     10|# endif
  717|     10|    if ((opts & OPENSSL_INIT_ENGINE_DYNAMIC)
  ------------------
  |  |  366|     10|# define OPENSSL_INIT_ENGINE_DYNAMIC         0x00000400L
  ------------------
  |  Branch (717:9): [True: 0, False: 10]
  ------------------
  718|     10|            && !RUN_ONCE(&engine_dynamic, ossl_init_engine_dynamic))
  ------------------
  |  |  119|      0|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (718:16): [True: 0, False: 0]
  ------------------
  719|      0|        return 0;
  720|     10|# ifndef OPENSSL_NO_STATIC_ENGINE
  721|     10|#  if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_PADLOCK)
  722|     10|    if ((opts & OPENSSL_INIT_ENGINE_PADLOCK)
  ------------------
  |  |  370|     10|# define OPENSSL_INIT_ENGINE_PADLOCK         0x00004000L
  ------------------
  |  Branch (722:9): [True: 0, False: 10]
  ------------------
  723|     10|            && !RUN_ONCE(&engine_padlock, ossl_init_engine_padlock))
  ------------------
  |  |  119|      0|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (723:16): [True: 0, False: 0]
  ------------------
  724|      0|        return 0;
  725|     10|#  endif
  726|       |#  if defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_NO_CAPIENG)
  727|       |    if ((opts & OPENSSL_INIT_ENGINE_CAPI)
  728|       |            && !RUN_ONCE(&engine_capi, ossl_init_engine_capi))
  729|       |        return 0;
  730|       |#  endif
  731|     10|#  if !defined(OPENSSL_NO_AFALGENG)
  732|     10|    if ((opts & OPENSSL_INIT_ENGINE_AFALG)
  ------------------
  |  |  371|     10|# define OPENSSL_INIT_ENGINE_AFALG           0x00008000L
  ------------------
  |  Branch (732:9): [True: 0, False: 10]
  ------------------
  733|     10|            && !RUN_ONCE(&engine_afalg, ossl_init_engine_afalg))
  ------------------
  |  |  119|      0|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (733:16): [True: 0, False: 0]
  ------------------
  734|      0|        return 0;
  735|     10|#  endif
  736|     10|# endif
  737|     10|    if (opts & (OPENSSL_INIT_ENGINE_ALL_BUILTIN
  ------------------
  |  |  381|     10|    (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \
  |  |  ------------------
  |  |  |  |  365|     10|# define OPENSSL_INIT_ENGINE_RDRAND          0x00000200L
  |  |  ------------------
  |  |                   (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \
  |  |  ------------------
  |  |  |  |  366|     10|# define OPENSSL_INIT_ENGINE_DYNAMIC         0x00000400L
  |  |  ------------------
  |  |  382|     10|    | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \
  |  |  ------------------
  |  |  |  |  368|     10|# define OPENSSL_INIT_ENGINE_CRYPTODEV       0x00001000L
  |  |  ------------------
  |  |                   | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \
  |  |  ------------------
  |  |  |  |  369|     10|# define OPENSSL_INIT_ENGINE_CAPI            0x00002000L
  |  |  ------------------
  |  |  383|     10|    OPENSSL_INIT_ENGINE_PADLOCK)
  |  |  ------------------
  |  |  |  |  370|     10|# define OPENSSL_INIT_ENGINE_PADLOCK         0x00004000L
  |  |  ------------------
  ------------------
  |  Branch (737:9): [True: 0, False: 10]
  ------------------
  738|     10|                | OPENSSL_INIT_ENGINE_OPENSSL
  ------------------
  |  |  367|     10|# define OPENSSL_INIT_ENGINE_OPENSSL         0x00000800L
  ------------------
  739|     10|                | OPENSSL_INIT_ENGINE_AFALG)) {
  ------------------
  |  |  371|     10|# define OPENSSL_INIT_ENGINE_AFALG           0x00008000L
  ------------------
  740|      0|        ENGINE_register_all_complete();
  741|      0|    }
  742|     10|#endif
  743|       |
  744|     10|#ifndef OPENSSL_NO_COMP
  745|     10|    if ((opts & OPENSSL_INIT_ZLIB)
  ------------------
  |  |   27|     10|# define OPENSSL_INIT_ZLIB                   0x00010000L
  ------------------
  |  Branch (745:9): [True: 0, False: 10]
  ------------------
  746|     10|            && !RUN_ONCE(&zlib, ossl_init_zlib))
  ------------------
  |  |  119|      0|    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
  |  |  ------------------
  |  |  |  Branch (119:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (746:16): [True: 0, False: 0]
  ------------------
  747|      0|        return 0;
  748|     10|#endif
  749|       |
  750|     10|    return 1;
  751|     10|}
init.c:ossl_init_thread_stop:
  419|      2|{
  420|       |    /* Can't do much about this */
  421|      2|    if (locals == NULL)
  ------------------
  |  Branch (421:9): [True: 0, False: 2]
  ------------------
  422|      0|        return;
  423|       |
  424|      2|    if (locals->async) {
  ------------------
  |  Branch (424:9): [True: 0, False: 2]
  ------------------
  425|       |#ifdef OPENSSL_INIT_DEBUG
  426|       |        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_stop: "
  427|       |                        "async_delete_thread_state()\n");
  428|       |#endif
  429|      0|        async_delete_thread_state();
  430|      0|    }
  431|       |
  432|      2|    if (locals->err_state) {
  ------------------
  |  Branch (432:9): [True: 2, False: 0]
  ------------------
  433|       |#ifdef OPENSSL_INIT_DEBUG
  434|       |        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_stop: "
  435|       |                        "err_delete_thread_state()\n");
  436|       |#endif
  437|      2|        err_delete_thread_state();
  438|      2|    }
  439|       |
  440|      2|    if (locals->rand) {
  ------------------
  |  Branch (440:9): [True: 0, False: 2]
  ------------------
  441|       |#ifdef OPENSSL_INIT_DEBUG
  442|       |        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_stop: "
  443|       |                        "drbg_delete_thread_state()\n");
  444|       |#endif
  445|      0|        drbg_delete_thread_state();
  446|      0|    }
  447|       |
  448|      2|    OPENSSL_free(locals);
  ------------------
  |  |  128|      2|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  449|      2|}
init.c:ossl_init_get_thread_local:
   60|      4|{
   61|      4|    struct thread_local_inits_st *local =
   62|      4|        CRYPTO_THREAD_get_local(&destructor_key.value);
   63|       |
   64|      4|    if (alloc) {
  ------------------
  |  Branch (64:9): [True: 2, False: 2]
  ------------------
   65|      2|        if (local == NULL
  ------------------
  |  Branch (65:13): [True: 2, False: 0]
  ------------------
   66|      2|            && (local = OPENSSL_zalloc(sizeof(*local))) != NULL
  ------------------
  |  |  120|      2|        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  |  Branch (66:16): [True: 2, False: 0]
  ------------------
   67|      2|            && !CRYPTO_THREAD_set_local(&destructor_key.value, local)) {
  ------------------
  |  Branch (67:16): [True: 0, False: 2]
  ------------------
   68|      0|            OPENSSL_free(local);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   69|      0|            return NULL;
   70|      0|        }
   71|      2|    } else {
   72|      2|        CRYPTO_THREAD_set_local(&destructor_key.value, NULL);
   73|      2|    }
   74|       |
   75|      4|    return local;
   76|      4|}
init.c:ossl_init_base:
   90|      2|{
   91|      2|    CRYPTO_THREAD_LOCAL key;
   92|       |
   93|       |#ifdef OPENSSL_INIT_DEBUG
   94|       |    fprintf(stderr, "OPENSSL_INIT: ossl_init_base: Setting up stop handlers\n");
   95|       |#endif
   96|       |#ifndef OPENSSL_NO_CRYPTO_MDEBUG
   97|       |    ossl_malloc_setup_failures();
   98|       |#endif
   99|      2|    if (!CRYPTO_THREAD_init_local(&key, ossl_init_thread_destructor))
  ------------------
  |  Branch (99:9): [True: 0, False: 2]
  ------------------
  100|      0|        return 0;
  101|      2|    if ((init_lock = CRYPTO_THREAD_lock_new()) == NULL)
  ------------------
  |  Branch (101:9): [True: 0, False: 2]
  ------------------
  102|      0|        goto err;
  103|      2|    OPENSSL_cpuid_setup();
  104|       |
  105|      2|    destructor_key.value = key;
  106|      2|    base_inited = 1;
  107|      2|    return 1;
  108|       |
  109|      0|err:
  110|       |#ifdef OPENSSL_INIT_DEBUG
  111|       |    fprintf(stderr, "OPENSSL_INIT: ossl_init_base not ok!\n");
  112|       |#endif
  113|      0|    CRYPTO_THREAD_lock_free(init_lock);
  114|      0|    init_lock = NULL;
  115|       |
  116|      0|    CRYPTO_THREAD_cleanup_local(&key);
  117|      0|    return 0;
  118|      2|}
init.c:ossl_init_register_atexit:
  130|      2|{
  131|       |#ifdef OPENSSL_INIT_DEBUG
  132|       |    fprintf(stderr, "OPENSSL_INIT: ossl_init_register_atexit()\n");
  133|       |#endif
  134|      2|#ifndef OPENSSL_SYS_UEFI
  135|       |# ifdef _WIN32
  136|       |    /* We use _onexit() in preference because it gets called on DLL unload */
  137|       |    if (_onexit(win32atexit) == NULL)
  138|       |        return 0;
  139|       |# else
  140|      2|    if (atexit(OPENSSL_cleanup) != 0)
  ------------------
  |  Branch (140:9): [True: 0, False: 2]
  ------------------
  141|      0|        return 0;
  142|      2|# endif
  143|      2|#endif
  144|       |
  145|      2|    return 1;
  146|      2|}
init.c:ossl_init_load_crypto_nodelete:
  160|      2|{
  161|       |#ifdef OPENSSL_INIT_DEBUG
  162|       |    fprintf(stderr, "OPENSSL_INIT: ossl_init_load_crypto_nodelete()\n");
  163|       |#endif
  164|       |#if !defined(OPENSSL_USE_NODELETE) \
  165|       |    && !defined(OPENSSL_NO_PINSHARED)
  166|       |# if defined(DSO_WIN32) && !defined(_WIN32_WCE)
  167|       |    {
  168|       |        HMODULE handle = NULL;
  169|       |        BOOL ret;
  170|       |
  171|       |        /* We don't use the DSO route for WIN32 because there is a better way */
  172|       |        ret = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
  173|       |                                | GET_MODULE_HANDLE_EX_FLAG_PIN,
  174|       |                                (void *)&base_inited, &handle);
  175|       |
  176|       |#  ifdef OPENSSL_INIT_DEBUG
  177|       |        fprintf(stderr, "OPENSSL_INIT: obtained DSO reference? %s\n",
  178|       |                (ret == TRUE ? "No!" : "Yes."));
  179|       |#  endif
  180|       |        return (ret == TRUE) ? 1 : 0;
  181|       |    }
  182|       |# elif !defined(DSO_NONE)
  183|       |    /*
  184|       |     * Deliberately leak a reference to ourselves. This will force the library
  185|       |     * to remain loaded until the atexit() handler is run at process exit.
  186|       |     */
  187|       |    {
  188|       |        DSO *dso;
  189|       |        void *err;
  190|       |
  191|       |        if (!err_shelve_state(&err))
  192|       |            return 0;
  193|       |
  194|       |        dso = DSO_dsobyaddr(&base_inited, DSO_FLAG_NO_UNLOAD_ON_FREE);
  195|       |#  ifdef OPENSSL_INIT_DEBUG
  196|       |        fprintf(stderr, "OPENSSL_INIT: obtained DSO reference? %s\n",
  197|       |                (dso == NULL ? "No!" : "Yes."));
  198|       |        /*
  199|       |         * In case of No!, it is uncertain our exit()-handlers can still be
  200|       |         * called. After dlclose() the whole library might have been unloaded
  201|       |         * already.
  202|       |         */
  203|       |#  endif
  204|       |        DSO_free(dso);
  205|       |        err_unshelve_state(err);
  206|       |    }
  207|       |# endif
  208|       |#endif
  209|       |
  210|      2|    return 1;
  211|      2|}
init.c:ossl_init_load_crypto_strings:
  216|      2|{
  217|      2|    int ret = 1;
  218|       |    /*
  219|       |     * OPENSSL_NO_AUTOERRINIT is provided here to prevent at compile time
  220|       |     * pulling in all the error strings during static linking
  221|       |     */
  222|      2|#if !defined(OPENSSL_NO_ERR) && !defined(OPENSSL_NO_AUTOERRINIT)
  223|       |# ifdef OPENSSL_INIT_DEBUG
  224|       |    fprintf(stderr, "OPENSSL_INIT: ossl_init_load_crypto_strings: "
  225|       |                    "err_load_crypto_strings_int()\n");
  226|       |# endif
  227|      2|    ret = err_load_crypto_strings_int();
  228|      2|#endif
  229|      2|    return ret;
  230|      2|}

ERR_load_KDF_strings:
   59|      2|{
   60|      2|#ifndef OPENSSL_NO_ERR
   61|      2|    if (ERR_func_error_string(KDF_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (61:9): [True: 2, False: 0]
  ------------------
   62|      2|        ERR_load_strings_const(KDF_str_functs);
   63|      2|        ERR_load_strings_const(KDF_str_reasons);
   64|      2|    }
   65|      2|#endif
   66|      2|    return 1;
   67|      2|}

OPENSSL_LH_new:
   48|      2|{
   49|      2|    OPENSSL_LHASH *ret;
   50|       |
   51|      2|    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
  ------------------
  |  |  120|      2|        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  |  Branch (51:9): [True: 0, False: 2]
  ------------------
   52|       |        /*
   53|       |         * Do not set the error code, because the ERR code uses LHASH
   54|       |         * and we want to avoid possible endless error loop.
   55|       |         * CRYPTOerr(CRYPTO_F_OPENSSL_LH_NEW, ERR_R_MALLOC_FAILURE);
   56|       |         */
   57|      0|        return NULL;
   58|      0|    }
   59|      2|    if ((ret->b = OPENSSL_zalloc(sizeof(*ret->b) * MIN_NODES)) == NULL)
  ------------------
  |  |  120|      2|        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  |  Branch (59:9): [True: 0, False: 2]
  ------------------
   60|      0|        goto err;
   61|      2|    ret->comp = ((c == NULL) ? (OPENSSL_LH_COMPFUNC)strcmp : c);
  ------------------
  |  Branch (61:18): [True: 0, False: 2]
  ------------------
   62|      2|    ret->hash = ((h == NULL) ? (OPENSSL_LH_HASHFUNC)OPENSSL_LH_strhash : h);
  ------------------
  |  Branch (62:18): [True: 0, False: 2]
  ------------------
   63|      2|    ret->num_nodes = MIN_NODES / 2;
  ------------------
  |  |   39|      2|#define MIN_NODES       16
  ------------------
   64|      2|    ret->num_alloc_nodes = MIN_NODES;
  ------------------
  |  |   39|      2|#define MIN_NODES       16
  ------------------
   65|      2|    ret->pmax = MIN_NODES / 2;
  ------------------
  |  |   39|      2|#define MIN_NODES       16
  ------------------
   66|      2|    ret->up_load = UP_LOAD;
  ------------------
  |  |   40|      2|#define UP_LOAD         (2*LH_LOAD_MULT) /* load times 256 (default 2) */
  |  |  ------------------
  |  |  |  |   70|      2|# define LH_LOAD_MULT    256
  |  |  ------------------
  ------------------
   67|      2|    ret->down_load = DOWN_LOAD;
  ------------------
  |  |   41|      2|#define DOWN_LOAD       (LH_LOAD_MULT) /* load times 256 (default 1) */
  |  |  ------------------
  |  |  |  |   70|      2|# define LH_LOAD_MULT    256
  |  |  ------------------
  ------------------
   68|      2|    return ret;
   69|       |
   70|      0|err:
   71|      0|    OPENSSL_free(ret->b);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   72|      0|    OPENSSL_free(ret);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   73|      0|    return NULL;
   74|      2|}
OPENSSL_LH_free:
   77|      4|{
   78|      4|    unsigned int i;
   79|      4|    OPENSSL_LH_NODE *n, *nn;
   80|       |
   81|      4|    if (lh == NULL)
  ------------------
  |  Branch (81:9): [True: 2, False: 2]
  ------------------
   82|      2|        return;
   83|       |
   84|  2.43k|    for (i = 0; i < lh->num_nodes; i++) {
  ------------------
  |  Branch (84:17): [True: 2.43k, False: 2]
  ------------------
   85|  2.43k|        n = lh->b[i];
   86|  7.30k|        while (n != NULL) {
  ------------------
  |  Branch (86:16): [True: 4.87k, False: 2.43k]
  ------------------
   87|  4.87k|            nn = n->next;
   88|  4.87k|            OPENSSL_free(n);
  ------------------
  |  |  128|  4.87k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  4.87k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  4.87k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   89|  4.87k|            n = nn;
   90|  4.87k|        }
   91|  2.43k|    }
   92|      2|    OPENSSL_free(lh->b);
  ------------------
  |  |  128|      2|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   93|      2|    OPENSSL_free(lh);
  ------------------
  |  |  128|      2|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   94|      2|}
OPENSSL_LH_insert:
   97|  15.1k|{
   98|  15.1k|    unsigned long hash;
   99|  15.1k|    OPENSSL_LH_NODE *nn, **rn;
  100|  15.1k|    void *ret;
  101|       |
  102|  15.1k|    lh->error = 0;
  103|  15.1k|    if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
  ------------------
  |  |   70|  15.1k|# define LH_LOAD_MULT    256
  ------------------
  |  Branch (103:9): [True: 2.42k, False: 12.7k]
  |  Branch (103:76): [True: 0, False: 2.42k]
  ------------------
  104|      0|        return NULL;        /* 'lh->error++' already done in 'expand' */
  105|       |
  106|  15.1k|    rn = getrn(lh, data, &hash);
  107|       |
  108|  15.1k|    if (*rn == NULL) {
  ------------------
  |  Branch (108:9): [True: 4.87k, False: 10.3k]
  ------------------
  109|  4.87k|        if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {
  ------------------
  |  |  118|  4.87k|        CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  4.87k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  4.87k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  |  Branch (109:13): [True: 0, False: 4.87k]
  ------------------
  110|      0|            lh->error++;
  111|      0|            return NULL;
  112|      0|        }
  113|  4.87k|        nn->data = data;
  114|  4.87k|        nn->next = NULL;
  115|  4.87k|        nn->hash = hash;
  116|  4.87k|        *rn = nn;
  117|  4.87k|        ret = NULL;
  118|  4.87k|        lh->num_insert++;
  119|  4.87k|        lh->num_items++;
  120|  10.3k|    } else {                    /* replace same key */
  121|  10.3k|        ret = (*rn)->data;
  122|  10.3k|        (*rn)->data = data;
  123|  10.3k|        lh->num_replace++;
  124|  10.3k|    }
  125|  15.1k|    return ret;
  126|  15.1k|}
OPENSSL_LH_retrieve:
  157|     58|{
  158|     58|    unsigned long hash;
  159|     58|    OPENSSL_LH_NODE **rn;
  160|     58|    void *ret;
  161|       |
  162|     58|    tsan_store((TSAN_QUALIFIER int *)&lh->error, 0);
  ------------------
  |  |   58|     58|#  define tsan_store(ptr, val) atomic_store_explicit((ptr), (val), memory_order_relaxed)
  ------------------
  163|       |
  164|     58|    rn = getrn(lh, data, &hash);
  165|       |
  166|     58|    if (*rn == NULL) {
  ------------------
  |  Branch (166:9): [True: 58, False: 0]
  ------------------
  167|     58|        tsan_counter(&lh->num_retrieve_miss);
  ------------------
  |  |   59|     58|#  define tsan_counter(ptr) atomic_fetch_add_explicit((ptr), 1, memory_order_relaxed)
  ------------------
  168|     58|        return NULL;
  169|     58|    } else {
  170|      0|        ret = (*rn)->data;
  171|      0|        tsan_counter(&lh->num_retrieve);
  ------------------
  |  |   59|      0|#  define tsan_counter(ptr) atomic_fetch_add_explicit((ptr), 1, memory_order_relaxed)
  ------------------
  172|      0|    }
  173|       |
  174|      0|    return ret;
  175|     58|}
OPENSSL_LH_num_items:
  378|      2|{
  379|      2|    return lh ? lh->num_items : 0;
  ------------------
  |  Branch (379:12): [True: 0, False: 2]
  ------------------
  380|      2|}
lhash.c:expand:
  215|  2.42k|{
  216|  2.42k|    OPENSSL_LH_NODE **n, **n1, **n2, *np;
  217|  2.42k|    unsigned int p, pmax, nni, j;
  218|  2.42k|    unsigned long hash;
  219|       |
  220|  2.42k|    nni = lh->num_alloc_nodes;
  221|  2.42k|    p = lh->p;
  222|  2.42k|    pmax = lh->pmax;
  223|  2.42k|    if (p + 1 >= pmax) {
  ------------------
  |  Branch (223:9): [True: 14, False: 2.40k]
  ------------------
  224|     14|        j = nni * 2;
  225|     14|        n = OPENSSL_realloc(lh->b, sizeof(OPENSSL_LH_NODE *) * j);
  ------------------
  |  |  122|     14|        CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|     14|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|     14|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  226|     14|        if (n == NULL) {
  ------------------
  |  Branch (226:13): [True: 0, False: 14]
  ------------------
  227|      0|            lh->error++;
  228|      0|            return 0;
  229|      0|        }
  230|     14|        lh->b = n;
  231|     14|        memset(n + nni, 0, sizeof(*n) * (j - nni));
  232|     14|        lh->pmax = nni;
  233|     14|        lh->num_alloc_nodes = j;
  234|     14|        lh->num_expand_reallocs++;
  235|     14|        lh->p = 0;
  236|  2.40k|    } else {
  237|  2.40k|        lh->p++;
  238|  2.40k|    }
  239|       |
  240|  2.42k|    lh->num_nodes++;
  241|  2.42k|    lh->num_expands++;
  242|  2.42k|    n1 = &(lh->b[p]);
  243|  2.42k|    n2 = &(lh->b[p + pmax]);
  244|  2.42k|    *n2 = NULL;
  245|       |
  246|  11.3k|    for (np = *n1; np != NULL;) {
  ------------------
  |  Branch (246:20): [True: 8.93k, False: 2.42k]
  ------------------
  247|  8.93k|        hash = np->hash;
  248|  8.93k|        if ((hash % nni) != p) { /* move it */
  ------------------
  |  Branch (248:13): [True: 704, False: 8.22k]
  ------------------
  249|    704|            *n1 = (*n1)->next;
  250|    704|            np->next = *n2;
  251|    704|            *n2 = np;
  252|    704|        } else
  253|  8.22k|            n1 = &((*n1)->next);
  254|  8.93k|        np = *n1;
  255|  8.93k|    }
  256|       |
  257|  2.42k|    return 1;
  258|  2.42k|}
lhash.c:getrn:
  297|  15.2k|{
  298|  15.2k|    OPENSSL_LH_NODE **ret, *n1;
  299|  15.2k|    unsigned long hash, nn;
  300|  15.2k|    OPENSSL_LH_COMPFUNC cf;
  301|       |
  302|  15.2k|    hash = (*(lh->hash)) (data);
  303|  15.2k|    tsan_counter(&lh->num_hash_calls);
  ------------------
  |  |   59|  15.2k|#  define tsan_counter(ptr) atomic_fetch_add_explicit((ptr), 1, memory_order_relaxed)
  ------------------
  304|  15.2k|    *rhash = hash;
  305|       |
  306|  15.2k|    nn = hash % lh->pmax;
  307|  15.2k|    if (nn < lh->p)
  ------------------
  |  Branch (307:9): [True: 8.94k, False: 6.30k]
  ------------------
  308|  8.94k|        nn = hash % lh->num_alloc_nodes;
  309|       |
  310|  15.2k|    cf = lh->comp;
  311|  15.2k|    ret = &(lh->b[(int)nn]);
  312|  44.6k|    for (n1 = *ret; n1 != NULL; n1 = n1->next) {
  ------------------
  |  Branch (312:21): [True: 39.6k, False: 4.92k]
  ------------------
  313|  39.6k|        tsan_counter(&lh->num_hash_comps);
  ------------------
  |  |   59|  39.6k|#  define tsan_counter(ptr) atomic_fetch_add_explicit((ptr), 1, memory_order_relaxed)
  ------------------
  314|  39.6k|        if (n1->hash != hash) {
  ------------------
  |  Branch (314:13): [True: 29.1k, False: 10.5k]
  ------------------
  315|  29.1k|            ret = &(n1->next);
  316|  29.1k|            continue;
  317|  29.1k|        }
  318|  39.6k|        tsan_counter(&lh->num_comp_calls);
  ------------------
  |  |   59|  39.6k|#  define tsan_counter(ptr) atomic_fetch_add_explicit((ptr), 1, memory_order_relaxed)
  ------------------
  319|  10.5k|        if (cf(n1->data, data) == 0)
  ------------------
  |  Branch (319:13): [True: 10.3k, False: 246]
  ------------------
  320|  10.3k|            break;
  321|    246|        ret = &(n1->next);
  322|    246|    }
  323|  15.2k|    return ret;
  324|  15.2k|}

CRYPTO_malloc:
  193|   122k|{
  194|   122k|    void *ret = NULL;
  195|       |
  196|   122k|    INCREMENT(malloc_count);
  197|   122k|    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
  ------------------
  |  Branch (197:9): [True: 122k, False: 0]
  |  Branch (197:32): [True: 0, False: 122k]
  ------------------
  198|      0|        return malloc_impl(num, file, line);
  199|       |
  200|   122k|    if (num == 0)
  ------------------
  |  Branch (200:9): [True: 0, False: 122k]
  ------------------
  201|      0|        return NULL;
  202|       |
  203|   122k|    FAILTEST();
  204|   122k|    if (allow_customize) {
  ------------------
  |  Branch (204:9): [True: 2, False: 122k]
  ------------------
  205|       |        /*
  206|       |         * Disallow customization after the first allocation. We only set this
  207|       |         * if necessary to avoid a store to the same cache line on every
  208|       |         * allocation.
  209|       |         */
  210|      2|        allow_customize = 0;
  211|      2|    }
  212|       |#ifndef OPENSSL_NO_CRYPTO_MDEBUG
  213|       |    if (call_malloc_debug) {
  214|       |        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);
  215|       |        ret = malloc(num);
  216|       |        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);
  217|       |    } else {
  218|       |        ret = malloc(num);
  219|       |    }
  220|       |#else
  221|   122k|    (void)(file); (void)(line);
  222|   122k|    ret = malloc(num);
  223|   122k|#endif
  224|       |
  225|   122k|    return ret;
  226|   122k|}
CRYPTO_zalloc:
  229|  65.4k|{
  230|  65.4k|    void *ret = CRYPTO_malloc(num, file, line);
  231|       |
  232|  65.4k|    FAILTEST();
  233|  65.4k|    if (ret != NULL)
  ------------------
  |  Branch (233:9): [True: 65.4k, False: 0]
  ------------------
  234|  65.4k|        memset(ret, 0, num);
  235|  65.4k|    return ret;
  236|  65.4k|}
CRYPTO_realloc:
  239|  38.5k|{
  240|  38.5k|    INCREMENT(realloc_count);
  241|  38.5k|    if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)
  ------------------
  |  Branch (241:9): [True: 38.5k, False: 0]
  |  Branch (241:33): [True: 0, False: 38.5k]
  ------------------
  242|      0|        return realloc_impl(str, num, file, line);
  243|       |
  244|  38.5k|    FAILTEST();
  245|  38.5k|    if (str == NULL)
  ------------------
  |  Branch (245:9): [True: 38.4k, False: 14]
  ------------------
  246|  38.4k|        return CRYPTO_malloc(num, file, line);
  247|       |
  248|     14|    if (num == 0) {
  ------------------
  |  Branch (248:9): [True: 0, False: 14]
  ------------------
  249|      0|        CRYPTO_free(str, file, line);
  250|      0|        return NULL;
  251|      0|    }
  252|       |
  253|       |#ifndef OPENSSL_NO_CRYPTO_MDEBUG
  254|       |    if (call_malloc_debug) {
  255|       |        void *ret;
  256|       |        CRYPTO_mem_debug_realloc(str, NULL, num, 0, file, line);
  257|       |        ret = realloc(str, num);
  258|       |        CRYPTO_mem_debug_realloc(str, ret, num, 1, file, line);
  259|       |        return ret;
  260|       |    }
  261|       |#else
  262|     14|    (void)(file); (void)(line);
  263|     14|#endif
  264|     14|    return realloc(str, num);
  265|       |
  266|     14|}
CRYPTO_free:
  296|   124k|{
  297|   124k|    INCREMENT(free_count);
  298|   124k|    if (free_impl != NULL && free_impl != &CRYPTO_free) {
  ------------------
  |  Branch (298:9): [True: 124k, False: 0]
  |  Branch (298:30): [True: 0, False: 124k]
  ------------------
  299|      0|        free_impl(str, file, line);
  300|      0|        return;
  301|      0|    }
  302|       |
  303|       |#ifndef OPENSSL_NO_CRYPTO_MDEBUG
  304|       |    if (call_malloc_debug) {
  305|       |        CRYPTO_mem_debug_free(str, 0, file, line);
  306|       |        free(str);
  307|       |        CRYPTO_mem_debug_free(str, 1, file, line);
  308|       |    } else {
  309|       |        free(str);
  310|       |    }
  311|       |#else
  312|   124k|    free(str);
  313|   124k|#endif
  314|   124k|}
CRYPTO_clear_free:
  317|  10.5k|{
  318|  10.5k|    if (str == NULL)
  ------------------
  |  Branch (318:9): [True: 0, False: 10.5k]
  ------------------
  319|      0|        return;
  320|  10.5k|    if (num)
  ------------------
  |  Branch (320:9): [True: 10.5k, False: 0]
  ------------------
  321|  10.5k|        OPENSSL_cleanse(str, num);
  322|  10.5k|    CRYPTO_free(str, file, line);
  323|  10.5k|}

CRYPTO_secure_malloc_done:
   98|      2|{
   99|      2|#ifdef OPENSSL_SECURE_MEMORY
  100|      2|    if (secure_mem_used == 0) {
  ------------------
  |  Branch (100:9): [True: 2, False: 0]
  ------------------
  101|      2|        sh_done();
  102|      2|        secure_mem_initialized = 0;
  103|      2|        CRYPTO_THREAD_lock_free(sec_malloc_lock);
  104|      2|        sec_malloc_lock = NULL;
  105|      2|        return 1;
  106|      2|    }
  107|      0|#endif /* OPENSSL_SECURE_MEMORY */
  108|      0|    return 0;
  109|      2|}
mem_sec.c:sh_done:
  507|      2|{
  508|      2|    OPENSSL_free(sh.freelist);
  ------------------
  |  |  128|      2|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  509|      2|    OPENSSL_free(sh.bittable);
  ------------------
  |  |  128|      2|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  510|      2|    OPENSSL_free(sh.bitmalloc);
  ------------------
  |  |  128|      2|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      2|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      2|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  511|      2|    if (sh.map_result != MAP_FAILED && sh.map_size)
  ------------------
  |  Branch (511:9): [True: 2, False: 0]
  |  Branch (511:40): [True: 0, False: 2]
  ------------------
  512|      0|        munmap(sh.map_result, sh.map_size);
  513|      2|    memset(&sh, 0, sizeof(sh));
  514|      2|}

openssl_fopen:
   39|      2|{
   40|      2|    FILE *file = NULL;
   41|       |# if defined(_WIN32) && defined(CP_UTF8)
   42|       |    int sz, len_0 = (int)strlen(filename) + 1;
   43|       |    DWORD flags;
   44|       |
   45|       |    /*
   46|       |     * Basically there are three cases to cover: a) filename is
   47|       |     * pure ASCII string; b) actual UTF-8 encoded string and
   48|       |     * c) locale-ized string, i.e. one containing 8-bit
   49|       |     * characters that are meaningful in current system locale.
   50|       |     * If filename is pure ASCII or real UTF-8 encoded string,
   51|       |     * MultiByteToWideChar succeeds and _wfopen works. If
   52|       |     * filename is locale-ized string, chances are that
   53|       |     * MultiByteToWideChar fails reporting
   54|       |     * ERROR_NO_UNICODE_TRANSLATION, in which case we fall
   55|       |     * back to fopen...
   56|       |     */
   57|       |    if ((sz = MultiByteToWideChar(CP_UTF8, (flags = MB_ERR_INVALID_CHARS),
   58|       |                                  filename, len_0, NULL, 0)) > 0 ||
   59|       |        (GetLastError() == ERROR_INVALID_FLAGS &&
   60|       |         (sz = MultiByteToWideChar(CP_UTF8, (flags = 0),
   61|       |                                   filename, len_0, NULL, 0)) > 0)
   62|       |        ) {
   63|       |        WCHAR wmode[8];
   64|       |        WCHAR *wfilename = _alloca(sz * sizeof(WCHAR));
   65|       |
   66|       |        if (MultiByteToWideChar(CP_UTF8, flags,
   67|       |                                filename, len_0, wfilename, sz) &&
   68|       |            MultiByteToWideChar(CP_UTF8, 0, mode, strlen(mode) + 1,
   69|       |                                wmode, OSSL_NELEM(wmode)) &&
   70|       |            (file = _wfopen(wfilename, wmode)) == NULL &&
   71|       |            (errno == ENOENT || errno == EBADF)
   72|       |            ) {
   73|       |            /*
   74|       |             * UTF-8 decode succeeded, but no file, filename
   75|       |             * could still have been locale-ized...
   76|       |             */
   77|       |            file = fopen(filename, mode);
   78|       |        }
   79|       |    } else if (GetLastError() == ERROR_NO_UNICODE_TRANSLATION) {
   80|       |        file = fopen(filename, mode);
   81|       |    }
   82|       |# elif defined(__DJGPP__)
   83|       |    {
   84|       |        char *newname = NULL;
   85|       |
   86|       |        if (pathconf(filename, _PC_NAME_MAX) <= 12) {  /* 8.3 file system? */
   87|       |            char *iterator;
   88|       |            char lastchar;
   89|       |
   90|       |            if ((newname = OPENSSL_malloc(strlen(filename) + 1)) == NULL) {
   91|       |                CRYPTOerr(CRYPTO_F_OPENSSL_FOPEN, ERR_R_MALLOC_FAILURE);
   92|       |                return NULL;
   93|       |            }
   94|       |
   95|       |            for (iterator = newname, lastchar = '\0';
   96|       |                *filename; filename++, iterator++) {
   97|       |                if (lastchar == '/' && filename[0] == '.'
   98|       |                    && filename[1] != '.' && filename[1] != '/') {
   99|       |                    /* Leading dots are not permitted in plain DOS. */
  100|       |                    *iterator = '_';
  101|       |                } else {
  102|       |                    *iterator = *filename;
  103|       |                }
  104|       |                lastchar = *filename;
  105|       |            }
  106|       |            *iterator = '\0';
  107|       |            filename = newname;
  108|       |        }
  109|       |        file = fopen(filename, mode);
  110|       |
  111|       |        OPENSSL_free(newname);
  112|       |    }
  113|       |# else
  114|      2|    file = fopen(filename, mode);
  115|      2|# endif
  116|      2|    return file;
  117|      2|}

OPENSSL_strnlen:
   73|   506k|{
   74|   506k|    const char *p;
   75|       |
   76|  1.08M|    for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
  ------------------
  |  Branch (76:19): [True: 1.08M, False: 0]
  |  Branch (76:36): [True: 574k, False: 506k]
  ------------------
   77|       |
   78|   506k|    return p - str;
   79|   506k|}
OPENSSL_strlcpy:
   82|  74.3k|{
   83|  74.3k|    size_t l = 0;
   84|   426k|    for (; size > 1 && *src; size--) {
  ------------------
  |  Branch (84:12): [True: 423k, False: 3.15k]
  |  Branch (84:24): [True: 351k, False: 71.2k]
  ------------------
   85|   351k|        *dst++ = *src++;
   86|   351k|        l++;
   87|   351k|    }
   88|  74.3k|    if (size)
  ------------------
  |  Branch (88:9): [True: 73.7k, False: 690]
  ------------------
   89|  73.7k|        *dst = '\0';
   90|  74.3k|    return l + strlen(src);
   91|  74.3k|}
openssl_strerror_r:
  222|    254|{
  223|       |#if defined(_MSC_VER) && _MSC_VER>=1400 && !defined(_WIN32_WCE)
  224|       |    return !strerror_s(buf, buflen, errnum);
  225|       |#elif defined(_GNU_SOURCE)
  226|       |    char *err;
  227|       |
  228|       |    /*
  229|       |     * GNU strerror_r may not actually set buf.
  230|       |     * It can return a pointer to some (immutable) static string in which case
  231|       |     * buf is left unused.
  232|       |     */
  233|       |    err = strerror_r(errnum, buf, buflen);
  234|       |    if (err == NULL || buflen == 0)
  235|       |        return 0;
  236|       |    /*
  237|       |     * If err is statically allocated, err != buf and we need to copy the data.
  238|       |     * If err points somewhere inside buf, OPENSSL_strlcpy can handle this,
  239|       |     * since src and dest are not annotated with __restrict and the function
  240|       |     * reads src byte for byte and writes to dest.
  241|       |     * If err == buf we do not have to copy anything.
  242|       |     */
  243|       |    if (err != buf)
  244|       |        OPENSSL_strlcpy(buf, err, buflen);
  245|       |    return 1;
  246|       |#elif (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \
  247|       |      (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)
  248|       |    /*
  249|       |     * We can use "real" strerror_r. The OpenSSL version differs in that it
  250|       |     * gives 1 on success and 0 on failure for consistency with other OpenSSL
  251|       |     * functions. Real strerror_r does it the other way around
  252|       |     */
  253|    254|    return !strerror_r(errnum, buf, buflen);
  254|       |#else
  255|       |    char *err;
  256|       |
  257|       |    /* Fall back to non-thread safe strerror()...its all we can do */
  258|       |    if (buflen < 2)
  259|       |        return 0;
  260|       |    err = strerror(errnum);
  261|       |    /* Can this ever happen? */
  262|       |    if (err == NULL)
  263|       |        return 0;
  264|       |    OPENSSL_strlcpy(buf, err, buflen);
  265|       |    return 1;
  266|       |#endif
  267|    254|}

OBJ_NAME_cleanup:
  390|      6|{
  391|      6|    unsigned long down_load;
  392|       |
  393|      6|    if (names_lh == NULL)
  ------------------
  |  Branch (393:9): [True: 6, False: 0]
  ------------------
  394|      6|        return;
  395|       |
  396|      0|    free_type = type;
  397|      0|    down_load = lh_OBJ_NAME_get_down_load(names_lh);
  398|      0|    lh_OBJ_NAME_set_down_load(names_lh, 0);
  399|       |
  400|      0|    lh_OBJ_NAME_doall(names_lh, names_lh_free_doall);
  401|      0|    if (type < 0) {
  ------------------
  |  Branch (401:9): [True: 0, False: 0]
  ------------------
  402|      0|        lh_OBJ_NAME_free(names_lh);
  403|      0|        sk_NAME_FUNCS_pop_free(name_funcs_stack, name_funcs_free);
  404|      0|        CRYPTO_THREAD_lock_free(obj_lock);
  405|      0|        names_lh = NULL;
  406|      0|        name_funcs_stack = NULL;
  407|      0|        obj_lock = NULL;
  408|      0|    } else
  409|      0|        lh_OBJ_NAME_set_down_load(names_lh, down_load);
  410|      0|}

obj_cleanup_int:
  154|      2|{
  155|      2|    if (added == NULL)
  ------------------
  |  Branch (155:9): [True: 2, False: 0]
  ------------------
  156|      2|        return;
  157|      0|    lh_ADDED_OBJ_set_down_load(added, 0);
  158|      0|    lh_ADDED_OBJ_doall(added, cleanup1_doall); /* zero counters */
  159|      0|    lh_ADDED_OBJ_doall(added, cleanup2_doall); /* set counters */
  160|      0|    lh_ADDED_OBJ_doall(added, cleanup3_doall); /* free objects */
  161|      0|    lh_ADDED_OBJ_free(added);
  162|      0|    added = NULL;
  163|      0|}
OBJ_nid2obj:
  221|  3.62k|{
  222|  3.62k|    ADDED_OBJ ad, *adp;
  223|  3.62k|    ASN1_OBJECT ob;
  224|       |
  225|  3.62k|    if ((n >= 0) && (n < NUM_NID)) {
  ------------------
  |  | 1081|  3.62k|#define NUM_NID 1195
  ------------------
  |  Branch (225:9): [True: 3.62k, False: 0]
  |  Branch (225:21): [True: 3.62k, False: 0]
  ------------------
  226|  3.62k|        if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
  ------------------
  |  |   14|  3.62k|#define NID_undef                       0
  ------------------
                      if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
  ------------------
  |  |   14|  3.62k|#define NID_undef                       0
  ------------------
  |  Branch (226:13): [True: 3.62k, False: 0]
  |  Branch (226:33): [True: 0, False: 3.62k]
  ------------------
  227|      0|            OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);
  ------------------
  |  |  107|      0|# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  228|      0|            return NULL;
  229|      0|        }
  230|  3.62k|        return (ASN1_OBJECT *)&(nid_objs[n]);
  231|  3.62k|    } else if (added == NULL) {
  ------------------
  |  Branch (231:16): [True: 0, False: 0]
  ------------------
  232|      0|        OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);
  ------------------
  |  |  107|      0|# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  233|      0|        return NULL;
  234|      0|    } else {
  235|      0|        ad.type = ADDED_NID;
  ------------------
  |  |   31|      0|#define ADDED_NID       3
  ------------------
  236|      0|        ad.obj = &ob;
  237|      0|        ob.nid = n;
  238|      0|        adp = lh_ADDED_OBJ_retrieve(added, &ad);
  239|      0|        if (adp != NULL)
  ------------------
  |  Branch (239:13): [True: 0, False: 0]
  ------------------
  240|      0|            return adp->obj;
  241|      0|        else {
  242|      0|            OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);
  ------------------
  |  |  107|      0|# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  243|      0|            return NULL;
  244|      0|        }
  245|      0|    }
  246|  3.62k|}
OBJ_nid2ln:
  276|  3.62k|{
  277|  3.62k|    ADDED_OBJ ad, *adp;
  278|  3.62k|    ASN1_OBJECT ob;
  279|       |
  280|  3.62k|    if ((n >= 0) && (n < NUM_NID)) {
  ------------------
  |  | 1081|  3.62k|#define NUM_NID 1195
  ------------------
  |  Branch (280:9): [True: 3.62k, False: 0]
  |  Branch (280:21): [True: 3.62k, False: 0]
  ------------------
  281|  3.62k|        if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
  ------------------
  |  |   14|  3.62k|#define NID_undef                       0
  ------------------
                      if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
  ------------------
  |  |   14|  3.62k|#define NID_undef                       0
  ------------------
  |  Branch (281:13): [True: 3.62k, False: 0]
  |  Branch (281:33): [True: 0, False: 3.62k]
  ------------------
  282|      0|            OBJerr(OBJ_F_OBJ_NID2LN, OBJ_R_UNKNOWN_NID);
  ------------------
  |  |  107|      0|# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  283|      0|            return NULL;
  284|      0|        }
  285|  3.62k|        return nid_objs[n].ln;
  286|  3.62k|    } else if (added == NULL)
  ------------------
  |  Branch (286:16): [True: 0, False: 0]
  ------------------
  287|      0|        return NULL;
  288|      0|    else {
  289|      0|        ad.type = ADDED_NID;
  ------------------
  |  |   31|      0|#define ADDED_NID       3
  ------------------
  290|      0|        ad.obj = &ob;
  291|      0|        ob.nid = n;
  292|      0|        adp = lh_ADDED_OBJ_retrieve(added, &ad);
  293|      0|        if (adp != NULL)
  ------------------
  |  Branch (293:13): [True: 0, False: 0]
  ------------------
  294|      0|            return adp->obj->ln;
  295|      0|        else {
  296|      0|            OBJerr(OBJ_F_OBJ_NID2LN, OBJ_R_UNKNOWN_NID);
  ------------------
  |  |  107|      0|# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |   29|      0|#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
  |  |  ------------------
  ------------------
  297|      0|            return NULL;
  298|      0|        }
  299|      0|    }
  300|  3.62k|}
OBJ_obj2nid:
  319|  20.4k|{
  320|  20.4k|    const unsigned int *op;
  321|  20.4k|    ADDED_OBJ ad, *adp;
  322|       |
  323|  20.4k|    if (a == NULL)
  ------------------
  |  Branch (323:9): [True: 0, False: 20.4k]
  ------------------
  324|      0|        return NID_undef;
  ------------------
  |  |   14|      0|#define NID_undef                       0
  ------------------
  325|  20.4k|    if (a->nid != 0)
  ------------------
  |  Branch (325:9): [True: 3.62k, False: 16.8k]
  ------------------
  326|  3.62k|        return a->nid;
  327|       |
  328|  16.8k|    if (a->length == 0)
  ------------------
  |  Branch (328:9): [True: 0, False: 16.8k]
  ------------------
  329|      0|        return NID_undef;
  ------------------
  |  |   14|      0|#define NID_undef                       0
  ------------------
  330|       |
  331|  16.8k|    if (added != NULL) {
  ------------------
  |  Branch (331:9): [True: 0, False: 16.8k]
  ------------------
  332|      0|        ad.type = ADDED_DATA;
  ------------------
  |  |   28|      0|#define ADDED_DATA      0
  ------------------
  333|      0|        ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  334|      0|        adp = lh_ADDED_OBJ_retrieve(added, &ad);
  335|      0|        if (adp != NULL)
  ------------------
  |  Branch (335:13): [True: 0, False: 0]
  ------------------
  336|      0|            return adp->obj->nid;
  337|      0|    }
  338|  16.8k|    op = OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);
  ------------------
  |  | 4660|  16.8k|#define NUM_OBJ 1071
  ------------------
  339|  16.8k|    if (op == NULL)
  ------------------
  |  Branch (339:9): [True: 13.1k, False: 3.62k]
  ------------------
  340|  13.1k|        return NID_undef;
  ------------------
  |  |   14|  13.1k|#define NID_undef                       0
  ------------------
  341|  3.62k|    return nid_objs[*op].nid;
  342|  16.8k|}
OBJ_obj2txt:
  398|  10.5k|{
  399|  10.5k|    int i, n = 0, len, nid, first, use_bn;
  400|  10.5k|    BIGNUM *bl;
  401|  10.5k|    unsigned long l;
  402|  10.5k|    const unsigned char *p;
  403|  10.5k|    char tbuf[DECIMAL_SIZE(i) + DECIMAL_SIZE(l) + 2];
  404|       |
  405|       |    /* Ensure that, at every state, |buf| is NUL-terminated. */
  406|  10.5k|    if (buf && buf_len > 0)
  ------------------
  |  Branch (406:9): [True: 10.5k, False: 0]
  |  Branch (406:16): [True: 10.5k, False: 0]
  ------------------
  407|  10.5k|        buf[0] = '\0';
  408|       |
  409|  10.5k|    if ((a == NULL) || (a->data == NULL))
  ------------------
  |  Branch (409:9): [True: 0, False: 10.5k]
  |  Branch (409:24): [True: 0, False: 10.5k]
  ------------------
  410|      0|        return 0;
  411|       |
  412|  10.5k|    if (!no_name && (nid = OBJ_obj2nid(a)) != NID_undef) {
  ------------------
  |  |   14|  10.5k|#define NID_undef                       0
  ------------------
  |  Branch (412:9): [True: 10.5k, False: 0]
  |  Branch (412:21): [True: 3.62k, False: 6.88k]
  ------------------
  413|  3.62k|        const char *s;
  414|  3.62k|        s = OBJ_nid2ln(nid);
  415|  3.62k|        if (s == NULL)
  ------------------
  |  Branch (415:13): [True: 0, False: 3.62k]
  ------------------
  416|      0|            s = OBJ_nid2sn(nid);
  417|  3.62k|        if (s) {
  ------------------
  |  Branch (417:13): [True: 3.62k, False: 0]
  ------------------
  418|  3.62k|            if (buf)
  ------------------
  |  Branch (418:17): [True: 3.62k, False: 0]
  ------------------
  419|  3.62k|                OPENSSL_strlcpy(buf, s, buf_len);
  420|  3.62k|            n = strlen(s);
  421|  3.62k|            return n;
  422|  3.62k|        }
  423|  3.62k|    }
  424|       |
  425|  6.88k|    len = a->length;
  426|  6.88k|    p = a->data;
  427|       |
  428|  6.88k|    first = 1;
  429|  6.88k|    bl = NULL;
  430|       |
  431|       |    /*
  432|       |     * RFC 2578 (STD 58) says this about OBJECT IDENTIFIERs:
  433|       |     *
  434|       |     * > 3.5. OBJECT IDENTIFIER values
  435|       |     * >
  436|       |     * > An OBJECT IDENTIFIER value is an ordered list of non-negative
  437|       |     * > numbers. For the SMIv2, each number in the list is referred to as a
  438|       |     * > sub-identifier, there are at most 128 sub-identifiers in a value,
  439|       |     * > and each sub-identifier has a maximum value of 2^32-1 (4294967295
  440|       |     * > decimal).
  441|       |     *
  442|       |     * So a legitimate OID according to this RFC is at most (32 * 128 / 7),
  443|       |     * i.e. 586 bytes long.
  444|       |     *
  445|       |     * Ref: https://datatracker.ietf.org/doc/html/rfc2578#section-3.5
  446|       |     */
  447|  6.88k|    if (len > 586)
  ------------------
  |  Branch (447:9): [True: 750, False: 6.13k]
  ------------------
  448|    750|        goto err;
  449|       |
  450|   103k|    while (len > 0) {
  ------------------
  |  Branch (450:12): [True: 97.4k, False: 6.13k]
  ------------------
  451|  97.4k|        l = 0;
  452|  97.4k|        use_bn = 0;
  453|   184k|        for (;;) {
  454|   184k|            unsigned char c = *p++;
  455|   184k|            len--;
  456|   184k|            if ((len == 0) && (c & 0x80))
  ------------------
  |  Branch (456:17): [True: 6.13k, False: 178k]
  |  Branch (456:31): [True: 0, False: 6.13k]
  ------------------
  457|      0|                goto err;
  458|   184k|            if (use_bn) {
  ------------------
  |  Branch (458:17): [True: 36.5k, False: 147k]
  ------------------
  459|  36.5k|                if (!BN_add_word(bl, c & 0x7f))
  ------------------
  |  Branch (459:21): [True: 0, False: 36.5k]
  ------------------
  460|      0|                    goto err;
  461|  36.5k|            } else
  462|   147k|                l |= c & 0x7f;
  463|   184k|            if (!(c & 0x80))
  ------------------
  |  Branch (463:17): [True: 97.4k, False: 86.6k]
  ------------------
  464|  97.4k|                break;
  465|  86.6k|            if (!use_bn && (l > (ULONG_MAX >> 7L))) {
  ------------------
  |  Branch (465:17): [True: 54.8k, False: 31.8k]
  |  Branch (465:28): [True: 4.72k, False: 50.1k]
  ------------------
  466|  4.72k|                if (bl == NULL && (bl = BN_new()) == NULL)
  ------------------
  |  Branch (466:21): [True: 2.25k, False: 2.46k]
  |  Branch (466:35): [True: 0, False: 2.25k]
  ------------------
  467|      0|                    goto err;
  468|  4.72k|                if (!BN_set_word(bl, l))
  ------------------
  |  Branch (468:21): [True: 0, False: 4.72k]
  ------------------
  469|      0|                    goto err;
  470|  4.72k|                use_bn = 1;
  471|  4.72k|            }
  472|  86.6k|            if (use_bn) {
  ------------------
  |  Branch (472:17): [True: 36.5k, False: 50.1k]
  ------------------
  473|  36.5k|                if (!BN_lshift(bl, bl, 7))
  ------------------
  |  Branch (473:21): [True: 0, False: 36.5k]
  ------------------
  474|      0|                    goto err;
  475|  36.5k|            } else
  476|  50.1k|                l <<= 7L;
  477|  86.6k|        }
  478|       |
  479|  97.4k|        if (first) {
  ------------------
  |  Branch (479:13): [True: 6.13k, False: 91.3k]
  ------------------
  480|  6.13k|            first = 0;
  481|  6.13k|            if (l >= 80) {
  ------------------
  |  Branch (481:17): [True: 3.94k, False: 2.18k]
  ------------------
  482|  3.94k|                i = 2;
  483|  3.94k|                if (use_bn) {
  ------------------
  |  Branch (483:21): [True: 1.91k, False: 2.03k]
  ------------------
  484|  1.91k|                    if (!BN_sub_word(bl, 80))
  ------------------
  |  Branch (484:25): [True: 0, False: 1.91k]
  ------------------
  485|      0|                        goto err;
  486|  1.91k|                } else
  487|  2.03k|                    l -= 80;
  488|  3.94k|            } else {
  489|  2.18k|                i = (int)(l / 40);
  490|  2.18k|                l -= (long)(i * 40);
  491|  2.18k|            }
  492|  6.13k|            if (buf && (buf_len > 1)) {
  ------------------
  |  Branch (492:17): [True: 6.13k, False: 0]
  |  Branch (492:24): [True: 6.13k, False: 0]
  ------------------
  493|  6.13k|                *buf++ = i + '0';
  494|  6.13k|                *buf = '\0';
  495|  6.13k|                buf_len--;
  496|  6.13k|            }
  497|  6.13k|            n++;
  498|  6.13k|        }
  499|       |
  500|  97.4k|        if (use_bn) {
  ------------------
  |  Branch (500:13): [True: 4.72k, False: 92.7k]
  ------------------
  501|  4.72k|            char *bndec;
  502|  4.72k|            bndec = BN_bn2dec(bl);
  503|  4.72k|            if (!bndec)
  ------------------
  |  Branch (503:17): [True: 0, False: 4.72k]
  ------------------
  504|      0|                goto err;
  505|  4.72k|            i = strlen(bndec);
  506|  4.72k|            if (buf) {
  ------------------
  |  Branch (506:17): [True: 4.72k, False: 0]
  ------------------
  507|  4.72k|                if (buf_len > 1) {
  ------------------
  |  Branch (507:21): [True: 4.03k, False: 692]
  ------------------
  508|  4.03k|                    *buf++ = '.';
  509|  4.03k|                    *buf = '\0';
  510|  4.03k|                    buf_len--;
  511|  4.03k|                }
  512|  4.72k|                OPENSSL_strlcpy(buf, bndec, buf_len);
  513|  4.72k|                if (i > buf_len) {
  ------------------
  |  Branch (513:21): [True: 910, False: 3.81k]
  ------------------
  514|    910|                    buf += buf_len;
  515|    910|                    buf_len = 0;
  516|  3.81k|                } else {
  517|  3.81k|                    buf += i;
  518|  3.81k|                    buf_len -= i;
  519|  3.81k|                }
  520|  4.72k|            }
  521|  4.72k|            n++;
  522|  4.72k|            n += i;
  523|  4.72k|            OPENSSL_free(bndec);
  ------------------
  |  |  128|  4.72k|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|  4.72k|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|  4.72k|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  524|  92.7k|        } else {
  525|  92.7k|            BIO_snprintf(tbuf, sizeof(tbuf), ".%lu", l);
  526|  92.7k|            i = strlen(tbuf);
  527|  92.7k|            if (buf && (buf_len > 0)) {
  ------------------
  |  Branch (527:17): [True: 92.7k, False: 0]
  |  Branch (527:24): [True: 66.0k, False: 26.7k]
  ------------------
  528|  66.0k|                OPENSSL_strlcpy(buf, tbuf, buf_len);
  529|  66.0k|                if (i > buf_len) {
  ------------------
  |  Branch (529:21): [True: 472, False: 65.5k]
  ------------------
  530|    472|                    buf += buf_len;
  531|    472|                    buf_len = 0;
  532|  65.5k|                } else {
  533|  65.5k|                    buf += i;
  534|  65.5k|                    buf_len -= i;
  535|  65.5k|                }
  536|  66.0k|            }
  537|  92.7k|            n += i;
  538|  92.7k|            l = 0;
  539|  92.7k|        }
  540|  97.4k|    }
  541|       |
  542|  6.13k|    BN_free(bl);
  543|  6.13k|    return n;
  544|       |
  545|    750| err:
  546|    750|    BN_free(bl);
  547|    750|    return -1;
  548|  6.13k|}
OBJ_bsearch_:
  604|  16.8k|{
  605|  16.8k|    return OBJ_bsearch_ex_(key, base, num, size, cmp, 0);
  606|  16.8k|}
OBJ_bsearch_ex_:
  612|  16.8k|{
  613|  16.8k|    const char *base = base_;
  614|  16.8k|    int l, h, i = 0, c = 0;
  615|  16.8k|    const char *p = NULL;
  616|       |
  617|  16.8k|    if (num == 0)
  ------------------
  |  Branch (617:9): [True: 0, False: 16.8k]
  ------------------
  618|      0|        return NULL;
  619|  16.8k|    l = 0;
  620|  16.8k|    h = num;
  621|   177k|    while (l < h) {
  ------------------
  |  Branch (621:12): [True: 164k, False: 13.1k]
  ------------------
  622|   164k|        i = (l + h) / 2;
  623|   164k|        p = &(base[i * size]);
  624|   164k|        c = (*cmp) (key, p);
  625|   164k|        if (c < 0)
  ------------------
  |  Branch (625:13): [True: 74.6k, False: 89.9k]
  ------------------
  626|  74.6k|            h = i;
  627|  89.9k|        else if (c > 0)
  ------------------
  |  Branch (627:18): [True: 86.3k, False: 3.62k]
  ------------------
  628|  86.3k|            l = i + 1;
  629|  3.62k|        else
  630|  3.62k|            break;
  631|   164k|    }
  632|       |#ifdef CHARSET_EBCDIC
  633|       |    /*
  634|       |     * THIS IS A KLUDGE - Because the *_obj is sorted in ASCII order, and I
  635|       |     * don't have perl (yet), we revert to a *LINEAR* search when the object
  636|       |     * wasn't found in the binary search.
  637|       |     */
  638|       |    if (c != 0) {
  639|       |        for (i = 0; i < num; ++i) {
  640|       |            p = &(base[i * size]);
  641|       |            c = (*cmp) (key, p);
  642|       |            if (c == 0 || (c < 0 && (flags & OBJ_BSEARCH_VALUE_ON_NOMATCH)))
  643|       |                return p;
  644|       |        }
  645|       |    }
  646|       |#endif
  647|  16.8k|    if (c != 0 && !(flags & OBJ_BSEARCH_VALUE_ON_NOMATCH))
  ------------------
  |  |   27|  13.1k|# define OBJ_BSEARCH_VALUE_ON_NOMATCH            0x01
  ------------------
  |  Branch (647:9): [True: 13.1k, False: 3.62k]
  |  Branch (647:19): [True: 13.1k, False: 0]
  ------------------
  648|  13.1k|        p = NULL;
  649|  3.62k|    else if (c == 0 && (flags & OBJ_BSEARCH_FIRST_VALUE_ON_MATCH)) {
  ------------------
  |  |   28|  3.62k|# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH        0x02
  ------------------
  |  Branch (649:14): [True: 3.62k, False: 0]
  |  Branch (649:24): [True: 0, False: 3.62k]
  ------------------
  650|      0|        while (i > 0 && (*cmp) (key, &(base[(i - 1) * size])) == 0)
  ------------------
  |  Branch (650:16): [True: 0, False: 0]
  |  Branch (650:25): [True: 0, False: 0]
  ------------------
  651|      0|            i--;
  652|      0|        p = &(base[i * size]);
  653|      0|    }
  654|  16.8k|    return p;
  655|  16.8k|}
obj_dat.c:obj_cmp:
  303|   164k|{
  304|   164k|    int j;
  305|   164k|    const ASN1_OBJECT *a = *ap;
  306|   164k|    const ASN1_OBJECT *b = &nid_objs[*bp];
  307|       |
  308|   164k|    j = (a->length - b->length);
  309|   164k|    if (j)
  ------------------
  |  Branch (309:9): [True: 130k, False: 34.4k]
  ------------------
  310|   130k|        return j;
  311|  34.4k|    if (a->length == 0)
  ------------------
  |  Branch (311:9): [True: 0, False: 34.4k]
  ------------------
  312|      0|        return 0;
  313|  34.4k|    return memcmp(a->data, b->data, a->length);
  314|  34.4k|}

ERR_load_OBJ_strings:
   38|      2|{
   39|      2|#ifndef OPENSSL_NO_ERR
   40|      2|    if (ERR_func_error_string(OBJ_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (40:9): [True: 2, False: 0]
  ------------------
   41|      2|        ERR_load_strings_const(OBJ_str_functs);
   42|      2|        ERR_load_strings_const(OBJ_str_reasons);
   43|      2|    }
   44|      2|#endif
   45|      2|    return 1;
   46|      2|}

OBJ_sigid_free:
  134|      2|{
  135|      2|    sk_nid_triple_pop_free(sig_app, sid_free);
  136|      2|    sig_app = NULL;
  137|      2|    sk_nid_triple_free(sigx_app);
  138|      2|    sigx_app = NULL;
  139|      2|}

ERR_load_OCSP_strings:
   93|      2|{
   94|      2|#ifndef OPENSSL_NO_ERR
   95|      2|    if (ERR_func_error_string(OCSP_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (95:9): [True: 2, False: 0]
  ------------------
   96|      2|        ERR_load_strings_const(OCSP_str_functs);
   97|      2|        ERR_load_strings_const(OCSP_str_reasons);
   98|      2|    }
   99|      2|#endif
  100|      2|    return 1;
  101|      2|}

ERR_load_PEM_strings:
  122|      2|{
  123|      2|#ifndef OPENSSL_NO_ERR
  124|      2|    if (ERR_func_error_string(PEM_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (124:9): [True: 2, False: 0]
  ------------------
  125|      2|        ERR_load_strings_const(PEM_str_functs);
  126|      2|        ERR_load_strings_const(PEM_str_reasons);
  127|      2|    }
  128|      2|#endif
  129|      2|    return 1;
  130|      2|}

ERR_load_PKCS12_strings:
  109|      2|{
  110|      2|#ifndef OPENSSL_NO_ERR
  111|      2|    if (ERR_func_error_string(PKCS12_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (111:9): [True: 2, False: 0]
  ------------------
  112|      2|        ERR_load_strings_const(PKCS12_str_functs);
  113|      2|        ERR_load_strings_const(PKCS12_str_reasons);
  114|      2|    }
  115|      2|#endif
  116|      2|    return 1;
  117|      2|}

ERR_load_PKCS7_strings:
  148|      2|{
  149|      2|#ifndef OPENSSL_NO_ERR
  150|      2|    if (ERR_func_error_string(PKCS7_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (150:9): [True: 2, False: 0]
  ------------------
  151|      2|        ERR_load_strings_const(PKCS7_str_functs);
  152|      2|        ERR_load_strings_const(PKCS7_str_reasons);
  153|      2|    }
  154|      2|#endif
  155|      2|    return 1;
  156|      2|}

rand_drbg_cleanup_int:
  925|      2|{
  926|      2|    if (master_drbg != NULL) {
  ------------------
  |  Branch (926:9): [True: 0, False: 2]
  ------------------
  927|      0|        RAND_DRBG_free(master_drbg);
  928|      0|        master_drbg = NULL;
  929|       |
  930|      0|        CRYPTO_THREAD_cleanup_local(&private_drbg);
  931|      0|        CRYPTO_THREAD_cleanup_local(&public_drbg);
  932|      0|    }
  933|      2|}

ERR_load_RAND_strings:
  131|      2|{
  132|      2|#ifndef OPENSSL_NO_ERR
  133|      2|    if (ERR_func_error_string(RAND_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (133:9): [True: 2, False: 0]
  ------------------
  134|      2|        ERR_load_strings_const(RAND_str_functs);
  135|      2|        ERR_load_strings_const(RAND_str_reasons);
  136|      2|    }
  137|      2|#endif
  138|      2|    return 1;
  139|      2|}

rand_cleanup_int:
  345|      2|{
  346|      2|    const RAND_METHOD *meth = default_RAND_meth;
  347|       |
  348|      2|    if (!rand_inited)
  ------------------
  |  Branch (348:9): [True: 2, False: 0]
  ------------------
  349|      2|        return;
  350|       |
  351|      0|    if (meth != NULL && meth->cleanup != NULL)
  ------------------
  |  Branch (351:9): [True: 0, False: 0]
  |  Branch (351:25): [True: 0, False: 0]
  ------------------
  352|      0|        meth->cleanup();
  353|      0|    RAND_set_rand_method(NULL);
  354|      0|    rand_pool_cleanup();
  355|      0|#ifndef OPENSSL_NO_ENGINE
  356|      0|    CRYPTO_THREAD_lock_free(rand_engine_lock);
  357|      0|    rand_engine_lock = NULL;
  358|      0|#endif
  359|      0|    CRYPTO_THREAD_lock_free(rand_meth_lock);
  360|      0|    rand_meth_lock = NULL;
  361|      0|    CRYPTO_THREAD_lock_free(rand_nonce_lock);
  362|      0|    rand_nonce_lock = NULL;
  363|      0|    rand_inited = 0;
  364|      0|}

ERR_load_RSA_strings:
  240|      2|{
  241|      2|#ifndef OPENSSL_NO_ERR
  242|      2|    if (ERR_func_error_string(RSA_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (242:9): [True: 2, False: 0]
  ------------------
  243|      2|        ERR_load_strings_const(RSA_str_functs);
  244|      2|        ERR_load_strings_const(RSA_str_reasons);
  245|      2|    }
  246|      2|#endif
  247|      2|    return 1;
  248|      2|}

OPENSSL_sk_pop_free:
  361|     36|{
  362|     36|    int i;
  363|       |
  364|     36|    if (st == NULL)
  ------------------
  |  Branch (364:9): [True: 36, False: 0]
  ------------------
  365|     36|        return;
  366|      0|    for (i = 0; i < st->num; i++)
  ------------------
  |  Branch (366:17): [True: 0, False: 0]
  ------------------
  367|      0|        if (st->data[i] != NULL)
  ------------------
  |  Branch (367:13): [True: 0, False: 0]
  ------------------
  368|      0|            func((char *)st->data[i]);
  369|      0|    OPENSSL_sk_free(st);
  370|      0|}
OPENSSL_sk_free:
  373|      6|{
  374|      6|    if (st == NULL)
  ------------------
  |  Branch (374:9): [True: 6, False: 0]
  ------------------
  375|      6|        return;
  376|      0|    OPENSSL_free(st->data);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  377|      0|    OPENSSL_free(st);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  378|      0|}
OPENSSL_sk_num:
  381|     10|{
  382|     10|    return st == NULL ? -1 : st->num;
  ------------------
  |  Branch (382:12): [True: 10, False: 0]
  ------------------
  383|     10|}

ERR_load_OSSL_STORE_strings:
  138|      2|{
  139|      2|#ifndef OPENSSL_NO_ERR
  140|      2|    if (ERR_func_error_string(OSSL_STORE_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (140:9): [True: 2, False: 0]
  ------------------
  141|      2|        ERR_load_strings_const(OSSL_STORE_str_functs);
  142|      2|        ERR_load_strings_const(OSSL_STORE_str_reasons);
  143|      2|    }
  144|      2|#endif
  145|      2|    return 1;
  146|      2|}

ossl_store_cleanup_int:
   31|      2|{
   32|      2|    ossl_store_destroy_loaders_int();
   33|      2|}

ossl_store_destroy_loaders_int:
  278|      2|{
  279|      2|    assert(lh_OSSL_STORE_LOADER_num_items(loader_register) == 0);
  280|      2|    lh_OSSL_STORE_LOADER_free(loader_register);
  281|      2|    loader_register = NULL;
  282|      2|    CRYPTO_THREAD_lock_free(registry_lock);
  283|      2|    registry_lock = NULL;
  284|      2|}

CRYPTO_THREAD_lock_new:
   25|      8|{
   26|      8|# ifdef USE_RWLOCK
   27|      8|    CRYPTO_RWLOCK *lock;
   28|       |
   29|      8|    if ((lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t))) == NULL) {
  ------------------
  |  |  120|      8|        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      8|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      8|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  |  Branch (29:9): [True: 0, False: 8]
  ------------------
   30|       |        /* Don't set error, to avoid recursion blowup. */
   31|      0|        return NULL;
   32|      0|    }
   33|       |
   34|      8|    if (pthread_rwlock_init(lock, NULL) != 0) {
  ------------------
  |  Branch (34:9): [True: 0, False: 8]
  ------------------
   35|      0|        OPENSSL_free(lock);
  ------------------
  |  |  128|      0|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      0|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      0|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
   36|      0|        return NULL;
   37|      0|    }
   38|       |# else
   39|       |    pthread_mutexattr_t attr;
   40|       |    CRYPTO_RWLOCK *lock;
   41|       |
   42|       |    if ((lock = OPENSSL_zalloc(sizeof(pthread_mutex_t))) == NULL) {
   43|       |        /* Don't set error, to avoid recursion blowup. */
   44|       |        return NULL;
   45|       |    }
   46|       |
   47|       |    pthread_mutexattr_init(&attr);
   48|       |    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
   49|       |
   50|       |    if (pthread_mutex_init(lock, &attr) != 0) {
   51|       |        pthread_mutexattr_destroy(&attr);
   52|       |        OPENSSL_free(lock);
   53|       |        return NULL;
   54|       |    }
   55|       |
   56|       |    pthread_mutexattr_destroy(&attr);
   57|       |# endif
   58|       |
   59|      8|    return lock;
   60|      8|}
CRYPTO_THREAD_read_lock:
   63|     58|{
   64|     58|# ifdef USE_RWLOCK
   65|     58|    if (pthread_rwlock_rdlock(lock) != 0)
  ------------------
  |  Branch (65:9): [True: 0, False: 58]
  ------------------
   66|      0|        return 0;
   67|       |# else
   68|       |    if (pthread_mutex_lock(lock) != 0)
   69|       |        return 0;
   70|       |# endif
   71|       |
   72|     58|    return 1;
   73|     58|}
CRYPTO_THREAD_write_lock:
   76|    594|{
   77|    594|# ifdef USE_RWLOCK
   78|    594|    if (pthread_rwlock_wrlock(lock) != 0)
  ------------------
  |  Branch (78:9): [True: 0, False: 594]
  ------------------
   79|      0|        return 0;
   80|       |# else
   81|       |    if (pthread_mutex_lock(lock) != 0)
   82|       |        return 0;
   83|       |# endif
   84|       |
   85|    594|    return 1;
   86|    594|}
CRYPTO_THREAD_unlock:
   89|    652|{
   90|    652|# ifdef USE_RWLOCK
   91|    652|    if (pthread_rwlock_unlock(lock) != 0)
  ------------------
  |  Branch (91:9): [True: 0, False: 652]
  ------------------
   92|      0|        return 0;
   93|       |# else
   94|       |    if (pthread_mutex_unlock(lock) != 0)
   95|       |        return 0;
   96|       |# endif
   97|       |
   98|    652|    return 1;
   99|    652|}
CRYPTO_THREAD_lock_free:
  102|     16|{
  103|     16|    if (lock == NULL)
  ------------------
  |  Branch (103:9): [True: 10, False: 6]
  ------------------
  104|     10|        return;
  105|       |
  106|      6|# ifdef USE_RWLOCK
  107|      6|    pthread_rwlock_destroy(lock);
  108|       |# else
  109|       |    pthread_mutex_destroy(lock);
  110|       |# endif
  111|      6|    OPENSSL_free(lock);
  ------------------
  |  |  128|      6|        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  109|      6|#  define OPENSSL_FILE __FILE__
  |  |  ------------------
  |  |                       CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
  |  |  ------------------
  |  |  |  |  110|      6|#  define OPENSSL_LINE __LINE__
  |  |  ------------------
  ------------------
  112|       |
  113|      6|    return;
  114|     16|}
CRYPTO_THREAD_run_once:
  117|  41.8k|{
  118|  41.8k|    if (pthread_once(once, init) != 0)
  ------------------
  |  Branch (118:9): [True: 0, False: 41.8k]
  ------------------
  119|      0|        return 0;
  120|       |
  121|  41.8k|    return 1;
  122|  41.8k|}
CRYPTO_THREAD_init_local:
  125|      4|{
  126|      4|    if (pthread_key_create(key, cleanup) != 0)
  ------------------
  |  Branch (126:9): [True: 0, False: 4]
  ------------------
  127|      0|        return 0;
  128|       |
  129|      4|    return 1;
  130|      4|}
CRYPTO_THREAD_get_local:
  133|  20.8k|{
  134|  20.8k|    return pthread_getspecific(*key);
  135|  20.8k|}
CRYPTO_THREAD_set_local:
  138|     10|{
  139|     10|    if (pthread_setspecific(*key, val) != 0)
  ------------------
  |  Branch (139:9): [True: 0, False: 10]
  ------------------
  140|      0|        return 0;
  141|       |
  142|     10|    return 1;
  143|     10|}
CRYPTO_THREAD_cleanup_local:
  146|      4|{
  147|      4|    if (pthread_key_delete(*key) != 0)
  ------------------
  |  Branch (147:9): [True: 0, False: 4]
  ------------------
  148|      0|        return 0;
  149|       |
  150|      4|    return 1;
  151|      4|}

ERR_load_TS_strings:
  176|      2|{
  177|      2|#ifndef OPENSSL_NO_ERR
  178|      2|    if (ERR_func_error_string(TS_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (178:9): [True: 2, False: 0]
  ------------------
  179|      2|        ERR_load_strings_const(TS_str_functs);
  180|      2|        ERR_load_strings_const(TS_str_reasons);
  181|      2|    }
  182|      2|#endif
  183|      2|    return 1;
  184|      2|}

ERR_load_UI_strings:
   70|      2|{
   71|      2|#ifndef OPENSSL_NO_ERR
   72|      2|    if (ERR_func_error_string(UI_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (72:9): [True: 2, False: 0]
  ------------------
   73|      2|        ERR_load_strings_const(UI_str_functs);
   74|      2|        ERR_load_strings_const(UI_str_reasons);
   75|      2|    }
   76|      2|#endif
   77|      2|    return 1;
   78|      2|}

ERR_load_X509_strings:
  176|      2|{
  177|      2|#ifndef OPENSSL_NO_ERR
  178|      2|    if (ERR_func_error_string(X509_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (178:9): [True: 2, False: 0]
  ------------------
  179|      2|        ERR_load_strings_const(X509_str_functs);
  180|      2|        ERR_load_strings_const(X509_str_reasons);
  181|      2|    }
  182|      2|#endif
  183|      2|    return 1;
  184|      2|}

ERR_load_X509V3_strings:
  253|      2|{
  254|      2|#ifndef OPENSSL_NO_ERR
  255|      2|    if (ERR_func_error_string(X509V3_str_functs[0].error) == NULL) {
  ------------------
  |  Branch (255:9): [True: 2, False: 0]
  ------------------
  256|      2|        ERR_load_strings_const(X509V3_str_functs);
  257|      2|        ERR_load_strings_const(X509V3_str_reasons);
  258|      2|    }
  259|      2|#endif
  260|      2|    return 1;
  261|      2|}

FuzzerInitialize:
   25|      2|{
   26|      2|    bio_out = BIO_new_file("/dev/null", "w");
   27|      2|    OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
  ------------------
  |  |  357|      2|# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS    0x00000002L
  ------------------
   28|      2|    ERR_get_state();
   29|      2|    CRYPTO_free_ex_index(0, -1);
   30|      2|    return 1;
   31|      2|}
FuzzerTestOneInput:
   34|  2.58k|{
   35|  2.58k|    (void)ASN1_parse_dump(bio_out, buf, len, 0, 0);
   36|  2.58k|    ERR_clear_error();
   37|  2.58k|    return 0;
   38|  2.58k|}

LLVMFuzzerInitialize:
   22|      2|{
   23|      2|    return FuzzerInitialize(argc, argv);
   24|      2|}
LLVMFuzzerTestOneInput:
   27|  2.58k|{
   28|  2.58k|    return FuzzerTestOneInput(buf, len);
   29|  2.58k|}

b_print.c:ossl_assert_int:
   33|   144M|{
   34|   144M|    if (!expr)
  ------------------
  |  Branch (34:9): [True: 0, False: 144M]
  ------------------
   35|      0|        OPENSSL_die(exprstr, file, line);
   36|       |
   37|   144M|    return expr;
   38|   144M|}

err.c:do_err_strings_init_ossl_:
   62|      2|    {                                           \
   63|      2|        init##_ossl_ret_ = init();              \
   64|      2|    }                                           \
err.c:err_do_init_ossl_:
   62|      2|    {                                           \
   63|      2|        init##_ossl_ret_ = init();              \
   64|      2|    }                                           \
ex_data.c:do_ex_data_init_ossl_:
   62|      2|    {                                           \
   63|      2|        init##_ossl_ret_ = init();              \
   64|      2|    }                                           \
init.c:ossl_init_base_ossl_:
   62|      2|    {                                           \
   63|      2|        init##_ossl_ret_ = init();              \
   64|      2|    }                                           \
init.c:ossl_init_register_atexit_ossl_:
   62|      2|    {                                           \
   63|      2|        init##_ossl_ret_ = init();              \
   64|      2|    }                                           \
init.c:ossl_init_load_crypto_nodelete_ossl_:
   62|      2|    {                                           \
   63|      2|        init##_ossl_ret_ = init();              \
   64|      2|    }                                           \
init.c:ossl_init_load_crypto_strings_ossl_:
   62|      2|    {                                           \
   63|      2|        init##_ossl_ret_ = init();              \
   64|      2|    }                                           \

d2i_ASN1_OCTET_STRING:
  836|  2.43k|        { \
  837|  2.43k|                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
  ------------------
  |  |  326|  2.43k|#  define ASN1_ITEM_rptr(ref) (&(ref##_it))
  ------------------
  838|  2.43k|        } \
d2i_ASN1_INTEGER:
  836|  36.6k|        { \
  837|  36.6k|                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
  ------------------
  |  |  326|  36.6k|#  define ASN1_ITEM_rptr(ref) (&(ref##_it))
  ------------------
  838|  36.6k|        } \
d2i_ASN1_ENUMERATED:
  836|  1.43k|        { \
  837|  1.43k|                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
  ------------------
  |  |  326|  1.43k|#  define ASN1_ITEM_rptr(ref) (&(ref##_it))
  ------------------
  838|  1.43k|        } \
ASN1_TYPE_free:
  826|  1.41k|        { \
  827|  1.41k|                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
  ------------------
  |  |  326|  1.41k|#  define ASN1_ITEM_rptr(ref) (&(ref##_it))
  ------------------
  828|  1.41k|        }

err.c:lh_ERR_STRING_DATA_free:
  130|      2|    { \
  131|      2|        OPENSSL_LH_free((OPENSSL_LHASH *)lh); \
  132|      2|    } \
err.c:lh_ERR_STRING_DATA_new:
  125|      2|    { \
  126|      2|        return (LHASH_OF(type) *) \
  127|      2|            OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn); \
  128|      2|    } \
err.c:lh_ERR_STRING_DATA_insert:
  134|  15.1k|    { \
  135|  15.1k|        return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \
  136|  15.1k|    } \
err.c:lh_ERR_STRING_DATA_retrieve:
  142|     58|    { \
  143|     58|        return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \
  144|     58|    } \
store_register.c:lh_OSSL_STORE_LOADER_num_items:
  150|      2|    { \
  151|      2|        return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \
  152|      2|    } \
store_register.c:lh_OSSL_STORE_LOADER_free:
  130|      2|    { \
  131|      2|        OPENSSL_LH_free((OPENSSL_LHASH *)lh); \
  132|      2|    } \

obj_dat.c:OBJ_bsearch_obj:
  121|  16.8k|      { \
  122|  16.8k|      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \
  123|  16.8k|                                        nm##_cmp_BSEARCH_CMP_FN); \
  124|  16.8k|      } \
obj_dat.c:obj_cmp_BSEARCH_CMP_FN:
  115|   164k|      { \
  116|   164k|      type1 const *a = a_; \
  117|   164k|      type2 const *b = b_; \
  118|   164k|      return nm##_cmp(a,b); \
  119|   164k|      } \

ex_data.c:sk_EX_CALLBACK_pop_free:
   85|     32|    { \
   86|     32|        OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \
   87|     32|    } \
ex_data.c:sk_EX_CALLBACK_num:
   28|      2|    { \
   29|      2|        return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \
   30|      2|    } \
conf_mod.c:sk_CONF_MODULE_num:
   28|      4|    { \
   29|      4|        return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \
   30|      4|    } \
conf_mod.c:sk_CONF_IMODULE_num:
   28|      4|    { \
   29|      4|        return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \
   30|      4|    } \
conf_mod.c:sk_CONF_IMODULE_free:
   52|      4|    { \
   53|      4|        OPENSSL_sk_free((OPENSSL_STACK *)sk); \
   54|      4|    } \
obj_xref.c:sk_nid_triple_pop_free:
   85|      2|    { \
   86|      2|        OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \
   87|      2|    } \
obj_xref.c:sk_nid_triple_free:
   52|      2|    { \
   53|      2|        OPENSSL_sk_free((OPENSSL_STACK *)sk); \
   54|      2|    } \
evp_pbe.c:sk_EVP_PBE_CTL_pop_free:
   85|      2|    { \
   86|      2|        OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \
   87|      2|    } \

