Skip to content

Commit 4c716e8

Browse files
committed
Merge branch 'master' into test
* master: (39 commits) Add __debugInfo() to UPGRADING. fix TS build Update NEWS Update NEWS Update NEWS Small tidy ups and raise visibility of GitHub PR process Bug #41631: Observe socket read timeouts in SSL streams wrap int8_t and int16_t with #ifdef to avoid possible clashes - Updated to version 2014.6 (2014f) Removed Countable::count() change info from UPGRADE.INTERNALS too NEWS and UPGRADING for intdiv() Revert "Add SO_REUSEPORT + SO_BROADCAST support via socket stream context option" Fixed skip case for intdiv 64-bit test Use callback structure Add EXPECTF Fix handling of multi-result sets with PS...used to clean not only the result set but the whole PS. 5.5.17 now 5.4.33-dev now Add SO_REUSEPORT + SO_BROADCAST support via socket stream context option Add SO_REUSEPORT + SO_BROADCAST support via socket stream context option ... Conflicts: ext/fileinfo/libmagic/softmagic.c main/streams/xp_socket.c
2 parents 0ae305e + 97bb078 commit 4c716e8

27 files changed

+1905
-1376
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ PHP NEWS
1616
- Standard:
1717
. Removed call_user_method() and call_user_method_array() functions. (Kalle)
1818
. Fix user session handlers (See rfc:session.user.return-value). (Sara)
19+
. Added intdiv() function. (Andrea)
1920

2021
- XSL:
2122
. Fixed bug #64776 (The XSLT extension is not thread safe). (Mike)

README.SUBMITTING_PATCH

+18-17
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Online Forums
1717
-------------
1818
There are several IRC channels where PHP developers are often
1919
available to discuss questions. They include #php.pecl and #php.doc
20-
on the EFNet network and #php-dev-win on FreeNode.
20+
on the EFNet network and #winphp-dev on FreeNode.
2121

2222

2323
PHP Patches
@@ -33,34 +33,35 @@ and discuss it on the development mail list internals@lists.php.net.
3333
RFC Wiki accounts can be requested on
3434
http://wiki.php.net/start?do=register. PHP extension maintainers can
3535
be found in the EXTENSIONS file in the PHP source. Mail list
36-
subscription is explained on http://www.php.net/mailing-lists.php.
36+
subscription is explained on http://php.net/mailing-lists.php.
3737

3838
Information on PHP internal C functions is at
39-
http://www.php.net/internals, though this is considered incomplete.
40-
Various external resources can be found on the web. A standard
39+
http://php.net/internals, though this is considered incomplete.
40+
Various external resources can be found on the web. See
41+
https://wiki.php.net/internals for some references. A standard
4142
printed reference is the book "Extending and Embedding PHP" by Sara
4243
Golemon.
4344

44-
Attach the patch to the PHP bug and consider sending a notification
45-
email about the change to internals@lists.php.net. Also CC the
46-
extension maintainer. Explain what has been changed by your patch.
47-
Test scripts should be included.
48-
49-
Please make the mail subject prefix "[PATCH]". If attaching a patch,
50-
ensure it has a file extension of ".txt". This is because only MIME
51-
attachments of type 'text/*' are accepted.
52-
5345
The preferred way to propose PHP patch is sending pull request from
54-
github.
55-
56-
https://github.com/php/php-src
46+
GitHub: https://github.com/php/php-src
5747

5848
Fork the official PHP repository and send a pull request. A
5949
notification will be sent to the pull request mailing list. Sending a
6050
note to PHP Internals list (internals@lists.php.net) may help getting
6151
more feedback and quicker turnaround. You can also add pull requests
6252
to bug reports at http://bugs.php.net/.
6353

54+
If you are not using GitHub, attach your patch to a PHP bug and
55+
consider sending a notification email about the change to
56+
internals@lists.php.net. If the bug is for an extension, also CC the
57+
extension maintainer. Explain what has been changed by your patch.
58+
Test scripts should be included.
59+
60+
Please make the mail subject prefix "[PATCH]". If attaching a patch,
61+
ensure it has a file extension of ".txt". This is because only MIME
62+
attachments of type 'text/*' are accepted.
63+
64+
6465

6566
PHP Documentation Patches
6667
-------------------------
@@ -71,7 +72,7 @@ the PHP mail archives.
7172

7273
If your change is large, then first discuss it with the mail list
7374
phpdoc@lists.php.net. Subscription is explained on
74-
http://www.php.net/mailing-lists.php.
75+
http://php.net/mailing-lists.php.
7576

7677
Information on contributing to PHP documentation is at
7778
http://php.net/dochowto and http://wiki.php.net/doc/howto

UPGRADING

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ PHP X.Y UPGRADE NOTES
2828
2. New Features
2929
========================================
3030

31+
- Standard
32+
. intdiv() function for integer division added.
3133

3234
========================================
3335
3. Changes in SAPI modules
@@ -69,7 +71,7 @@ PHP X.Y UPGRADE NOTES
6971
========================================
7072

7173
- Core
72-
, PHP_INT_MIN added.
74+
. PHP_INT_MIN added.
7375

7476
========================================
7577
11. Changes to INI File Handling

ext/date/lib/timezonedb.h

+1,389-1,315
Large diffs are not rendered by default.

ext/fileinfo/data_file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -121057,7 +121057,7 @@ const unsigned char php_magic_database[2803888] = {
121057121057
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
121058121058
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
121059121059
0x00, 0x00, 0x40, 0x00, 0x3D, 0x1B, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
121060-
0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
121060+
0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
121061121061
0x5E, 0x5C, 0x73, 0x7B, 0x30, 0x2C, 0x31, 0x30, 0x30, 0x7D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x5C,
121062121062
0x73, 0x7B, 0x30, 0x2C, 0x31, 0x30, 0x30, 0x7D, 0x5B, 0x7B, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00,
121063121063
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

ext/fileinfo/libmagic/softmagic.c

+19-10
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private int32_t mprint(struct magic_set *, struct magic *);
6767
private int32_t moffset(struct magic_set *, struct magic *);
6868
private void mdebug(uint32_t, const char *, size_t);
6969
private int mcopy(struct magic_set *, union VALUETYPE *, int, int,
70-
const unsigned char *, uint32_t, size_t, size_t);
70+
const unsigned char *, uint32_t, size_t, struct magic *);
7171
private int mconvert(struct magic_set *, struct magic *, int);
7272
private int print_sep(struct magic_set *, int);
7373
private int handle_annotation(struct magic_set *, struct magic *);
@@ -1041,7 +1041,7 @@ mdebug(uint32_t offset, const char *str, size_t len)
10411041

10421042
private int
10431043
mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
1044-
const unsigned char *s, uint32_t offset, size_t nbytes, size_t linecnt)
1044+
const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m)
10451045
{
10461046
/*
10471047
* Note: FILE_SEARCH and FILE_REGEX do not actually copy
@@ -1061,15 +1061,24 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
10611061
const char *last; /* end of search region */
10621062
const char *buf; /* start of search region */
10631063
const char *end;
1064-
size_t lines;
1064+
size_t lines, linecnt, bytecnt;
10651065

1066+
linecnt = m->str_range;
1067+
bytecnt = linecnt * 80;
1068+
1069+
if (bytecnt == 0) {
1070+
bytecnt = 8192;
1071+
}
1072+
if (bytecnt > nbytes) {
1073+
bytecnt = nbytes;
1074+
}
10661075
if (s == NULL) {
10671076
ms->search.s_len = 0;
10681077
ms->search.s = NULL;
10691078
return 0;
10701079
}
10711080
buf = RCAST(const char *, s) + offset;
1072-
end = last = RCAST(const char *, s) + nbytes;
1081+
end = last = RCAST(const char *, s) + bytecnt;
10731082
/* mget() guarantees buf <= last */
10741083
for (lines = linecnt, b = buf; lines && b < end &&
10751084
((b = CAST(const char *,
@@ -1082,7 +1091,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
10821091
b++;
10831092
}
10841093
if (lines)
1085-
last = RCAST(const char *, s) + nbytes;
1094+
last = RCAST(const char *, s) + bytecnt;
10861095

10871096
ms->search.s = buf;
10881097
ms->search.s_len = last - buf;
@@ -1153,7 +1162,6 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
11531162
int *need_separator, int *returnval)
11541163
{
11551164
uint32_t soffset, offset = ms->offset;
1156-
uint32_t count = m->str_range;
11571165
int rv, oneed_separator, in_type;
11581166
char *sbuf, *rbuf;
11591167
union VALUETYPE *p = &ms->ms_value;
@@ -1165,13 +1173,12 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
11651173
}
11661174

11671175
if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),
1168-
(uint32_t)nbytes, count) == -1)
1176+
(uint32_t)nbytes, m) == -1)
11691177
return -1;
11701178

11711179
if ((ms->flags & MAGIC_DEBUG) != 0) {
11721180
fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%zu, "
1173-
"nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o,
1174-
nbytes, count);
1181+
"nbytes=%zu)\n", m->type, m->flag, offset, o, nbytes);
11751182
mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
11761183
}
11771184

@@ -1664,7 +1671,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
16641671
if ((ms->flags & MAGIC_DEBUG) != 0)
16651672
fprintf(stderr, "indirect +offs=%u\n", offset);
16661673
}
1667-
if (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1)
1674+
if (mcopy(ms, p, m->type, 0, s, offset, nbytes, m) == -1)
16681675
return -1;
16691676
ms->offset = offset;
16701677

@@ -2092,7 +2099,9 @@ magiccheck(struct magic_set *ms, struct magic *m)
20922099
zval subpats;
20932100
char *haystack;
20942101

2102+
ZVAL_NULL(&retval);
20952103
ZVAL_NULL(&subpats);
2104+
20962105
/* Cut the search len from haystack, equals to REG_STARTEND */
20972106
haystack = estrndup(ms->search.s, ms->search.s_len);
20982107

ext/fileinfo/magicdata.patch

+55-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,58 @@
1-
Patches applied to file sources tree before generating magic.mgc
1+
Patches applied to file 5.17 sources tree before generating magic.mgc
22
and before running create_data_file.php to create data_file.c.
33

44

5+
6+
From 0b478f445b6b7540b58af5d1fe583fa9e48fd745 Mon Sep 17 00:00:00 2001
7+
From: Christos Zoulas <christos@zoulas.com>
8+
Date: Wed, 28 May 2014 19:52:36 +0000
9+
Subject: [PATCH] further optimize awk by not looking for the BEGIN regex until
10+
we found the BEGIN (Jan Kaluza)
11+
12+
---
13+
magic/Magdir/commands | 5 +++--
14+
1 file changed, 3 insertions(+), 2 deletions(-)
15+
16+
diff --git a/magic/Magdir/commands b/magic/Magdir/commands
17+
index bfffdef..26b2869 100644
18+
--- a/magic/Magdir/commands
19+
+++ b/magic/Magdir/commands
20+
@@ -49,7 +49,8 @@
21+
!:mime text/x-awk
22+
0 string/wt #!\ /usr/bin/awk awk script text executable
23+
!:mime text/x-awk
24+
-0 regex =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
25+
+0 search/16384 BEGIN
26+
+>0 regex =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
27+
28+
# AT&T Bell Labs' Plan 9 shell
29+
0 string/wt #!\ /bin/rc Plan 9 rc shell script text executable
30+
--
31+
2.0.3
32+
33+
From 71a8b6c0d758acb0f73e2e51421a711b5e9d6668 Mon Sep 17 00:00:00 2001
34+
From: Christos Zoulas <christos@zoulas.com>
35+
Date: Fri, 30 May 2014 16:48:44 +0000
36+
Subject: [PATCH] Limit regex search for BEGIN to the first 4K of the file.
37+
38+
---
39+
magic/Magdir/commands | 5 ++---
40+
1 file changed, 2 insertions(+), 3 deletions(-)
41+
42+
diff --git a/magic/Magdir/commands b/magic/Magdir/commands
43+
index 26b2869..bcd0f43 100644
44+
--- a/magic/Magdir/commands
45+
+++ b/magic/Magdir/commands
46+
@@ -49,8 +49,7 @@
47+
!:mime text/x-awk
48+
0 string/wt #!\ /usr/bin/awk awk script text executable
49+
!:mime text/x-awk
50+
-0 search/16384 BEGIN
51+
->0 regex =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
52+
+0 regex/4096 =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
53+
54+
# AT&T Bell Labs' Plan 9 shell
55+
0 string/wt #!\ /bin/rc Plan 9 rc shell script text executable
56+
--
57+
2.0.3
58+

ext/fileinfo/tests/cve-2014-3538.phpt

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
Bug #66731: file: extensive backtraking
3+
--SKIPIF--
4+
<?php
5+
if (!class_exists('finfo'))
6+
die('skip no fileinfo extension');
7+
--FILE--
8+
<?php
9+
$fd = __DIR__.'/cve-2014-3538.data';
10+
11+
file_put_contents($fd,
12+
'try:' .
13+
str_repeat("\n", 1000000));
14+
15+
$fi = finfo_open(FILEINFO_NONE);
16+
$t = microtime(true);
17+
var_dump(finfo_file($fi, $fd));
18+
$t = microtime(true) - $t;
19+
finfo_close($fi);
20+
if ($t < 1) {
21+
echo "Ok\n";
22+
} else {
23+
printf("Failed, time=%.2f\n", $t);
24+
}
25+
26+
?>
27+
Done
28+
--CLEAN--
29+
<?php
30+
@unlink(__DIR__.'/cve-2014-3538.data');
31+
?>
32+
--EXPECTF--
33+
string(%d) "%s"
34+
Ok
35+
Done

ext/ftp/ftp.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ ftp_open(const char *host, short port, long timeout_sec TSRMLS_DC)
136136

137137
ftp->fd = php_network_connect_socket_to_host(host,
138138
(unsigned short) (port ? port : 21), SOCK_STREAM,
139-
0, &tv, NULL, NULL, NULL, 0 TSRMLS_CC);
139+
0, &tv, NULL, NULL, NULL, 0, STREAM_SOCKOP_NONE TSRMLS_CC);
140140
if (ftp->fd == -1) {
141141
goto bail;
142142
}

ext/gd/libgd/gdxpm.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ gdImagePtr gdImageCreateFromXpm (char *filename)
3131
if (ret != XpmSuccess) {
3232
return 0;
3333
}
34+
number = image.ncolors;
35+
for(i = 0; i < number; i++) {
36+
if (!image.colorTable[i].c_color) {
37+
goto done;
38+
}
39+
}
3440

3541
if (!(im = gdImageCreate(image.width, image.height))) {
3642
goto done;
3743
}
3844

39-
number = image.ncolors;
4045
colors = (int *) safe_emalloc(number, sizeof(int), 0);
4146
for (i = 0; i < number; i++) {
4247
switch (strlen (image.colorTable[i].c_color)) {

0 commit comments

Comments
 (0)