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


crypto/evp/e_aes.c:2683:13: Call
2681.           }
2682.           /* If encrypting then just get the tag */
2683.           if (CRYPTO_ocb128_tag(&octx->ocb, octx->tag, 16) != 1)
                    ^
2684.               return -1;
2685.           /* Don't reuse the IV */

crypto/modes/ocb128.c:542:1: <Offset trace>
540.    * Retrieve the calculated tag
541.    */
542. > int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len)
543.   {
544.       if (len > 16 || len < 1) {

crypto/modes/ocb128.c:542:1: Parameter `len`
  540.    * Retrieve the calculated tag
  541.    */
  542. > int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len)
  543.   {
  544.       if (len > 16 || len < 1) {

crypto/modes/ocb128.c:542:1: <Length trace>
540.    * Retrieve the calculated tag
541.    */
542. > int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len)
543.   {
544.       if (len > 16 || len < 1) {

crypto/modes/ocb128.c:542:1: Parameter `ctx->tag.c[*]`
  540.    * Retrieve the calculated tag
  541.    */
  542. > int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len)
  543.   {
  544.       if (len > 16 || len < 1) {

crypto/modes/ocb128.c:552:5: Array access: Offset added: 16 Size: [0, +oo] by call to `CRYPTO_ocb128_tag` 
  550.   
  551.       /* Copy the tag into the supplied buffer */
  552.       memcpy(tag, ctx->tag.c, len);
             ^
  553.   
  554.       return 1;

int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len)
{
    if (len > 16 || len < 1) {
        return -1;
    }
    CRYPTO_ocb128_finish(ctx, NULL, 0);
    memcpy(tag, ctx->tag.c, len);
    return 1;
}
['static int aes_ocb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                          const unsigned char *in, size_t len)\n{\n    unsigned char *buf;\n    int *buf_len;\n    int written_len = 0;\n    size_t trailing_len;\n    EVP_AES_OCB_CTX *octx = EVP_C_DATA(EVP_AES_OCB_CTX,ctx);\n    if (!octx->iv_set)\n        return -1;\n    if (!octx->key_set)\n        return -1;\n    if (in != NULL) {\n        if (out == NULL) {\n            buf = octx->aad_buf;\n            buf_len = &(octx->aad_buf_len);\n        } else {\n            buf = octx->data_buf;\n            buf_len = &(octx->data_buf_len);\n            if (is_partially_overlapping(out + *buf_len, in, len)) {\n                EVPerr(EVP_F_AES_OCB_CIPHER, EVP_R_PARTIALLY_OVERLAPPING);\n                return 0;\n            }\n        }\n        if (*buf_len > 0) {\n            unsigned int remaining;\n            remaining = AES_BLOCK_SIZE - (*buf_len);\n            if (remaining > len) {\n                memcpy(buf + (*buf_len), in, len);\n                *(buf_len) += len;\n                return 0;\n            }\n            memcpy(buf + (*buf_len), in, remaining);\n            len -= remaining;\n            in += remaining;\n            if (out == NULL) {\n                if (!CRYPTO_ocb128_aad(&octx->ocb, buf, AES_BLOCK_SIZE))\n                    return -1;\n            } else if (EVP_CIPHER_CTX_encrypting(ctx)) {\n                if (!CRYPTO_ocb128_encrypt(&octx->ocb, buf, out,\n                                           AES_BLOCK_SIZE))\n                    return -1;\n            } else {\n                if (!CRYPTO_ocb128_decrypt(&octx->ocb, buf, out,\n                                           AES_BLOCK_SIZE))\n                    return -1;\n            }\n            written_len = AES_BLOCK_SIZE;\n            *buf_len = 0;\n            if (out != NULL)\n                out += AES_BLOCK_SIZE;\n        }\n        trailing_len = len % AES_BLOCK_SIZE;\n        if (len != trailing_len) {\n            if (out == NULL) {\n                if (!CRYPTO_ocb128_aad(&octx->ocb, in, len - trailing_len))\n                    return -1;\n            } else if (EVP_CIPHER_CTX_encrypting(ctx)) {\n                if (!CRYPTO_ocb128_encrypt\n                    (&octx->ocb, in, out, len - trailing_len))\n                    return -1;\n            } else {\n                if (!CRYPTO_ocb128_decrypt\n                    (&octx->ocb, in, out, len - trailing_len))\n                    return -1;\n            }\n            written_len += len - trailing_len;\n            in += len - trailing_len;\n        }\n        if (trailing_len > 0) {\n            memcpy(buf, in, trailing_len);\n            *buf_len = trailing_len;\n        }\n        return written_len;\n    } else {\n        if (octx->data_buf_len > 0) {\n            if (EVP_CIPHER_CTX_encrypting(ctx)) {\n                if (!CRYPTO_ocb128_encrypt(&octx->ocb, octx->data_buf, out,\n                                           octx->data_buf_len))\n                    return -1;\n            } else {\n                if (!CRYPTO_ocb128_decrypt(&octx->ocb, octx->data_buf, out,\n                                           octx->data_buf_len))\n                    return -1;\n            }\n            written_len = octx->data_buf_len;\n            octx->data_buf_len = 0;\n        }\n        if (octx->aad_buf_len > 0) {\n            if (!CRYPTO_ocb128_aad\n                (&octx->ocb, octx->aad_buf, octx->aad_buf_len))\n                return -1;\n            octx->aad_buf_len = 0;\n        }\n        if (!EVP_CIPHER_CTX_encrypting(ctx)) {\n            if (octx->taglen < 0)\n                return -1;\n            if (CRYPTO_ocb128_finish(&octx->ocb,\n                                     octx->tag, octx->taglen) != 0)\n                return -1;\n            octx->iv_set = 0;\n            return written_len;\n        }\n        if (CRYPTO_ocb128_tag(&octx->ocb, octx->tag, 16) != 1)\n            return -1;\n        octx->iv_set = 0;\n        return written_len;\n    }\n}', 'int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len)\n{\n    if (len > 16 || len < 1) {\n        return -1;\n    }\n    CRYPTO_ocb128_finish(ctx, NULL, 0);\n    memcpy(tag, ctx->tag.c, len);\n    return 1;\n}']