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)));
    assert(!overlapped);
    return overlapped;
}
['int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen,\n                  pem_password_cb *callback, void *u)\n{\n    int ok;\n    int keylen;\n    long len = *plen;\n    int ilen = (int) len;\n    EVP_CIPHER_CTX *ctx;\n    unsigned char key[EVP_MAX_KEY_LENGTH];\n    char buf[PEM_BUFSIZE];\n#if LONG_MAX > INT_MAX\n    if (len > INT_MAX) {\n        PEMerr(PEM_F_PEM_DO_HEADER, PEM_R_HEADER_TOO_LONG);\n        return 0;\n    }\n#endif\n    if (cipher->cipher == NULL)\n        return 1;\n    if (callback == NULL)\n        keylen = PEM_def_callback(buf, PEM_BUFSIZE, 0, u);\n    else\n        keylen = callback(buf, PEM_BUFSIZE, 0, u);\n    if (keylen <= 0) {\n        PEMerr(PEM_F_PEM_DO_HEADER, PEM_R_BAD_PASSWORD_READ);\n        return 0;\n    }\n#ifdef CHARSET_EBCDIC\n    ebcdic2ascii(buf, buf, keylen);\n#endif\n    if (!EVP_BytesToKey(cipher->cipher, EVP_md5(), &(cipher->iv[0]),\n                        (unsigned char *)buf, keylen, 1, key, NULL))\n        return 0;\n    ctx = EVP_CIPHER_CTX_new();\n    if (ctx == NULL)\n        return 0;\n    ok = EVP_DecryptInit_ex(ctx, cipher->cipher, NULL, key, &(cipher->iv[0]));\n    if (ok)\n        ok = EVP_DecryptUpdate(ctx, data, &ilen, data, ilen);\n    if (ok) {\n        *plen = ilen;\n        ok = EVP_DecryptFinal_ex(ctx, &(data[ilen]), &ilen);\n    }\n    if (ok)\n        *plen += ilen;\n    else\n        PEMerr(PEM_F_PEM_DO_HEADER, PEM_R_BAD_DECRYPT);\n    EVP_CIPHER_CTX_free(ctx);\n    OPENSSL_cleanse((char *)buf, sizeof(buf));\n    OPENSSL_cleanse((char *)key, sizeof(key));\n    return ok;\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;\n    unsigned int b;\n    b = ctx->cipher->block_size;\n    if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {\n        if (b == 1 && is_partially_overlapping(out, in, inl)) {\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    assert(!overlapped);\n    return overlapped;\n}']