-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDEV-35299 #3613
base: 10.5
Are you sure you want to change the base?
MDEV-35299 #3613
Conversation
|
@@ -493,8 +493,13 @@ size_t Inet6::to_string(char *dst, size_t dstsize) const | |||
// | |||
// If it is not the last field, append closing ':'. | |||
|
|||
p += sprintf(p, "%x", ipv6_words[i]); | |||
int ret= snprintf(p, dstsize_available, "%x", ipv6_words[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With Vista EOL this could be inet_ntop
now. Btw good pattern, a recent security conference shows the dangers of p+= snprintf(p
because it doesn't mean that the full length was written to the buffer.
Is it really safe to return without a SQL warning pushed?
sql/log_event.cc
Outdated
@@ -1409,7 +1409,14 @@ code_name(int code) | |||
case Q_MASTER_DATA_WRITTEN_CODE: return "Q_MASTER_DATA_WRITTEN_CODE"; | |||
case Q_HRNOW: return "Q_HRNOW"; | |||
} | |||
#ifdef __clang__ | |||
#pragma clang diagnostic push | |||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notably never reached as CHECK_SPACE
, the only caller of code_name
always has a valid code. Changing to a snprint would be less verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the exact same comment in MDEV-35299 a couple of days ago. Basically, after a proper fix, git grep -w sprintf
should not return anything.
sql/log_event.h
Outdated
@@ -3177,22 +3188,11 @@ inline char *serialize_xid(char *buf, long fmt, long gln, long bln, | |||
c+= 2; | |||
} | |||
c[0]= '\''; | |||
sprintf(c+1, ",%lu", fmt); | |||
snprintf(c + 1, ser_buf_size - 1, ",%lu", fmt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically ser_buf_size - 1 - (2 + (gln + bln) * 2 + 4 + 1)
sql/log_event_client.cc
Outdated
sprintf(tmp, "%-.20g", dbl); /* strmake doesn't support %-20g */ | ||
#ifdef __clang__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think compilers could determine if this is safe with a sizeof rather than warning suppression.
Could expand on safe vs not safe in commit message.
01b027b
to
dbb581e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that all occurrences of sprintf()
must be replaced. This should be easy to check with git grep -w sprintf
.
storage/innobase/ut/ut0ut.cc
Outdated
char* buf) /*!< in: buffer where to sprintf */ | ||
char* buf, /*!< in: buffer where to sprintf */ | ||
size_t len) | ||
{ | ||
#ifdef _WIN32 | ||
SYSTEMTIME cal_tm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter len
is undocumented and not used #ifdef _WIN32
.
dbb581e
to
9ab2c7c
Compare
sql/password.c
Outdated
{ | ||
ulong hash_res[2]; | ||
hash_password(hash_res, password, (uint) pass_len); | ||
#ifdef __clang__ | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
#endif | ||
sprintf(to, "%08lx%08lx", hash_res[0], hash_res[1]); | ||
#ifdef __clang__ | ||
#pragma clang diagnostic pop | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least one caller (execute_commands()
in client/mysqladmin.cc
) is invoking this with to
pointing to a buffer of 64 bytes. Based on the format expression, the length should be 16 bytes. Based on the ulong
data type, whose size is 64 bits on LP64 systems and 32 bits elsewhere (including the LLP64 Microsoft Windows), the length could be up to 32 bytes. It seems to me that the ulong
should be replaced with uint32_t
, because SCRAMBLE_LENGTH_323
is defined as 8.
In Item_func_password::val_str_ascii()
, the argument is a pointer to the buffer tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH+1]
. It seems that this is the length that should be passed to snprintf
here, and should be mentioned in the function documentation as well.
sql/password.c
Outdated
void make_password_from_salt_323(char *to, const ulong *salt) | ||
{ | ||
#ifdef __clang__ | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
#endif | ||
sprintf(to,"%08lx%08lx", salt[0], salt[1]); | ||
#ifdef __clang__ | ||
#pragma clang diagnostic pop | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function seems to have been orphaned in 1ff476b. Is it really needed?
13f17b0
to
c13f5ca
Compare
Build failure was caused by using the sprintf C API function that is marked as deprecated in MacOS Monterey. Since building of server is performaed with the compiler flag -Werror it results in build failure. To fix the issue, every use of the C API function sprintf has been replaced with snprintf throughout the source code. Source code of the storage engine CONNECT wasn't modified.
c13f5ca
to
689a190
Compare
Description
Support compilation of the server on MacOS with XCode 14.2
How can this PR be tested?
Try to build server on MacOS with XCode 14.2
Basing the PR against the correct MariaDB version
main
branch.PR quality check