mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix crashes in enchant when passing null bytes
This commit is contained in:
@@ -332,7 +332,7 @@ PHP_FUNCTION(enchant_broker_set_dict_path)
|
||||
char *value;
|
||||
size_t value_len;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ols", &broker, enchant_broker_ce, &dict_type, &value, &value_len) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olp", &broker, enchant_broker_ce, &dict_type, &value, &value_len) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ PHP_FUNCTION(enchant_broker_request_dict)
|
||||
char *tag;
|
||||
size_t taglen;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &broker, enchant_broker_ce, &tag, &taglen) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op", &broker, enchant_broker_ce, &tag, &taglen) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ PHP_FUNCTION(enchant_broker_dict_exists)
|
||||
size_t taglen;
|
||||
enchant_broker * pbroker;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &broker, enchant_broker_ce, &tag, &taglen) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op", &broker, enchant_broker_ce, &tag, &taglen) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@@ -548,7 +548,7 @@ PHP_FUNCTION(enchant_broker_set_ordering)
|
||||
size_t ptaglen;
|
||||
enchant_broker * pbroker;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oss", &broker, enchant_broker_ce, &ptag, &ptaglen, &pordering, &porderinglen) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Opp", &broker, enchant_broker_ce, &ptag, &ptaglen, &pordering, &porderinglen) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ PHP_FUNCTION(enchant_dict_quick_check)
|
||||
size_t wordlen;
|
||||
enchant_dict *pdict;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os|z", &dict, enchant_dict_ce, &word, &wordlen, &sugg) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op|z", &dict, enchant_dict_ce, &word, &wordlen, &sugg) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ PHP_FUNCTION(enchant_dict_check)
|
||||
size_t wordlen;
|
||||
enchant_dict *pdict;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ PHP_FUNCTION(enchant_dict_suggest)
|
||||
enchant_dict *pdict;
|
||||
size_t n_sugg;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@@ -679,7 +679,7 @@ PHP_FUNCTION(enchant_dict_add)
|
||||
size_t wordlen;
|
||||
enchant_dict *pdict;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@@ -697,7 +697,7 @@ PHP_FUNCTION(enchant_dict_add_to_session)
|
||||
size_t wordlen;
|
||||
enchant_dict *pdict;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@@ -715,7 +715,7 @@ PHP_FUNCTION(enchant_dict_is_added)
|
||||
size_t wordlen;
|
||||
enchant_dict *pdict;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@@ -737,7 +737,7 @@ PHP_FUNCTION(enchant_dict_store_replacement)
|
||||
|
||||
enchant_dict *pdict;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oss", &dict, enchant_dict_ce, &mis, &mislen, &cor, &corlen) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Opp", &dict, enchant_dict_ce, &mis, &mislen, &cor, &corlen) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
|
||||
70
ext/enchant/tests/null_bytes.phpt
Normal file
70
ext/enchant/tests/null_bytes.phpt
Normal file
@@ -0,0 +1,70 @@
|
||||
--TEST--
|
||||
null bytes
|
||||
--EXTENSIONS--
|
||||
enchant
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$broker = enchant_broker_init();
|
||||
if (!enchant_broker_list_dicts($broker)) die("skip No broker dicts installed");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$broker = enchant_broker_init();
|
||||
$dicts = enchant_broker_list_dicts($broker);
|
||||
$requestDict = enchant_broker_request_dict($broker, $dicts[0]['lang_tag']);
|
||||
|
||||
$two_params_broker = [
|
||||
"enchant_broker_request_dict",
|
||||
"enchant_broker_dict_exists",
|
||||
];
|
||||
|
||||
$two_params_dict = [
|
||||
"enchant_dict_quick_check",
|
||||
"enchant_dict_check",
|
||||
"enchant_dict_suggest",
|
||||
"enchant_dict_add",
|
||||
"enchant_dict_add_to_session",
|
||||
"enchant_dict_is_added",
|
||||
];
|
||||
|
||||
foreach ($two_params_broker as $func) {
|
||||
try {
|
||||
$func($broker, "foo\0bar");
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($two_params_dict as $func) {
|
||||
try {
|
||||
$func($requestDict, "foo\0bar");
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump(enchant_broker_set_ordering($broker, "foo\0bar", "foo\0bar"));
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump(enchant_dict_store_replacement($requestDict, "foo\0bar", "foo\0bar"));
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
enchant_broker_request_dict(): Argument #2 ($tag) must not contain any null bytes
|
||||
enchant_broker_dict_exists(): Argument #2 ($tag) must not contain any null bytes
|
||||
enchant_dict_quick_check(): Argument #2 ($word) must not contain any null bytes
|
||||
enchant_dict_check(): Argument #2 ($word) must not contain any null bytes
|
||||
enchant_dict_suggest(): Argument #2 ($word) must not contain any null bytes
|
||||
enchant_dict_add(): Argument #2 ($word) must not contain any null bytes
|
||||
enchant_dict_add_to_session(): Argument #2 ($word) must not contain any null bytes
|
||||
enchant_dict_is_added(): Argument #2 ($word) must not contain any null bytes
|
||||
enchant_broker_set_ordering(): Argument #2 ($tag) must not contain any null bytes
|
||||
enchant_dict_store_replacement(): Argument #2 ($misspelled) must not contain any null bytes
|
||||
Reference in New Issue
Block a user