Bug #91642 Document how protocol version 4.0 and 4.1 differ on how strings are terminated
Submitted: 15 Jul 2018 15:29 Modified: 16 Jul 2018 5:44
Reporter: Rene' Cannao' Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.7, 8.0 OS:Any
Assigned to: CPU Architecture:Any

[15 Jul 2018 15:29] Rene' Cannao'
Description:
From sql/auth/sql_authentication.cc:

  /*
    The 4.0 and 4.1 versions of the protocol differ on how strings
    are terminated. In the 4.0 version, if a string is at the end
    of the packet, the string is not null terminated. Do not assume
    that the returned string is always null terminated.
  */

This details should be described in either of both of these two documentation pages:
https://dev.mysql.com/doc/internals/en/string.html
https://dev.mysql.com/doc/internals/en/connection-phase-packets.html

For instance, the above link expects that database is a null terminated string (string[NUL], or Protocol::NulTerminatedString).
While on protocol version 4.0 it is either Protocol::NulTerminatedString or Protocol::RestOfPacketString

How to repeat:
Open the links above: there is no description of how strings are terminated in protocol 4.0 and 4.1

Suggested fix:
Add in the documentation what described in the source code:

  /*
    The 4.0 and 4.1 versions of the protocol differ on how strings
    are terminated. In the 4.0 version, if a string is at the end
    of the packet, the string is not null terminated. Do not assume
    that the returned string is always null terminated.
  */
[16 Jul 2018 5:44] MySQL Verification Team
Hello Rene,

Thank you for the report!

Regards,
Umesh