File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ def parse_handshake(self, packet):
173
173
capabilities2 ,
174
174
auth_data_length
175
175
) = struct_unpack ('<I8sx2sBH2sBxxxxxxxxxx' , packet [0 :31 ])
176
+ res ['server_version_original' ] = res ['server_version_original' ].decode ()
176
177
177
178
packet = packet [31 :]
178
179
@@ -186,15 +187,19 @@ def parse_handshake(self, packet):
186
187
auth_data2 = auth_data2 [:- 1 ]
187
188
188
189
if capabilities & ClientFlag .PLUGIN_AUTH :
189
- (packet , res ['auth_plugin' ]) = utils .read_string (
190
- packet , end = b'\x00 ' )
190
+ if (b'\x00 ' not in packet
191
+ and res ['server_version_original' ].startswith ("5.5.8" )):
192
+ # MySQL server 5.5.8 has a bug where end byte is not send
193
+ (packet , res ['auth_plugin' ]) = (b'' , packet )
194
+ else :
195
+ (packet , res ['auth_plugin' ]) = utils .read_string (
196
+ packet , end = b'\x00 ' )
191
197
res ['auth_plugin' ] = res ['auth_plugin' ].decode ('utf-8' )
192
198
else :
193
199
res ['auth_plugin' ] = 'mysql_native_password'
194
200
195
201
res ['auth_data' ] = auth_data1 + auth_data2
196
202
res ['capabilities' ] = capabilities
197
- res ['server_version_original' ] = res ['server_version_original' ].decode ()
198
203
return res
199
204
200
205
def parse_ok (self , packet ):
Original file line number Diff line number Diff line change @@ -231,6 +231,11 @@ def test_parse_handshake(self):
231
231
res = self ._protocol .parse_handshake (handshake )
232
232
self .assertEqual (exp , res )
233
233
234
+ # Test when end byte \x00 is not present for server 5.5.8
235
+ handshake = handshake [:- 1 ]
236
+ res = self ._protocol .parse_handshake (handshake )
237
+ self .assertEqual (exp , res )
238
+
234
239
def test_parse_ok (self ):
235
240
"""Parse OK-packet sent by MySQL"""
236
241
res = self ._protocol .parse_ok (OK_PACKET )
You can’t perform that action at this time.
0 commit comments