Merge branch 'master' of git.php.net:php-src

This commit is contained in:
andrey 2012-05-30 15:25:26 +03:00
commit 56532895a8
12 changed files with 178 additions and 84 deletions

View File

@ -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--

View File

@ -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

View File

@ -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===

View File

@ -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
/**

View File

@ -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===

View File

@ -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]])

View File

@ -15,7 +15,7 @@ $value = $formatter->parse('2147483650', \NumberFormatter::TYPE_INT64);
var_dump($value);
?>
--EXPECTREGEX--
--EXPECT--
int(2147483647)
int(2147483650)

View File

@ -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) {

View File

@ -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))

View File

@ -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"

View File

@ -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;