[php-src] master: ext/mysqlnd: add a hardening assertion that the fetch callback is set (#23716)

From: Date: Fri, 18 Sep 2026 01:15:06 +0000
Subject: [php-src] master: ext/mysqlnd: add a hardening assertion that the fetch callback is set (#23716)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141259@lists.php.net to get a copy of this message
Author: Daniel Scherzer (DanielEScherzer) Committer: GitHub (web-flow) Pusher: DanielEScherzer Date: 2026-09-17T18:15:03-07:00 Commit: https://github.com/php/php-src/commit/5774f0edaa1db09cc02030b6348bef4b5d4bf4c2 Raw diff: https://github.com/php/php-src/commit/5774f0edaa1db09cc02030b6348bef4b5d4bf4c2.diff ext/mysqlnd: add a hardening assertion that the fetch callback is set (#23716) Given that the knowledge that the fetch callback is not null is based on validation that was done separately, and there are indeed entries in mysqlnd_ps_fetch_functions where the callback is null, add a ZEND_ASSERT that the function is not null as a hardening measure. Changed paths: M ext/mysqlnd/mysqlnd_wireprotocol.c Diff: diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index b957240a4088..c779f747ec8c 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -1497,7 +1497,10 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fi php_error_docref(NULL, E_WARNING, "Malformed server packet. No packet space left for the field"); DBG_RETURN(FAIL); } - mysqlnd_ps_fetch_functions[type].func(current_field, &fields_metadata[i], rbs - row_position, &p); + const ps_field_fetch_func type_fetch = mysqlnd_ps_fetch_functions[type].func; + /* Some agents think that this can be null. */ + ZEND_ASSERT(type_fetch != NULL && "Type was validated, known types have functions set properly"); + type_fetch(current_field, &fields_metadata[i], rbs - row_position, &p); if (p == NULL) { for (j = 0, current_field = start_field; j < i; current_field++, j++) { zval_ptr_dtor(current_field);

« previous php.cvs (#141259) next »