From df5bf138e4b52aca42b3e49fbe39b9336c0e43f1 Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Sun, 19 Jul 2020 22:02:04 +0000 Subject: [PATCH] Removed dependency from ma_global.h Closes #2959 --- include/proxysql.h | 4 ---- lib/MySQL_Protocol.cpp | 39 +++++++++++++++++---------------------- src/main.cpp | 7 +++---- 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/include/proxysql.h b/include/proxysql.h index 7950d8953..d8afd677c 100644 --- a/include/proxysql.h +++ b/include/proxysql.h @@ -50,10 +50,6 @@ #include -#if !defined(__FreeBSD__) && !defined(__APPLE__) -#define HAVE_BOOL -//#include "my_pthread.h" -#endif #include "mysql.h" #include "mariadb_com.h" diff --git a/lib/MySQL_Protocol.cpp b/lib/MySQL_Protocol.cpp index a93df5905..69cf509d6 100644 --- a/lib/MySQL_Protocol.cpp +++ b/lib/MySQL_Protocol.cpp @@ -24,11 +24,6 @@ extern ClickHouse_Authentication *GloClickHouseAuth; #undef max_allowed_packet #endif -#if defined(__FreeBSD__) || defined(__APPLE__) -typedef uint8_t uint8; -typedef uint8_t uchar; -#endif - //#define RESULTSET_BUFLEN 16300 #ifndef CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA @@ -130,7 +125,7 @@ static inline int write_encoded_length_and_string(unsigned char *p, uint64_t val return l+val; } -void proxy_compute_sha1_hash_multi(uint8 *digest, const char *buf1, int len1, const char *buf2, int len2) { +void proxy_compute_sha1_hash_multi(uint8_t *digest, const char *buf1, int len1, const char *buf2, int len2) { PROXY_TRACE(); SHA_CTX sha1_context; @@ -140,7 +135,7 @@ void proxy_compute_sha1_hash_multi(uint8 *digest, const char *buf1, int len1, co SHA1_Final(digest, &sha1_context); } -void proxy_compute_sha1_hash(uint8 *digest, const char *buf, int len) { +void proxy_compute_sha1_hash(uint8_t *digest, const char *buf, int len) { PROXY_TRACE(); SHA_CTX sha1_context; @@ -149,13 +144,13 @@ void proxy_compute_sha1_hash(uint8 *digest, const char *buf, int len) { SHA1_Final(digest, &sha1_context); } -void proxy_compute_two_stage_sha1_hash(const char *password, size_t pass_len, uint8 *hash_stage1, uint8 *hash_stage2) { +void proxy_compute_two_stage_sha1_hash(const char *password, size_t pass_len, uint8_t *hash_stage1, uint8_t *hash_stage2) { proxy_compute_sha1_hash(hash_stage1, password, pass_len); proxy_compute_sha1_hash(hash_stage2, (const char *) hash_stage1, SHA_DIGEST_LENGTH); } -void proxy_my_crypt(char *to, const uchar *s1, const uchar *s2, uint len) { - const uint8 *s1_end= s1 + len; +void proxy_my_crypt(char *to, const uint8_t *s1, const uint8_t *s2, uint len) { + const uint8_t *s1_end= s1 + len; while (s1 < s1_end) *to++= *s1++ ^ *s2++; } @@ -189,23 +184,23 @@ void unhex_pass(uint8_t *out, const char *in) { void proxy_scramble(char *to, const char *message, const char *password) { - uint8 hash_stage1[SHA_DIGEST_LENGTH]; - uint8 hash_stage2[SHA_DIGEST_LENGTH]; + uint8_t hash_stage1[SHA_DIGEST_LENGTH]; + uint8_t hash_stage2[SHA_DIGEST_LENGTH]; proxy_compute_two_stage_sha1_hash(password, strlen(password), hash_stage1, hash_stage2); - proxy_compute_sha1_hash_multi((uint8 *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH); - proxy_my_crypt(to, (const uchar *) to, hash_stage1, SCRAMBLE_LENGTH); + proxy_compute_sha1_hash_multi((uint8_t *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH); + proxy_my_crypt(to, (const uint8_t *) to, hash_stage1, SCRAMBLE_LENGTH); return; } bool proxy_scramble_sha1(char *pass_reply, const char *message, const char *sha1_sha1_pass, char *sha1_pass) { bool ret=false; - uint8 hash_stage1[SHA_DIGEST_LENGTH]; - uint8 hash_stage2[SHA_DIGEST_LENGTH]; - uint8 hash_stage3[SHA_DIGEST_LENGTH]; - uint8 to[SHA_DIGEST_LENGTH]; + uint8_t hash_stage1[SHA_DIGEST_LENGTH]; + uint8_t hash_stage2[SHA_DIGEST_LENGTH]; + uint8_t hash_stage3[SHA_DIGEST_LENGTH]; + uint8_t to[SHA_DIGEST_LENGTH]; unhex_pass(hash_stage2,sha1_sha1_pass); - proxy_compute_sha1_hash_multi((uint8 *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH); - proxy_my_crypt((char *)hash_stage1,(const uchar *) pass_reply, to, SCRAMBLE_LENGTH); + proxy_compute_sha1_hash_multi((uint8_t *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH); + proxy_my_crypt((char *)hash_stage1,(const uint8_t *) pass_reply, to, SCRAMBLE_LENGTH); proxy_compute_sha1_hash(hash_stage3, (const char *) hash_stage1, SHA_DIGEST_LENGTH); if (memcmp(hash_stage2,hash_stage3,SHA_DIGEST_LENGTH)==0) { memcpy(sha1_pass,hash_stage1,SHA_DIGEST_LENGTH); @@ -1912,8 +1907,8 @@ __do_auth: unhex_pass(hash_stage2,sha1_2); */ proxy_debug(PROXY_DEBUG_MYSQL_AUTH, 5, "Session=%p , DS=%p , username='%s' , session_type=%d\n", (*myds), (*myds)->sess, user, session_type); - uint8 hash_stage1[SHA_DIGEST_LENGTH]; - uint8 hash_stage2[SHA_DIGEST_LENGTH]; + uint8_t hash_stage1[SHA_DIGEST_LENGTH]; + uint8_t hash_stage2[SHA_DIGEST_LENGTH]; SHA_CTX sha1_context; SHA1_Init(&sha1_context); SHA1_Update(&sha1_context, pass, pass_len); diff --git a/src/main.cpp b/src/main.cpp index 12bf2f504..8e0591b5e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,11 +3,10 @@ #include #include "btree_map.h" #include "proxysql.h" -#if defined(__FreeBSD__) || defined(__APPLE__) -#include -#endif + +#include +#include #include -#include //#define PROXYSQL_EXTERN #include "cpp.h"