[php-src] PR #25827: Fix FFI::memcpy(), FFI::memcmp() and FFI::memset() accepting a negative size

From: Date: Fri, 27 Nov 2026 09:09:52 +0000
Subject: [php-src] PR #25827: Fix FFI::memcpy(), FFI::memcmp() and FFI::memset() accepting a negative size
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-41099@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25827 Author: marc-mabe Follow-up to GH-25731, which rejected a negative size in FFI::string(). FFI::memcpy(), FFI::memcmp() and FFI::memset() have the same issue: the size was only compared with the size of non-pointer CData and the length of strings, where a negative size became a huge unsigned one and failed with a misleading data or string boundary error. For pointers, it was passed on to memcpy(), memcmp() or memset() as nearly SIZE_MAX, which crashed. Reject a negative size with a ValueError, like FFI::string() does. As GH-25731 is not released yet, its NEWS entry now covers these functions too, and string_negative_size.phpt becomes part of mem_size.phpt, which tests the sizes of all four functions.

« previous php.git-pulls (#41099) next »