Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static zend_always_inline uint32_t prop_get_flags(const property_reference *ref)

static inline bool is_closure_invoke(const zend_class_entry *ce, const zend_string *lcname) {
return ce == zend_ce_closure
&& zend_string_equals_literal(lcname, ZEND_INVOKE_FUNC_NAME);
&& zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE));
}

static zend_function *_copy_function(zend_function *fptr) /* {{{ */
Expand Down
11 changes: 1 addition & 10 deletions ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "ext/standard/url_scanner_ex.h"
#include "ext/standard/info.h"
#include "zend_smart_str.h"
#include "zend_exceptions.h"
#include "ext/standard/url.h"
#include "ext/standard/basic_functions.h"
#include "ext/standard/head.h"
Expand Down Expand Up @@ -1725,16 +1724,8 @@ PHPAPI php_session_status php_get_session_status(void)
static bool php_session_abort(void)
{
if (PS(session_status) == php_session_active) {
if ((PS(mod_data) || PS(mod_user_implemented)) && PS(mod)->s_close) {
zend_object *old_exception = EG(exception);
EG(exception) = NULL;

if (PS(mod_data) || PS(mod_user_implemented)) {
PS(mod)->s_close(&PS(mod_data));
if (!EG(exception)) {
EG(exception) = old_exception;
} else if (old_exception) {
zend_exception_set_previous(EG(exception), old_exception);
}
}
PS(session_status) = php_session_none;
return true;
Expand Down
35 changes: 0 additions & 35 deletions ext/session/tests/sessionhandler_validateid_return_type.phpt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i
--EXPECTF--
*** Testing session_set_save_handler() : incorrect arguments for existing handler open ***
Open:

Warning: SessionHandler::close(): Parent session handler is not open in %s on line %d
SessionHandler::open() expects exactly 2 arguments, 0 given

Warning: Undefined global variable $_SESSION in %s on line %d
Expand Down
15 changes: 5 additions & 10 deletions ext/soap/php_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -2439,13 +2439,7 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
if (style == SOAP_ENCODED) {
if (soap_version == SOAP_1_1) {
smart_str_0(&array_type);
#if defined(__GNUC__) && __GNUC__ >= 11
ZEND_DIAGNOSTIC_IGNORED_START("-Wstringop-overread")
#endif
bool is_xsd_any_type = strcmp(ZSTR_VAL(array_type.s),"xsd:anyType") == 0;
#if defined(__GNUC__) && __GNUC__ >= 11
ZEND_DIAGNOSTIC_IGNORED_END
#endif
bool is_xsd_any_type = zend_string_equals_literal(array_type.s, "xsd:anyType");
if (is_xsd_any_type) {
smart_str_free(&array_type);
smart_str_appendl(&array_type,"xsd:ur-type",sizeof("xsd:ur-type")-1);
Expand Down Expand Up @@ -2529,19 +2523,20 @@ static zval *to_zval_array(zval *ret, encodeTypePtr type, xmlNodePtr data)
xmlNsPtr nsptr;

parse_namespace(attr->children->content, &type, &ns);
char *type_dup = estrdup(type);
nsptr = xmlSearchNs(attr->doc, attr->parent, BAD_CAST(ns));

end = strrchr(type,'[');
end = strrchr(type_dup,'[');
if (end) {
*end = '\0';
dimension = calc_dimension(end+1);
dims = get_position(dimension, end+1);
}
if (nsptr != NULL) {
enc = get_encoder(SOAP_GLOBAL(sdl), (char*)nsptr->href, type);
enc = get_encoder(SOAP_GLOBAL(sdl), (char*)nsptr->href, type_dup);
}
if (ns) {efree(ns);}

if (type_dup) efree(type_dup);
} else if ((attr = get_soap_enc_attribute(data->properties,"itemType")) &&
attr->children &&
attr->children->content) {
Expand Down
8 changes: 5 additions & 3 deletions ext/sysvshm/sysvshm.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,13 @@ PHP_FUNCTION(shm_get_var)
shm_data = &shm_var->mem;

PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (php_var_unserialize(return_value, (const unsigned char **) &shm_data, (unsigned char *) shm_data + shm_var->length, &var_hash) != 1) {
int res = php_var_unserialize(return_value, (const unsigned char **) &shm_data, (unsigned char *) shm_data + shm_var->length, &var_hash);
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
if (res != 1) {
php_error_docref(NULL, E_WARNING, "Variable data in shared memory is corrupted");
RETVAL_FALSE;
zval_ptr_dtor(return_value);
RETURN_FALSE;
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
}
/* }}} */

Expand Down
37 changes: 37 additions & 0 deletions ext/sysvshm/tests/shm_get_var_leak.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--TEST--
shm_get_var() leaks if variable is corrupted
--EXTENSIONS--
sysvshm
ffi
--INI--
ffi.enable=1
--SKIPIF--
<?php
if (!function_exists('ftok')) die('skip needs ftok');
if (PHP_INT_SIZE !== 8) die('skip only for 64-bit');
if (PHP_OS_FAMILY !== 'Linux') die('skip only for decent operating systems');
?>
--FILE--
<?php

$key = ftok(__FILE__, 't');
$s = shm_attach($key, 128);

shm_put_var($s, 0, [1, 2]);

$ffi = FFI::cdef(<<<CODE
int shmget(int, size_t, int);
char *shmat(int, const void *, int);
CODE);
$ptr = $ffi->shmat($ffi->shmget($key, 0, 0), $ffi->new('void *'), 0);

$ptr[0x40 + 13] = 0; // Corrupt first byte of second element of serialized data

var_dump(shm_get_var($s, 0));

shm_remove($s);

?>
--EXPECTF--
Warning: shm_get_var(): Variable data in shared memory is corrupted in %s on line %d
bool(false)