crypto/modes/gcm128.c:845: error: BUFFER_OVERRUN_L3
  Offset added: 12 Size: [0, +oo].
Showing all 3 steps of the trace


crypto/modes/gcm128.c:827:1: <Length trace>
825.   }
826.   
827. > void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,
828.                            size_t len)
829.   {

crypto/modes/gcm128.c:827:1: Parameter `ctx->Yi.c[*]`
825.   }
826.   
827. > void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,
828.                            size_t len)
829.   {

crypto/modes/gcm128.c:845:9: Array access: Offset added: 12 Size: [0, +oo]
843.   
844.       if (len == 12) {
845.           memcpy(ctx->Yi.c, iv, 12);
               ^
846.           ctx->Yi.c[12] = 0;
847.           ctx->Yi.c[13] = 0;

void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,
                         size_t len)
{
    const union {
        long one;
        char little;
    } is_endian = { 1 };
    unsigned int ctr;
#ifdef GCM_FUNCREF_4BIT
    void (*gcm_gmult_p) (u64 Xi[2], const u128 Htable[16]) = ctx->gmult;
#endif
    ctx->len.u[0] = 0;
    ctx->len.u[1] = 0;
    ctx->ares = 0;
    ctx->mres = 0;
    if (len == 12) {
        memcpy(ctx->Yi.c, iv, 12);
        ctx->Yi.c[12] = 0;
        ctx->Yi.c[13] = 0;
        ctx->Yi.c[14] = 0;
        ctx->Yi.c[15] = 1;
        ctr = 1;
    } else {
        size_t i;
        u64 len0 = len;
        ctx->Xi.u[0] = 0;
        ctx->Xi.u[1] = 0;
        while (len >= 16) {
            for (i = 0; i < 16; ++i)
                ctx->Xi.c[i] ^= iv[i];
            GCM_MUL(ctx);
            iv += 16;
            len -= 16;
        }
        if (len) {
            for (i = 0; i < len; ++i)
                ctx->Xi.c[i] ^= iv[i];
            GCM_MUL(ctx);
        }
        len0 <<= 3;
        if (is_endian.little) {
#ifdef BSWAP8
            ctx->Xi.u[1] ^= BSWAP8(len0);
#else
            ctx->Xi.c[8] ^= (u8)(len0 >> 56);
            ctx->Xi.c[9] ^= (u8)(len0 >> 48);
            ctx->Xi.c[10] ^= (u8)(len0 >> 40);
            ctx->Xi.c[11] ^= (u8)(len0 >> 32);
            ctx->Xi.c[12] ^= (u8)(len0 >> 24);
            ctx->Xi.c[13] ^= (u8)(len0 >> 16);
            ctx->Xi.c[14] ^= (u8)(len0 >> 8);
            ctx->Xi.c[15] ^= (u8)(len0);
#endif
        } else {
            ctx->Xi.u[1] ^= len0;
        }
        GCM_MUL(ctx);
        if (is_endian.little)
#ifdef BSWAP4
            ctr = BSWAP4(ctx->Xi.d[3]);
#else
            ctr = GETU32(ctx->Xi.c + 12);
#endif
        else
            ctr = ctx->Xi.d[3];
        ctx->Yi.u[0] = ctx->Xi.u[0];
        ctx->Yi.u[1] = ctx->Xi.u[1];
    }
    ctx->Xi.u[0] = 0;
    ctx->Xi.u[1] = 0;
    (*ctx->block) (ctx->Yi.c, ctx->EK0.c, ctx->key);
    ++ctr;
    if (is_endian.little)
#ifdef BSWAP4
        ctx->Yi.d[3] = BSWAP4(ctr);
#else
        PUTU32(ctx->Yi.c + 12, ctr);
#endif
    else
        ctx->Yi.d[3] = ctr;
}
['void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,\n                         size_t len)\n{\n    const union {\n        long one;\n        char little;\n    } is_endian = { 1 };\n    unsigned int ctr;\n#ifdef GCM_FUNCREF_4BIT\n    void (*gcm_gmult_p) (u64 Xi[2], const u128 Htable[16]) = ctx->gmult;\n#endif\n    ctx->len.u[0] = 0;\n    ctx->len.u[1] = 0;\n    ctx->ares = 0;\n    ctx->mres = 0;\n    if (len == 12) {\n        memcpy(ctx->Yi.c, iv, 12);\n        ctx->Yi.c[12] = 0;\n        ctx->Yi.c[13] = 0;\n        ctx->Yi.c[14] = 0;\n        ctx->Yi.c[15] = 1;\n        ctr = 1;\n    } else {\n        size_t i;\n        u64 len0 = len;\n        ctx->Xi.u[0] = 0;\n        ctx->Xi.u[1] = 0;\n        while (len >= 16) {\n            for (i = 0; i < 16; ++i)\n                ctx->Xi.c[i] ^= iv[i];\n            GCM_MUL(ctx);\n            iv += 16;\n            len -= 16;\n        }\n        if (len) {\n            for (i = 0; i < len; ++i)\n                ctx->Xi.c[i] ^= iv[i];\n            GCM_MUL(ctx);\n        }\n        len0 <<= 3;\n        if (is_endian.little) {\n#ifdef BSWAP8\n            ctx->Xi.u[1] ^= BSWAP8(len0);\n#else\n            ctx->Xi.c[8] ^= (u8)(len0 >> 56);\n            ctx->Xi.c[9] ^= (u8)(len0 >> 48);\n            ctx->Xi.c[10] ^= (u8)(len0 >> 40);\n            ctx->Xi.c[11] ^= (u8)(len0 >> 32);\n            ctx->Xi.c[12] ^= (u8)(len0 >> 24);\n            ctx->Xi.c[13] ^= (u8)(len0 >> 16);\n            ctx->Xi.c[14] ^= (u8)(len0 >> 8);\n            ctx->Xi.c[15] ^= (u8)(len0);\n#endif\n        } else {\n            ctx->Xi.u[1] ^= len0;\n        }\n        GCM_MUL(ctx);\n        if (is_endian.little)\n#ifdef BSWAP4\n            ctr = BSWAP4(ctx->Xi.d[3]);\n#else\n            ctr = GETU32(ctx->Xi.c + 12);\n#endif\n        else\n            ctr = ctx->Xi.d[3];\n        ctx->Yi.u[0] = ctx->Xi.u[0];\n        ctx->Yi.u[1] = ctx->Xi.u[1];\n    }\n    ctx->Xi.u[0] = 0;\n    ctx->Xi.u[1] = 0;\n    (*ctx->block) (ctx->Yi.c, ctx->EK0.c, ctx->key);\n    ++ctr;\n    if (is_endian.little)\n#ifdef BSWAP4\n        ctx->Yi.d[3] = BSWAP4(ctr);\n#else\n        PUTU32(ctx->Yi.c + 12, ctr);\n#endif\n    else\n        ctx->Yi.d[3] = ctr;\n}']