Skip to content

Commit

Permalink
Add NULL terminator to mysql_clear_password. Fixes #703
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrainger committed Sep 25, 2019
1 parent c28126e commit dc3b75c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/MySqlConnector/Core/ServerSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,10 @@ private async Task<PayloadData> SwitchAuthenticationAsync(ConnectionSettings cs,
Log.Error("Session{0} needs a secure connection to use AuthenticationMethod '{1}'", m_logArguments);
throw new MySqlException(MySqlErrorCode.UnableToConnectToHost, "Authentication method '{0}' requires a secure connection.".FormatInvariant(switchRequest.Name));
}
payload = new PayloadData(Encoding.UTF8.GetBytes(cs.Password));
// send the password as a NULL-terminated UTF-8 string
var passwordBytes = Encoding.UTF8.GetBytes(cs.Password);
Array.Resize(ref passwordBytes, passwordBytes.Length + 1);
payload = new PayloadData(passwordBytes);
await SendReplyAsync(payload, ioBehavior, cancellationToken).ConfigureAwait(false);
return await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);

Expand Down

0 comments on commit dc3b75c

Please sign in to comment.