test/evp_extra_test.c:385: error: INTEGER_OVERFLOW_L2
  (0 - [-oo, 32]):unsigned64 by call to `EVP_DecryptUpdate`.
Showing all 7 steps of the trace


test/evp_extra_test.c:385:17: Call
383.   
384.       if (!TEST_true(EVP_OpenInit(ctx, type, kek, kek_len, iv, keypair))
385.               || !TEST_true(EVP_OpenUpdate(ctx, plaintext, &plaintext_len,
                       ^
386.                                            ciphertext, ciphertext_len))
387.               || !TEST_true(EVP_OpenFinal(ctx, plaintext + plaintext_len, &len)))

crypto/evp/evp_enc.c:423:1: Parameter `ctx->cipher->block_size`
  421.   }
  422.   
  423. > int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
  424.                         const unsigned char *in, int inl)
  425.   {

crypto/evp/evp_enc.c:429:5: Assignment
  427.       unsigned int b;
  428.   
  429.       b = ctx->cipher->block_size;
             ^
  430.   
  431.       if (EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS))

crypto/evp/evp_enc.c:462:16: Call
  460.           /* see comment about PTRDIFF_T comparison above */
  461.           if (((PTRDIFF_T)out == (PTRDIFF_T)in)
  462.               || is_partially_overlapping(out, in, b)) {
                        ^
  463.               EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING);
  464.               return 0;

crypto/evp/evp_enc.c:283:1: <RHS trace>
281.   #endif
282.   
283. > int is_partially_overlapping(const void *ptr1, const void *ptr2, int len)
284.   {
285.       PTRDIFF_T diff = (PTRDIFF_T)ptr1-(PTRDIFF_T)ptr2;

crypto/evp/evp_enc.c:283:1: Parameter `len`
    281.   #endif
    282.   
    283. > int is_partially_overlapping(const void *ptr1, const void *ptr2, int len)
    284.   {
    285.       PTRDIFF_T diff = (PTRDIFF_T)ptr1-(PTRDIFF_T)ptr2;

crypto/evp/evp_enc.c:292:50: Binary operation: (0 - [-oo, 32]):unsigned64 by call to `EVP_DecryptUpdate` 
    290.        */
    291.       int overlapped = (len > 0) & (diff != 0) & ((diff < (PTRDIFF_T)len) |
    292.                                                   (diff > (0 - (PTRDIFF_T)len)));
                                                            ^
    293.   
    294.       return overlapped;

int is_partially_overlapping(const void *ptr1, const void *ptr2, int len)
{
    PTRDIFF_T diff = (PTRDIFF_T)ptr1-(PTRDIFF_T)ptr2;
    int overlapped = (len > 0) & (diff != 0) & ((diff < (PTRDIFF_T)len) |
                                                (diff > (0 - (PTRDIFF_T)len)));
    return overlapped;
}
['static int test_EVP_Enveloped(void)\n{\n    int ret = 0;\n    EVP_CIPHER_CTX *ctx = NULL;\n    EVP_PKEY *keypair = NULL;\n    unsigned char *kek = NULL;\n    unsigned char iv[EVP_MAX_IV_LENGTH];\n    static const unsigned char msg[] = { 1, 2, 3, 4, 5, 6, 7, 8 };\n    int len, kek_len, ciphertext_len, plaintext_len;\n    unsigned char ciphertext[32], plaintext[16];\n    const EVP_CIPHER *type = EVP_aes_256_cbc();\n    if (!TEST_ptr(keypair = load_example_rsa_key())\n            || !TEST_ptr(kek = OPENSSL_zalloc(EVP_PKEY_size(keypair)))\n            || !TEST_ptr(ctx = EVP_CIPHER_CTX_new())\n            || !TEST_true(EVP_SealInit(ctx, type, &kek, &kek_len, iv,\n                                       &keypair, 1))\n            || !TEST_true(EVP_SealUpdate(ctx, ciphertext, &ciphertext_len,\n                                         msg, sizeof(msg)))\n            || !TEST_true(EVP_SealFinal(ctx, ciphertext + ciphertext_len,\n                                        &len)))\n        goto err;\n    ciphertext_len += len;\n    if (!TEST_true(EVP_OpenInit(ctx, type, kek, kek_len, iv, keypair))\n            || !TEST_true(EVP_OpenUpdate(ctx, plaintext, &plaintext_len,\n                                         ciphertext, ciphertext_len))\n            || !TEST_true(EVP_OpenFinal(ctx, plaintext + plaintext_len, &len)))\n        goto err;\n    plaintext_len += len;\n    if (!TEST_mem_eq(msg, sizeof(msg), plaintext, plaintext_len))\n        goto err;\n    ret = 1;\nerr:\n    OPENSSL_free(kek);\n    EVP_PKEY_free(keypair);\n    EVP_CIPHER_CTX_free(ctx);\n    return ret;\n}', 'int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl)\n{\n    int fix_len, cmpl = inl;\n    unsigned int b;\n    b = ctx->cipher->block_size;\n    if (EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS))\n        cmpl = (cmpl + 7) / 8;\n    if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {\n        if (b == 1 && is_partially_overlapping(out, in, cmpl)) {\n            EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING);\n            return 0;\n        }\n        fix_len = ctx->cipher->do_cipher(ctx, out, in, inl);\n        if (fix_len < 0) {\n            *outl = 0;\n            return 0;\n        } else\n            *outl = fix_len;\n        return 1;\n    }\n    if (inl <= 0) {\n        *outl = 0;\n        return inl == 0;\n    }\n    if (ctx->flags & EVP_CIPH_NO_PADDING)\n        return EVP_EncryptUpdate(ctx, out, outl, in, inl);\n    OPENSSL_assert(b <= sizeof(ctx->final));\n    if (ctx->final_used) {\n        if (((PTRDIFF_T)out == (PTRDIFF_T)in)\n            || is_partially_overlapping(out, in, b)) {\n            EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING);\n            return 0;\n        }\n        memcpy(out, ctx->final, b);\n        out += b;\n        fix_len = 1;\n    } else\n        fix_len = 0;\n    if (!EVP_EncryptUpdate(ctx, out, outl, in, inl))\n        return 0;\n    if (b > 1 && !ctx->buf_len) {\n        *outl -= b;\n        ctx->final_used = 1;\n        memcpy(ctx->final, &out[*outl], b);\n    } else\n        ctx->final_used = 0;\n    if (fix_len)\n        *outl += b;\n    return 1;\n}', 'int is_partially_overlapping(const void *ptr1, const void *ptr2, int len)\n{\n    PTRDIFF_T diff = (PTRDIFF_T)ptr1-(PTRDIFF_T)ptr2;\n    int overlapped = (len > 0) & (diff != 0) & ((diff < (PTRDIFF_T)len) |\n                                                (diff > (0 - (PTRDIFF_T)len)));\n    return overlapped;\n}']