From: Christoph M. Becker Date: Mon, 23 Mar 2020 13:31:16 +0000 (+0100) Subject: Merge branch 'PHP-7.4' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=324337a3b1676353fef7d451e41af09e905334c9;p=php Merge branch 'PHP-7.4' * PHP-7.4: Fix #79200: Some iconv functions cut Windows-1258 --- 324337a3b1676353fef7d451e41af09e905334c9 diff --cc ext/iconv/iconv.c index 26603c26a4,eeca0340a0..80af1dc8b9 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@@ -608,10 -761,7 +611,6 @@@ static php_iconv_err_t _php_iconv_strle } } - if (out_left > 0) { - cnt -= out_left / GENERIC_SUPERSET_NBYTES; - } - -#if ICONV_SUPPORTS_ERRNO switch (errno) { case EINVAL: err = PHP_ICONV_ERR_ILLEGAL_CHAR; @@@ -833,29 -1002,32 +834,30 @@@ static php_iconv_err_t _php_iconv_strpo out_p = buf; out_left = sizeof(buf); - prev_in_left = in_left; + more = in_left > 0; - if (iconv(cd, (char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) { - if (prev_in_left == in_left) { - switch (errno) { - case EINVAL: - err = PHP_ICONV_ERR_ILLEGAL_CHAR; - break; + iconv_ret = iconv(cd, more ? (char **)&in_p : NULL, more ? &in_left : NULL, (char **) &out_p, &out_left); + if (out_left == sizeof(buf)) { + break; + } -#if ICONV_SUPPORTS_ERRNO + if (iconv_ret == (size_t)-1) { + switch (errno) { + case EINVAL: + err = PHP_ICONV_ERR_ILLEGAL_CHAR; + break; - case EILSEQ: - err = PHP_ICONV_ERR_ILLEGAL_SEQ; - break; + case EILSEQ: + err = PHP_ICONV_ERR_ILLEGAL_SEQ; + break; - case E2BIG: - break; + case E2BIG: + break; - default: - err = PHP_ICONV_ERR_UNKNOWN; - break; - } - break; + default: + err = PHP_ICONV_ERR_UNKNOWN; + break; } } -#endif if (offset >= 0) { if (cnt >= (size_t)offset) { if (_php_iconv_memequal(buf, ndl_buf_p, sizeof(buf))) {