tony2001 Tue Oct 11 09:51:31 2005 EDT
Modified files: (Branch: PHP_5_0)
/php-src/ext/iconv iconv.c
/php-src NEWS
Log:
MF51: fix #34757 (iconv_substr() gives "Unknown error" when offset > string
length)
http://cvs.php.net/diff.php/php-src/ext/iconv/iconv.c?r1=1.117.2.6&r2=1.117.2.7&ty=u
Index: php-src/ext/iconv/iconv.c
diff -u php-src/ext/iconv/iconv.c:1.117.2.6 php-src/ext/iconv/iconv.c:1.117.2.7
--- php-src/ext/iconv/iconv.c:1.117.2.6 Wed Jun 8 19:51:05 2005
+++ php-src/ext/iconv/iconv.c Tue Oct 11 09:51:28 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: iconv.c,v 1.117.2.6 2005/06/08 23:51:05 iliaa Exp $ */
+/* $Id: iconv.c,v 1.117.2.7 2005/10/11 13:51:28 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -583,26 +583,38 @@
size_t out_left;
unsigned int cnt;
-
+ unsigned int total_len;
+
+ err = _php_iconv_strlen(&total_len, str, nbytes, enc);
+ if (err != PHP_ICONV_ERR_SUCCESS) {
+ return err;
+ }
+
/* normalize the offset and the length */
- if (offset < 0 || len < 0) {
- unsigned int total_len;
- err = _php_iconv_strlen(&total_len, str, nbytes, enc);
- if (err != PHP_ICONV_ERR_SUCCESS) {
- return err;
- }
- if (offset < 0) {
- if ((offset += total_len) < 0) {
- offset = 0;
- }
+ if (offset < 0) {
+ if ((offset += total_len) < 0) {
+ offset = 0;
}
- if (len < 0) {
- if ((len += (total_len - offset)) < 0) {
- len = 0;
- }
+ }
+ if (len < 0) {
+ if ((len += (total_len - offset)) < 0) {
+ len = 0;
}
}
+ if (offset >= total_len) {
+ return PHP_ICONV_ERR_SUCCESS;
+ }
+
+ if ((offset + len) > total_len) {
+ /* trying to compute the length */
+ len = total_len - offset;
+ }
+
+ if (len == 0) {
+ return PHP_ICONV_ERR_SUCCESS;
+ }
+
cd1 = iconv_open(GENERIC_SUPERSET_NAME, enc);
if (cd1 == (iconv_t)(-1)) {
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.497&r2=1.1760.2.498&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1760.2.497 php-src/NEWS:1.1760.2.498
--- php-src/NEWS:1.1760.2.497 Tue Oct 11 02:48:10 2005
+++ php-src/NEWS Tue Oct 11 09:51:29 2005
@@ -9,6 +9,8 @@
- Fixed bug #34788 (SOAP Client not applying correct namespace to generated
values). (Dmitry)
- Fixed bug #34787 (SOAP Client not handling boolean types correctly). (Dmitry)
+- Fixed bug #34757 (iconv_substr() gives "Unknown error" when offset > string
+ length). (Tony)
- Fixed bug #34723 (array_count_values() strips leading zeroes). (Tony)
- Fixed bug #34704 (Infinite recursion due to corrupt JPEG). (Marcus)
- Fixed bug #34678 (__call(), is_callable() and static methods). (Dmitry)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php