summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-02-24 11:45:25 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-02-24 11:46:35 +0100
commit23afc62080588f612fa6c5d0ea217564930dab3d (patch)
treecae7bd5ade44f4e82d68ae003d21ea69065d10ba /ext
parentae2ea348dd340ef90108efbf0a815380caf1873e (diff)
downloadphp-git-23afc62080588f612fa6c5d0ea217564930dab3d.tar.gz
Allow pointer to end of memory in IS_UNSERIALIZED()
We already use <= for IS_SERIALIZED(), but the same general problem can also occur for IS_UNSERIALIZED(). We don't seem to hit this in practice prior to GH-5595 though.
Diffstat (limited to 'ext')
-rw-r--r--ext/opcache/zend_file_cache.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index 7948797864..d89c462df5 100644
--- a/ext/opcache/zend_file_cache.c
+++ b/ext/opcache/zend_file_cache.c
@@ -113,11 +113,13 @@ static int zend_file_cache_flock(int fd, int type)
#define IS_SERIALIZED_INTERNED(ptr) \
((size_t)(ptr) & Z_UL(1))
-/* Allowing == here to account for a potential empty allocation at the end of the memory */
+/* Allowing == on the upper bound accounts for a potential empty allocation at the end of the
+ * memory region. This can also happen for a return-type-only arg_info, where &arg_info[1] is
+ * stored, which may point to the end of the region. */
#define IS_SERIALIZED(ptr) \
((char*)(ptr) <= (char*)script->size)
#define IS_UNSERIALIZED(ptr) \
- (((char*)(ptr) >= (char*)script->mem && (char*)(ptr) < (char*)script->mem + script->size) || \
+ (((char*)(ptr) >= (char*)script->mem && (char*)(ptr) <= (char*)script->mem + script->size) || \
IS_ACCEL_INTERNED(ptr))
#define SERIALIZE_PTR(ptr) do { \
if (ptr) { \