Skip to content

Commit

Permalink
BIO_get_mem_data is just a define
Browse files Browse the repository at this point in the history
so fixup error implementation to match
  • Loading branch information
prince-chrismc committed Dec 26, 2023
1 parent b650a64 commit f53e166
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions tests/OpenSSLErrorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static uint64_t fail_X509_get_pubkey = 0;
static uint64_t fail_PEM_write_bio_PUBKEY = 0;
static uint64_t fail_PEM_write_bio_cert = 0;
static uint64_t fail_BIO_ctrl = 0;
#define fail_BIO_get_mem_data fail_BIO_ctrl
static uint64_t fail_BIO_write = 0;
static uint64_t fail_PEM_read_bio_PUBKEY = 0;
static uint64_t fail_PEM_read_bio_PrivateKey = 0;
Expand Down Expand Up @@ -61,7 +62,6 @@ static uint64_t fail_EVP_PKEY_fromdata = 0;
static uint64_t fail_PEM_write_bio_RSA_PUBKEY = 0;
static uint64_t fail_RSA_set0_key = 0;
#endif
static uint64_t fail_BIO_get_mem_data = 0;

BIO* BIO_new(const BIO_METHOD* type) {
static BIO* (*origMethod)(const BIO_METHOD*) = nullptr;
Expand Down Expand Up @@ -510,17 +510,6 @@ int RSA_set0_key(RSA* r, BIGNUM* n, BIGNUM* e, BIGNUM* d) {
}
#endif

long BIO_get_mem_data(BIO* b, char** pp) {
static long (*origMethod)(BIO * b, char** pp) = nullptr;
if (origMethod == nullptr) origMethod = (decltype(origMethod))dlsym(RTLD_NEXT, "BIO_get_mem_data");
bool fail = fail_BIO_get_mem_data & 1;
fail_BIO_get_mem_data = fail_BIO_get_mem_data >> 1;
if (fail)
return 0;
else
return origMethod(b, pp);
}

/**
* =========== End of black magic ============
*/
Expand Down

0 comments on commit f53e166

Please sign in to comment.