crypto/modes/ocb128.c:354: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `ocb_lookup_l`.
Showing all 7 steps of the trace


crypto/modes/ocb128.c:354:36: Call
352.   
353.           /* Offset_i = Offset_{i-1} xor L_{ntz(i)} */
354.           lookup = ocb_lookup_l(ctx, ocb_ntz(i));
                                          ^
355.           if (!lookup)
356.               return 0;

crypto/modes/ocb128.c:66:5: Assignment
  64.   static u32 ocb_ntz(u64 n)
  65.   {
  66.       u32 cnt = 0;
            ^
  67.   
  68.       /*

crypto/modes/ocb128.c:80:5: Assignment
  78.           cnt++;
  79.       }
  80.       return cnt;
            ^
  81.   }
  82.   

crypto/modes/ocb128.c:354:18: Call
352.   
353.           /* Offset_i = Offset_{i-1} xor L_{ntz(i)} */
354.           lookup = ocb_lookup_l(ctx, ocb_ntz(i));
                        ^
355.           if (!lookup)
356.               return 0;

crypto/modes/ocb128.c:154:1: <LHS trace>
152.    * calculate it
153.    */
154. > static OCB_BLOCK *ocb_lookup_l(OCB128_CONTEXT *ctx, size_t idx)
155.   {
156.       if (idx <= ctx->l_index) {

crypto/modes/ocb128.c:154:1: Parameter `idx`
  152.    * calculate it
  153.    */
  154. > static OCB_BLOCK *ocb_lookup_l(OCB128_CONTEXT *ctx, size_t idx)
  155.   {
  156.       if (idx <= ctx->l_index) {

crypto/modes/ocb128.c:169:5: Binary operation: ([0, +oo] - 1):unsigned64 by call to `ocb_lookup_l` 
  167.               return NULL;
  168.       }
  169.       ocb_double(ctx->l + (idx - 1), ctx->l + idx);
             ^
  170.   
  171.       return ctx->l + idx;

static OCB_BLOCK *ocb_lookup_l(OCB128_CONTEXT *ctx, size_t idx)
{
    if (idx <= ctx->l_index) {
        return ctx->l + idx;
    }
    ctx->l_index++;
    if (ctx->l_index == ctx->max_l_index) {
        ctx->max_l_index *= 2;
        ctx->l =
            OPENSSL_realloc(ctx->l, ctx->max_l_index * sizeof(OCB_BLOCK));
        if (!ctx->l)
            return NULL;
    }
    ocb_double(ctx->l + (idx - 1), ctx->l + idx);
    return ctx->l + idx;
}
['int CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad,\n                      size_t len)\n{\n    u64 all_num_blocks, num_blocks;\n    u64 i;\n    OCB_BLOCK tmp1;\n    OCB_BLOCK tmp2;\n    int last_len;\n    num_blocks = len / 16;\n    all_num_blocks = num_blocks + ctx->blocks_hashed;\n    for (i = ctx->blocks_hashed + 1; i <= all_num_blocks; i++) {\n        OCB_BLOCK *lookup;\n        OCB_BLOCK *aad_block;\n        lookup = ocb_lookup_l(ctx, ocb_ntz(i));\n        if (!lookup)\n            return 0;\n        ocb_block16_xor(&ctx->offset_aad, lookup, &ctx->offset_aad);\n        aad_block = (OCB_BLOCK *)(aad + ((i - ctx->blocks_hashed - 1) * 16));\n        ocb_block16_xor(&ctx->offset_aad, aad_block, &tmp1);\n        ocb_encrypt(ctx, &tmp1, &tmp2, ctx->keyenc);\n        ocb_block16_xor(&ctx->sum, &tmp2, &ctx->sum);\n    }\n    last_len = len % 16;\n    if (last_len > 0) {\n        ocb_block16_xor(&ctx->offset_aad, &ctx->l_star, &ctx->offset_aad);\n        memset((void *)&tmp1, 0, 16);\n        memcpy((void *)&tmp1, aad + (num_blocks * 16), last_len);\n        ((unsigned char *)&tmp1)[last_len] = 0x80;\n        ocb_block16_xor(&ctx->offset_aad, &tmp1, &tmp2);\n        ocb_encrypt(ctx, &tmp2, &tmp1, ctx->keyenc);\n        ocb_block16_xor(&ctx->sum, &tmp1, &ctx->sum);\n    }\n    ctx->blocks_hashed = all_num_blocks;\n    return 1;\n}', 'static u32 ocb_ntz(u64 n)\n{\n    u32 cnt = 0;\n    while (!(n & 1)) {\n        n >>= 1;\n        cnt++;\n    }\n    return cnt;\n}', 'static OCB_BLOCK *ocb_lookup_l(OCB128_CONTEXT *ctx, size_t idx)\n{\n    if (idx <= ctx->l_index) {\n        return ctx->l + idx;\n    }\n    ctx->l_index++;\n    if (ctx->l_index == ctx->max_l_index) {\n        ctx->max_l_index *= 2;\n        ctx->l =\n            OPENSSL_realloc(ctx->l, ctx->max_l_index * sizeof(OCB_BLOCK));\n        if (!ctx->l)\n            return NULL;\n    }\n    ocb_double(ctx->l + (idx - 1), ctx->l + idx);\n    return ctx->l + idx;\n}']