Skip to content

Fix #78114: segfault when calling sodium_* functions from eval #4230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 4 additions & 2 deletions ext/sodium/libsodium.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,10 @@ static void sodium_remove_param_values_from_backtrace(zend_object *obj) {
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(trace), frame) {
if (Z_TYPE_P(frame) == IS_ARRAY) {
zval *args = zend_hash_str_find(Z_ARRVAL_P(frame), "args", sizeof("args")-1);
zval_ptr_dtor(args);
ZVAL_EMPTY_ARRAY(args);
if (args) {
zval_ptr_dtor(args);
ZVAL_EMPTY_ARRAY(args);
}
}
} ZEND_HASH_FOREACH_END();
}
Expand Down
18 changes: 18 additions & 0 deletions ext/sodium/tests/bug78114.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Bug #78114 (segfault when calling sodium_* functions from eval)
--SKIPIF--
<?php
if (!extension_loaded('sodium')) die('skip sodium extension not available');
?>
--FILE--
<?php
try {
eval('sodium_bin2hex();');
} catch (Throwable $ex) {
echo $ex->getMessage(), PHP_EOL;
}
?>
===DONE===
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop unnecessary ===DONE===.

--EXPECT--
sodium_bin2hex() expects exactly 1 parameter, 0 given
===DONE===