Skip to content

Commit f371dd5

Browse files
committed
Fix connection procedure auth-switch password.
For AuthSwitch feature, mysql_native_password and mysql_old_password should reply only 8-byte or 20-byte scrambled password without \0. So fixed it.
1 parent a29347c commit f371dd5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pymysql/connections.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1183,10 +1183,10 @@ def _process_auth(self, plugin_name, auth_packet):
11831183
handler = None
11841184
if plugin_name == b"mysql_native_password":
11851185
# https://dev.mysql.com/doc/internals/en/secure-password-authentication.html#packet-Authentication::Native41
1186-
data = _scramble(self.password.encode('latin1'), auth_packet.read_all()) + b'\0'
1186+
data = _scramble(self.password.encode('latin1'), auth_packet.read_all())
11871187
elif plugin_name == b"mysql_old_password":
11881188
# https://dev.mysql.com/doc/internals/en/old-password-authentication.html
1189-
data = _scramble_323(self.password.encode('latin1'), auth_packet.read_all()) + b'\0'
1189+
data = _scramble_323(self.password.encode('latin1'), auth_packet.read_all())
11901190
elif plugin_name == b"mysql_clear_password":
11911191
# https://dev.mysql.com/doc/internals/en/clear-text-authentication.html
11921192
data = self.password.encode('latin1') + b'\0'

0 commit comments

Comments
 (0)