]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.4'
authorChristoph M. Becker <cmbecker69@gmx.de>
Mon, 23 Mar 2020 13:31:16 +0000 (14:31 +0100)
committerChristoph M. Becker <cmbecker69@gmx.de>
Mon, 23 Mar 2020 13:31:16 +0000 (14:31 +0100)
* PHP-7.4:
  Fix #79200: Some iconv functions cut Windows-1258

1  2 
ext/iconv/iconv.c

index 26603c26a4d78026eabc2f53834d47ae2e303d51,eeca0340a0d47bc431dd7dee36c2104184b41f76..80af1dc8b9edbd22010c965342f72870e08d188a
@@@ -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))) {