Skip to content

Commit

Permalink
Merge pull request #4448 from sysown/v2.6.0-update_to_openssl_v3.2.1
Browse files Browse the repository at this point in the history
update OpenSSL from v3.1.4 to v3.2.1
  • Loading branch information
renecannao authored Feb 20, 2024
2 parents 6e18b04 + 0971a48 commit b3dcee9
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 29 deletions.
2 changes: 1 addition & 1 deletion deps/libssl/openssl
Binary file not shown.
12 changes: 9 additions & 3 deletions deps/libssl/verify-bio_st-match.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ echo "extracting 'struct bio_st' from 'lib/mysql_data_stream.cpp'"
LIBBIOST=$(cd ../../; cat ./lib/mysql_data_stream.cpp | sed '/^\/\*/,/*\//d' | sed -n '/^struct bio_st {/,/}/p')

echo -n "Comparing ... "
if [[ "$LIBBIOST" == "$DEPBIOST" ]]; then
echo "PASS - bio_st is a match!";
if [[ "$LIBBIOST" =~ "$DEPBIOST" ]]; then
echo "PASS - bio_st is a match!"
else
echo "FAIL - bio_st does not match!";
echo "FAIL - bio_st does not match!"
echo
echo ">>> lib/mysql_data_stream.cpp"
echo "$LIBBIOST"
echo "==="
echo "$DEPBIOST"
echo "<<< deps/libssl/openssl/crypto/bio/bio_local.h"
exit 1
fi
82 changes: 57 additions & 25 deletions lib/mysql_data_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,39 @@

#include <openssl/x509v3.h>

/*
in libssl 1.1.0
struct bio_st {
const BIO_METHOD *method;
long (*callback) (struct bio_st *, int, const char *, int, long, long);
char *cb_arg;
int init;
int shutdown;
int flags;
int retry_reason;
int num;
void *ptr;
struct bio_st *next_bio;
struct bio_st *prev_bio;
int references;
uint64_t num_read;
uint64_t num_write;
CRYPTO_EX_DATA ex_data;
CRYPTO_RWLOCK *lock;
};
*/

typedef int CRYPTO_REF_COUNT;

/**
* @brief This is the 'bio_st' struct definition from libssl 3.0.0. NOTE: This is an internal struct from
* @brief This is the 'bio_st' struct definition from libssl. NOTE: This is an internal struct from
* OpenSSL library, currently it's used for performing checks on the reads/writes performed on the BIO objects.
* It's extremely important to keep this struct up to date with each OpenSSL dependency update.
*/
typedef int CRYPTO_REF_COUNT;

#if (OPENSSL_VERSION_NUMBER & 0xFFFF0000) == 0x10100000
#pragma message "libssl 1.1.x detected"
struct bio_st {
const BIO_METHOD *method;
/* bio, mode, argp, argi, argl, ret */
BIO_callback_fn callback;
BIO_callback_fn_ex callback_ex;
char *cb_arg; /* first argument for the callback */
int init;
int shutdown;
int flags; /* extra storage */
int retry_reason;
int num;
void *ptr;
struct bio_st *next_bio; /* used by filter BIOs */
struct bio_st *prev_bio; /* used by filter BIOs */
CRYPTO_REF_COUNT references;
uint64_t num_read;
uint64_t num_write;
CRYPTO_EX_DATA ex_data;
CRYPTO_RWLOCK *lock;
};

#elif (OPENSSL_VERSION_NUMBER & 0xFFFF0000) == 0x30000000 || (OPENSSL_VERSION_NUMBER & 0xFFFF0000) == 0x30100000
#pragma message "libssl 3.0.x / 3.1.x detected"
struct bio_st {
OSSL_LIB_CTX *libctx;
const BIO_METHOD *method;
Expand All @@ -64,6 +67,35 @@ struct bio_st {
CRYPTO_RWLOCK *lock;
};

#elif (OPENSSL_VERSION_NUMBER & 0xFFFF0000) == 0x30200000
#pragma message "libssl 3.2.x detected"
struct bio_st {
OSSL_LIB_CTX *libctx;
const BIO_METHOD *method;
/* bio, mode, argp, argi, argl, ret */
#ifndef OPENSSL_NO_DEPRECATED_3_0
BIO_callback_fn callback;
#endif
BIO_callback_fn_ex callback_ex;
char *cb_arg; /* first argument for the callback */
int init;
int shutdown;
int flags; /* extra storage */
int retry_reason;
int num;
void *ptr;
struct bio_st *next_bio; /* used by filter BIOs */
struct bio_st *prev_bio; /* used by filter BIOs */
CRYPTO_REF_COUNT references;
uint64_t num_read;
uint64_t num_write;
CRYPTO_EX_DATA ex_data;
};

#else
#error "libssl version not supported: OPENSSL_VERSION_NUMBER = " ##OPENSSL_VERSION_NUMBER
#endif


#define RESULTSET_BUFLEN_DS_16K 16000
#define RESULTSET_BUFLEN_DS_1M 1000*1024
Expand Down

0 comments on commit b3dcee9

Please sign in to comment.