test/drbgtest.c:308: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64.
Showing all 5 steps of the trace


test/drbgtest.c:280:10: <LHS trace>
278.       int ret = 0;
279.   
280.       if (!TEST_ptr(dctx = RAND_DRBG_new(0, 0, NULL)))
                ^
281.           goto err;
282.   

test/drbgtest.c:280:10: Call
278.       int ret = 0;
279.   
280.       if (!TEST_ptr(dctx = RAND_DRBG_new(0, 0, NULL)))
                ^
281.           goto err;
282.   

crypto/rand/drbg_lib.c:99:9: Call
  97.   
  98.       dctx->parent = parent;
  99.       if (RAND_DRBG_set(dctx, type, flags) < 0) {
                 ^
  100.           OPENSSL_free(dctx);
  101.           return NULL;

crypto/rand/drbg_lib.c:58:1: Parameter `dctx->min_entropy`
    56.    * failure.
    57.    */
    58. > int RAND_DRBG_set(DRBG_CTX *dctx, int nid, unsigned int flags)
    59.   {
    60.       int ret = 1;

test/drbgtest.c:308:5: Binary operation: ([0, +oo] - 1):unsigned64
306.   
307.       /* Test insufficient entropy */
308.       t.entlen = dctx->min_entropy - 1;
           ^
309.       if (!init(dctx, td, &t)
310.               || RAND_DRBG_instantiate(dctx, td->pers, td->perslen) > 0

static int error_check(DRBG_SELFTEST_DATA *td)
{
    static char zero[sizeof(DRBG_CTX)];
    DRBG_CTX *dctx = NULL;
    TEST_CTX t;
    unsigned char buff[1024];
    unsigned int reseed_counter_tmp;
    int ret = 0;
    if (!TEST_ptr(dctx = RAND_DRBG_new(0, 0, NULL)))
        goto err;
    if (!init(dctx, td, &t)
            || RAND_DRBG_instantiate(dctx, td->pers, dctx->max_pers + 1) > 0)
        goto err;
    t.entlen = 0;
    if (TEST_int_le(RAND_DRBG_instantiate(dctx, td->pers, td->perslen), 0))
        goto err;
    if (!TEST_false(RAND_DRBG_generate(dctx, buff, td->exlen, 0,
                                       td->adin, td->adinlen))
            || !uninstantiate(dctx))
        goto err;
    t.entlen = dctx->min_entropy - 1;
    if (!init(dctx, td, &t)
            || RAND_DRBG_instantiate(dctx, td->pers, td->perslen) > 0
            || !uninstantiate(dctx))
        goto err;
    t.entlen = dctx->max_entropy + 1;
    if (!init(dctx, td, &t)
            || RAND_DRBG_instantiate(dctx, td->pers, td->perslen) > 0
            || !uninstantiate(dctx))
        goto err;
    if (dctx->min_nonce) {
        t.noncelen = dctx->min_nonce - 1;
        if (!init(dctx, td, &t)
                || RAND_DRBG_instantiate(dctx, td->pers, td->perslen) > 0
                || !uninstantiate(dctx))
            goto err;
    }
    if (dctx->max_nonce) {
        t.noncelen = dctx->max_nonce + 1;
        if (!init(dctx, td, &t)
                || RAND_DRBG_instantiate(dctx, td->pers, td->perslen) > 0
                || !uninstantiate(dctx))
            goto err;
    }
    if (!instantiate(dctx, td, &t)
            || !TEST_true(RAND_DRBG_generate(dctx, buff, td->exlen, 0,
                                             td->adin, td->adinlen)))
        goto err;
    if (!TEST_false(RAND_DRBG_generate(dctx, buff, dctx->max_request + 1, 0,
                                       td->adin, td->adinlen)))
        goto err;
    if (!TEST_false(RAND_DRBG_generate(dctx, buff, td->exlen, 0,
                                       td->adin, dctx->max_adin + 1)))
        goto err;
    t.entlen = 0;
    if (TEST_false(RAND_DRBG_generate(dctx, buff, td->exlen, 1,
                                      td->adin, td->adinlen))
            || !uninstantiate(dctx))
        goto err;
    if (!instantiate(dctx, td, &t))
        goto err;
    reseed_counter_tmp = dctx->reseed_counter;
    dctx->reseed_counter = dctx->reseed_interval;
    t.entcnt = 0;
    if (!TEST_true(RAND_DRBG_generate(dctx, buff, td->exlen, 0,
                                      td->adin, td->adinlen))
            || !TEST_int_eq(t.entcnt, 1)
            || !TEST_int_eq(dctx->reseed_counter, reseed_counter_tmp + 1)
            || !uninstantiate(dctx))
        goto err;
    t.entlen = 0;
    if (!TEST_false(RAND_DRBG_generate(dctx, buff, td->exlen, 1,
                                       td->adin, td->adinlen))
            || !uninstantiate(dctx))
        goto err;
    if (!instantiate(dctx, td, &t))
        goto err;
    reseed_counter_tmp = dctx->reseed_counter;
    dctx->reseed_counter = dctx->reseed_interval;
    t.entcnt = 0;
    if (!TEST_true(RAND_DRBG_generate(dctx, buff, td->exlen, 0,
                                      td->adin, td->adinlen))
            || !TEST_int_eq(t.entcnt, 1)
            || !TEST_int_eq(dctx->reseed_counter, reseed_counter_tmp + 1)
            || !uninstantiate(dctx))
        goto err;
    if (!init(dctx, td, &t)
            || RAND_DRBG_reseed(dctx, td->adin, dctx->max_adin + 1) > 0)
        goto err;
    t.entlen = 0;
    if (!TEST_int_le(RAND_DRBG_reseed(dctx, td->adin, td->adinlen), 0)
            || !uninstantiate(dctx))
        goto err;
    if (!init(dctx, td, &t))
        goto err;
    t.entlen = dctx->max_entropy + 1;
    if (!TEST_int_le(RAND_DRBG_reseed(dctx, td->adin, td->adinlen), 0)
            || !uninstantiate(dctx))
        goto err;
    if (!init(dctx, td, &t))
        goto err;
    t.entlen = dctx->min_entropy - 1;
    if (!TEST_int_le(RAND_DRBG_reseed(dctx, td->adin, td->adinlen), 0)
            || !uninstantiate(dctx))
        goto err;
    if (!TEST_mem_eq(zero, sizeof(dctx->ctr), &dctx->ctr, sizeof(dctx->ctr)))
        goto err;
    ret = 1;
err:
    uninstantiate(dctx);
    RAND_DRBG_free(dctx);
    return ret;
}
['static int error_check(DRBG_SELFTEST_DATA *td)\n{\n    static char zero[sizeof(DRBG_CTX)];\n    DRBG_CTX *dctx = NULL;\n    TEST_CTX t;\n    unsigned char buff[1024];\n    unsigned int reseed_counter_tmp;\n    int ret = 0;\n    if (!TEST_ptr(dctx = RAND_DRBG_new(0, 0, NULL)))\n        goto err;\n    if (!init(dctx, td, &t)\n            || RAND_DRBG_instantiate(dctx, td->pers, dctx->max_pers + 1) > 0)\n        goto err;\n    t.entlen = 0;\n    if (TEST_int_le(RAND_DRBG_instantiate(dctx, td->pers, td->perslen), 0))\n        goto err;\n    if (!TEST_false(RAND_DRBG_generate(dctx, buff, td->exlen, 0,\n                                       td->adin, td->adinlen))\n            || !uninstantiate(dctx))\n        goto err;\n    t.entlen = dctx->min_entropy - 1;\n    if (!init(dctx, td, &t)\n            || RAND_DRBG_instantiate(dctx, td->pers, td->perslen) > 0\n            || !uninstantiate(dctx))\n        goto err;\n    t.entlen = dctx->max_entropy + 1;\n    if (!init(dctx, td, &t)\n            || RAND_DRBG_instantiate(dctx, td->pers, td->perslen) > 0\n            || !uninstantiate(dctx))\n        goto err;\n    if (dctx->min_nonce) {\n        t.noncelen = dctx->min_nonce - 1;\n        if (!init(dctx, td, &t)\n                || RAND_DRBG_instantiate(dctx, td->pers, td->perslen) > 0\n                || !uninstantiate(dctx))\n            goto err;\n    }\n    if (dctx->max_nonce) {\n        t.noncelen = dctx->max_nonce + 1;\n        if (!init(dctx, td, &t)\n                || RAND_DRBG_instantiate(dctx, td->pers, td->perslen) > 0\n                || !uninstantiate(dctx))\n            goto err;\n    }\n    if (!instantiate(dctx, td, &t)\n            || !TEST_true(RAND_DRBG_generate(dctx, buff, td->exlen, 0,\n                                             td->adin, td->adinlen)))\n        goto err;\n    if (!TEST_false(RAND_DRBG_generate(dctx, buff, dctx->max_request + 1, 0,\n                                       td->adin, td->adinlen)))\n        goto err;\n    if (!TEST_false(RAND_DRBG_generate(dctx, buff, td->exlen, 0,\n                                       td->adin, dctx->max_adin + 1)))\n        goto err;\n    t.entlen = 0;\n    if (TEST_false(RAND_DRBG_generate(dctx, buff, td->exlen, 1,\n                                      td->adin, td->adinlen))\n            || !uninstantiate(dctx))\n        goto err;\n    if (!instantiate(dctx, td, &t))\n        goto err;\n    reseed_counter_tmp = dctx->reseed_counter;\n    dctx->reseed_counter = dctx->reseed_interval;\n    t.entcnt = 0;\n    if (!TEST_true(RAND_DRBG_generate(dctx, buff, td->exlen, 0,\n                                      td->adin, td->adinlen))\n            || !TEST_int_eq(t.entcnt, 1)\n            || !TEST_int_eq(dctx->reseed_counter, reseed_counter_tmp + 1)\n            || !uninstantiate(dctx))\n        goto err;\n    t.entlen = 0;\n    if (!TEST_false(RAND_DRBG_generate(dctx, buff, td->exlen, 1,\n                                       td->adin, td->adinlen))\n            || !uninstantiate(dctx))\n        goto err;\n    if (!instantiate(dctx, td, &t))\n        goto err;\n    reseed_counter_tmp = dctx->reseed_counter;\n    dctx->reseed_counter = dctx->reseed_interval;\n    t.entcnt = 0;\n    if (!TEST_true(RAND_DRBG_generate(dctx, buff, td->exlen, 0,\n                                      td->adin, td->adinlen))\n            || !TEST_int_eq(t.entcnt, 1)\n            || !TEST_int_eq(dctx->reseed_counter, reseed_counter_tmp + 1)\n            || !uninstantiate(dctx))\n        goto err;\n    if (!init(dctx, td, &t)\n            || RAND_DRBG_reseed(dctx, td->adin, dctx->max_adin + 1) > 0)\n        goto err;\n    t.entlen = 0;\n    if (!TEST_int_le(RAND_DRBG_reseed(dctx, td->adin, td->adinlen), 0)\n            || !uninstantiate(dctx))\n        goto err;\n    if (!init(dctx, td, &t))\n        goto err;\n    t.entlen = dctx->max_entropy + 1;\n    if (!TEST_int_le(RAND_DRBG_reseed(dctx, td->adin, td->adinlen), 0)\n            || !uninstantiate(dctx))\n        goto err;\n    if (!init(dctx, td, &t))\n        goto err;\n    t.entlen = dctx->min_entropy - 1;\n    if (!TEST_int_le(RAND_DRBG_reseed(dctx, td->adin, td->adinlen), 0)\n            || !uninstantiate(dctx))\n        goto err;\n    if (!TEST_mem_eq(zero, sizeof(dctx->ctr), &dctx->ctr, sizeof(dctx->ctr)))\n        goto err;\n    ret = 1;\nerr:\n    uninstantiate(dctx);\n    RAND_DRBG_free(dctx);\n    return ret;\n}', 'DRBG_CTX *RAND_DRBG_new(int type, unsigned int flags, DRBG_CTX *parent)\n{\n    DRBG_CTX *dctx = OPENSSL_zalloc(sizeof(*dctx));\n    if (dctx == NULL) {\n        RANDerr(RAND_F_RAND_DRBG_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    dctx->parent = parent;\n    if (RAND_DRBG_set(dctx, type, flags) < 0) {\n        OPENSSL_free(dctx);\n        return NULL;\n    }\n    return dctx;\n}', 'int RAND_DRBG_set(DRBG_CTX *dctx, int nid, unsigned int flags)\n{\n    int ret = 1;\n    dctx->status = DRBG_STATUS_UNINITIALISED;\n    dctx->flags = flags;\n    dctx->nid = nid;\n    switch (nid) {\n    default:\n        RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_UNSUPPORTED_DRBG_TYPE);\n        return -2;\n    case 0:\n        return 1;\n    case NID_aes_128_ctr:\n    case NID_aes_192_ctr:\n    case NID_aes_256_ctr:\n        ret = ctr_init(dctx);\n        break;\n    }\n    if (ret < 0)\n        RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_ERROR_INITIALISING_DRBG);\n    return ret;\n}']