Skip to content

Commit 5a5cfd5

Browse files
committed
Bug#33520778 compiler warnings in authentication_win
Issue ===== clang on windows reports: libmysql/authentication_win/common.h(169,41): warning: cast from 'const char *' to 'unsigned char *' drops const qualifier [-Wcast-qual] Blob(const char *str) : m_ptr((byte *)str) { m_len = strlen(str); } libmysql/authentication_win/plugin_client.cc(64,30): warning: missing field 'authenticate_user_nonblocking' initializer [-Wmissing-field-initializers] win_auth_handshake_client}; libmysql/authentication_win/handshake.cc(57,25): warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] NULL, (SEC_CHAR *)ssp, libmysql/authentication_win/handshake_client.cc(183,17): warning: variable 'saved_byte' may be uninitialized when used here [-Wconditional-uninitialized] data[254] = saved_byte; Change ====== - reinterpret_cast<...>(byte) instead of c-style cast - set authenticate_user_nonblocking in win_auth_client_plugin to 0 - const_cast<SEC_CHAR *> - initialize saved_byte RB: 27204
1 parent 4754aec commit 5a5cfd5

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

libmysql/authentication_win/common.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ class Blob {
166166
Blob(const byte *ptr, const size_t len)
167167
: m_ptr(const_cast<byte *>(ptr)), m_len(len) {}
168168

169-
Blob(const char *str) : m_ptr((byte *)str) { m_len = strlen(str); }
169+
Blob(const char *str)
170+
: m_ptr(const_cast<byte *>(reinterpret_cast<const byte *>(str))) {
171+
m_len = strlen(str);
172+
}
170173

171174
byte *ptr() const { return m_ptr; }
172175

libmysql/authentication_win/handshake.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Handshake::Handshake(const char *ssp, side_t side)
5454
// Obtain credentials for the authentication handshake.
5555

5656
ret = AcquireCredentialsHandle(
57-
NULL, (SEC_CHAR *)ssp,
57+
NULL, const_cast<SEC_CHAR *>(ssp),
5858
side == SERVER ? SECPKG_CRED_INBOUND : SECPKG_CRED_OUTBOUND, NULL, NULL,
5959
NULL, NULL, &m_cred, &m_expire);
6060

libmysql/authentication_win/handshake_client.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ int Handshake_client::write_packet(Blob &data) {
139139
which can be used to allocate buffer of appropriate size.
140140
*/
141141

142-
size_t len2 = 0; // length of the second part of first data payload
143-
byte saved_byte; // for saving byte 255 in which data length is stored
142+
size_t len2 = 0; // length of the second part of first data payload
143+
byte saved_byte = 0; // for saving byte 255 in which data length is stored
144144

145145
if (m_round == 1 && data.len() > 254) {
146146
len2 = data.len() - 254;

libmysql/authentication_win/plugin_client.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ extern "C" auth_plugin_t win_auth_client_plugin = {
6161
win_auth_client_plugin_deinit,
6262
NULL, // option handling
6363
NULL,
64-
win_auth_handshake_client};
64+
win_auth_handshake_client,
65+
nullptr};

0 commit comments

Comments
 (0)