diff options
-rw-r--r-- | include/base64.h | 62 | ||||
-rw-r--r-- | include/mysql/plugin_audit.h.pp | 16 | ||||
-rw-r--r-- | include/mysql/plugin_auth.h.pp | 16 | ||||
-rw-r--r-- | include/mysql/plugin_encryption.h.pp | 16 | ||||
-rw-r--r-- | include/mysql/plugin_ftparser.h.pp | 16 | ||||
-rw-r--r-- | include/mysql/plugin_password_validation.h.pp | 16 | ||||
-rw-r--r-- | include/mysql/service_base64.h | 82 | ||||
-rw-r--r-- | include/mysql/services.h | 1 | ||||
-rw-r--r-- | include/service_versions.h | 1 | ||||
-rw-r--r-- | libservices/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libservices/base64_service.c | 18 | ||||
-rw-r--r-- | mysys/base64.c | 1 | ||||
-rw-r--r-- | plugin/feedback/utils.cc | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 1 | ||||
-rw-r--r-- | sql/log_event.cc | 1 | ||||
-rw-r--r-- | sql/sql_binlog.cc | 1 | ||||
-rw-r--r-- | sql/sql_plugin_services.ic | 10 | ||||
-rw-r--r-- | unittest/mysys/base64-t.c | 1 |
18 files changed, 193 insertions, 69 deletions
diff --git a/include/base64.h b/include/base64.h deleted file mode 100644 index 9a843b5088e..00000000000 --- a/include/base64.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (c) 2003-2006 MySQL AB - Use is subject to license terms - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - -#ifndef __BASE64_H_INCLUDED__ -#define __BASE64_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - Calculate how much memory needed for dst of base64_encode() -*/ -int base64_needed_encoded_length(int length_of_data); - -/* - Maximum length base64_encode_needed_length() can accept with no overflow. -*/ -int base64_encode_max_arg_length(void); - -/* - Calculate how much memory needed for dst of base64_decode() -*/ -int base64_needed_decoded_length(int length_of_encoded_data); - -/* - Maximum length base64_decode_needed_length() can accept with no overflow. -*/ -int base64_decode_max_arg_length(); - -/* - Encode data as a base64 string -*/ -int base64_encode(const void *src, size_t src_len, char *dst); - -/* - Decode a base64 string into data -*/ -int base64_decode(const char *src, size_t src_len, - void *dst, const char **end_ptr, int flags); - -/* Allow multuple chunks 'AAA= AA== AA==', binlog uses this */ -#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS 1 - - -#ifdef __cplusplus -} -#endif -#endif /* !__BASE64_H_INCLUDED__ */ diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index d69da914215..309bae1a0b0 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -176,6 +176,22 @@ size_t my_md5_context_size(); void my_md5_init(void *context); void my_md5_input(void *context, const unsigned char *buf, size_t len); void my_md5_result(void *context, unsigned char *digest); +extern struct base64_service_st { + int (*base64_needed_encoded_length_ptr)(int length_of_data); + int (*base64_encode_max_arg_length_ptr)(void); + int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data); + int (*base64_decode_max_arg_length_ptr)(); + int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst); + int (*base64_decode_ptr)(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); +} *base64_service; +int base64_needed_encoded_length(int length_of_data); +int base64_encode_max_arg_length(void); +int base64_needed_decoded_length(int length_of_encoded_data); +int base64_decode_max_arg_length(); +int base64_encode(const void *src, size_t src_len, char *dst); +int base64_decode(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); typedef struct logger_handle_st LOGGER_HANDLE; extern struct logger_service_st { void (*logger_init_mutexes)(); diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index 274208c177d..4c28ad4035e 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -176,6 +176,22 @@ size_t my_md5_context_size(); void my_md5_init(void *context); void my_md5_input(void *context, const unsigned char *buf, size_t len); void my_md5_result(void *context, unsigned char *digest); +extern struct base64_service_st { + int (*base64_needed_encoded_length_ptr)(int length_of_data); + int (*base64_encode_max_arg_length_ptr)(void); + int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data); + int (*base64_decode_max_arg_length_ptr)(); + int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst); + int (*base64_decode_ptr)(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); +} *base64_service; +int base64_needed_encoded_length(int length_of_data); +int base64_encode_max_arg_length(void); +int base64_needed_decoded_length(int length_of_encoded_data); +int base64_decode_max_arg_length(); +int base64_encode(const void *src, size_t src_len, char *dst); +int base64_decode(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); typedef struct logger_handle_st LOGGER_HANDLE; extern struct logger_service_st { void (*logger_init_mutexes)(); diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp index 604f5386f7d..86d4427bc03 100644 --- a/include/mysql/plugin_encryption.h.pp +++ b/include/mysql/plugin_encryption.h.pp @@ -176,6 +176,22 @@ size_t my_md5_context_size(); void my_md5_init(void *context); void my_md5_input(void *context, const unsigned char *buf, size_t len); void my_md5_result(void *context, unsigned char *digest); +extern struct base64_service_st { + int (*base64_needed_encoded_length_ptr)(int length_of_data); + int (*base64_encode_max_arg_length_ptr)(void); + int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data); + int (*base64_decode_max_arg_length_ptr)(); + int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst); + int (*base64_decode_ptr)(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); +} *base64_service; +int base64_needed_encoded_length(int length_of_data); +int base64_encode_max_arg_length(void); +int base64_needed_decoded_length(int length_of_encoded_data); +int base64_decode_max_arg_length(); +int base64_encode(const void *src, size_t src_len, char *dst); +int base64_decode(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); typedef struct logger_handle_st LOGGER_HANDLE; extern struct logger_service_st { void (*logger_init_mutexes)(); diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index b11ced22a96..595735f0cf5 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -176,6 +176,22 @@ size_t my_md5_context_size(); void my_md5_init(void *context); void my_md5_input(void *context, const unsigned char *buf, size_t len); void my_md5_result(void *context, unsigned char *digest); +extern struct base64_service_st { + int (*base64_needed_encoded_length_ptr)(int length_of_data); + int (*base64_encode_max_arg_length_ptr)(void); + int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data); + int (*base64_decode_max_arg_length_ptr)(); + int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst); + int (*base64_decode_ptr)(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); +} *base64_service; +int base64_needed_encoded_length(int length_of_data); +int base64_encode_max_arg_length(void); +int base64_needed_decoded_length(int length_of_encoded_data); +int base64_decode_max_arg_length(); +int base64_encode(const void *src, size_t src_len, char *dst); +int base64_decode(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); typedef struct logger_handle_st LOGGER_HANDLE; extern struct logger_service_st { void (*logger_init_mutexes)(); diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp index ecadc9440b0..23a56273e51 100644 --- a/include/mysql/plugin_password_validation.h.pp +++ b/include/mysql/plugin_password_validation.h.pp @@ -176,6 +176,22 @@ size_t my_md5_context_size(); void my_md5_init(void *context); void my_md5_input(void *context, const unsigned char *buf, size_t len); void my_md5_result(void *context, unsigned char *digest); +extern struct base64_service_st { + int (*base64_needed_encoded_length_ptr)(int length_of_data); + int (*base64_encode_max_arg_length_ptr)(void); + int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data); + int (*base64_decode_max_arg_length_ptr)(); + int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst); + int (*base64_decode_ptr)(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); +} *base64_service; +int base64_needed_encoded_length(int length_of_data); +int base64_encode_max_arg_length(void); +int base64_needed_decoded_length(int length_of_encoded_data); +int base64_decode_max_arg_length(); +int base64_encode(const void *src, size_t src_len, char *dst); +int base64_decode(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); typedef struct logger_handle_st LOGGER_HANDLE; extern struct logger_service_st { void (*logger_init_mutexes)(); diff --git a/include/mysql/service_base64.h b/include/mysql/service_base64.h new file mode 100644 index 00000000000..6020daed6cb --- /dev/null +++ b/include/mysql/service_base64.h @@ -0,0 +1,82 @@ +#ifndef MYSQL_SERVICE_BASE64_INCLUDED +/* Copyright (c) 2017, MariaDB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + @file + my base64 service + + Functions for base64 en- and decoding +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MYSQL_ABI_CHECK +#include <stdlib.h> +#endif + +/* Allow multuple chunks 'AAA= AA== AA==', binlog uses this */ +#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS 1 + +extern struct base64_service_st { + int (*base64_needed_encoded_length_ptr)(int length_of_data); + int (*base64_encode_max_arg_length_ptr)(void); + int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data); + int (*base64_decode_max_arg_length_ptr)(); + int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst); + int (*base64_decode_ptr)(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); +} *base64_service; + +#ifdef MYSQL_DYNAMIC_PLUGIN + +#define base64_needed_encoded_length(A) base64_service->base64_needed_encoded_length_ptr(A) +#define base64_encode_max_arg_length() base64_service->base64_encode_max_arg_length_ptr() +#define base64_needed_decoded_length(A) base64_service->base64_needed_decoded_length_ptr(A) +#define base64_decode_max_arg_length() base64_service->base64_decode_max_arg_length_ptr() +#define base64_encode(A,B,C) base64_service->base64_encode_ptr(A,B,C) +#define base64_decode(A,B,C,D,E) base64_service->base64_decode_ptr(A,B,C,D,E) + +#else + +/* Calculate how much memory needed for dst of base64_encode() */ +int base64_needed_encoded_length(int length_of_data); + +/* Maximum length base64_encode_needed_length() can accept with no overflow. */ +int base64_encode_max_arg_length(void); + +/* Calculate how much memory needed for dst of base64_decode() */ +int base64_needed_decoded_length(int length_of_encoded_data); + +/* Maximum length base64_decode_needed_length() can accept with no overflow. */ +int base64_decode_max_arg_length(); + +/* Encode data as a base64 string */ +int base64_encode(const void *src, size_t src_len, char *dst); + +/* Decode a base64 string into data */ +int base64_decode(const char *src, size_t src_len, + void *dst, const char **end_ptr, int flags); + +#endif + +#ifdef __cplusplus +} +#endif + +#define MYSQL_SERVICE_BASE64_INCLUDED +#endif diff --git a/include/mysql/services.h b/include/mysql/services.h index 89c177ce7ad..3ba0ce6511c 100644 --- a/include/mysql/services.h +++ b/include/mysql/services.h @@ -29,6 +29,7 @@ extern "C" { #include <mysql/service_sha2.h> #include <mysql/service_sha1.h> #include <mysql/service_md5.h> +#include <mysql/service_base64.h> #include <mysql/service_logger.h> #include <mysql/service_thd_autoinc.h> #include <mysql/service_thd_error_context.h> diff --git a/include/service_versions.h b/include/service_versions.h index 9b333127858..f78697d277c 100644 --- a/include/service_versions.h +++ b/include/service_versions.h @@ -33,6 +33,7 @@ #define VERSION_my_md5 0x0100 #define VERSION_wsrep 0x0201 #define VERSION_logger 0x0100 +#define VERSION_base64 0x0100 #define VERSION_thd_autoinc 0x0100 #define VERSION_thd_error_context 0x0100 #define VERSION_thd_specifics 0x0100 diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt index 66ceb3087de..04f3cb4b69b 100644 --- a/libservices/CMakeLists.txt +++ b/libservices/CMakeLists.txt @@ -28,6 +28,7 @@ SET(MYSQLSERVICES_SOURCES my_sha2_service.c my_sha1_service.c my_md5_service.c + base64_service.c wsrep_service.c encryption_service.c encryption_scheme_service.c diff --git a/libservices/base64_service.c b/libservices/base64_service.c new file mode 100644 index 00000000000..af35ccd2a1c --- /dev/null +++ b/libservices/base64_service.c @@ -0,0 +1,18 @@ +/* Copyright (c) 2017 MariaDB + Use is subject to license terms. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include <service_versions.h> +SERVICE_VERSION base64_service= (void*)VERSION_base64; diff --git a/mysys/base64.c b/mysys/base64.c index 265b2f22aad..04411418857 100644 --- a/mysys/base64.c +++ b/mysys/base64.c @@ -17,7 +17,6 @@ #include <my_global.h> #include <m_string.h> /* strchr() */ #include <m_ctype.h> /* my_isspace() */ -#include <base64.h> #ifndef MAIN diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc index 669ed9a4427..0998721c868 100644 --- a/plugin/feedback/utils.cc +++ b/plugin/feedback/utils.cc @@ -19,8 +19,6 @@ #include <unistd.h> #endif -#include <base64.h> - #if defined (_WIN32) #define HAVE_SYS_UTSNAME_H diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 84cf21bd0d3..fb057f20dcf 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -48,7 +48,6 @@ #include "password.h" // my_make_scrambled_password, // my_make_scrambled_password_323 #include <m_ctype.h> -#include <base64.h> #include <my_md5.h> #include <zlib.h> C_MODE_START diff --git a/sql/log_event.cc b/sql/log_event.cc index 13a271d98da..3e2592808b1 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -46,7 +46,6 @@ #include "wsrep_mysqld.h" #endif /* MYSQL_CLIENT */ -#include <base64.h> #include <my_bitmap.h> #include "rpl_utility.h" #include "rpl_constants.h" diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index f0465cdf5bf..91cf038907e 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -20,7 +20,6 @@ #include "sql_parse.h" // check_global_access #include "sql_acl.h" // *_ACL #include "rpl_rli.h" -#include "base64.h" #include "slave.h" // apply_event_and_update_pos #include "log_event.h" // Format_description_log_event, // EVENT_LEN_OFFSET, diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic index e4a9732e888..e08870e9f98 100644 --- a/sql/sql_plugin_services.ic +++ b/sql/sql_plugin_services.ic @@ -119,6 +119,15 @@ static struct thd_autoinc_service_st thd_autoinc_handler= { thd_get_autoinc }; +static struct base64_service_st base64_handler= { + base64_needed_encoded_length, + base64_encode_max_arg_length, + base64_needed_decoded_length, + base64_decode_max_arg_length, + base64_encode, + base64_decode +}; + static struct thd_error_context_service_st thd_error_conext_handler= { thd_get_error_message, thd_get_error_number, @@ -195,6 +204,7 @@ static struct st_service_ref list_of_services[]= { "my_sha1_service", VERSION_my_sha1, &my_sha1_handler}, { "my_md5_service", VERSION_my_md5, &my_md5_handler}, { "logger_service", VERSION_logger, &logger_service_handler }, + { "base64_service", VERSION_base64, &base64_handler }, { "thd_autoinc_service", VERSION_thd_autoinc, &thd_autoinc_handler }, { "wsrep_service", VERSION_wsrep, &wsrep_handler }, { "encryption_service", VERSION_encryption, &encryption_handler }, diff --git a/unittest/mysys/base64-t.c b/unittest/mysys/base64-t.c index 1cf54f9b673..4561606936a 100644 --- a/unittest/mysys/base64-t.c +++ b/unittest/mysys/base64-t.c @@ -16,7 +16,6 @@ #include <my_global.h> #include <my_sys.h> -#include <base64.h> #include <tap.h> #include <string.h> |