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;
}
['unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor,\n                                const char *pass, int passlen,\n                                const unsigned char *in, int inlen,\n                                unsigned char **data, int *datalen, int en_de)\n{\n    unsigned char *out = NULL;\n    int outlen, i;\n    EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();\n    if (ctx == NULL) {\n        PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!EVP_PBE_CipherInit(algor->algorithm, pass, passlen,\n                            algor->parameter, ctx, en_de)) {\n        PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,\n                  PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR);\n        goto err;\n    }\n    if ((out = OPENSSL_malloc(inlen + EVP_CIPHER_CTX_block_size(ctx)))\n            == NULL) {\n        PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!EVP_CipherUpdate(ctx, out, &i, in, inlen)) {\n        OPENSSL_free(out);\n        out = NULL;\n        PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, ERR_R_EVP_LIB);\n        goto err;\n    }\n    outlen = i;\n    if (!EVP_CipherFinal_ex(ctx, out + i, &i)) {\n        OPENSSL_free(out);\n        out = NULL;\n        PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,\n                  PKCS12_R_PKCS12_CIPHERFINAL_ERROR);\n        goto err;\n    }\n    outlen += i;\n    if (datalen)\n        *datalen = outlen;\n    if (data)\n        *data = out;\n err:\n    EVP_CIPHER_CTX_free(ctx);\n    return out;\n}', 'int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl)\n{\n    if (ctx->encrypt)\n        return EVP_EncryptUpdate(ctx, out, outl, in, inl);\n    else\n        return EVP_DecryptUpdate(ctx, out, outl, in, inl);\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    return overlapped;\n}']