Repository navigation
Conversation
|
can the following test case be added ? $linger = new stdClass();
$linger->l_onoff = new stdClass();
$linger->l_linger = 5;
set_error_handler(function () use ($linger) {
$tmp = (array) $linger;
$linger->extra = 1;
unset($tmp);
return true;
});
socket_set_option(socket_create(AF_INET, SOCK_STREAM, SOL_TCP), SOL_SOCKET, SO_LINGER, $linger); |
|
Added in 37088c0. That case still crashed, so the object's property table is now held with |
| RETURN_THROWS(); | ||
| } else { | ||
| opt_ht = Z_OBJPROP_P(arg4); | ||
| opt_ht = opt_props = zend_get_properties_for(arg4, ZEND_PROP_PURPOSE_ARRAY_CAST); |
There was a problem hiding this comment.
| opt_ht = opt_props = zend_get_properties_for(arg4, ZEND_PROP_PURPOSE_ARRAY_CAST); | |
| - opt_ht = opt_props = zend_get_properties_for(arg4, ZEND_PROP_PURPOSE_ARRAY_CAST); | |
| + opt_props = zend_get_properties_for(arg4, ZEND_PROP_PURPOSE_ARRAY_CAST); | |
| + opt_ht = opt_props ? opt_props : (HashTable *) &zend_empty_array; |
There was a problem hiding this comment.
Applied in 2f771be, for SO_RCVTIMEO/SO_SNDTIMEO as well.
iliaal
left a comment
There was a problem hiding this comment.
Please address the lifetime issue noted inline.
|
|
||
| zend_long val_lonoff = zval_get_long(l_onoff); | ||
| zend_long val_linger = zval_get_long(l_linger); | ||
| zend_release_properties(opt_props); |
There was a problem hiding this comment.
zend_get_properties_for(..., ZEND_PROP_PURPOSE_ARRAY_CAST) can return a temporary table (for example, ArrayObject returns a duplicate). This release destroys that table, but the subsequent linger range-error formatter still passes l_linger to %s, causing a use-after-free read.
The incorrect format argument predates this PR; freeing its backing table before formatting introduces the lifetime defect. Please pass l_linger_key instead of l_linger to zend_argument_value_error() and add regression coverage for this validation path with a temporary property table.
There was a problem hiding this comment.
Fixed in 312d69e. The error now uses l_linger_key, and gh24748.phpt covers it with an out-of-range ArrayObject.
iliaal
left a comment
There was a problem hiding this comment.
Thanks for fix, i'll merge once ci/cd passes
|
We normally just removed support for code that crashes as clearly nobody used it. |
I'll +1 the RFC to deprecate/remove it if you write it ;-) |
|
It crashes, why are you trying to fix code that crashes in a way that will get deprecated? |
|
The RFC line was tongue-in-cheek. More to the point, this isn't code that always crashed: through 8.3.15 and 8.4.2 the value went through |
Declared properties sit in the object's property table as indirect slots, and the SO_LINGER and SO_RCVTIMEO/SO_SNDTIMEO paths looked them up with
zend_hash_str_find(), sozval_get_long()got anIS_INDIRECTzval and crashed. Usingzend_hash_str_find_ind()follows the slot, and an uninitialized typed property now gives the usual "must have key" error.Fixes #24748