Skip to content

Commit f1c5013

Browse files
committed
Fix generating authentication response with long strings
Connection attributes shall be encoded using lenenc-str approach for a separate string and the whole section.
1 parent 6ccbecc commit f1c5013

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pymysql/connections.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -898,10 +898,10 @@ def _request_authentication(self):
898898
connect_attrs = b""
899899
for k, v in self._connect_attrs.items():
900900
k = k.encode("utf-8")
901-
connect_attrs += struct.pack("B", len(k)) + k
901+
connect_attrs += _lenenc_int(len(k)) + k
902902
v = v.encode("utf-8")
903-
connect_attrs += struct.pack("B", len(v)) + v
904-
data += struct.pack("B", len(connect_attrs)) + connect_attrs
903+
connect_attrs += _lenenc_int(len(v)) + v
904+
data += _lenenc_int(len(connect_attrs)) + connect_attrs
905905

906906
self.write_packet(data)
907907
auth_packet = self._read_packet()

0 commit comments

Comments
 (0)