From 0d922aa59512a994336c243f1527258d09e4b3f8 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 9 Aug 2023 18:09:54 +0100 Subject: [PATCH] Fix error checking in mysqlnd Closes GH-11925 --- NEWS | 2 ++ ext/mysqlnd/mysqlnd_protocol_frame_codec.c | 1 + 2 files changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 8057a9cf0a736..b8bfcace9f65f 100644 --- a/NEWS +++ b/NEWS @@ -42,6 +42,8 @@ PHP NEWS . Fixed bug GH-11550 (MySQL Statement has a empty query result when the response field has changed, also Segmentation fault). (Yurunsoft) + . Fixed invalid error message "Malformed packet" when connection is dropped. + (Kamil Tekiela) - Opcache: . Fixed bug GH-11715 (opcache.interned_strings_buffer either has no effect or diff --git a/ext/mysqlnd/mysqlnd_protocol_frame_codec.c b/ext/mysqlnd/mysqlnd_protocol_frame_codec.c index ca34108d72668..4fcf5fb9aa9ea 100644 --- a/ext/mysqlnd/mysqlnd_protocol_frame_codec.c +++ b/ext/mysqlnd/mysqlnd_protocol_frame_codec.c @@ -202,6 +202,7 @@ MYSQLND_METHOD(mysqlnd_pfc, send)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const v if (bytes_sent <= 0) { DBG_ERR_FMT("Can't %zu send bytes", count); SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); + bytes_sent = 0; // the return type is unsigned and 0 represents an error condition } DBG_RETURN(bytes_sent); }