crypto/evp/e_aes.c:2523: error: BUFFER_OVERRUN_L2
  Offset added: [2, 30] (⇐ [1, 15] + [1, 15]) Size: 16 by call to `CRYPTO_ocb128_setiv`.
Showing all 6 steps of the trace


crypto/evp/e_aes.c:2523:17: Call
2521.               iv = octx->iv;
2522.           if (iv) {
2523.               if (CRYPTO_ocb128_setiv(&octx->ocb, iv, octx->ivlen, octx->taglen)
                        ^
2524.                   != 1)
2525.                   return 0;

crypto/modes/ocb128.c:262:1: <Offset trace>
260.    * Set the IV to be used for this operation. Must be 1 - 15 bytes.
261.    */
262. > int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,
263.                           size_t len, size_t taglen)
264.   {

crypto/modes/ocb128.c:262:1: Parameter `len`
  260.    * Set the IV to be used for this operation. Must be 1 - 15 bytes.
  261.    */
  262. > int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,
  263.                           size_t len, size_t taglen)
  264.   {

crypto/modes/ocb128.c:262:1: <Length trace>
260.    * Set the IV to be used for this operation. Must be 1 - 15 bytes.
261.    */
262. > int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,
263.                           size_t len, size_t taglen)
264.   {

crypto/modes/ocb128.c:262:1: Array declaration
  260.    * Set the IV to be used for this operation. Must be 1 - 15 bytes.
  261.    */
  262. > int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,
  263.                           size_t len, size_t taglen)
  264.   {

crypto/modes/ocb128.c:280:5: Array access: Offset added: [2, 30] (⇐ [1, 15] + [1, 15]) Size: 16 by call to `CRYPTO_ocb128_setiv` 
  278.       nonce[0] = ((taglen * 8) % 128) << 1;
  279.       memset(nonce + 1, 0, 15);
  280.       memcpy(nonce + 16 - len, iv, len);
             ^
  281.       nonce[15 - len] |= 1;
  282.   

int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,
                        size_t len, size_t taglen)
{
    unsigned char ktop[16], tmp[16], mask;
    unsigned char stretch[24], nonce[16];
    size_t bottom, shift;
    if ((len > 15) || (len < 1) || (taglen > 16) || (taglen < 1)) {
        return -1;
    }
    nonce[0] = ((taglen * 8) % 128) << 1;
    memset(nonce + 1, 0, 15);
    memcpy(nonce + 16 - len, iv, len);
    nonce[15 - len] |= 1;
    memcpy(tmp, nonce, 16);
    tmp[15] &= 0xc0;
    ctx->encrypt(tmp, ktop, ctx->keyenc);
    memcpy(stretch, ktop, 16);
    ocb_block_xor(ktop, ktop + 1, 8, stretch + 16);
    bottom = nonce[15] & 0x3f;
    shift = bottom % 8;
    ocb_block_lshift(stretch + (bottom / 8), shift, ctx->offset.c);
    mask = 0xff;
    mask <<= 8 - shift;
    ctx->offset.c[15] |=
        (*(stretch + (bottom / 8) + 16) & mask) >> (8 - shift);
    return 1;
}
['static int aes_ocb_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,\n                            const unsigned char *iv, int enc)\n{\n    EVP_AES_OCB_CTX *octx = EVP_C_DATA(EVP_AES_OCB_CTX,ctx);\n    if (!iv && !key)\n        return 1;\n    if (key) {\n        do {\n#  ifdef HWAES_CAPABLE\n            if (HWAES_CAPABLE) {\n                HWAES_set_encrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,\n                                      &octx->ksenc.ks);\n                HWAES_set_decrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,\n                                      &octx->ksdec.ks);\n                if (!CRYPTO_ocb128_init(&octx->ocb,\n                                        &octx->ksenc.ks, &octx->ksdec.ks,\n                                        (block128_f) HWAES_encrypt,\n                                        (block128_f) HWAES_decrypt,\n                                        enc ? HWAES_ocb_encrypt\n                                            : HWAES_ocb_decrypt))\n                    return 0;\n                break;\n            }\n#  endif\n#  ifdef VPAES_CAPABLE\n            if (VPAES_CAPABLE) {\n                vpaes_set_encrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,\n                                      &octx->ksenc.ks);\n                vpaes_set_decrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,\n                                      &octx->ksdec.ks);\n                if (!CRYPTO_ocb128_init(&octx->ocb,\n                                        &octx->ksenc.ks, &octx->ksdec.ks,\n                                        (block128_f) vpaes_encrypt,\n                                        (block128_f) vpaes_decrypt,\n                                        NULL))\n                    return 0;\n                break;\n            }\n#  endif\n            AES_set_encrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,\n                                &octx->ksenc.ks);\n            AES_set_decrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,\n                                &octx->ksdec.ks);\n            if (!CRYPTO_ocb128_init(&octx->ocb,\n                                    &octx->ksenc.ks, &octx->ksdec.ks,\n                                    (block128_f) AES_encrypt,\n                                    (block128_f) AES_decrypt,\n                                    NULL))\n                return 0;\n        }\n        while (0);\n        if (iv == NULL && octx->iv_set)\n            iv = octx->iv;\n        if (iv) {\n            if (CRYPTO_ocb128_setiv(&octx->ocb, iv, octx->ivlen, octx->taglen)\n                != 1)\n                return 0;\n            octx->iv_set = 1;\n        }\n        octx->key_set = 1;\n    } else {\n        if (octx->key_set)\n            CRYPTO_ocb128_setiv(&octx->ocb, iv, octx->ivlen, octx->taglen);\n        else\n            memcpy(octx->iv, iv, octx->ivlen);\n        octx->iv_set = 1;\n    }\n    return 1;\n}', 'int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,\n                        size_t len, size_t taglen)\n{\n    unsigned char ktop[16], tmp[16], mask;\n    unsigned char stretch[24], nonce[16];\n    size_t bottom, shift;\n    if ((len > 15) || (len < 1) || (taglen > 16) || (taglen < 1)) {\n        return -1;\n    }\n    nonce[0] = ((taglen * 8) % 128) << 1;\n    memset(nonce + 1, 0, 15);\n    memcpy(nonce + 16 - len, iv, len);\n    nonce[15 - len] |= 1;\n    memcpy(tmp, nonce, 16);\n    tmp[15] &= 0xc0;\n    ctx->encrypt(tmp, ktop, ctx->keyenc);\n    memcpy(stretch, ktop, 16);\n    ocb_block_xor(ktop, ktop + 1, 8, stretch + 16);\n    bottom = nonce[15] & 0x3f;\n    shift = bottom % 8;\n    ocb_block_lshift(stretch + (bottom / 8), shift, ctx->offset.c);\n    mask = 0xff;\n    mask <<= 8 - shift;\n    ctx->offset.c[15] |=\n        (*(stretch + (bottom / 8) + 16) & mask) >> (8 - shift);\n    return 1;\n}']