commit 6e08515d6ae372a8963937da5d4130fc875fe43e (HEAD -> 8.0) Author: wangzhengmao.wzm Date: Mon Mar 18 10:08:25 2024 +0800 BUG#114338 Client might receive incorrect data in ps-protocol When sending time data type in ps-protocol, if server cannot allocate new buffer on the heap, data got by client would be wrong. Even crash occurs in debug mode. Reason: For return value of Protocol_binary::store_time function, False on success, true on failure. If pos is assigned as nullptr, it means that an error occurred when attempting to allocate memory or memory allocation length exceeded allowed limit (4GB) for String Class. But when pos is aqual to nullptr, Protocol_binary::store_time function return false, indicating that no errors have occurred. How to fix: When pos is assigned as nullptr, Protocol_binary::store_time should return true instead of false to indicate that an error has occurred. diff --git a/sql/protocol_classic.cc b/sql/protocol_classic.cc index 4473ab2edc4..73f67a567a6 100644 --- a/sql/protocol_classic.cc +++ b/sql/protocol_classic.cc @@ -3950,7 +3950,7 @@ bool Protocol_binary::store_time(const MYSQL_TIME &tm, uint precision) { length = 0; char *pos = packet->prep_append(length + 1, PACKET_BUFFER_EXTRA_ALLOC); - if (pos == nullptr) return false; + if (pos == nullptr) return true; *pos++ = char(length); const char *const end = pos + length;