diff options
author | Jerome Loyet <fat@php.net> | 2012-06-01 11:30:49 +0200 |
---|---|---|
committer | Jerome Loyet <fat@php.net> | 2012-06-01 11:30:49 +0200 |
commit | 1fa8ecd082607858084994ad7081ef06e37db5f5 (patch) | |
tree | 1fec830a259d4de551dc0a0f77d253821d923e20 | |
parent | 238caeb63c4f4faf67b9f8de62a753eb3e954dbe (diff) | |
parent | b548d9ad2e02f3f216320b5f47e26046021a5bac (diff) | |
download | php-git-1fa8ecd082607858084994ad7081ef06e37db5f5.tar.gz |
Merge branch 'PHP-5.4' of git.php.net:php-src into PHP-5.4
* 'PHP-5.4' of git.php.net:php-src: (27 commits)
Fixed Bug #62202 (ReflectionParameter::getDefaultValue() memory leaks with constant)
sort NEWS
fix bug #55042 - erealloc without updating pointer
Fix bug #62186 readline fails to compile
fix unchecked emalloc (cherry picked from commit 158d8a6b088662ce9d31e0c777c6ebe90efdc854)
fix test
fix test
Typofix in comment in proc_open.c
fix CVE-2012-2143
updated the libmagic patch after Felipes regex fix
Fix bug #62150 Test Bug - ext/fileinfo/tests/finfo_open_error.phpt
Bug #62177 deactivate the linux test version on win
Fix bug #62177 Test Bug - finfo_file_regex.phpt
Fixed bug #62176 Test Bug - sapi/cli/tests/bug61546.phpt
fix unchecked emalloc
add CVE
add bug 62146
add bug #62082
sync with HEAD
sync with HEAD
...
-rw-r--r-- | Zend/tests/bug62097.phpt | 2 | ||||
-rw-r--r-- | ext/fileinfo/libmagic.patch | 124 | ||||
-rw-r--r-- | ext/fileinfo/tests/finfo_file_regex-win32.phpt | 36 | ||||
-rw-r--r-- | ext/fileinfo/tests/finfo_file_regex.phpt | 6 | ||||
-rw-r--r-- | ext/fileinfo/tests/finfo_open_error-win32.phpt | 46 | ||||
-rw-r--r-- | ext/fileinfo/tests/finfo_open_error.phpt | 5 | ||||
-rw-r--r-- | ext/iconv/iconv.c | 128 | ||||
-rw-r--r-- | ext/intl/tests/bug59597_64.phpt | 2 | ||||
-rw-r--r-- | ext/phar/tar.c | 6 | ||||
-rw-r--r-- | ext/readline/readline.c | 2 | ||||
-rw-r--r-- | ext/reflection/php_reflection.c | 3 | ||||
-rw-r--r-- | ext/standard/crypt_freesec.c | 3 | ||||
-rw-r--r-- | ext/standard/proc_open.c | 2 | ||||
-rw-r--r-- | ext/standard/tests/strings/crypt_chars.phpt | 19 | ||||
-rwxr-xr-x | run-tests.php | 5 | ||||
-rw-r--r-- | sapi/cli/tests/bug61546.phpt | 11 |
16 files changed, 248 insertions, 152 deletions
diff --git a/Zend/tests/bug62097.phpt b/Zend/tests/bug62097.phpt index bee72e7a23..07e93bfa88 100644 --- a/Zend/tests/bug62097.phpt +++ b/Zend/tests/bug62097.phpt @@ -1,7 +1,7 @@ --TEST-- Bug #62097: fix for bug #54547 is wrong for 32-bit machines --SKIPIF-- -<php +<?php if (PHP_INT_MAX !== 2147483647) die('skip for system with 32-bit wide longs only'); --FILE-- diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index baeac1dc16..48a02360b0 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1,6 +1,6 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c ---- libmagic.orig/apprentice.c 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/apprentice.c 2012-04-22 19:28:57.346309536 +0800 +--- libmagic.orig/apprentice.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/apprentice.c 2012-04-22 18:57:16.215980866 +0200 @@ -29,6 +29,8 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ @@ -729,8 +729,8 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c m->str_flags = swap4(m->str_flags); } diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c ---- libmagic.orig/ascmagic.c 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/ascmagic.c 2012-04-22 19:28:57.330309533 +0800 +--- libmagic.orig/ascmagic.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/ascmagic.c 2012-04-22 18:57:16.215980866 +0200 @@ -139,10 +139,8 @@ /* malloc size is a conservative overestimate; could be improved, or at least realloced after conversion. */ @@ -755,8 +755,8 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c return rv; } diff -u libmagic.orig/cdf.c libmagic/cdf.c ---- libmagic.orig/cdf.c 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/cdf.c 2012-04-22 19:28:57.370309531 +0800 +--- libmagic.orig/cdf.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/cdf.c 2012-04-22 18:57:16.219978162 +0200 @@ -43,7 +43,17 @@ #include <err.h> #endif @@ -819,8 +819,8 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c (void)fprintf(stderr, "timestamp %s\n", buf); } else { diff -u libmagic.orig/cdf.h libmagic/cdf.h ---- libmagic.orig/cdf.h 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/cdf.h 2012-04-22 19:28:57.370309531 +0800 +--- libmagic.orig/cdf.h 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/cdf.h 2012-04-22 18:57:16.219978162 +0200 @@ -35,7 +35,7 @@ #ifndef _H_CDF_ #define _H_CDF_ @@ -857,8 +857,8 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h void cdf_swap_header(cdf_header_t *); void cdf_unpack_header(cdf_header_t *, char *); diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c ---- libmagic.orig/cdf_time.c 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/cdf_time.c 2012-04-22 19:28:57.326309537 +0800 +--- libmagic.orig/cdf_time.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/cdf_time.c 2012-04-22 18:57:16.219978162 +0200 @@ -96,7 +96,7 @@ } @@ -916,8 +916,8 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c static const char *ref = "Sat Apr 23 01:30:00 1977"; char *p, *q; diff -u libmagic.orig/compress.c libmagic/compress.c ---- libmagic.orig/compress.c 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/compress.c 2012-04-22 19:28:57.314309548 +0800 +--- libmagic.orig/compress.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/compress.c 2012-04-22 18:57:16.219978162 +0200 @@ -32,6 +32,7 @@ * uncompress(method, old, n, newch) - uncompress old into new, * using method, return sizeof new @@ -1079,8 +1079,8 @@ diff -u libmagic.orig/compress.c libmagic/compress.c -#endif +#endif /* if PHP_FILEINFO_UNCOMPRESS */ diff -u libmagic.orig/file.h libmagic/file.h ---- libmagic.orig/file.h 2012-04-22 19:30:43.186305188 +0800 -+++ libmagic/file.h 2012-04-22 19:49:58.922256776 +0800 +--- libmagic.orig/file.h 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/file.h 2012-04-22 18:57:16.219978162 +0200 @@ -33,11 +33,9 @@ #ifndef __file_h__ #define __file_h__ @@ -1252,8 +1252,8 @@ diff -u libmagic.orig/file.h libmagic/file.h + #endif /* __file_h__ */ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c ---- libmagic.orig/fsmagic.c 2012-04-22 19:30:43.186305188 +0800 -+++ libmagic/fsmagic.c 2012-04-22 19:28:57.298309521 +0800 +--- libmagic.orig/fsmagic.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/fsmagic.c 2012-04-22 18:57:16.219978162 +0200 @@ -59,27 +59,21 @@ # define minor(dev) ((dev) & 0xff) #endif @@ -1577,8 +1577,8 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c /* diff -u libmagic.orig/funcs.c libmagic/funcs.c ---- libmagic.orig/funcs.c 2012-04-22 19:30:43.186305188 +0800 -+++ libmagic/funcs.c 2012-04-22 19:28:57.370309531 +0800 +--- libmagic.orig/funcs.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/funcs.c 2012-04-22 18:57:16.219978162 +0200 @@ -41,52 +41,42 @@ #if defined(HAVE_WCTYPE_H) #include <wctype.h> @@ -1872,11 +1872,9 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c + return rep_cnt; } + -Only in libmagic.orig: funcs.c.orig -Only in libmagic.orig: funcs.c.rej diff -u libmagic.orig/magic.c libmagic/magic.c ---- libmagic.orig/magic.c 2012-04-22 19:30:43.186305188 +0800 -+++ libmagic/magic.c 2012-04-22 19:28:57.370309531 +0800 +--- libmagic.orig/magic.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/magic.c 2012-04-22 18:57:16.219978162 +0200 @@ -25,11 +25,6 @@ * SUCH DAMAGE. */ @@ -2253,8 +2251,8 @@ diff -u libmagic.orig/magic.c libmagic/magic.c public const char * magic_error(struct magic_set *ms) diff -u libmagic.orig/magic.h libmagic/magic.h ---- libmagic.orig/magic.h 2012-04-22 19:30:43.190305058 +0800 -+++ libmagic/magic.h 2012-04-22 19:28:57.326309537 +0800 +--- libmagic.orig/magic.h 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/magic.h 2012-04-22 18:57:16.219978162 +0200 @@ -85,6 +85,7 @@ const char *magic_getpath(const char *, int); @@ -2272,8 +2270,8 @@ diff -u libmagic.orig/magic.h libmagic/magic.h int magic_errno(magic_t); diff -u libmagic.orig/print.c libmagic/print.c ---- libmagic.orig/print.c 2012-04-22 19:30:43.190305058 +0800 -+++ libmagic/print.c 2012-04-22 19:28:57.326309537 +0800 +--- libmagic.orig/print.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/print.c 2012-05-29 14:34:03.770376387 +0200 @@ -29,6 +29,9 @@ * print.c - debugging printout routines */ @@ -2467,8 +2465,8 @@ diff -u libmagic.orig/print.c libmagic/print.c protected const char * diff -u libmagic.orig/readcdf.c libmagic/readcdf.c ---- libmagic.orig/readcdf.c 2012-04-22 19:30:43.190305058 +0800 -+++ libmagic/readcdf.c 2012-04-22 19:28:57.326309537 +0800 +--- libmagic.orig/readcdf.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/readcdf.c 2012-04-22 18:57:16.219978162 +0200 @@ -30,7 +30,11 @@ #endif @@ -2515,8 +2513,8 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if ((ec = strchr(c, '\n')) != NULL) *ec = '\0'; diff -u libmagic.orig/readelf.c libmagic/readelf.c ---- libmagic.orig/readelf.c 2012-04-22 19:30:43.190305058 +0800 -+++ libmagic/readelf.c 2012-04-22 19:28:57.378309534 +0800 +--- libmagic.orig/readelf.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/readelf.c 2012-04-22 18:57:16.219978162 +0200 @@ -49,7 +49,7 @@ off_t, int *, int); private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, @@ -2672,8 +2670,8 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (fstat(fd, &st) == -1) { diff -u libmagic.orig/softmagic.c libmagic/softmagic.c ---- libmagic.orig/softmagic.c 2012-04-22 19:30:43.194304945 +0800 -+++ libmagic/softmagic.c 2012-04-22 19:28:57.286309597 +0800 +--- libmagic.orig/softmagic.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/softmagic.c 2012-05-29 14:34:31.900417647 +0200 @@ -41,6 +41,11 @@ #include <stdlib.h> #include <time.h> @@ -2860,7 +2858,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } } -@@ -1669,6 +1642,65 @@ +@@ -1669,6 +1642,42 @@ return file_strncmp(a, b, len, flags); } @@ -2876,29 +2874,6 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + + for (i=0; i<Z_STRLEN_P(pattern); i++, j++) { + switch (Z_STRVAL_P(pattern)[i]) { -+ case '?': -+ t[j] = '.'; -+ break; -+ case '*': -+ t[j++] = '.'; -+ t[j] = '*'; -+ break; -+ case '.': -+ t[j++] = '\\'; -+ t[j] = '.'; -+ break; -+ case '\\': -+ t[j++] = '\\'; -+ t[j] = '\\'; -+ break; -+ case '(': -+ t[j++] = '\\'; -+ t[j] = '('; -+ break; -+ case ')': -+ t[j++] = '\\'; -+ t[j] = ')'; -+ break; + case '~': + t[j++] = '\\'; + t[j] = '~'; @@ -2926,7 +2901,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c private int magiccheck(struct magic_set *ms, struct magic *m) { -@@ -1825,67 +1857,163 @@ +@@ -1825,67 +1834,163 @@ break; } case FILE_REGEX: { @@ -2937,23 +2912,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - if (ms->search.s == NULL) - return 0; - -+ zval *pattern; -+ int options = 0; -+ pcre_cache_entry *pce; -+ TSRMLS_FETCH(); -+ -+ MAKE_STD_ZVAL(pattern); -+ ZVAL_STRINGL(pattern, (char *)m->value.s, m->vallen, 0); -+ -+ options |= PCRE_MULTILINE; -+ -+ if (m->str_flags & STRING_IGNORE_CASE) { -+ options |= PCRE_CASELESS; -+ } -+ -+ convert_libmagic_pattern(pattern, options); -+ - l = 0; +- l = 0; - rc = regcomp(&rx, m->value.s, - REG_EXTENDED|REG_NEWLINE| - ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0)); @@ -2970,6 +2929,23 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - size_t l = ms->search.s_len - 1; - char c = ms->search.s[l]; - ((char *)(intptr_t)ms->search.s)[l] = '\0'; ++ zval *pattern; ++ int options = 0; ++ pcre_cache_entry *pce; ++ TSRMLS_FETCH(); ++ ++ MAKE_STD_ZVAL(pattern); ++ ZVAL_STRINGL(pattern, (char *)m->value.s, m->vallen, 0); ++ ++ options |= PCRE_MULTILINE; ++ ++ if (m->str_flags & STRING_IGNORE_CASE) { ++ options |= PCRE_CASELESS; ++ } ++ ++ convert_libmagic_pattern(pattern, options); ++ ++ l = v = 0; +#if (PHP_MAJOR_VERSION < 6) + if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) { #else diff --git a/ext/fileinfo/tests/finfo_file_regex-win32.phpt b/ext/fileinfo/tests/finfo_file_regex-win32.phpt new file mode 100644 index 0000000000..1eda48c4d0 --- /dev/null +++ b/ext/fileinfo/tests/finfo_file_regex-win32.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test finfo_file() function : regex rules +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip.. only for Windows'); +} +?> +--FILE-- +<?php +/** + * Works with the unix file command: + * $ file -m magic resources/test.awk + * resources/test.awk: awk script, ASCII text + */ +$magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic'; +$finfo = finfo_open( FILEINFO_MIME, $magicFile ); + +echo "*** Testing finfo_file() : regex rules ***\n"; + +// Calling finfo_file() with all possible arguments +$file = __DIR__ . '/resources/test.awk'; +var_dump( finfo_file( $finfo, $file ) ); +var_dump( finfo_file( $finfo, $file, FILEINFO_CONTINUE ) ); + +// Windows uses libfileinfo 1.0.5-dev +// this may be causing the slightly different output from the first +// finfo_file() call + +?> +===DONE=== +--EXPECTF-- +*** Testing finfo_file() : regex rules *** +string(10) "text/plain" +string(22) "awk script, ASCII text" +===DONE=== diff --git a/ext/fileinfo/tests/finfo_file_regex.phpt b/ext/fileinfo/tests/finfo_file_regex.phpt index c1cc36f2b3..ee4c8b0b7a 100644 --- a/ext/fileinfo/tests/finfo_file_regex.phpt +++ b/ext/fileinfo/tests/finfo_file_regex.phpt @@ -1,7 +1,11 @@ --TEST-- Test finfo_file() function : regex rules --SKIPIF-- -<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +<?php require_once(dirname(__FILE__) . '/skipif.inc'); +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. only for Non Windows Systems'); +} +?> --FILE-- <?php /** diff --git a/ext/fileinfo/tests/finfo_open_error-win32.phpt b/ext/fileinfo/tests/finfo_open_error-win32.phpt new file mode 100644 index 0000000000..bd50327b2d --- /dev/null +++ b/ext/fileinfo/tests/finfo_open_error-win32.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test finfo_open() function : error functionality +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); +if(substr(PHP_OS, 0, 3) != 'WIN' ) + die("skip Not Valid for Linux"); +?> +--FILE-- +<?php +/* Prototype : resource finfo_open([int options [, string arg]]) + * Description: Create a new fileinfo resource. + * Source code: ext/fileinfo/fileinfo.c + * Alias to functions: + */ + +$magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic'; + +echo "*** Testing finfo_open() : error functionality ***\n"; + +var_dump( finfo_open( FILEINFO_MIME, 'foobarfile' ) ); +var_dump( finfo_open( array(), $magicFile ) ); +var_dump( finfo_open( FILEINFO_MIME, $magicFile, 'extraArg' ) ); +var_dump( finfo_open( PHP_INT_MAX - 1, $magicFile ) ); +var_dump( finfo_open( 'foobar' ) ); + +var_dump( new finfo('foobar') ); + +?> +===DONE=== +--EXPECTF-- +*** Testing finfo_open() : error functionality *** +bool(false) + +Warning: finfo_open() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: finfo_open() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +resource(%d) of type (file_info) + +Warning: finfo_open() expects parameter 1 to be long, %unicode_string_optional% given in %s on line %d +bool(false) + +Warning: finfo::finfo() expects parameter 1 to be long, %unicode_string_optional% given in %s on line %d +NULL +===DONE=== diff --git a/ext/fileinfo/tests/finfo_open_error.phpt b/ext/fileinfo/tests/finfo_open_error.phpt index 19ae7a6013..5d1eff5973 100644 --- a/ext/fileinfo/tests/finfo_open_error.phpt +++ b/ext/fileinfo/tests/finfo_open_error.phpt @@ -1,7 +1,10 @@ --TEST-- Test finfo_open() function : error functionality --SKIPIF-- -<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +<?php require_once(dirname(__FILE__) . '/skipif.inc'); +if(substr(PHP_OS, 0, 3) == 'WIN' ) + die("skip Not Valid for Windows"); +?> --FILE-- <?php /* Prototype : resource finfo_open([int options [, string arg]]) diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 92675eb128..9cae535138 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -190,7 +190,7 @@ typedef enum _php_iconv_enc_scheme_t { #define PHP_ICONV_MIME_DECODE_STRICT (1<<0) #define PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR (1<<1) -/* {{{ prototypes */ +/* {{{ prototypes */ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, iconv_t cd); static php_iconv_err_t _php_iconv_appendc(smart_str *d, const char c, iconv_t cd); @@ -249,7 +249,7 @@ PHP_MINIT_FUNCTION(miconv) { static char buf[16]; snprintf(buf, sizeof(buf), "%d.%d", - ((_libiconv_version >> 8) & 0x0f), (_libiconv_version & 0x0f)); + ((_libiconv_version >> 8) & 0x0f), (_libiconv_version & 0x0f)); version = buf; } #elif HAVE_GLIBC_ICONV @@ -354,7 +354,7 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) { int len; - char *p = strstr(ICONVG(output_encoding), "//"); + char *p = strstr(ICONVG(output_encoding), "//"); if (p) { len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, (int)(p - ICONVG(output_encoding)), ICONVG(output_encoding)); @@ -375,7 +375,7 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c return SUCCESS; } - + /* {{{ _php_iconv_appendl() */ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, iconv_t cd) { @@ -400,7 +400,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, if (iconv(cd, (char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) { #if ICONV_SUPPORTS_ERRNO - switch (errno) { + switch (errno) { case EINVAL: return PHP_ICONV_ERR_ILLEGAL_CHAR; @@ -415,7 +415,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, } #else if (prev_in_left == in_left) { - return PHP_ICONV_ERR_UNKNOWN; + return PHP_ICONV_ERR_UNKNOWN; } #endif } @@ -446,7 +446,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, #else if (out_left != 0) { return PHP_ICONV_ERR_UNKNOWN; - } + } #endif } (d)->len += (buf_growth - out_left); @@ -492,31 +492,35 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, in_size = in_len; cd = iconv_open(out_charset, in_charset); - + if (cd == (iconv_t)(-1)) { return PHP_ICONV_ERR_UNKNOWN; } out_buffer = (char *) emalloc(out_size + 1); out_p = out_buffer; - + #ifdef NETWARE result = iconv(cd, (char **) &in_p, &in_size, (char **) #else result = iconv(cd, (const char **) &in_p, &in_size, (char **) #endif &out_p, &out_left); - + if (result == (size_t)(-1)) { efree(out_buffer); return PHP_ICONV_ERR_UNKNOWN; } if (out_left < 8) { - out_buffer = (char *) erealloc(out_buffer, out_size + 8); + size_t pos = out_p - out_buffer; + out_buffer = (char *) safe_erealloc(out_buffer, out_size, 1, 8); + out_p = out_buffer+pos; + out_size += 7; + out_left += 7; } - /* flush the shift-out sequences */ + /* flush the shift-out sequences */ result = iconv(cd, NULL, NULL, &out_p, &out_left); if (result == (size_t)(-1)) { @@ -555,10 +559,10 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, } } in_left= in_len; - out_left = in_len + 32; /* Avoid realloc() most cases */ + out_left = in_len + 32; /* Avoid realloc() most cases */ out_size = 0; bsz = out_left; - out_buf = (char *) emalloc(bsz+1); + out_buf = (char *) emalloc(bsz+1); out_p = out_buf; while (in_left > 0) { @@ -573,14 +577,14 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, out_p = out_buf = tmp_buf; out_p += out_size; out_left = bsz - out_size; - continue; + continue; } } break; } if (result != (size_t)(-1)) { - /* flush the shift-out sequences */ + /* flush the shift-out sequences */ for (;;) { result = iconv(cd, NULL, NULL, (char **) &out_p, &out_left); out_size = bsz - out_left; @@ -592,7 +596,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, if (errno == E2BIG) { bsz += 16; tmp_buf = (char *) erealloc(out_buf, bsz); - + out_p = out_buf = tmp_buf; out_p += out_size; out_left = bsz - out_size; @@ -684,7 +688,7 @@ static php_iconv_err_t _php_iconv_strlen(unsigned int *pretval, const char *str, } if (out_left > 0) { - cnt -= out_left / GENERIC_SUPERSET_NBYTES; + cnt -= out_left / GENERIC_SUPERSET_NBYTES; } #if ICONV_SUPPORTS_ERRNO @@ -735,12 +739,12 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval, unsigned int cnt; int total_len; - + err = _php_iconv_strlen(&total_len, str, nbytes, enc); if (err != PHP_ICONV_ERR_SUCCESS) { return err; } - + if (len < 0) { if ((len += (total_len - offset)) < 0) { return PHP_ICONV_ERR_SUCCESS; @@ -772,7 +776,7 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval, smart_str_0(pretval); return PHP_ICONV_ERR_SUCCESS; } - + cd1 = iconv_open(GENERIC_SUPERSET_NAME, enc); if (cd1 == (iconv_t)(-1)) { @@ -857,7 +861,7 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval, if (cd2 != (iconv_t)NULL) { iconv_close(cd2); - } + } return err; } @@ -1042,7 +1046,7 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval, if (ndl_buf) { efree(ndl_buf); } - + iconv_close(cd); return err; @@ -1089,7 +1093,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn if ((fname_nbytes + 2) >= max_line_len || (out_charset_len + 12) >= max_line_len) { /* field name is too long */ - err = PHP_ICONV_ERR_TOO_BIG; + err = PHP_ICONV_ERR_TOO_BIG; goto out; } @@ -1131,7 +1135,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn char_cnt -= 2; in_p = fval; - in_left = fval_nbytes; + in_left = fval_nbytes; do { size_t prev_in_left; @@ -1142,8 +1146,8 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn smart_str_appendl(pretval, lfchars, lfchars_len); smart_str_appendc(pretval, ' '); char_cnt = max_line_len - 1; - } - + } + smart_str_appendl(pretval, "=?", sizeof("=?") - 1); char_cnt -= 2; smart_str_appendl(pretval, out_charset, out_charset_len); @@ -1195,7 +1199,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn goto out; } break; - + default: err = PHP_ICONV_ERR_UNKNOWN; goto out; @@ -1295,7 +1299,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn goto out; } break; - + default: err = PHP_ICONV_ERR_UNKNOWN; goto out; @@ -1372,7 +1376,7 @@ out: } if (encoded != NULL) { efree(encoded); - } + } if (buf != NULL) { efree(buf); } @@ -1391,7 +1395,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st size_t str_left; unsigned int scan_stat = 0; const char *csname = NULL; - size_t csname_len; + size_t csname_len; const char *encoded_text = NULL; size_t encoded_text_len = 0; const char *encoded_word = NULL; @@ -1430,7 +1434,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st break; case '\n': - scan_stat = 8; + scan_stat = 8; break; case '=': /* first letter of an encoded chunk */ @@ -1455,7 +1459,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st case 1: /* expecting a delimiter */ if (*p1 != '?') { - err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); + err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); if (err != PHP_ICONV_ERR_SUCCESS) { goto out; } @@ -1470,7 +1474,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st csname = p1 + 1; scan_stat = 2; break; - + case 2: /* expecting a charset name */ switch (*p1) { case '?': /* normal delimiter: encoding scheme follows */ @@ -1480,7 +1484,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st case '*': /* new style delimiter: locale id follows */ scan_stat = 10; break; - } + } if (scan_stat != 2) { char tmpbuf[80]; @@ -1493,7 +1497,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st if (csname_len > sizeof(tmpbuf) - 1) { if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) { - err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); + err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); if (err != PHP_ICONV_ERR_SUCCESS) { goto out; } @@ -1549,7 +1553,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st --str_left; } - err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); + err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); if (err != PHP_ICONV_ERR_SUCCESS) { goto out; } @@ -1608,12 +1612,12 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st } } break; - + case 4: /* expecting a delimiter */ if (*p1 != '?') { if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) { /* pass the entire chunk through the converter */ - err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); + err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); if (err != PHP_ICONV_ERR_SUCCESS) { goto out; } @@ -1669,7 +1673,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st if (*p1 != '=') { if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) { /* pass the entire chunk through the converter */ - err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); + err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); if (err != PHP_ICONV_ERR_SUCCESS) { goto out; } @@ -1696,17 +1700,17 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st switch (*p1) { default: /* Handle non-RFC-compliant formats - * + * * RFC2047 requires the character that comes right * after an encoded word (chunk) to be a whitespace, * while there are lots of broken implementations that * generate such malformed headers that don't fulfill * that requirement. - */ - if (!eos) { + */ + if (!eos) { if ((mode & PHP_ICONV_MIME_DECODE_STRICT)) { /* pass the entire chunk through the converter */ - err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); + err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); if (err != PHP_ICONV_ERR_SUCCESS) { goto out; } @@ -1738,7 +1742,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st if (decoded_text == NULL) { if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) { /* pass the entire chunk through the converter */ - err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); + err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); if (err != PHP_ICONV_ERR_SUCCESS) { goto out; } @@ -1761,7 +1765,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st if (err != PHP_ICONV_ERR_SUCCESS) { if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) { /* pass the entire chunk through the converter */ - err = _php_iconv_appendl(pretval, encoded_word, (size_t)(p1 - encoded_word), cd_pl); + err = _php_iconv_appendl(pretval, encoded_word, (size_t)(p1 - encoded_word), cd_pl); encoded_word = NULL; if (err != PHP_ICONV_ERR_SUCCESS) { break; @@ -1956,7 +1960,7 @@ PHP_FUNCTION(iconv_strlen) char *charset = ICONVG(internal_encoding); int charset_len = 0; char *str; - int str_len; + int str_len; php_iconv_err_t err; @@ -1972,7 +1976,7 @@ PHP_FUNCTION(iconv_strlen) RETURN_FALSE; } - err = _php_iconv_strlen(&retval, str, str_len, charset); + err = _php_iconv_strlen(&retval, str, str_len, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); if (err == PHP_ICONV_ERR_SUCCESS) { RETVAL_LONG(retval); @@ -1989,7 +1993,7 @@ PHP_FUNCTION(iconv_substr) char *charset = ICONVG(internal_encoding); int charset_len = 0; char *str; - int str_len; + int str_len; long offset, length = 0; php_iconv_err_t err; @@ -2008,10 +2012,10 @@ PHP_FUNCTION(iconv_substr) } if (ZEND_NUM_ARGS() < 3) { - length = str_len; + length = str_len; } - err = _php_iconv_substr(&retval, str, str_len, offset, length, charset); + err = _php_iconv_substr(&retval, str, str_len, offset, length, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); if (err == PHP_ICONV_ERR_SUCCESS && str != NULL && retval.c != NULL) { @@ -2029,7 +2033,7 @@ PHP_FUNCTION(iconv_strpos) char *charset = ICONVG(internal_encoding); int charset_len = 0; char *haystk; - int haystk_len; + int haystk_len; char *ndl; int ndl_len; long offset = 0; @@ -2059,7 +2063,7 @@ PHP_FUNCTION(iconv_strpos) } err = _php_iconv_strpos(&retval, haystk, haystk_len, ndl, ndl_len, - offset, charset); + offset, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); if (err == PHP_ICONV_ERR_SUCCESS && retval != (unsigned int)-1) { @@ -2077,7 +2081,7 @@ PHP_FUNCTION(iconv_strrpos) char *charset = ICONVG(internal_encoding); int charset_len = 0; char *haystk; - int haystk_len; + int haystk_len; char *ndl; int ndl_len; @@ -2101,7 +2105,7 @@ PHP_FUNCTION(iconv_strrpos) } err = _php_iconv_strpos(&retval, haystk, haystk_len, ndl, ndl_len, - -1, charset); + -1, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); if (err == PHP_ICONV_ERR_SUCCESS && retval != (unsigned int)-1) { @@ -2241,7 +2245,7 @@ PHP_FUNCTION(iconv_mime_decode) char *charset = ICONVG(internal_encoding); int charset_len = 0; long mode = 0; - + smart_str retval = {0}; php_iconv_err_t err; @@ -2282,7 +2286,7 @@ PHP_FUNCTION(iconv_mime_decode_headers) char *charset = ICONVG(internal_encoding); int charset_len = 0; long mode = 0; - + php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", @@ -2350,14 +2354,14 @@ PHP_FUNCTION(iconv_mime_decode_headers) zend_hash_update(Z_ARRVAL_P(return_value), header_name, header_name_len, (void *)&new_elem, sizeof(new_elem), NULL); elem = &new_elem; - } + } add_next_index_stringl(*elem, header_value, header_value_len, 1); } else { add_assoc_stringl_ex(return_value, header_name, header_name_len, header_value, header_value_len, 1); } } encoded_str_len -= next_pos - encoded_str; - encoded_str = next_pos; + encoded_str = next_pos; smart_str_free(&decoded_header); } @@ -2378,7 +2382,7 @@ PHP_NAMED_FUNCTION(php_if_iconv) size_t out_len; int in_charset_len = 0, out_charset_len = 0, in_buffer_len; php_iconv_err_t err; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &in_charset, &in_charset_len, &out_charset, &out_charset_len, &in_buffer, &in_buffer_len) == FAILURE) return; @@ -2390,7 +2394,7 @@ PHP_NAMED_FUNCTION(php_if_iconv) err = php_iconv_string(in_buffer, (size_t)in_buffer_len, &out_buffer, &out_len, out_charset, in_charset); - _php_iconv_show_error(err, out_charset, in_charset TSRMLS_CC); + _php_iconv_show_error(err, out_charset, in_charset TSRMLS_CC); if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) { RETVAL_STRINGL(out_buffer, out_len, 0); } else { @@ -2539,7 +2543,7 @@ static int php_iconv_stream_filter_append_bucket( icnt = buf_len; } - out_buf_size = ocnt = prev_ocnt = initial_out_buf_size; + out_buf_size = ocnt = prev_ocnt = initial_out_buf_size; if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) { return FAILURE; } diff --git a/ext/intl/tests/bug59597_64.phpt b/ext/intl/tests/bug59597_64.phpt index 4b96bf72e9..f96c72da54 100644 --- a/ext/intl/tests/bug59597_64.phpt +++ b/ext/intl/tests/bug59597_64.phpt @@ -15,7 +15,7 @@ $value = $formatter->parse('2147483650', \NumberFormatter::TYPE_INT64); var_dump($value); ?> ---EXPECTREGEX-- +--EXPECT-- int(2147483647) int(2147483650) diff --git a/ext/phar/tar.c b/ext/phar/tar.c index b914db129e..917734c992 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -38,7 +38,7 @@ static php_uint32 phar_tar_number(char *buf, int len) /* {{{ */ /* }}} */ /* adapted from format_octal() in libarchive - * + * * Copyright (c) 2003-2009 Tim Kientzle * All rights reserved. * @@ -161,7 +161,7 @@ static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRM size_t save = php_stream_tell(fp), read; phar_entry_info *mentry; - metadata = (char *) emalloc(entry->uncompressed_filesize + 1); + metadata = (char *) safe_emalloc(1, entry->uncompressed_filesize, 1); read = php_stream_read(fp, metadata, entry->uncompressed_filesize); if (read != entry->uncompressed_filesize) { @@ -377,7 +377,7 @@ bail: } read = php_stream_read(fp, buf, sizeof(buf)); - + if (read != sizeof(buf)) { efree(entry.filename); if (error) { diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 1054b0ea3b..92236a54f7 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -198,7 +198,7 @@ PHP_RSHUTDOWN_FUNCTION(readline) PHP_MINFO_FUNCTION(readline) { - return PHP_MINFO(cli_readline)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); + PHP_MINFO(cli_readline)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); } /* }}} */ diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 1cf65cee16..9346587eb7 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2561,7 +2561,8 @@ ZEND_METHOD(reflection_parameter, getDefaultValue) *return_value = *precv->op2.zv; INIT_PZVAL(return_value); - if (Z_TYPE_P(return_value) != IS_CONSTANT && Z_TYPE_P(return_value) != IS_CONSTANT_ARRAY) { + if ((Z_TYPE_P(return_value) & IS_CONSTANT_TYPE_MASK) != IS_CONSTANT + && (Z_TYPE_P(return_value) & IS_CONSTANT_TYPE_MASK) != IS_CONSTANT_ARRAY) { zval_copy_ctor(return_value); } zval_update_constant_ex(&return_value, (void*)0, param->fptr->common.scope TSRMLS_CC); diff --git a/ext/standard/crypt_freesec.c b/ext/standard/crypt_freesec.c index 49c397cca1..0a5c3ba5fa 100644 --- a/ext/standard/crypt_freesec.c +++ b/ext/standard/crypt_freesec.c @@ -629,7 +629,8 @@ _crypt_extended_r(const char *key, const char *setting, */ q = (u_char *) keybuf; while (q - (u_char *) keybuf < sizeof(keybuf)) { - if ((*q++ = *key << 1)) + *q++ = *key << 1; + if (*key) key++; } if (des_setkey((u_char *) keybuf, data)) diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 4dd52ed28b..5ff91994a7 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -56,7 +56,7 @@ /* This symbol is defined in ext/standard/config.m4. * Essentially, it is set if you HAVE_FORK || PHP_WIN32 - * Otherplatforms may modify that configure check and add suitable #ifdefs + * Other platforms may modify that configure check and add suitable #ifdefs * around the alternate code. * */ #ifdef PHP_CAN_SUPPORT_PROC_OPEN diff --git a/ext/standard/tests/strings/crypt_chars.phpt b/ext/standard/tests/strings/crypt_chars.phpt new file mode 100644 index 0000000000..09cd868216 --- /dev/null +++ b/ext/standard/tests/strings/crypt_chars.phpt @@ -0,0 +1,19 @@ +--TEST-- +crypt() function - characters > 0x80 +--SKIPIF-- +<?php +if (!function_exists('crypt')) { + die("SKIP crypt() is not available"); +} +?> +--FILE-- +<?php +var_dump(crypt("À1234abcd", "99")); +var_dump(crypt("À9234abcd", "99")); +var_dump(crypt("À1234abcd", "_01234567")); +var_dump(crypt("À9234abcd", "_01234567")); +--EXPECT-- +string(13) "99PxawtsTfX56" +string(13) "99jcVcGxUZOWk" +string(20) "_01234567IBjxKliXXRQ" +string(20) "_012345678OSGpGQRVHA" diff --git a/run-tests.php b/run-tests.php index 1fe0deb6af..2b37ec4f4a 100755 --- a/run-tests.php +++ b/run-tests.php @@ -239,10 +239,7 @@ $ini_overwrites = array( 'magic_quotes_runtime=0', 'ignore_repeated_errors=0', 'precision=14', - 'unicode.runtime_encoding=ISO-8859-1', - 'unicode.script_encoding=UTF-8', - 'unicode.output_encoding=UTF-8', - 'unicode.from_error_mode=U_INVALID_SUBSTITUTE', + 'memory_limit=128M', ); function write_information($show_html) diff --git a/sapi/cli/tests/bug61546.phpt b/sapi/cli/tests/bug61546.phpt index 2cd690f65c..071edb7224 100644 --- a/sapi/cli/tests/bug61546.phpt +++ b/sapi/cli/tests/bug61546.phpt @@ -2,13 +2,22 @@ Bug #61546 (functions related to current script failed when chdir() in cli sapi) --FILE-- <?php +// reference doc for getmyinode() on php.net states that it returns an integer or FALSE on error +// on Windows, getmyinode() returns 0 which normally casts to FALSE +// however, the implementation of getmyinode() (in pageinfo.c) returns an explicit FALSE in the +// event that the internal page_inode structure is less than 0, otherwise it returns the long value +// of page_inode. therefore, an explicit 0 should be a passing value for this test. +// +// the ext/standard/tests/file/statpage.phpt test also tests getmyinode() returns an integer and will +// pass even if that integer is 0. on Windows, the getmyinode() call in statpage.phpt returns 0 and +// passes on Windows. $php = getenv("TEST_PHP_EXECUTABLE"); $test_code = <<<PHP <?php chdir('..'); var_dump(get_current_user() != ""); chdir('..'); -var_dump(getmyinode() != false); +var_dump(getmyinode() !== false); var_dump(getlastmod() != false); PHP; |