Skip to content

Update iconv names #6234

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 2 commits 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
22 changes: 11 additions & 11 deletions ext/iconv/iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ static void _php_iconv_show_error(php_iconv_err_t err, const char *out_charset,
break;

case PHP_ICONV_ERR_WRONG_CHARSET:
php_error_docref(NULL, E_WARNING, "Wrong charset, conversion from \"%s\" to \"%s\" is not allowed",
php_error_docref(NULL, E_WARNING, "Wrong encoding, conversion from \"%s\" to \"%s\" is not allowed",
in_charset, out_charset);
break;

Expand Down Expand Up @@ -1799,7 +1799,7 @@ PHP_FUNCTION(iconv_strlen)
if (charset == NULL) {
charset = get_internal_encoding();
} else if (charset_len >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}

Expand Down Expand Up @@ -1835,7 +1835,7 @@ PHP_FUNCTION(iconv_substr)
if (charset == NULL) {
charset = get_internal_encoding();
} else if (charset_len >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}

Expand Down Expand Up @@ -1876,7 +1876,7 @@ PHP_FUNCTION(iconv_strpos)
if (charset == NULL) {
charset = get_internal_encoding();
} else if (charset_len >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}

Expand Down Expand Up @@ -1937,7 +1937,7 @@ PHP_FUNCTION(iconv_strrpos)
if (charset == NULL) {
charset = get_internal_encoding();
} else if (charset_len >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}

Expand Down Expand Up @@ -1996,7 +1996,7 @@ PHP_FUNCTION(iconv_mime_encode)

if ((pzval = zend_hash_str_find_deref(Z_ARRVAL_P(pref), "input-charset", sizeof("input-charset") - 1)) != NULL && Z_TYPE_P(pzval) == IS_STRING) {
if (Z_STRLEN_P(pzval) >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}

Expand All @@ -2008,7 +2008,7 @@ PHP_FUNCTION(iconv_mime_encode)

if ((pzval = zend_hash_str_find_deref(Z_ARRVAL_P(pref), "output-charset", sizeof("output-charset") - 1)) != NULL && Z_TYPE_P(pzval) == IS_STRING) {
if (Z_STRLEN_P(pzval) >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}

Expand Down Expand Up @@ -2077,7 +2077,7 @@ PHP_FUNCTION(iconv_mime_decode)
if (charset == NULL) {
charset = get_internal_encoding();
} else if (charset_len >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}

Expand Down Expand Up @@ -2118,7 +2118,7 @@ PHP_FUNCTION(iconv_mime_decode_headers)
if (charset == NULL) {
charset = get_internal_encoding();
} else if (charset_len >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}

Expand Down Expand Up @@ -2211,7 +2211,7 @@ PHP_FUNCTION(iconv)
}

if (in_charset_len >= ICONV_CSNMAXLEN || out_charset_len >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}

Expand Down Expand Up @@ -2241,7 +2241,7 @@ PHP_FUNCTION(iconv_set_encoding)
}

if (ZSTR_LEN(charset) >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}

Expand Down
18 changes: 9 additions & 9 deletions ext/iconv/iconv.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

/** @generate-function-entries */

function iconv_strlen(string $str, ?string $charset = null): int|false {}
function iconv_strlen(string $string, ?string $encoding = null): int|false {}

function iconv_substr(string $str, int $offset, ?int $length = null, ?string $charset = null): string|false {}
function iconv_substr(string $string, int $offset, ?int $length = null, ?string $encoding = null): string|false {}

function iconv_strpos(string $haystack, string $needle, int $offset = 0, ?string $charset = null): int|false {}
function iconv_strpos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false {}

function iconv_strrpos(string $haystack, string $needle, ?string $charset = null): int|false {}
function iconv_strrpos(string $haystack, string $needle, ?string $encoding = null): int|false {}

function iconv_mime_encode(string $field_name, string $field_value, array $preference = []): string|false {}
function iconv_mime_encode(string $field_name, string $field_value, array $options = []): string|false {}

function iconv_mime_decode(string $encoded_string, int $mode = 0, ?string $charset = null): string|false {}
function iconv_mime_decode(string $string, int $mode = 0, ?string $encoding = null): string|false {}

function iconv_mime_decode_headers(string $headers, int $mode = 0, ?string $charset = null): array|false {}
function iconv_mime_decode_headers(string $headers, int $mode = 0, ?string $encoding = null): array|false {}

function iconv(string $in_charset, string $out_charset, string $str): string|false {}
function iconv(string $from_encoding, string $to_encoding, string $string): string|false {}

function iconv_set_encoding(string $type, string $charset): bool {}
function iconv_set_encoding(string $type, string $encoding): bool {}

function iconv_get_encoding(string $type = "all"): array|string|false {}
30 changes: 15 additions & 15 deletions ext/iconv/iconv_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 4e26168b04450adf510a4e638184c46757679ac1 */
* Stub hash: 5d05deb60466c6e1ee73b44ad0b09a032bc8410e */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_strlen, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_substr, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_strpos, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_strrpos, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_mime_encode, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, field_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, field_value, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preference, IS_ARRAY, 0, "[]")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_mime_decode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, encoded_string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_mime_decode_headers, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, headers, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv, 0, 3, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, in_charset, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, out_charset, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, from_encoding, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, to_encoding, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_iconv_set_encoding, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, charset, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_get_encoding, 0, 0, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_FALSE)
Expand Down
4 changes: 2 additions & 2 deletions ext/iconv/tests/iconv-charset-length-cve-2007-4840.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ var_dump(iconv($a, "b", "test"));
var_dump(iconv("x", $a, "test"));
?>
--EXPECTF--
Warning: iconv(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)

Warning: iconv(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ $a = str_repeat("/", 9000000);
var_dump(iconv_mime_decode("a", null, $a));
?>
--EXPECTF--
Warning: iconv_mime_decode(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv_mime_decode(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ $a = str_repeat("/", 9000000);
var_dump(iconv_mime_decode_headers("a", null, $a));
?>
--EXPECTF--
Warning: iconv_mime_decode_headers(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv_mime_decode_headers(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ var_dump(iconv_set_encoding("output_encoding", $a));
var_dump(iconv_set_encoding("internal_encoding", $a));
?>
--EXPECTF--
Warning: iconv_set_encoding(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv_set_encoding(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)

Warning: iconv_set_encoding(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv_set_encoding(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)

Warning: iconv_set_encoding(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv_set_encoding(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ $a = str_repeat("/", 9791999);
var_dump(iconv_strlen(1, $a));
?>
--EXPECTF--
Warning: iconv_strlen(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv_strlen(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)
2 changes: 1 addition & 1 deletion ext/iconv/tests/iconv_strlen_error2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ var_dump(iconv_strlen($string, $encoding));
--EXPECTF--
*** Testing iconv_strlen() : error ***

Warning: iconv_strlen(): Wrong charset, conversion from "unknown-encoding" to "UCS-4LE" is not allowed in %s on line %d
Warning: iconv_strlen(): Wrong encoding, conversion from "unknown-encoding" to "UCS-4LE" is not allowed in %s on line %d
bool(false)
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ $a = str_repeat("/", 9000000);
var_dump(iconv_strpos("a", "b", 0, $a));
?>
--EXPECTF--
Warning: iconv_strpos(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv_strpos(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)
2 changes: 1 addition & 1 deletion ext/iconv/tests/iconv_strpos_error2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ echo "Done";
--EXPECTF--
*** Testing iconv_strpos() : error conditions ***

Warning: iconv_strpos(): Wrong charset, conversion from "unknown-encoding" to "UCS-4LE" is not allowed in %s on line %d
Warning: iconv_strpos(): Wrong encoding, conversion from "unknown-encoding" to "UCS-4LE" is not allowed in %s on line %d
bool(false)
Done
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ $a = str_repeat("/", 9000000);
var_dump(iconv_strrpos("a", "b", $a));
?>
--EXPECTF--
Warning: iconv_strrpos(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv_strrpos(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)
2 changes: 1 addition & 1 deletion ext/iconv/tests/iconv_strrpos_error2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ echo "Done";
--EXPECTF--
*** Testing iconv_strrpos() : error conditions ***

Warning: iconv_strrpos(): Wrong charset, conversion from "unknown-encoding" to "UCS-4LE" is not allowed in %s on line %d
Warning: iconv_strrpos(): Wrong encoding, conversion from "unknown-encoding" to "UCS-4LE" is not allowed in %s on line %d
bool(false)
Done
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ $b = str_repeat('/', 2798349);
var_dump(iconv_substr($a, 0, 1, $b));
?>
--EXPECTF--
Warning: iconv_substr(): Charset parameter exceeds the maximum allowed length of %d characters in %s on line %d
Warning: iconv_substr(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d
bool(false)
2 changes: 1 addition & 1 deletion ext/iconv/tests/iconv_substr_error2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ echo "Done";
--EXPECTF--
*** Testing iconv_substr() : error conditions ***

Warning: iconv_substr(): Wrong charset, conversion from "unknown-encoding" to "UCS-4LE" is not allowed in %s on line %d
Warning: iconv_substr(): Wrong encoding, conversion from "unknown-encoding" to "UCS-4LE" is not allowed in %s on line %d
bool(false)
Done