crypto/evp/e_aes.c:1688: error: BUFFER_OVERRUN_L3
  Offset added: 16 Size: [0, +oo] by call to `CRYPTO_gcm128_tag`.
Showing all 7 steps of the trace


crypto/evp/e_aes.c:1688:9: Call
1686.               return 0;
1687.           }
1688.           CRYPTO_gcm128_tag(&gctx->gcm, ctx->buf, 16);
                ^
1689.           gctx->taglen = 16;
1690.           /* Don't reuse the IV */

crypto/modes/gcm128.c:1697:12: <Offset trace>
1695.       CRYPTO_gcm128_finish(ctx, NULL, 0);
1696.       memcpy(tag, ctx->Xi.c,
1697.              len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c));
                   ^
1698.   }
1699.   

crypto/modes/gcm128.c:1697:12: Assignment
  1695.       CRYPTO_gcm128_finish(ctx, NULL, 0);
  1696.       memcpy(tag, ctx->Xi.c,
  1697.              len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c));
                     ^
  1698.   }
  1699.   

crypto/modes/gcm128.c:1695:5: <Length trace>
1693.   void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len)
1694.   {
1695.       CRYPTO_gcm128_finish(ctx, NULL, 0);
            ^
1696.       memcpy(tag, ctx->Xi.c,
1697.              len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c));

crypto/modes/gcm128.c:1695:5: Call
  1693.   void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len)
  1694.   {
  1695.       CRYPTO_gcm128_finish(ctx, NULL, 0);
              ^
  1696.       memcpy(tag, ctx->Xi.c,
  1697.              len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c));

crypto/modes/gcm128.c:1649:1: Parameter `ctx->Xi.c[*]`
    1647.   }
    1648.   
    1649. > int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,
    1650.                            size_t len)
    1651.   {

crypto/modes/gcm128.c:1696:5: Array access: Offset added: 16 Size: [0, +oo] by call to `CRYPTO_gcm128_tag` 
  1694.   {
  1695.       CRYPTO_gcm128_finish(ctx, NULL, 0);
  1696.       memcpy(tag, ctx->Xi.c,
              ^
  1697.              len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c));
  1698.   }

void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len)
{
    CRYPTO_gcm128_finish(ctx, NULL, 0);
    memcpy(tag, ctx->Xi.c,
           len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c));
}
['static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                          const unsigned char *in, size_t len)\n{\n    EVP_AES_GCM_CTX *gctx = ctx->cipher_data;\n    if (!gctx->key_set)\n        return -1;\n    if (gctx->tls_aad_len >= 0)\n        return aes_gcm_tls_cipher(ctx, out, in, len);\n    if (!gctx->iv_set)\n        return -1;\n    if (in) {\n        if (out == NULL) {\n            if (CRYPTO_gcm128_aad(&gctx->gcm, in, len))\n                return -1;\n        } else if (ctx->encrypt) {\n            if (gctx->ctr) {\n                size_t bulk = 0;\n# if defined(AES_GCM_ASM)\n                if (len >= 32 && AES_GCM_ASM(gctx)) {\n                    size_t res = (16 - gctx->gcm.mres) % 16;\n                    if (CRYPTO_gcm128_encrypt(&gctx->gcm, in, out, res))\n                        return -1;\n                    bulk = AES_gcm_encrypt(in + res,\n                                           out + res, len - res,\n                                           gctx->gcm.key, gctx->gcm.Yi.c,\n                                           gctx->gcm.Xi.u);\n                    gctx->gcm.len.u[1] += bulk;\n                    bulk += res;\n                }\n# endif\n                if (CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm,\n                                                in + bulk,\n                                                out + bulk,\n                                                len - bulk, gctx->ctr))\n                    return -1;\n            } else {\n                size_t bulk = 0;\n# if defined(AES_GCM_ASM2)\n                if (len >= 32 && AES_GCM_ASM2(gctx)) {\n                    size_t res = (16 - gctx->gcm.mres) % 16;\n                    if (CRYPTO_gcm128_encrypt(&gctx->gcm, in, out, res))\n                        return -1;\n                    bulk = AES_gcm_encrypt(in + res,\n                                           out + res, len - res,\n                                           gctx->gcm.key, gctx->gcm.Yi.c,\n                                           gctx->gcm.Xi.u);\n                    gctx->gcm.len.u[1] += bulk;\n                    bulk += res;\n                }\n# endif\n                if (CRYPTO_gcm128_encrypt(&gctx->gcm,\n                                          in + bulk, out + bulk, len - bulk))\n                    return -1;\n            }\n        } else {\n            if (gctx->ctr) {\n                size_t bulk = 0;\n# if defined(AES_GCM_ASM)\n                if (len >= 16 && AES_GCM_ASM(gctx)) {\n                    size_t res = (16 - gctx->gcm.mres) % 16;\n                    if (CRYPTO_gcm128_decrypt(&gctx->gcm, in, out, res))\n                        return -1;\n                    bulk = AES_gcm_decrypt(in + res,\n                                           out + res, len - res,\n                                           gctx->gcm.key,\n                                           gctx->gcm.Yi.c, gctx->gcm.Xi.u);\n                    gctx->gcm.len.u[1] += bulk;\n                    bulk += res;\n                }\n# endif\n                if (CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm,\n                                                in + bulk,\n                                                out + bulk,\n                                                len - bulk, gctx->ctr))\n                    return -1;\n            } else {\n                size_t bulk = 0;\n# if defined(AES_GCM_ASM2)\n                if (len >= 16 && AES_GCM_ASM2(gctx)) {\n                    size_t res = (16 - gctx->gcm.mres) % 16;\n                    if (CRYPTO_gcm128_decrypt(&gctx->gcm, in, out, res))\n                        return -1;\n                    bulk = AES_gcm_decrypt(in + res,\n                                           out + res, len - res,\n                                           gctx->gcm.key,\n                                           gctx->gcm.Yi.c, gctx->gcm.Xi.u);\n                    gctx->gcm.len.u[1] += bulk;\n                    bulk += res;\n                }\n# endif\n                if (CRYPTO_gcm128_decrypt(&gctx->gcm,\n                                          in + bulk, out + bulk, len - bulk))\n                    return -1;\n            }\n        }\n        return len;\n    } else {\n        if (!ctx->encrypt) {\n            if (gctx->taglen < 0)\n                return -1;\n            if (CRYPTO_gcm128_finish(&gctx->gcm, ctx->buf, gctx->taglen) != 0)\n                return -1;\n            gctx->iv_set = 0;\n            return 0;\n        }\n        CRYPTO_gcm128_tag(&gctx->gcm, ctx->buf, 16);\n        gctx->taglen = 16;\n        gctx->iv_set = 0;\n        return 0;\n    }\n}', 'void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len)\n{\n    CRYPTO_gcm128_finish(ctx, NULL, 0);\n    memcpy(tag, ctx->Xi.c,\n           len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c));\n}', 'int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,\n                         size_t len)\n{\n    const union {\n        long one;\n        char little;\n    } is_endian = { 1 };\n    u64 alen = ctx->len.u[0] << 3;\n    u64 clen = ctx->len.u[1] << 3;\n#ifdef GCM_FUNCREF_4BIT\n    void (*gcm_gmult_p) (u64 Xi[2], const u128 Htable[16]) = ctx->gmult;\n#endif\n    if (ctx->mres || ctx->ares)\n        GCM_MUL(ctx, Xi);\n    if (is_endian.little) {\n#ifdef BSWAP8\n        alen = BSWAP8(alen);\n        clen = BSWAP8(clen);\n#else\n        u8 *p = ctx->len.c;\n        ctx->len.u[0] = alen;\n        ctx->len.u[1] = clen;\n        alen = (u64)GETU32(p) << 32 | GETU32(p + 4);\n        clen = (u64)GETU32(p + 8) << 32 | GETU32(p + 12);\n#endif\n    }\n    ctx->Xi.u[0] ^= alen;\n    ctx->Xi.u[1] ^= clen;\n    GCM_MUL(ctx, Xi);\n    ctx->Xi.u[0] ^= ctx->EK0.u[0];\n    ctx->Xi.u[1] ^= ctx->EK0.u[1];\n    if (tag && len <= sizeof(ctx->Xi))\n        return CRYPTO_memcmp(ctx->Xi.c, tag, len);\n    else\n        return -1;\n}']