Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 779d17d

Browse files
committed
Fix handle AuthSwitch packet bug.
MySQL documents annouce the AuthSwitch packet is contains with two component `auth_plugin_name` and `auth_data`, which `auth_data` is a string[EOF] string. But in fact it will return a string[NUL] string or can also say the string[EOF] is consist of a 20bytes string and a '\0' byte. Now we just follow the document which use those 21bytes as salt and that is not correct.
1 parent ef91351 commit 779d17d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pymysql/connections.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,16 @@ def is_ascii(data):
132132
print()
133133

134134

135+
SCRAMBLE_LENGTH = 20
136+
135137
def _scramble(password, message):
136138
if not password:
137139
return b''
138140
if DEBUG: print('password=' + str(password))
139141
stage1 = sha_new(password).digest()
140142
stage2 = sha_new(stage1).digest()
141143
s = sha_new()
142-
s.update(message)
144+
s.update(message[:SCRAMBLE_LENGTH])
143145
s.update(stage2)
144146
result = s.digest()
145147
return _my_crypt(result, stage1)

0 commit comments

Comments
 (0)