Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmake/do_abi_check.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
# leave a <build directory>/abi_check.out file.
#
# A developer with a justified API change will then do a
# mv <build directory>/abi_check.out include/mysql/plugin.pp
# to replace the old canons with the new ones.
# build of the target abi_update and verify the API change
# in the git difference is as intended.
#

SET(abi_check_out ${BINARY_DIR}/abi_check.out)
Expand All @@ -65,7 +65,7 @@ FOREACH(file ${ABI_HEADERS})
ERROR_QUIET OUTPUT_FILE ${tmpfile})
EXECUTE_PROCESS(
COMMAND sed -e "/^# /d"
-e "/^[ ]*$/d"
-e "/^[ ;]*$/d"
-e "/^#pragma GCC set_debug_pwd/d"
-e "/^#ident/d"
RESULT_VARIABLE result OUTPUT_FILE ${abi_check_out} INPUT_FILE ${tmpfile})
Expand Down
1 change: 0 additions & 1 deletion include/mysql/plugin_audit.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
int res1, res2;
unsigned int d1, d2= *dlen;
assert(*dlen >= slen);
assert((dst[*dlen - 1]= 1) == 1);
if (src < dst)
assert(src + slen <= dst);
else
Expand Down
1 change: 0 additions & 1 deletion include/mysql/plugin_auth.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
int res1, res2;
unsigned int d1, d2= *dlen;
assert(*dlen >= slen);
assert((dst[*dlen - 1]= 1) == 1);
if (src < dst)
assert(src + slen <= dst);
else
Expand Down
1 change: 0 additions & 1 deletion include/mysql/plugin_data_type.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
int res1, res2;
unsigned int d1, d2= *dlen;
assert(*dlen >= slen);
assert((dst[*dlen - 1]= 1) == 1);
if (src < dst)
assert(src + slen <= dst);
else
Expand Down
1 change: 0 additions & 1 deletion include/mysql/plugin_encryption.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
int res1, res2;
unsigned int d1, d2= *dlen;
assert(*dlen >= slen);
assert((dst[*dlen - 1]= 1) == 1);
if (src < dst)
assert(src + slen <= dst);
else
Expand Down
1 change: 0 additions & 1 deletion include/mysql/plugin_ftparser.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
int res1, res2;
unsigned int d1, d2= *dlen;
assert(*dlen >= slen);
assert((dst[*dlen - 1]= 1) == 1);
if (src < dst)
assert(src + slen <= dst);
else
Expand Down
1 change: 0 additions & 1 deletion include/mysql/plugin_function.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
int res1, res2;
unsigned int d1, d2= *dlen;
assert(*dlen >= slen);
assert((dst[*dlen - 1]= 1) == 1);
if (src < dst)
assert(src + slen <= dst);
else
Expand Down
1 change: 0 additions & 1 deletion include/mysql/plugin_password_validation.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
int res1, res2;
unsigned int d1, d2= *dlen;
assert(*dlen >= slen);
assert((dst[*dlen - 1]= 1) == 1);
if (src < dst)
assert(src + slen <= dst);
else
Expand Down
22 changes: 19 additions & 3 deletions include/mysql/service_encryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,23 @@

#ifndef MYSQL_ABI_CHECK
#include <my_alloca.h>
#ifdef __has_include
#if __has_include(<my_valgrind.h>)
#include <my_valgrind.h>
#endif
Comment on lines +30 to +32
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The __has_include preprocessor operator is not available in all compilers (it was introduced in GCC 5). Using it directly will cause a compilation error on older compilers that MariaDB still supports. It should be guarded with #ifdef __has_include to ensure portability.

Suggested change
#if __has_include(<my_valgrind.h>)
#include <my_valgrind.h>
#endif
#ifdef __has_include
#if __has_include(<my_valgrind.h>)
#include <my_valgrind.h>
#endif
#endif

#endif
#ifdef _WIN32
#ifndef __cplusplus
#define inline __inline
#endif
#endif
#endif

#ifndef MEM_UNDEFINED
#define MEM_UNDEFINED(addr, length)
#define MEM_CHECK_ADDRESSABLE(addr, length)
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -119,10 +129,16 @@ static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
int res1, res2;
unsigned int d1, d2= *dlen;

// Verify dlen is initialized properly. See MDEV-30389
/* Verify dlen is initialized properly. */
assert(*dlen >= slen);
assert((dst[*dlen - 1]= 1) == 1);
// Verify buffers do not overlap
/* ensure we're not leaking output */
MEM_UNDEFINED(dst, *dlen);
/* inputs should be accessible */
MEM_CHECK_ADDRESSABLE(src, slen);
MEM_CHECK_ADDRESSABLE(dst, *dlen);
MEM_CHECK_ADDRESSABLE(key, klen);
MEM_CHECK_ADDRESSABLE(iv, ivlen);
/* Verify buffers do not overlap */
if (src < dst)
assert(src + slen <= dst);
else
Expand Down
Loading