crypto/rand/drbg_lib.c:401: error: INTEGER_OVERFLOW_L2
  ([1, max(1, `adinlen`)] - [min(16, `drbg->ctr.keylen`), max(32, `drbg->ctr.keylen`)]):unsigned64 by call to `ctr_generate`.
Showing all 11 steps of the trace


crypto/rand/drbg_lib.c:355:1: Parameter `adinlen`
353.    *
354.    */
355. > int RAND_DRBG_generate(RAND_DRBG *drbg, unsigned char *out, size_t outlen,
356.                          int prediction_resistance,
357.                          const unsigned char *adin, size_t adinlen)

crypto/rand/drbg_lib.c:401:10: Call
399.       }
400.   
401.       if (!ctr_generate(drbg, out, outlen, adin, adinlen)) {
                ^
402.           drbg->state = DRBG_ERROR;
403.           RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_GENERATE_ERROR);

crypto/rand/drbg_rand.c:266:1: Parameter `adinlen`
  264.   }
  265.   
  266. > int ctr_generate(RAND_DRBG *drbg,
  267.                    unsigned char *out, size_t outlen,
  268.                    const unsigned char *adin, size_t adinlen)

crypto/rand/drbg_rand.c:298:5: Call
  296.       }
  297.   
  298.       ctr_update(drbg, adin, adinlen, NULL, 0, NULL, 0);
             ^
  299.       return 1;
  300.   }

crypto/rand/drbg_rand.c:199:1: Parameter `in1len`
    197.    * so we handle both cases in this function instead.
    198.    */
    199. > static void ctr_update(RAND_DRBG *drbg,
    200.                          const unsigned char *in1, size_t in1len,
    201.                          const unsigned char *in2, size_t in2len,

crypto/rand/drbg_rand.c:232:9: Call
    230.               ctr_XOR(ctr, ctr->KX, drbg->seedlen);
    231.       } else {
    232.           ctr_XOR(ctr, in1, in1len);
                   ^
    233.           ctr_XOR(ctr, in2, in2len);
    234.       }

crypto/rand/drbg_rand.c:39:1: <LHS trace>
37.   }
38.   
39. > static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
40.   {
41.       size_t i, n;

crypto/rand/drbg_rand.c:39:1: Parameter `inlen`
      37.   }
      38.   
      39. > static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
      40.   {
      41.       size_t i, n;

crypto/rand/drbg_rand.c:39:1: <RHS trace>
37.   }
38.   
39. > static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
40.   {
41.       size_t i, n;

crypto/rand/drbg_rand.c:39:1: Parameter `inlen`
      37.   }
      38.   
      39. > static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
      40.   {
      41.       size_t i, n;

crypto/rand/drbg_rand.c:56:5: Binary operation: ([1, max(1, adinlen)] - [min(16, drbg->ctr.keylen), max(32, drbg->ctr.keylen)]):unsigned64 by call to `ctr_generate` 
      54.           return;
      55.   
      56.       n = inlen - ctr->keylen;
                ^
      57.       if (n > 16) {
      58.           /* Should never happen */

static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
{
    size_t i, n;
    if (in == NULL || inlen == 0)
        return;
    n = inlen < ctr->keylen ? inlen : ctr->keylen;
    for (i = 0; i < n; i++)
        ctr->K[i] ^= in[i];
    if (inlen <= ctr->keylen)
        return;
    n = inlen - ctr->keylen;
    if (n > 16) {
        n = 16;
    }
    for (i = 0; i < n; i++)
        ctr->V[i] ^= in[i + ctr->keylen];
}
['int RAND_DRBG_generate(RAND_DRBG *drbg, unsigned char *out, size_t outlen,\n                       int prediction_resistance,\n                       const unsigned char *adin, size_t adinlen)\n{\n    int reseed_required = 0;\n    if (drbg->state != DRBG_READY) {\n        rand_drbg_restart(drbg, NULL, 0, 0);\n        if (drbg->state == DRBG_ERROR) {\n            RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_IN_ERROR_STATE);\n            return 0;\n        }\n        if (drbg->state == DRBG_UNINITIALISED) {\n            RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_NOT_INSTANTIATED);\n            return 0;\n        }\n    }\n    if (outlen > drbg->max_request) {\n        RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_REQUEST_TOO_LARGE_FOR_DRBG);\n        return 0;\n    }\n    if (adinlen > drbg->max_adinlen) {\n        RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_ADDITIONAL_INPUT_TOO_LONG);\n        return 0;\n    }\n    if (drbg->fork_count != rand_fork_count) {\n        drbg->fork_count = rand_fork_count;\n        reseed_required = 1;\n    }\n    if (drbg->reseed_counter >= drbg->reseed_interval)\n        reseed_required = 1;\n    if (reseed_required || prediction_resistance) {\n        if (!RAND_DRBG_reseed(drbg, adin, adinlen)) {\n            RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_RESEED_ERROR);\n            return 0;\n        }\n        adin = NULL;\n        adinlen = 0;\n    }\n    if (!ctr_generate(drbg, out, outlen, adin, adinlen)) {\n        drbg->state = DRBG_ERROR;\n        RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_GENERATE_ERROR);\n        return 0;\n    }\n    drbg->reseed_counter++;\n    return 1;\n}', 'int ctr_generate(RAND_DRBG *drbg,\n                 unsigned char *out, size_t outlen,\n                 const unsigned char *adin, size_t adinlen)\n{\n    RAND_DRBG_CTR *ctr = &drbg->ctr;\n    if (adin != NULL && adinlen != 0) {\n        ctr_update(drbg, adin, adinlen, NULL, 0, NULL, 0);\n        if (drbg->flags & RAND_DRBG_FLAG_CTR_USE_DF) {\n            adin = NULL;\n            adinlen = 1;\n        }\n    } else {\n        adinlen = 0;\n    }\n    for ( ; ; ) {\n        inc_128(ctr);\n        if (outlen < 16) {\n            AES_encrypt(ctr->V, ctr->K, &ctr->ks);\n            memcpy(out, ctr->K, outlen);\n            break;\n        }\n        AES_encrypt(ctr->V, out, &ctr->ks);\n        out += 16;\n        outlen -= 16;\n        if (outlen == 0)\n            break;\n    }\n    ctr_update(drbg, adin, adinlen, NULL, 0, NULL, 0);\n    return 1;\n}', 'static void ctr_update(RAND_DRBG *drbg,\n                       const unsigned char *in1, size_t in1len,\n                       const unsigned char *in2, size_t in2len,\n                       const unsigned char *nonce, size_t noncelen)\n{\n    RAND_DRBG_CTR *ctr = &drbg->ctr;\n    inc_128(ctr);\n    AES_encrypt(ctr->V, ctr->K, &ctr->ks);\n    if (ctr->keylen != 16) {\n        inc_128(ctr);\n        AES_encrypt(ctr->V, ctr->K + 16, &ctr->ks);\n    }\n    inc_128(ctr);\n    AES_encrypt(ctr->V, ctr->V, &ctr->ks);\n    if (ctr->keylen == 24) {\n        memcpy(ctr->V + 8, ctr->V, 8);\n        memcpy(ctr->V, ctr->K + 24, 8);\n    }\n    if (drbg->flags & RAND_DRBG_FLAG_CTR_USE_DF) {\n        if (in1 != NULL || nonce != NULL || in2 != NULL)\n            ctr_df(ctr, in1, in1len, nonce, noncelen, in2, in2len);\n        if (in1len)\n            ctr_XOR(ctr, ctr->KX, drbg->seedlen);\n    } else {\n        ctr_XOR(ctr, in1, in1len);\n        ctr_XOR(ctr, in2, in2len);\n    }\n    AES_set_encrypt_key(ctr->K, drbg->strength, &ctr->ks);\n}', 'static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)\n{\n    size_t i, n;\n    if (in == NULL || inlen == 0)\n        return;\n    n = inlen < ctr->keylen ? inlen : ctr->keylen;\n    for (i = 0; i < n; i++)\n        ctr->K[i] ^= in[i];\n    if (inlen <= ctr->keylen)\n        return;\n    n = inlen - ctr->keylen;\n    if (n > 16) {\n        n = 16;\n    }\n    for (i = 0; i < n; i++)\n        ctr->V[i] ^= in[i + ctr->keylen];\n}']