mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-09 02:00:49 +00:00
Compare commits
296
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5747a70cf | ||
|
|
155619184f | ||
|
|
0c7250f260 | ||
|
|
fc0b0afdc3 | ||
|
|
2af6dded37 | ||
|
|
c395c6e5d7 | ||
|
|
b028cacf31 | ||
|
|
e1d2f86a41 | ||
|
|
5f107ab8a6 | ||
|
|
7f428cae88 | ||
|
|
6c5211a0ce | ||
|
|
f6aef68089 | ||
|
|
3f627e580a | ||
|
|
b9ec171e7d | ||
|
|
5b597a2e5b | ||
|
|
e9ac8954be | ||
|
|
7722455726 | ||
|
|
7245bff300 | ||
|
|
88746d60ab | ||
|
|
489fd56fe3 | ||
|
|
a44c89e8af | ||
|
|
6f73079ce1 | ||
|
|
f96ebb0986 | ||
|
|
4dd03651f3 | ||
|
|
0c84740450 | ||
|
|
9a826a3bd9 | ||
|
|
f423e1bb89 | ||
|
|
e955913115 | ||
|
|
7a1aac3343 | ||
|
|
97eff7eb57 | ||
|
|
0da8b8b801 | ||
|
|
41fc3c76e9 | ||
|
|
abd159cce4 | ||
|
|
95ed19ae28 | ||
|
|
a4abd2bed9 | ||
|
|
5c571626e3 | ||
|
|
6058b78878 | ||
|
|
9649ca1630 | ||
|
|
008f983ba6 | ||
|
|
61c7a06e7c | ||
|
|
dccda88f27 | ||
|
|
f856734c67 | ||
|
|
082aecfc3a | ||
|
|
d650063a04 | ||
|
|
fd9689745c | ||
|
|
b15f0ecc0f | ||
|
|
8a4d164c2b | ||
|
|
4b0b1cec00 | ||
|
|
f0120ff878 | ||
|
|
551423c642 | ||
|
|
fe13566c93 | ||
|
|
9c19a08b9d | ||
|
|
3dd82caf57 | ||
|
|
f8dd10508b | ||
|
|
64f42c73ef | ||
|
|
95433e8e33 | ||
|
|
72281f29dd | ||
|
|
914d33c40e | ||
|
|
3c8ccdd9d3 | ||
|
|
54df59b729 | ||
|
|
153a44d6bb | ||
|
|
a6fdc5bb27 | ||
|
|
b1bd4119bc | ||
|
|
377d353c9f | ||
|
|
7d875fb9df | ||
|
|
2a7d8c0a06 | ||
|
|
e7051cb47a | ||
|
|
0d86a98c31 | ||
|
|
b5ef8ed168 | ||
|
|
ca02d9c2d6 | ||
|
|
07c7df68bd | ||
|
|
a1c675e3f2 | ||
|
|
686a17893a | ||
|
|
f4d7bbf4ac | ||
|
|
828364e59c | ||
|
|
df78eacc2f | ||
|
|
54c210d2ea | ||
|
|
6297a117d7 | ||
|
|
1c1b8b6998 | ||
|
|
285cd3417f | ||
|
|
635ba1f2c3 | ||
|
|
13ad4d3e97 | ||
|
|
aa8d3a8cc6 | ||
|
|
a6734f70e1 | ||
|
|
74dcbe1299 | ||
|
|
2baeb167a0 | ||
|
|
dcf3c9761c | ||
|
|
1785d2b805 | ||
|
|
4df84a648e | ||
|
|
be19dbcb84 | ||
|
|
4bb422343f | ||
|
|
2e157c5275 | ||
|
|
f3838a9c35 | ||
|
|
d7fb43e30d | ||
|
|
3f08fc0466 | ||
|
|
932f707177 | ||
|
|
1ddf72180a | ||
|
|
f98ab19dc0 | ||
|
|
e78ac461db | ||
|
|
d698f0ae51 | ||
|
|
bb98ed600a | ||
|
|
a12cef979d | ||
|
|
ea807f9c07 | ||
|
|
51fca4b77d | ||
|
|
43c2dfa7b3 | ||
|
|
4aeff30337 | ||
|
|
1922c650ba | ||
|
|
32fe02c27d | ||
|
|
31b634bf7c | ||
|
|
0fac73a3bf | ||
|
|
7ceb0e3a18 | ||
|
|
53d274beb0 | ||
|
|
33d3acaae7 | ||
|
|
48cfd1160b | ||
|
|
7c31203935 | ||
|
|
e2291e4b1a | ||
|
|
1390a5812b | ||
|
|
3605d1baf5 | ||
|
|
906f19f136 | ||
|
|
6935058a98 | ||
|
|
c8f07ad477 | ||
|
|
259057b2a4 | ||
|
|
f06a069c46 | ||
|
|
e8429400d4 | ||
|
|
e201f01ac1 | ||
|
|
f9c2bf73ad | ||
|
|
ce2c67c8e8 | ||
|
|
03964892c0 | ||
|
|
64043cb9e5 | ||
|
|
fc8eff897b | ||
|
|
24dda816d0 | ||
|
|
95a0b11d0a | ||
|
|
e93d7953df | ||
|
|
941bbf2067 | ||
|
|
df4bf28f9f | ||
|
|
85d34c3264 | ||
|
|
1744be2d17 | ||
|
|
9ff3334397 | ||
|
|
dc72378ff0 | ||
|
|
15e9f4baf4 | ||
|
|
b221df5549 | ||
|
|
2425f88afd | ||
|
|
da5321013c | ||
|
|
f2f8ea9ac5 | ||
|
|
f1acac154a | ||
|
|
d52c485717 | ||
|
|
742c54aecf | ||
|
|
0a21b5d970 | ||
|
|
ee61c7175f | ||
|
|
69ed3969dd | ||
|
|
51f9a00b47 | ||
|
|
dda81f0505 | ||
|
|
0e09009753 | ||
|
|
4d2278143a | ||
|
|
863bf294fe | ||
|
|
7381b6accc | ||
|
|
c7d3c027d5 | ||
|
|
c2e197e4ef | ||
|
|
7fc04937f5 | ||
|
|
66edc15875 | ||
|
|
8f1baa6e1c | ||
|
|
ce5c4500cd | ||
|
|
16023f3e3b | ||
|
|
7a4584d3f6 | ||
|
|
b7fa67742c | ||
|
|
e488690d95 | ||
|
|
c96d08b272 | ||
|
|
daa0abaf77 | ||
|
|
34b624f122 | ||
|
|
496f291f3d | ||
|
|
b4b082e63e | ||
|
|
545eddba93 | ||
|
|
885edfef0a | ||
|
|
c8157619ef | ||
|
|
97aa752fee | ||
|
|
6dedeb40db | ||
|
|
bf58162ddf | ||
|
|
b6f5cb11a4 | ||
|
|
29533ae528 | ||
|
|
ed84af4b88 | ||
|
|
eda31f57fb | ||
|
|
09de64a58d | ||
|
|
61b0b80388 | ||
|
|
485b7c6981 | ||
|
|
c938d2f537 | ||
|
|
303d97feda | ||
|
|
0d2f147d80 | ||
|
|
3e88d610e5 | ||
|
|
452d30cf7d | ||
|
|
8f2e08239f | ||
|
|
cd9c39d77c | ||
|
|
80f9a9725c | ||
|
|
8e440dc1d7 | ||
|
|
cd068b1ed6 | ||
|
|
b03f743e7d | ||
|
|
8da8dc04b6 | ||
|
|
921544cad9 | ||
|
|
a621781fdb | ||
|
|
1cbcbcbc21 | ||
|
|
23e25f3319 | ||
|
|
eef6b10b7c | ||
|
|
75b2ce28aa | ||
|
|
a39beaa251 | ||
|
|
b0954ebb79 | ||
|
|
8877feaeec | ||
|
|
fdb580a5ad | ||
|
|
5fe078abba | ||
|
|
d263ecd864 | ||
|
|
dacea3f6fb | ||
|
|
6a8db93115 | ||
|
|
c0119ca7f3 | ||
|
|
a85156db7d | ||
|
|
1edb2e9a10 | ||
|
|
ca33ae3eb2 | ||
|
|
cc7194dd10 | ||
|
|
991b2cc37b | ||
|
|
189af22cf0 | ||
|
|
5f67caad54 | ||
|
|
d241711f44 | ||
|
|
61d58f2d9e | ||
|
|
7469c7e7d0 | ||
|
|
558342124e | ||
|
|
9026a66579 | ||
|
|
1d6f4891bd | ||
|
|
9e4d720825 | ||
|
|
7f4e1a0eef | ||
|
|
b60efdce9f | ||
|
|
7c0b8f872e | ||
|
|
44b09b80f2 | ||
|
|
a037b6de21 | ||
|
|
dcfd1153ec | ||
|
|
e711325ca6 | ||
|
|
cd927cca50 | ||
|
|
72b8a30c1a | ||
|
|
9d5ab7e22f | ||
|
|
9ba3a4c66a | ||
|
|
f14141aca2 | ||
|
|
60e181c20a | ||
|
|
0c8136654d | ||
|
|
82e5260104 | ||
|
|
741b949a6f | ||
|
|
aef5a02ebb | ||
|
|
36222eb4cc | ||
|
|
2ba9681e8e | ||
|
|
616b932ab0 | ||
|
|
2b8ba3e9f8 | ||
|
|
c2d4704744 | ||
|
|
f1ffb4b1ad | ||
|
|
e10af61862 | ||
|
|
9d168b863e | ||
|
|
6b53b7cd84 | ||
|
|
eee8b6c33f | ||
|
|
539738c438 | ||
|
|
4e2fb47092 | ||
|
|
8036758491 | ||
|
|
f7d7befae8 | ||
|
|
5f7c1917e3 | ||
|
|
531c306fe6 | ||
|
|
b347f2c47a | ||
|
|
6bb24823d0 | ||
|
|
78d1228ef6 | ||
|
|
f5bf7b6b27 | ||
|
|
eb7c33b204 | ||
|
|
b5d1530e4f | ||
|
|
33a9f01d36 | ||
|
|
7ced40e24e | ||
|
|
4cc46b2a99 | ||
|
|
90a8ea9827 | ||
|
|
17f2d1e8a7 | ||
|
|
b754e3ec4b | ||
|
|
b470d9a0d6 | ||
|
|
75c2aa9d3a | ||
|
|
9a0bdd9069 | ||
|
|
1cbd25ca15 | ||
|
|
9031a902e3 | ||
|
|
8746163153 | ||
|
|
0765623d69 | ||
|
|
f029a2856b | ||
|
|
b24fedbd24 | ||
|
|
e44b040faf | ||
|
|
1e9522021a | ||
|
|
31d59bf915 | ||
|
|
50d4ea90b3 | ||
|
|
7e731e4d9d | ||
|
|
05351f9ccb | ||
|
|
930fb8b1f3 | ||
|
|
f38ca75a3c | ||
|
|
5683b6fa39 | ||
|
|
c4e9651b58 | ||
|
|
09b92a3a54 | ||
|
|
00d8e26d71 | ||
|
|
88aab478bf | ||
|
|
593c4b9b00 | ||
|
|
3ee3066bd0 | ||
|
|
f93d24aa67 | ||
|
|
4ceb7b46ad |
No files matched your search
@@ -20,6 +20,9 @@
|
||||
*.tar.gz
|
||||
*.tar.bz2
|
||||
*.tar.xz
|
||||
*.tar.gz.asc
|
||||
*.tar.bz2.asc
|
||||
*.tar.xz.asc
|
||||
.FBCIndex
|
||||
.FBCLockFolder
|
||||
.deps
|
||||
|
||||
+13
-6
@@ -1,9 +1,21 @@
|
||||
language: c
|
||||
|
||||
sudo: false
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- locales
|
||||
- language-pack-de
|
||||
- re2c
|
||||
- libgmp-dev
|
||||
- libicu-dev
|
||||
- libmcrypt-dev
|
||||
- libtidy-dev
|
||||
notifications:
|
||||
email:
|
||||
on_failure: change
|
||||
irc:
|
||||
template:
|
||||
- "%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message} - Change view : %{compare_url} - Build details : %{build_url}"
|
||||
channels:
|
||||
- "irc.efnet.org#php.pecl"
|
||||
on_success: change
|
||||
@@ -25,11 +37,6 @@ env:
|
||||
- ENABLE_MAINTAINER_ZTS=0 ENABLE_DEBUG=0
|
||||
- ENABLE_MAINTAINER_ZTS=1 ENABLE_DEBUG=1
|
||||
|
||||
before_install:
|
||||
- sudo cp ./travis/de /var/lib/locales/supported.d/de
|
||||
- sudo dpkg-reconfigure locales
|
||||
- ./travis/install.sh
|
||||
|
||||
before_script:
|
||||
# Compile PHP
|
||||
- ./travis/compile.sh
|
||||
|
||||
@@ -1,5 +1,291 @@
|
||||
PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
23 Jun 2016, PHP 5.5.37
|
||||
|
||||
- Core:
|
||||
. Fixed bug #72268 (Integer Overflow in nl2br()). (Stas)
|
||||
. Fixed bug #72275 (Integer Overflow in json_encode()/json_decode()/
|
||||
json_utf8_to_utf16()). (Stas)
|
||||
. Fixed bug #72400 (Integer Overflow in addcslashes/addslashes). (Stas)
|
||||
. Fixed bug #72403 (Integer Overflow in Length of String-typed ZVAL). (Stas)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #66387 (Stack overflow with imagefilltoborder) (CVE-2015-8874).
|
||||
(cmb)
|
||||
. Fixed bug #72298 (pass2_no_dither out-of-bounds access). (Stas)
|
||||
. Fixed bug #72339 (Integer Overflow in _gd2GetHeader() resulting in
|
||||
heap overflow). (Pierre)
|
||||
. Fixed bug #72407 (NULL Pointer Dereference at _gdScaleVert). (Stas)
|
||||
. Fixed bug #72446 (Integer Overflow in gdImagePaletteToTrueColor() resulting
|
||||
in heap overflow). (Pierre)
|
||||
|
||||
- mbstring:
|
||||
. Fixed bug #72402 (_php_mb_regex_ereg_replace_exec - double free). (Stas)
|
||||
|
||||
- mcrypt:
|
||||
. Fixed bug #72455 (Heap Overflow due to integer overflows). (Stas)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #72262 (int/size_t confusion in SplFileObject::fread). (Stas)
|
||||
. Fixed bug #72433 (Use After Free Vulnerability in PHP's GC algorithm and
|
||||
unserialize). (Dmitry)
|
||||
|
||||
- WDDX:
|
||||
. Fixed bug #72340 (Double Free Courruption in wddx_deserialize). (Stas)
|
||||
|
||||
- zip:
|
||||
. Fixed bug #72434 (ZipArchive class Use After Free Vulnerability in PHP's GC
|
||||
algorithm and unserialize). (Dmitry)
|
||||
|
||||
26 May 2016, PHP 5.5.36
|
||||
|
||||
- Core:
|
||||
. Fixed bug #72114 (Integer underflow / arbitrary null write in
|
||||
fread/gzread). (Stas)
|
||||
. Fixed bug #72135 (Integer Overflow in php_html_entities). (Stas)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #72227 (imagescale out-of-bounds read). (Stas)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug #72241 (get_icu_value_internal out-of-bounds read). (Stas)
|
||||
|
||||
- Phar:
|
||||
. Fixed bug #71331 (Uninitialized pointer in phar_make_dirstream()).
|
||||
(CVE-2016-4343) (Stas)
|
||||
|
||||
28 Apr 2016, PHP 5.5.35
|
||||
|
||||
- BCMath:
|
||||
. Fixed bug #72093 (bcpowmod accepts negative scale and corrupts _one_
|
||||
definition). (Stas)
|
||||
|
||||
- Exif:
|
||||
. Fixed bug #72094 (Out of bounds heap read access in exif header
|
||||
processing). (Stas)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #71912 (libgd: signedness vulnerability) (CVE-2016-3074). (Stas)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug #72061 (Out-of-bounds reads in zif_grapheme_stripos with negative
|
||||
offset). (Stas)
|
||||
|
||||
- XML:
|
||||
. Fixed bug #72099 (xml_parse_into_struct segmentation fault). (Stas)
|
||||
|
||||
31 Mar 2016, PHP 5.5.34
|
||||
|
||||
- Fileinfo:
|
||||
. Fixed bug #71527 (Buffer over-write in finfo_open with malformed magic
|
||||
file). (CVE-2015-8865) (Anatol)
|
||||
|
||||
- Mbstring:
|
||||
. Fixed bug #71906 (AddressSanitizer: negative-size-param (-1) in
|
||||
mbfl_strcut). (CVE-2016-4073) (Stas)
|
||||
|
||||
- ODBC:
|
||||
. Fixed bug #71860 (Invalid memory write in phar on filename with \0 in
|
||||
name). (CVE-2016-4072) (Stas)
|
||||
|
||||
- SNMP:
|
||||
. Fixed bug #71704 (php_snmp_error() Format String Vulnerability).
|
||||
(CVE-2016-4071) (andrew at jmpesp dot org)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #71798 (Integer Overflow in php_raw_url_encode). (CVE-2016-4070)
|
||||
(taoguangchen at icloud dot com, Stas)
|
||||
|
||||
03 Mar 2016, PHP 5.5.33
|
||||
|
||||
- Phar:
|
||||
. Fixed bug #71498 (Out-of-Bound Read in phar_parse_zipfile()). (Stas)
|
||||
|
||||
- WDDX:
|
||||
. Fixed bug #71587 (Use-After-Free / Double-Free in WDDX Deserialize). (Stas)
|
||||
|
||||
04 Feb 2016, PHP 5.5.32
|
||||
|
||||
- Core:
|
||||
. Fixed bug #71039 (exec functions ignore length but look for NULL termination).
|
||||
(Anatol)
|
||||
. Fixed bug #71323 (Output of stream_get_meta_data can be falsified by its
|
||||
input). (Leo Gaspard)
|
||||
. Fixed bug #71459 (Integer overflow in iptcembed()). (Stas)
|
||||
|
||||
- GD:
|
||||
. Improved the fix for bug #70976. (Remi)
|
||||
|
||||
- PCRE:
|
||||
. Upgraded pcrelib to 8.38. (CVE-2015-8383, CVE-2015-8386, CVE-2015-8387,
|
||||
CVE-2015-8389, CVE-2015-8390, CVE-2015-8391, CVE-2015-8393, CVE-2015-8394)
|
||||
|
||||
- Phar:
|
||||
. Fixed bug #71354 (Heap corruption in tar/zip/phar parser). (CVE-2016-4342)
|
||||
(Stas)
|
||||
. Fixed bug #71391 (NULL Pointer Dereference in phar_tar_setupmetadata()).
|
||||
(Stas)
|
||||
. Fixed bug #71488 (Stack overflow when decompressing tar archives).
|
||||
(CVE-2016-2554) (Stas)
|
||||
|
||||
- WDDX:
|
||||
. Fixed bug #71335 (Type Confusion in WDDX Packet Deserialization). (Stas)
|
||||
|
||||
07 Jan 2015, PHP 5.5.31
|
||||
|
||||
- FPM:
|
||||
. Fixed bug #70755 (fpm_log.c memory leak and buffer overflow). (Stas)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #70976 (Memory Read via gdImageRotateInterpolated Array Index
|
||||
Out of Bounds). (CVE-2016-1903) (emmanuel dot law at gmail dot com).
|
||||
|
||||
- WDDX:
|
||||
. Fixed bug #70661 (Use After Free Vulnerability in WDDX Packet Deserialization).
|
||||
(taoguangchen at icloud dot com)
|
||||
. Fixed bug #70741 (Session WDDX Packet Deserialization Type Confusion
|
||||
Vulnerability). (taoguangchen at icloud dot com)
|
||||
|
||||
- XMLRPC:
|
||||
. Fixed bug #70728 (Type Confusion Vulnerability in PHP_to_XMLRPC_worker()).
|
||||
(Julien)
|
||||
|
||||
01 Oct 2015, PHP 5.5.30
|
||||
|
||||
- Phar:
|
||||
. Fixed bug #69720 (Null pointer dereference in phar_get_fp_offset()).
|
||||
(CVE-2015-7803) (Stas)
|
||||
. Fixed bug #70433 (Uninitialized pointer in phar_make_dirstream when zip
|
||||
entry filename is "/"). (CVE-2015-7804) (Stas)
|
||||
|
||||
03 Sep 2015, PHP 5.5.29
|
||||
|
||||
- Core:
|
||||
. Fixed bug #70172 (Use After Free Vulnerability in unserialize()).
|
||||
(CVE-2015-6834) (Stas)
|
||||
. Fixed bug #70219 (Use after free vulnerability in session deserializer).
|
||||
(CVE-2015-6835) (taoguangchen at icloud dot com)
|
||||
|
||||
- EXIF:
|
||||
. Fixed bug #70385 (Buffer over-read in exif_read_data with TIFF IFD tag byte
|
||||
value of 32 bytes). (Stas)
|
||||
|
||||
- hash:
|
||||
. Fixed bug #70312 (HAVAL gives wrong hashes in specific cases). (letsgolee
|
||||
at naver dot com)
|
||||
|
||||
- PCRE:
|
||||
. Fixed bug #70345 (Multiple vulnerabilities related to PCRE functions).
|
||||
(Anatol Belski)
|
||||
|
||||
- SOAP:
|
||||
. Fixed bug #70388 (SOAP serialize_function_call() type confusion / RCE).
|
||||
(CVE-2015-6836) (Stas)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #70365 (Use-after-free vulnerability in unserialize() with
|
||||
SplObjectStorage). (CVE-2015-6834) (taoguangchen at icloud dot com)
|
||||
. Fixed bug #70366 (Use-after-free vulnerability in unserialize() with
|
||||
SplDoublyLinkedList). (CVE-2015-6834) (taoguangchen at icloud dot com)
|
||||
|
||||
- XSLT:
|
||||
. Fixed bug #69782 (NULL pointer dereference). (CVE-2015-6837, CVE-2015-6838)
|
||||
(Stas)
|
||||
|
||||
- ZIP:
|
||||
. Fixed bug #70350 (ZipArchive::extractTo allows for directory traversal when
|
||||
creating directories). (CVE-2014-9767) (neal at fb dot com)
|
||||
|
||||
06 Aug 2015, PHP 5.5.28
|
||||
|
||||
- Core:
|
||||
. Fixed bug #69793 (Remotely triggerable stack exhaustion via recursive
|
||||
method calls). (Stas)
|
||||
. Fixed bug #69892 (Different arrays compare indentical due to integer key
|
||||
truncation). (Nikita)
|
||||
. Fixed bug #70002 (TS issues with temporary dir handling). (Anatol)
|
||||
. Fixed bug #70121 (unserialize() could lead to unexpected methods execution
|
||||
/ NULL pointer deref). (Stas)
|
||||
|
||||
- OpenSSL:
|
||||
. Fixed bug #70014 (openssl_random_pseudo_bytes() is not cryptographically
|
||||
secure). (CVE-2015-8867) (Stas)
|
||||
|
||||
- Phar:
|
||||
. Improved fix for bug #69441. (Anatol Belski)
|
||||
. Fixed bug #70019 (Files extracted from archive may be placed outside of
|
||||
destination directory). (CVE-2015-6833) (Anatol Belski)
|
||||
|
||||
- SOAP:
|
||||
. Fixed bug #70081 (SoapClient info leak / null pointer dereference via
|
||||
multiple type confusions). (Stas)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #70068 (Dangling pointer in the unserialization of ArrayObject
|
||||
items). (CVE-2015-6832) (sean.heelan)
|
||||
. Fixed bug #70166 (Use After Free Vulnerability in unserialize() with
|
||||
SPLArrayObject). (CVE-2015-6831) (taoguangchen at icloud dot com)
|
||||
. Fixed bug #70168 (Use After Free Vulnerability in unserialize() with
|
||||
SplObjectStorage). (CVE-2015-6831) (taoguangchen at icloud dot com)
|
||||
. Fixed bug #70169 (Use After Free Vulnerability in unserialize() with
|
||||
SplDoublyLinkedList). (CVE-2015-6831) (taoguangchen at icloud dot com)
|
||||
|
||||
9 Jul 2015, PHP 5.5.27
|
||||
|
||||
- Core:
|
||||
. Fixed bug #69768 (escapeshell*() doesn't cater to !). (cmb)
|
||||
. Fixed bug #69703 (Use __builtin_clzl on PowerPC).
|
||||
(dja at axtens dot net, Kalle)
|
||||
. Fixed bug #69732 (can induce segmentation fault with basic php code).
|
||||
(Dmitry)
|
||||
. Fixed bug #69642 (Windows 10 reported as Windows 8).
|
||||
(Christian Wenz, Anatol Belski)
|
||||
. Fixed bug #69551 (parse_ini_file() and parse_ini_string() segmentation
|
||||
fault). (Christoph M. Becker)
|
||||
. Fixed bug #69781 (phpinfo() reports Professional Editions of Windows
|
||||
7/8/8.1/10 as "Business"). (Christian Wenz)
|
||||
. Fixed bug #69835 (phpinfo() does not report many Windows SKUs).
|
||||
(Christian Wenz)
|
||||
. Fixed bug #69892 (Different arrays compare indentical due to integer key
|
||||
truncation). (Nikita)
|
||||
. Fixed bug #69874 (Can't set empty additional_headers for mail()), regression
|
||||
from fix to bug #68776. (Yasuo)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #61221 (imagegammacorrect function loses alpha channel). (cmb)
|
||||
|
||||
- Mysqlnd:
|
||||
. Fixed bug #69669 (mysqlnd is vulnerable to BACKRONYM) (CVE-2015-3152).
|
||||
(Andrey)
|
||||
|
||||
- PCRE:
|
||||
. Fixed Bug #53823 (preg_replace: * qualifier on unicode replace garbles the
|
||||
string). (cmb)
|
||||
. Fixed bug #69864 (Segfault in preg_replace_callback) (cmb, ab)
|
||||
|
||||
- PDO_pgsql:
|
||||
. Fixed bug #69752 (PDOStatement::execute() leaks memory with DML
|
||||
Statements when closeCuror() is u). (Philip Hofstetter)
|
||||
. Fixed bug #69362 (PDO-pgsql fails to connect if password contains a
|
||||
leading single quote). (Matteo)
|
||||
. Fixed bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps).
|
||||
(Matteo)
|
||||
|
||||
- Phar:
|
||||
. Fixed bug #69958 (Segfault in Phar::convertToData on invalid file).
|
||||
(CVE-2015-5589) (Stas)
|
||||
. Fixed bug #69923 (Buffer overflow and stack smashing error in
|
||||
phar_fix_filepath). (CVE-2015-5590) (Stas)
|
||||
|
||||
- SimpleXML:
|
||||
. Refactored the fix for bug #66084 (simplexml_load_string() mangles empty
|
||||
node name). (Christoph Michael Becker)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #69737 (Segfault when SplMinHeap::compare produces fatal error).
|
||||
(Stas)
|
||||
. Fixed bug #67805 (SplFileObject setMaxLineLength). (Willian Gustavo Veiga).
|
||||
|
||||
11 Jun 2015, PHP 5.5.26
|
||||
|
||||
- Core:
|
||||
@@ -9,13 +295,12 @@ PHP NEWS
|
||||
(Julien)
|
||||
. Fixed bug #69628 (complex GLOB_BRACE fails on Windows).
|
||||
(Christoph M. Becker)
|
||||
. Improved fix for bug #69545 (Integer overflow in ftp_genlist() resulting in
|
||||
heap overflow). (CVE-2015-4643) (Max Spelsberg)
|
||||
. Fixed bug #69646 (OS command injection vulnerability in escapeshellarg).
|
||||
(Anatol Belski)
|
||||
. Fixed bug #69719 (Incorrect handling of paths with NULs). (Stas)
|
||||
|
||||
- FTP:
|
||||
. Improved fix for bug #69545 (Integer overflow in ftp_genlist()
|
||||
resulting in heap overflow). (Max Spelsberg)
|
||||
(CVE-2015-4642) (Anatol Belski)
|
||||
. Fixed bug #69719 (Incorrect handling of paths with NULs). (CVE-2015-4598)
|
||||
(Stas)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #69479 (GD fails to build with newer libvpx). (Remi)
|
||||
@@ -33,10 +318,6 @@ PHP NEWS
|
||||
- MCrypt:
|
||||
. Added file descriptor caching to mcrypt_create_iv() (Leigh)
|
||||
|
||||
- Opcache
|
||||
. Fixed bug #69549 (Memory leak with opcache.optimization_level=0xFFFFFFFF).
|
||||
(Laruence, Dmitry)
|
||||
|
||||
- PCRE:
|
||||
. Upgraded pcrelib to 8.37. (CVE-2015-2325, CVE-2015-2326)
|
||||
|
||||
@@ -45,7 +326,11 @@ PHP NEWS
|
||||
(Matteo Bernardini, Remi)
|
||||
|
||||
- Postgres:
|
||||
. Fixed bug #69667 (segfault in php_pgsql_meta_data). (Remi)
|
||||
. Fixed bug #69667 (segfault in php_pgsql_meta_data). (CVE-2015-4644) (Remi)
|
||||
|
||||
- Opcache
|
||||
. Fixed bug #69549 (Memory leak with opcache.optimization_level=0xFFFFFFFF).
|
||||
(Laruence, Dmitry)
|
||||
|
||||
- Sqlite3:
|
||||
. Upgrade bundled sqlite to 3.8.10.2. (CVE-2015-3414, CVE-2015-3415,
|
||||
@@ -263,7 +548,8 @@ PHP NEWS
|
||||
|
||||
- SOAP:
|
||||
. Fixed bug #69085 (SoapClient's __call() type confusion through
|
||||
unserialize()). (andrea dot palazzo at truel dot it, Laruence)
|
||||
unserialize()). (CVE-2015-4147, CVE-2015-4148)
|
||||
(andrea dot palazzo at truel dot it, Laruence)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #69108 ("Segmentation fault" when (de)serializing
|
||||
|
||||
+6
-6
@@ -12,7 +12,7 @@ Collaboration is a Good Thing(tm), and Git lets us do this. Thus, following
|
||||
some basic rules with regards to Git usage will::
|
||||
|
||||
a. Make everybody happier, especially those responsible for maintaining
|
||||
Git itself.
|
||||
PHP itself.
|
||||
|
||||
b. Keep the changes consistently well documented and easily trackable.
|
||||
|
||||
@@ -48,11 +48,11 @@ Currently we have the following branches in use::
|
||||
PHP-5.6 Is used to release the PHP 5.6.x series. This is a current
|
||||
stable version and is open for bugfixes only.
|
||||
|
||||
PHP-5.5 Is used to release the PHP 5.5.x series. This is a current
|
||||
stable version and is open for bugfixes only.
|
||||
PHP-5.5 Is used to release the PHP 5.5.x series. This is an old
|
||||
stable version and is open for security fixes only.
|
||||
|
||||
PHP-5.4 Is used to release the PHP 5.4.x series. This is a current
|
||||
stable version and is open for bugfixes only.
|
||||
PHP-5.4 Is used to release the PHP 5.4.x series. This is an old
|
||||
stable version and is open for security fixes only.
|
||||
|
||||
PHP-5.3 This branch is closed.
|
||||
|
||||
@@ -67,7 +67,7 @@ Currently we have the following branches in use::
|
||||
|
||||
The next few rules are more of a technical nature::
|
||||
|
||||
1. All changes should first go to the lowest branch (i.e. 5.4) and then
|
||||
1. All changes should first go to the lowest branch (i.e. 5.6) and then
|
||||
get merged up to all other branches. If a change is not needed for
|
||||
later branches (i.e. fixes for features which where dropped from later
|
||||
branches) an empty merge should be done.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Bug #69551 - parse_ini_file() and parse_ini_string() segmentation fault
|
||||
--FILE--
|
||||
<?php
|
||||
$ini = <<<INI
|
||||
[Network.eth0]
|
||||
SubnetMask = "
|
||||
"
|
||||
INI;
|
||||
$settings = parse_ini_string($ini, false, INI_SCANNER_RAW);
|
||||
var_dump($settings);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: syntax error, unexpected '"' in Unknown on line %d
|
||||
in %s on line %d
|
||||
bool(false)
|
||||
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Bug #69732 (can induce segmentation fault with basic php code)
|
||||
--FILE--
|
||||
<?php
|
||||
class wpq {
|
||||
private $unreferenced;
|
||||
|
||||
public function __get($name) {
|
||||
return $this->$name . "XXX";
|
||||
}
|
||||
}
|
||||
|
||||
function ret_assoc() {
|
||||
$x = "XXX";
|
||||
return array('foo' => 'bar', $x);
|
||||
}
|
||||
|
||||
$wpq = new wpq;
|
||||
$wpq->interesting =& ret_assoc();
|
||||
$x = $wpq->interesting;
|
||||
printf("%s\n", $x);
|
||||
--EXPECTF--
|
||||
Notice: Undefined property: wpq::$interesting in %sbug69732.php on line 6
|
||||
|
||||
Notice: Indirect modification of overloaded property wpq::$interesting has no effect in %sbug69732.php on line 16
|
||||
|
||||
Strict Standards: Only variables should be assigned by reference in %sbug69732.php on line 16
|
||||
|
||||
Notice: Undefined property: wpq::$interesting in %sbug69732.php on line 6
|
||||
XXX
|
||||
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Bug #69892: Different arrays compare indentical due to integer key truncation
|
||||
--SKIPIF--
|
||||
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump([0 => 0] === [0x100000000 => 0]);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
Bug #70121 (unserialize() could lead to unexpected methods execution / NULL pointer deref)
|
||||
--FILE--
|
||||
<?php
|
||||
unserialize('O:12:"DateInterval":1:{s:4:"days";O:9:"Exception":7:{s:10:"'."\0".'*'."\0".'message";s:1:"x";s:17:"'."\0".'Exception'."\0".'string";s:1:"A";s:7:"'."\0".'*'."\0".'code";i:0;s:7:"'."\0".'*'."\0".'file";s:1:"a";s:7:"'."\0".'*'."\0".'line";i:1337;s:16:"'."\0".'Exception'."\0".'trace";a:0:{}s:19:"'."\0".'Exception'."\0".'previous";O:8:"stdClass":0:{}}}');
|
||||
?>
|
||||
OK
|
||||
--EXPECT--
|
||||
OK
|
||||
@@ -13,5 +13,5 @@ var_dump(gc_collect_cycles());
|
||||
echo "ok\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
||||
int(2)
|
||||
ok
|
||||
+2
-2
@@ -678,7 +678,7 @@ static inline unsigned int zend_mm_high_bit(size_t _size)
|
||||
__asm {
|
||||
bsr eax, _size
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
|
||||
#elif defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__) || defined(__powerpc__))
|
||||
return (8 * SIZEOF_SIZE_T - 1) - __builtin_clzl(_size);
|
||||
#else
|
||||
unsigned int n = 0;
|
||||
@@ -706,7 +706,7 @@ static inline unsigned int zend_mm_low_bit(size_t _size)
|
||||
__asm {
|
||||
bsf eax, _size
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
|
||||
#elif defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__) || defined(__powerpc__))
|
||||
return __builtin_ctzl(_size);
|
||||
#else
|
||||
static const int offset[16] = {4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
|
||||
|
||||
+37
-8
@@ -41,7 +41,7 @@ void zend_exception_set_previous(zval *exception, zval *add_previous TSRMLS_DC)
|
||||
if (exception == add_previous || !add_previous || !exception) {
|
||||
return;
|
||||
}
|
||||
if (Z_TYPE_P(add_previous) != IS_OBJECT && !instanceof_function(Z_OBJCE_P(add_previous), default_exception_ce TSRMLS_CC)) {
|
||||
if (Z_TYPE_P(add_previous) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(add_previous), default_exception_ce TSRMLS_CC)) {
|
||||
zend_error(E_ERROR, "Cannot set non exception as previous exception");
|
||||
return;
|
||||
}
|
||||
@@ -218,6 +218,33 @@ ZEND_METHOD(exception, __construct)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto Exception::__wakeup()
|
||||
Exception unserialize checks */
|
||||
#define CHECK_EXC_TYPE(name, type) \
|
||||
value = zend_read_property(default_exception_ce, object, name, sizeof(name)-1, 0 TSRMLS_CC); \
|
||||
if(value && Z_TYPE_P(value) != type) { \
|
||||
zval *tmp; \
|
||||
MAKE_STD_ZVAL(tmp); \
|
||||
ZVAL_STRINGL(tmp, name, sizeof(name)-1, 1); \
|
||||
Z_OBJ_HANDLER_P(object, unset_property)(object, tmp, 0 TSRMLS_CC); \
|
||||
zval_ptr_dtor(&tmp); \
|
||||
}
|
||||
|
||||
ZEND_METHOD(exception, __wakeup)
|
||||
{
|
||||
zval *value;
|
||||
zval *object = getThis();
|
||||
HashTable *intern_ht = zend_std_get_properties(getThis() TSRMLS_CC);
|
||||
CHECK_EXC_TYPE("message", IS_STRING);
|
||||
CHECK_EXC_TYPE("string", IS_STRING);
|
||||
CHECK_EXC_TYPE("code", IS_LONG);
|
||||
CHECK_EXC_TYPE("file", IS_STRING);
|
||||
CHECK_EXC_TYPE("line", IS_LONG);
|
||||
CHECK_EXC_TYPE("trace", IS_ARRAY);
|
||||
CHECK_EXC_TYPE("previous", IS_OBJECT);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto ErrorException::__construct(string message, int code, int severity [, string filename [, int lineno [, Exception previous]]])
|
||||
ErrorException constructor */
|
||||
ZEND_METHOD(error_exception, __construct)
|
||||
@@ -586,7 +613,7 @@ ZEND_METHOD(exception, getTraceAsString)
|
||||
int res_len = 0, *len = &res_len, num = 0;
|
||||
|
||||
DEFAULT_0_PARAMS;
|
||||
|
||||
|
||||
trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
|
||||
if (Z_TYPE_P(trace) != IS_ARRAY) {
|
||||
RETURN_FALSE;
|
||||
@@ -602,8 +629,8 @@ ZEND_METHOD(exception, getTraceAsString)
|
||||
TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
|
||||
efree(s_tmp);
|
||||
|
||||
res[res_len] = '\0';
|
||||
RETURN_STRINGL(res, res_len, 0);
|
||||
res[res_len] = '\0';
|
||||
RETURN_STRINGL(res, res_len, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -640,15 +667,15 @@ ZEND_METHOD(exception, __toString)
|
||||
int len = 0;
|
||||
zend_fcall_info fci;
|
||||
zval fname;
|
||||
|
||||
|
||||
DEFAULT_0_PARAMS;
|
||||
|
||||
|
||||
str = estrndup("", 0);
|
||||
|
||||
exception = getThis();
|
||||
ZVAL_STRINGL(&fname, "gettraceasstring", sizeof("gettraceasstring")-1, 1);
|
||||
|
||||
while (exception && Z_TYPE_P(exception) == IS_OBJECT) {
|
||||
while (exception && Z_TYPE_P(exception) == IS_OBJECT && instanceof_function(Z_OBJCE_P(exception), default_exception_ce TSRMLS_CC)) {
|
||||
prev_str = str;
|
||||
_default_exception_get_entry(exception, "message", sizeof("message")-1, &message TSRMLS_CC);
|
||||
_default_exception_get_entry(exception, "file", sizeof("file")-1, &file TSRMLS_CC);
|
||||
@@ -658,6 +685,7 @@ ZEND_METHOD(exception, __toString)
|
||||
convert_to_string(&file);
|
||||
convert_to_long(&line);
|
||||
|
||||
trace = NULL;
|
||||
fci.size = sizeof(fci);
|
||||
fci.function_table = &Z_OBJCE_P(exception)->function_table;
|
||||
fci.function_name = &fname;
|
||||
@@ -670,7 +698,7 @@ ZEND_METHOD(exception, __toString)
|
||||
|
||||
zend_call_function(&fci, NULL TSRMLS_CC);
|
||||
|
||||
if (Z_TYPE_P(trace) != IS_STRING) {
|
||||
if (trace && Z_TYPE_P(trace) != IS_STRING) {
|
||||
zval_ptr_dtor(&trace);
|
||||
trace = NULL;
|
||||
}
|
||||
@@ -727,6 +755,7 @@ ZEND_END_ARG_INFO()
|
||||
const static zend_function_entry default_exception_functions[] = {
|
||||
ZEND_ME(exception, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
|
||||
ZEND_ME(exception, __construct, arginfo_exception___construct, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(exception, __wakeup, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(exception, getMessage, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
||||
ZEND_ME(exception, getCode, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
||||
ZEND_ME(exception, getFile, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
||||
|
||||
+2
-3
@@ -1534,11 +1534,10 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
|
||||
}
|
||||
if (ordered) {
|
||||
if (p1->nKeyLength==0 && p2->nKeyLength==0) { /* numeric indices */
|
||||
result = p1->h - p2->h;
|
||||
if (result!=0) {
|
||||
if (p1->h != p2->h) {
|
||||
HASH_UNPROTECT_RECURSION(ht1);
|
||||
HASH_UNPROTECT_RECURSION(ht2);
|
||||
return result;
|
||||
return p1->h > p2->h ? 1 : -1;
|
||||
}
|
||||
} else { /* string indices */
|
||||
result = p1->nKeyLength - p2->nKeyLength;
|
||||
|
||||
@@ -1926,7 +1926,7 @@ end_raw_value_chars:
|
||||
}
|
||||
|
||||
/* Eat leading and trailing double quotes */
|
||||
if (yytext[0] == '"' && yytext[yyleng - 1] == '"') {
|
||||
if (yyleng > 1 && yytext[0] == '"' && yytext[yyleng - 1] == '"') {
|
||||
SCNG(yy_text)++;
|
||||
yyleng = yyleng - 2;
|
||||
} else if (sc) {
|
||||
|
||||
@@ -472,7 +472,7 @@ end_raw_value_chars:
|
||||
}
|
||||
|
||||
/* Eat leading and trailing double quotes */
|
||||
if (yytext[0] == '"' && yytext[yyleng - 1] == '"') {
|
||||
if (yyleng > 1 && yytext[0] == '"' && yytext[yyleng - 1] == '"') {
|
||||
SCNG(yy_text)++;
|
||||
yyleng = yyleng - 2;
|
||||
} else if (sc) {
|
||||
|
||||
@@ -1254,6 +1254,10 @@ ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2)
|
||||
int length = Z_STRLEN_P(op1) + 1;
|
||||
char *buf;
|
||||
|
||||
if (UNEXPECTED(length < 0)) {
|
||||
zend_error(E_ERROR, "String size overflow");
|
||||
}
|
||||
|
||||
if (IS_INTERNED(Z_STRVAL_P(op1))) {
|
||||
buf = (char *) emalloc(length + 1);
|
||||
memcpy(buf, Z_STRVAL_P(op1), Z_STRLEN_P(op1));
|
||||
@@ -1273,6 +1277,9 @@ ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2
|
||||
int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);
|
||||
char *buf;
|
||||
|
||||
if (UNEXPECTED(length < 0)) {
|
||||
zend_error(E_ERROR, "String size overflow");
|
||||
}
|
||||
if (IS_INTERNED(Z_STRVAL_P(op1))) {
|
||||
buf = (char *) emalloc(length+1);
|
||||
memcpy(buf, Z_STRVAL_P(op1), Z_STRLEN_P(op1));
|
||||
|
||||
+3
-1
@@ -1762,7 +1762,9 @@ ZEND_VM_HANDLER(38, ZEND_ASSIGN, VAR|CV, CONST|TMP|VAR|CV)
|
||||
}
|
||||
}
|
||||
|
||||
FREE_OP1_VAR_PTR();
|
||||
if (OP1_TYPE == IS_VAR && OP1_FREE) {
|
||||
zval_ptr_dtor(&value);
|
||||
}
|
||||
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
FREE_OP2_IF_VAR();
|
||||
|
||||
+28
-4
@@ -15307,7 +15307,9 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER
|
||||
}
|
||||
}
|
||||
|
||||
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
|
||||
if (IS_VAR == IS_VAR && (free_op1.var != NULL)) {
|
||||
zval_ptr_dtor(&value);
|
||||
}
|
||||
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
|
||||
@@ -17662,7 +17664,9 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A
|
||||
}
|
||||
}
|
||||
|
||||
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
|
||||
if (IS_VAR == IS_VAR && (free_op1.var != NULL)) {
|
||||
zval_ptr_dtor(&value);
|
||||
}
|
||||
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
|
||||
@@ -19923,7 +19927,9 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A
|
||||
}
|
||||
}
|
||||
|
||||
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
|
||||
if (IS_VAR == IS_VAR && (free_op1.var != NULL)) {
|
||||
zval_ptr_dtor(&value);
|
||||
}
|
||||
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
if (free_op2.var) {zval_ptr_dtor(&free_op2.var);};
|
||||
@@ -23395,7 +23401,9 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR
|
||||
}
|
||||
}
|
||||
|
||||
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
|
||||
if (IS_VAR == IS_VAR && (free_op1.var != NULL)) {
|
||||
zval_ptr_dtor(&value);
|
||||
}
|
||||
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
|
||||
@@ -32828,6 +32836,10 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_CV == IS_VAR && 0) {
|
||||
zval_ptr_dtor(&value);
|
||||
}
|
||||
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
|
||||
CHECK_EXCEPTION();
|
||||
@@ -34948,6 +34960,10 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_CV == IS_VAR && 0) {
|
||||
zval_ptr_dtor(&value);
|
||||
}
|
||||
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
|
||||
CHECK_EXCEPTION();
|
||||
@@ -37071,6 +37087,10 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_CV == IS_VAR && 0) {
|
||||
zval_ptr_dtor(&value);
|
||||
}
|
||||
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
if (free_op2.var) {zval_ptr_dtor(&free_op2.var);};
|
||||
|
||||
@@ -40256,6 +40276,10 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_CV == IS_VAR && 0) {
|
||||
zval_ptr_dtor(&value);
|
||||
}
|
||||
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||
|
||||
PHP_MAJOR_VERSION=5
|
||||
PHP_MINOR_VERSION=5
|
||||
PHP_RELEASE_VERSION=26
|
||||
PHP_RELEASE_VERSION=37
|
||||
PHP_EXTRA_VERSION=""
|
||||
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
|
||||
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
|
||||
|
||||
+41
-19
@@ -201,6 +201,21 @@ static void php_str2num(bc_num *num, char *str TSRMLS_DC)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ split_bc_num
|
||||
Convert to bc_num detecting scale */
|
||||
static bc_num split_bc_num(bc_num num) {
|
||||
bc_num newnum;
|
||||
if (num->n_refs >= 1) {
|
||||
return num;
|
||||
}
|
||||
newnum = _bc_new_num_ex(0, 0, 0);
|
||||
*newnum = *num;
|
||||
newnum->n_refs = 1;
|
||||
num->n_refs--;
|
||||
return newnum;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bcadd(string left_operand, string right_operand [, int scale])
|
||||
Returns the sum of two arbitrary precision numbers */
|
||||
PHP_FUNCTION(bcadd)
|
||||
@@ -214,7 +229,7 @@ PHP_FUNCTION(bcadd)
|
||||
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 3) {
|
||||
scale = (int) ((int)scale_param < 0) ? 0 : scale_param;
|
||||
}
|
||||
@@ -225,11 +240,12 @@ PHP_FUNCTION(bcadd)
|
||||
php_str2num(&first, left TSRMLS_CC);
|
||||
php_str2num(&second, right TSRMLS_CC);
|
||||
bc_add (first, second, &result, scale);
|
||||
|
||||
|
||||
if (result->n_scale > scale) {
|
||||
result = split_bc_num(result);
|
||||
result->n_scale = scale;
|
||||
}
|
||||
|
||||
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
@@ -253,7 +269,7 @@ PHP_FUNCTION(bcsub)
|
||||
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 3) {
|
||||
scale = (int) ((int)scale_param < 0) ? 0 : scale_param;
|
||||
}
|
||||
@@ -266,6 +282,7 @@ PHP_FUNCTION(bcsub)
|
||||
bc_sub (first, second, &result, scale);
|
||||
|
||||
if (result->n_scale > scale) {
|
||||
result = split_bc_num(result);
|
||||
result->n_scale = scale;
|
||||
}
|
||||
|
||||
@@ -292,11 +309,11 @@ PHP_FUNCTION(bcmul)
|
||||
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 3) {
|
||||
scale = (int) ((int)scale_param < 0) ? 0 : scale_param;
|
||||
}
|
||||
|
||||
|
||||
bc_init_num(&first TSRMLS_CC);
|
||||
bc_init_num(&second TSRMLS_CC);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
@@ -305,6 +322,7 @@ PHP_FUNCTION(bcmul)
|
||||
bc_multiply (first, second, &result, scale TSRMLS_CC);
|
||||
|
||||
if (result->n_scale > scale) {
|
||||
result = split_bc_num(result);
|
||||
result->n_scale = scale;
|
||||
}
|
||||
|
||||
@@ -331,11 +349,11 @@ PHP_FUNCTION(bcdiv)
|
||||
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 3) {
|
||||
scale = (int) ((int)scale_param < 0) ? 0 : scale_param;
|
||||
}
|
||||
|
||||
|
||||
bc_init_num(&first TSRMLS_CC);
|
||||
bc_init_num(&second TSRMLS_CC);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
@@ -345,6 +363,7 @@ PHP_FUNCTION(bcdiv)
|
||||
switch (bc_divide(first, second, &result, scale TSRMLS_CC)) {
|
||||
case 0: /* OK */
|
||||
if (result->n_scale > scale) {
|
||||
result = split_bc_num(result);
|
||||
result->n_scale = scale;
|
||||
}
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
@@ -374,13 +393,13 @@ PHP_FUNCTION(bcmod)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &left, &left_len, &right, &right_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bc_init_num(&first TSRMLS_CC);
|
||||
bc_init_num(&second TSRMLS_CC);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
bc_str2num(&first, left, 0 TSRMLS_CC);
|
||||
bc_str2num(&second, right, 0 TSRMLS_CC);
|
||||
|
||||
|
||||
switch (bc_modulo(first, second, &result, 0 TSRMLS_CC)) {
|
||||
case 0:
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
@@ -391,7 +410,7 @@ PHP_FUNCTION(bcmod)
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
bc_free_num(&first);
|
||||
bc_free_num(&second);
|
||||
bc_free_num(&result);
|
||||
@@ -424,8 +443,9 @@ PHP_FUNCTION(bcpowmod)
|
||||
scale_int = (int) ((int)scale < 0) ? 0 : scale;
|
||||
|
||||
if (bc_raisemod(first, second, mod, &result, scale_int TSRMLS_CC) != -1) {
|
||||
if (result->n_scale > scale) {
|
||||
result->n_scale = scale;
|
||||
if (result->n_scale > scale_int) {
|
||||
result = split_bc_num(result);
|
||||
result->n_scale = scale_int;
|
||||
}
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
@@ -433,7 +453,7 @@ PHP_FUNCTION(bcpowmod)
|
||||
} else {
|
||||
RETVAL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
bc_free_num(&first);
|
||||
bc_free_num(&second);
|
||||
bc_free_num(&mod);
|
||||
@@ -455,7 +475,7 @@ PHP_FUNCTION(bcpow)
|
||||
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 3) {
|
||||
scale = (int) ((int)scale_param < 0) ? 0 : scale_param;
|
||||
}
|
||||
@@ -468,6 +488,7 @@ PHP_FUNCTION(bcpow)
|
||||
bc_raise (first, second, &result, scale TSRMLS_CC);
|
||||
|
||||
if (result->n_scale > scale) {
|
||||
result = split_bc_num(result);
|
||||
result->n_scale = scale;
|
||||
}
|
||||
|
||||
@@ -494,16 +515,17 @@ PHP_FUNCTION(bcsqrt)
|
||||
if (zend_parse_parameters(argc TSRMLS_CC, "s|l", &left, &left_len, &scale_param) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 2) {
|
||||
scale = (int) ((int)scale_param < 0) ? 0 : scale_param;
|
||||
}
|
||||
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
php_str2num(&result, left TSRMLS_CC);
|
||||
|
||||
|
||||
if (bc_sqrt (&result, scale TSRMLS_CC) != 0) {
|
||||
if (result->n_scale > scale) {
|
||||
result = split_bc_num(result);
|
||||
result->n_scale = scale;
|
||||
}
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
@@ -531,7 +553,7 @@ PHP_FUNCTION(bccomp)
|
||||
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 3) {
|
||||
scale = (int) ((int)scale_param < 0) ? 0 : scale_param;
|
||||
}
|
||||
@@ -555,7 +577,7 @@ PHP_FUNCTION(bccomp)
|
||||
PHP_FUNCTION(bcscale)
|
||||
{
|
||||
long new_scale;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_scale) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
--TEST--
|
||||
Bug 72093: bcpowmod accepts negative scale and corrupts _one_ definition
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(bcpowmod(1, "A", 128, -200));
|
||||
var_dump(bcpowmod(1, 1.2, 1, 1));
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(1) "1"
|
||||
bc math warning: non-zero scale in exponent
|
||||
string(3) "0.0"
|
||||
+785
-748
File diff suppressed because it is too large.
Load diff
+72
-62
@@ -593,7 +593,7 @@ static zend_object_handlers date_object_handlers_period;
|
||||
#define DATE_SET_CONTEXT \
|
||||
zval *object; \
|
||||
object = getThis(); \
|
||||
|
||||
|
||||
#define DATE_FETCH_OBJECT \
|
||||
php_date_obj *obj; \
|
||||
DATE_SET_CONTEXT; \
|
||||
@@ -762,7 +762,7 @@ PHP_RSHUTDOWN_FUNCTION(date)
|
||||
* RFC2822, Section 3.3: http://www.ietf.org/rfc/rfc2822.txt
|
||||
* FWS = ([*WSP CRLF] 1*WSP) / ; Folding white space
|
||||
* CFWS = *([FWS] comment) (([FWS] comment) / FWS)
|
||||
*
|
||||
*
|
||||
* date-time = [ day-of-week "," ] date FWS time [CFWS]
|
||||
* day-of-week = ([FWS] day-name)
|
||||
* day-name = "Mon" / "Tue" / "Wed" / "Thu" / "Fri" / "Sat" / "Sun"
|
||||
@@ -784,19 +784,19 @@ PHP_RSHUTDOWN_FUNCTION(date)
|
||||
* date-fullyear = 4DIGIT
|
||||
* date-month = 2DIGIT ; 01-12
|
||||
* date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on month/year
|
||||
*
|
||||
*
|
||||
* time-hour = 2DIGIT ; 00-23
|
||||
* time-minute = 2DIGIT ; 00-59
|
||||
* time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second rules
|
||||
*
|
||||
*
|
||||
* time-secfrac = "." 1*DIGIT
|
||||
* time-numoffset = ("+" / "-") time-hour ":" time-minute
|
||||
* time-offset = "Z" / time-numoffset
|
||||
*
|
||||
*
|
||||
* partial-time = time-hour ":" time-minute ":" time-second [time-secfrac]
|
||||
* full-date = date-fullyear "-" date-month "-" date-mday
|
||||
* full-time = partial-time time-offset
|
||||
*
|
||||
*
|
||||
* date-time = full-date "T" full-time
|
||||
*/
|
||||
#define DATE_FORMAT_RFC3339 "Y-m-d\\TH:i:sP"
|
||||
@@ -877,6 +877,10 @@ PHP_MSHUTDOWN_FUNCTION(date)
|
||||
timelib_error_container_dtor(DATEG(last_errors));
|
||||
}
|
||||
|
||||
#ifndef ZTS
|
||||
DATEG(default_timezone) = NULL;
|
||||
#endif
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -885,7 +889,7 @@ PHP_MSHUTDOWN_FUNCTION(date)
|
||||
PHP_MINFO_FUNCTION(date)
|
||||
{
|
||||
const timelib_tzdb *tzdb = DATE_TIMEZONEDB;
|
||||
|
||||
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "date/time support", "enabled");
|
||||
php_info_print_table_row(2, "\"Olson\" Timezone Database Version", tzdb->version);
|
||||
@@ -1037,8 +1041,8 @@ char *php_date_full_day_name(timelib_sll y, timelib_sll m, timelib_sll d)
|
||||
timelib_sll day_of_week = timelib_day_of_week(y, m, d);
|
||||
if (day_of_week < 0) {
|
||||
return "Unknown";
|
||||
}
|
||||
return day_full_names[day_of_week];
|
||||
}
|
||||
return day_full_names[day_of_week];
|
||||
}
|
||||
|
||||
char *php_date_short_day_name(timelib_sll y, timelib_sll m, timelib_sll d)
|
||||
@@ -1046,8 +1050,8 @@ char *php_date_short_day_name(timelib_sll y, timelib_sll m, timelib_sll d)
|
||||
timelib_sll day_of_week = timelib_day_of_week(y, m, d);
|
||||
if (day_of_week < 0) {
|
||||
return "Unknown";
|
||||
}
|
||||
return day_short_names[day_of_week];
|
||||
}
|
||||
return day_short_names[day_of_week];
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -1079,7 +1083,7 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca
|
||||
offset->leap_secs = 0;
|
||||
offset->is_dst = 0;
|
||||
offset->abbr = malloc(9); /* GMT�xxxx\0 */
|
||||
snprintf(offset->abbr, 9, "GMT%c%02d%02d",
|
||||
snprintf(offset->abbr, 9, "GMT%c%02d%02d",
|
||||
localtime ? ((offset->offset < 0) ? '-' : '+') : '+',
|
||||
localtime ? abs(offset->offset / 3600) : 0,
|
||||
localtime ? abs((offset->offset % 3600) / 60) : 0 );
|
||||
@@ -1125,7 +1129,7 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca
|
||||
case 'a': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "pm" : "am"); break;
|
||||
case 'A': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "PM" : "AM"); break;
|
||||
case 'B': {
|
||||
int retval = (((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10) / 864);
|
||||
int retval = (((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10) / 864);
|
||||
while (retval < 0) {
|
||||
retval += 1000;
|
||||
}
|
||||
@@ -1225,7 +1229,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime)
|
||||
}
|
||||
|
||||
string = php_format_date(format, format_len, ts, localtime TSRMLS_CC);
|
||||
|
||||
|
||||
RETVAL_STRING(string, 0);
|
||||
}
|
||||
/* }}} */
|
||||
@@ -1249,7 +1253,7 @@ PHPAPI char *php_format_date(char *format, int format_len, time_t ts, int localt
|
||||
}
|
||||
|
||||
string = date_format(format, format_len, t, localtime);
|
||||
|
||||
|
||||
timelib_time_dtor(t);
|
||||
return string;
|
||||
}
|
||||
@@ -1290,7 +1294,7 @@ PHPAPI int php_idate(char format, time_t ts, int localtime TSRMLS_DC)
|
||||
offset->leap_secs = 0;
|
||||
offset->is_dst = t->dst;
|
||||
offset->abbr = malloc(9); /* GMT�xxxx\0 */
|
||||
snprintf(offset->abbr, 9, "GMT%c%02d%02d",
|
||||
snprintf(offset->abbr, 9, "GMT%c%02d%02d",
|
||||
!localtime ? ((offset->offset < 0) ? '-' : '+') : '+',
|
||||
!localtime ? abs(offset->offset / 3600) : 0,
|
||||
!localtime ? abs((offset->offset % 3600) / 60) : 0 );
|
||||
@@ -1322,7 +1326,7 @@ PHPAPI int php_idate(char format, time_t ts, int localtime TSRMLS_DC)
|
||||
|
||||
/* Swatch Beat a.k.a. Internet Time */
|
||||
case 'B':
|
||||
retval = (((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10) / 864);
|
||||
retval = (((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10) / 864);
|
||||
while (retval < 0) {
|
||||
retval += 1000;
|
||||
}
|
||||
@@ -1374,7 +1378,7 @@ PHP_FUNCTION(idate)
|
||||
char *format;
|
||||
int format_len;
|
||||
long ts = 0;
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &ts) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
@@ -1402,7 +1406,7 @@ PHP_FUNCTION(idate)
|
||||
PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb)
|
||||
{
|
||||
const timelib_tzdb *builtin = timelib_builtin_db();
|
||||
|
||||
|
||||
if (php_version_compare(tzdb->version, builtin->version) > 0) {
|
||||
php_date_global_timezone_db = tzdb;
|
||||
php_date_global_timezone_db_enabled = 1;
|
||||
@@ -1473,7 +1477,7 @@ PHP_FUNCTION(strtotime)
|
||||
}
|
||||
|
||||
if (!time_len) {
|
||||
timelib_time_dtor(now);
|
||||
timelib_time_dtor(now);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -1922,7 +1926,7 @@ static void date_period_it_current_data(zend_object_iterator *iter, zval ***data
|
||||
if (it_time->tz_info) {
|
||||
newdateobj->time->tz_info = it_time->tz_info;
|
||||
}
|
||||
|
||||
|
||||
*data = &iterator->current;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -2116,13 +2120,13 @@ static inline zend_object_value date_object_new_date_ex(zend_class_entry *class_
|
||||
if (ptr) {
|
||||
*ptr = intern;
|
||||
}
|
||||
|
||||
|
||||
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
|
||||
object_properties_init(&intern->std, class_type);
|
||||
|
||||
|
||||
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_date, NULL TSRMLS_CC);
|
||||
retval.handlers = &date_object_handlers_date;
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -2136,12 +2140,12 @@ static zend_object_value date_object_clone_date(zval *this_ptr TSRMLS_DC)
|
||||
php_date_obj *new_obj = NULL;
|
||||
php_date_obj *old_obj = (php_date_obj *) zend_object_store_get_object(this_ptr TSRMLS_CC);
|
||||
zend_object_value new_ov = date_object_new_date_ex(old_obj->std.ce, &new_obj TSRMLS_CC);
|
||||
|
||||
|
||||
zend_objects_clone_members(&new_obj->std, new_ov, &old_obj->std, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
|
||||
if (!old_obj->time) {
|
||||
return new_ov;
|
||||
}
|
||||
|
||||
|
||||
/* this should probably moved to a new `timelib_time *timelime_time_clone(timelib_time *)` */
|
||||
new_obj->time = timelib_time_ctor();
|
||||
*new_obj->time = *old_obj->time;
|
||||
@@ -2151,7 +2155,7 @@ static zend_object_value date_object_clone_date(zval *this_ptr TSRMLS_DC)
|
||||
if (old_obj->time->tz_info) {
|
||||
new_obj->time->tz_info = old_obj->time->tz_info;
|
||||
}
|
||||
|
||||
|
||||
return new_ov;
|
||||
}
|
||||
|
||||
@@ -2268,10 +2272,10 @@ static inline zend_object_value date_object_new_timezone_ex(zend_class_entry *cl
|
||||
|
||||
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
|
||||
object_properties_init(&intern->std, class_type);
|
||||
|
||||
|
||||
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_timezone, NULL TSRMLS_CC);
|
||||
retval.handlers = &date_object_handlers_timezone;
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -2285,12 +2289,12 @@ static zend_object_value date_object_clone_timezone(zval *this_ptr TSRMLS_DC)
|
||||
php_timezone_obj *new_obj = NULL;
|
||||
php_timezone_obj *old_obj = (php_timezone_obj *) zend_object_store_get_object(this_ptr TSRMLS_CC);
|
||||
zend_object_value new_ov = date_object_new_timezone_ex(old_obj->std.ce, &new_obj TSRMLS_CC);
|
||||
|
||||
|
||||
zend_objects_clone_members(&new_obj->std, new_ov, &old_obj->std, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
|
||||
if (!old_obj->initialized) {
|
||||
return new_ov;
|
||||
}
|
||||
|
||||
|
||||
new_obj->type = old_obj->type;
|
||||
new_obj->initialized = 1;
|
||||
switch (new_obj->type) {
|
||||
@@ -2306,7 +2310,7 @@ static zend_object_value date_object_clone_timezone(zval *this_ptr TSRMLS_DC)
|
||||
new_obj->tzi.z.abbr = strdup(old_obj->tzi.z.abbr);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return new_ov;
|
||||
}
|
||||
|
||||
@@ -2367,10 +2371,10 @@ static inline zend_object_value date_object_new_interval_ex(zend_class_entry *cl
|
||||
|
||||
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
|
||||
object_properties_init(&intern->std, class_type);
|
||||
|
||||
|
||||
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_interval, NULL TSRMLS_CC);
|
||||
retval.handlers = &date_object_handlers_interval;
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -2384,7 +2388,7 @@ static zend_object_value date_object_clone_interval(zval *this_ptr TSRMLS_DC)
|
||||
php_interval_obj *new_obj = NULL;
|
||||
php_interval_obj *old_obj = (php_interval_obj *) zend_object_store_get_object(this_ptr TSRMLS_CC);
|
||||
zend_object_value new_ov = date_object_new_interval_ex(old_obj->std.ce, &new_obj TSRMLS_CC);
|
||||
|
||||
|
||||
zend_objects_clone_members(&new_obj->std, new_ov, &old_obj->std, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
|
||||
|
||||
/** FIX ME ADD CLONE STUFF **/
|
||||
@@ -2456,10 +2460,10 @@ static inline zend_object_value date_object_new_period_ex(zend_class_entry *clas
|
||||
|
||||
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
|
||||
object_properties_init(&intern->std, class_type);
|
||||
|
||||
|
||||
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_period, NULL TSRMLS_CC);
|
||||
retval.handlers = &date_object_handlers_period;
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -2473,7 +2477,7 @@ static zend_object_value date_object_clone_period(zval *this_ptr TSRMLS_DC)
|
||||
php_period_obj *new_obj = NULL;
|
||||
php_period_obj *old_obj = (php_period_obj *) zend_object_store_get_object(this_ptr TSRMLS_CC);
|
||||
zend_object_value new_ov = date_object_new_period_ex(old_obj->std.ce, &new_obj TSRMLS_CC);
|
||||
|
||||
|
||||
zend_objects_clone_members(&new_obj->std, new_ov, &old_obj->std, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
|
||||
|
||||
/** FIX ME ADD CLONE STUFF **/
|
||||
@@ -2559,7 +2563,7 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
|
||||
int type = TIMELIB_ZONETYPE_ID, new_dst = 0;
|
||||
char *new_abbr = NULL;
|
||||
timelib_sll new_offset;
|
||||
|
||||
|
||||
if (dateobj->time) {
|
||||
timelib_time_dtor(dateobj->time);
|
||||
}
|
||||
@@ -2938,7 +2942,7 @@ void php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAMETERS, timelib_time *
|
||||
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(hour, h);
|
||||
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(minute, i);
|
||||
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(second, s);
|
||||
|
||||
|
||||
if (parsed_time->f == -99999) {
|
||||
add_assoc_bool(return_value, "fraction", 0);
|
||||
} else {
|
||||
@@ -3005,7 +3009,7 @@ PHP_FUNCTION(date_parse)
|
||||
int date_len;
|
||||
struct timelib_error_container *error;
|
||||
timelib_time *parsed_time;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &date, &date_len) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -3024,7 +3028,7 @@ PHP_FUNCTION(date_parse_from_format)
|
||||
int date_len, format_len;
|
||||
struct timelib_error_container *error;
|
||||
timelib_time *parsed_time;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &format, &format_len, &date, &date_len) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -3508,7 +3512,7 @@ static void php_date_isodate_set(zval *object, long y, long w, long d, zval *ret
|
||||
memset(&dateobj->time->relative, 0, sizeof(dateobj->time->relative));
|
||||
dateobj->time->relative.d = timelib_daynr_from_weeknr(y, w, d);
|
||||
dateobj->time->have_relative = 1;
|
||||
|
||||
|
||||
timelib_update_ts(dateobj->time, NULL);
|
||||
}
|
||||
|
||||
@@ -3697,7 +3701,7 @@ PHP_METHOD(DateTimeZone, __construct)
|
||||
int tz_len;
|
||||
php_timezone_obj *tzobj;
|
||||
zend_error_handling error_handling;
|
||||
|
||||
|
||||
zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
|
||||
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &tz, &tz_len)) {
|
||||
tzobj = zend_object_store_get_object(getThis() TSRMLS_CC);
|
||||
@@ -3975,7 +3979,7 @@ static int date_interval_initialize(timelib_rel_time **rt, /*const*/ char *forma
|
||||
struct timelib_error_container *errors;
|
||||
|
||||
timelib_strtointerval(format, format_length, &b, &e, &p, &r, &errors);
|
||||
|
||||
|
||||
if (errors->error_count > 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown or bad format (%s)", format);
|
||||
retval = FAILURE;
|
||||
@@ -4134,7 +4138,7 @@ PHP_METHOD(DateInterval, __construct)
|
||||
php_interval_obj *diobj;
|
||||
timelib_rel_time *reltime;
|
||||
zend_error_handling error_handling;
|
||||
|
||||
|
||||
zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &interval_string, &interval_string_length) == SUCCESS) {
|
||||
if (date_interval_initialize(&reltime, interval_string, interval_string_length TSRMLS_CC) == SUCCESS) {
|
||||
@@ -4157,8 +4161,7 @@ static int php_date_interval_initialize_from_hash(zval **return_value, php_inter
|
||||
#define PHP_DATE_INTERVAL_READ_PROPERTY(element, member, itype, def) \
|
||||
do { \
|
||||
zval **z_arg = NULL; \
|
||||
if (zend_hash_find(myht, element, strlen(element) + 1, (void**) &z_arg) == SUCCESS) { \
|
||||
convert_to_long(*z_arg); \
|
||||
if (zend_hash_find(myht, element, strlen(element) + 1, (void**) &z_arg) == SUCCESS && Z_TYPE_PP(z_arg) == IS_LONG) { \
|
||||
(*intobj)->diff->member = (itype)Z_LVAL_PP(z_arg); \
|
||||
} else { \
|
||||
(*intobj)->diff->member = (itype)def; \
|
||||
@@ -4169,8 +4172,15 @@ static int php_date_interval_initialize_from_hash(zval **return_value, php_inter
|
||||
do { \
|
||||
zval **z_arg = NULL; \
|
||||
if (zend_hash_find(myht, element, strlen(element) + 1, (void**) &z_arg) == SUCCESS) { \
|
||||
convert_to_string(*z_arg); \
|
||||
DATE_A64I((*intobj)->diff->member, Z_STRVAL_PP(z_arg)); \
|
||||
if (Z_TYPE_PP(z_arg) == IS_STRING) { \
|
||||
DATE_A64I((*intobj)->diff->member, Z_STRVAL_PP(z_arg)); \
|
||||
} else if (Z_TYPE_PP(z_arg) == IS_LONG || Z_TYPE_PP(z_arg) == IS_BOOL) { \
|
||||
(*intobj)->diff->member = (timelib_sll)Z_LVAL_PP(z_arg); \
|
||||
} else if (Z_TYPE_PP(z_arg) == IS_DOUBLE) { \
|
||||
(*intobj)->diff->member = (timelib_sll)Z_DVAL_PP(z_arg); \
|
||||
} else { \
|
||||
(*intobj)->diff->member = -1LL; \
|
||||
} \
|
||||
} else { \
|
||||
(*intobj)->diff->member = -1LL; \
|
||||
} \
|
||||
@@ -4348,7 +4358,7 @@ static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_
|
||||
struct timelib_error_container *errors;
|
||||
|
||||
timelib_strtointerval(format, format_length, &b, &e, &p, &r, &errors);
|
||||
|
||||
|
||||
if (errors->error_count > 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown or bad format (%s)", format);
|
||||
retval = FAILURE;
|
||||
@@ -4377,7 +4387,7 @@ PHP_METHOD(DatePeriod, __construct)
|
||||
int isostr_len = 0;
|
||||
timelib_time *clone;
|
||||
zend_error_handling error_handling;
|
||||
|
||||
|
||||
zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
|
||||
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "OOl|l", &start, date_ce_interface, &interval, date_ce_interval, &recurrences, &options) == FAILURE) {
|
||||
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "OOO|l", &start, date_ce_interface, &interval, date_ce_interval, &end, date_ce_interface, &options) == FAILURE) {
|
||||
@@ -4492,7 +4502,7 @@ PHP_FUNCTION(timezone_identifiers_list)
|
||||
tzdb = DATE_TIMEZONEDB;
|
||||
item_count = tzdb->index_size;
|
||||
table = tzdb->index;
|
||||
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
for (i = 0; i < item_count; ++i) {
|
||||
@@ -4526,7 +4536,7 @@ PHP_FUNCTION(timezone_abbreviations_list)
|
||||
{
|
||||
const timelib_tz_lookup_table *table, *entry;
|
||||
zval *element, **abbr_array_pp, *abbr_array;
|
||||
|
||||
|
||||
table = timelib_timezone_abbreviations_list();
|
||||
array_init(return_value);
|
||||
entry = table;
|
||||
@@ -4602,11 +4612,11 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
|
||||
timelib_time *t;
|
||||
timelib_tzinfo *tzi;
|
||||
char *retstr;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|ldddd", &time, &retformat, &latitude, &longitude, &zenith, &gmt_offset) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
switch (ZEND_NUM_ARGS()) {
|
||||
case 1:
|
||||
retformat = SUNFUNCS_RET_STRING;
|
||||
@@ -4650,7 +4660,7 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
|
||||
timelib_unixtime2local(t, time);
|
||||
rs = timelib_astro_rise_set_altitude(t, longitude, latitude, altitude, 1, &h_rise, &h_set, &rise, &set, &transit);
|
||||
timelib_time_dtor(t);
|
||||
|
||||
|
||||
if (rs != 0) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -4704,7 +4714,7 @@ PHP_FUNCTION(date_sun_info)
|
||||
timelib_sll rise, set, transit;
|
||||
int dummy;
|
||||
double ddummy;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ldd", &time, &latitude, &longitude) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -4718,7 +4728,7 @@ PHP_FUNCTION(date_sun_info)
|
||||
/* Setup */
|
||||
t2 = timelib_time_ctor();
|
||||
array_init(return_value);
|
||||
|
||||
|
||||
/* Get sun up/down and transit */
|
||||
rs = timelib_astro_rise_set_altitude(t, longitude, latitude, -35.0/60, 1, &ddummy, &ddummy, &rise, &set, &transit);
|
||||
switch (rs) {
|
||||
@@ -4862,7 +4872,7 @@ static HashTable *date_object_get_properties_period(zval *object TSRMLS_DC)
|
||||
ZVAL_NULL(zv);
|
||||
}
|
||||
zend_hash_update(props, "interval", sizeof("interval"), &zv, sizeof(zv), NULL);
|
||||
|
||||
|
||||
/* converted to larger type (int->long); must check when unserializing */
|
||||
MAKE_STD_ZVAL(zv);
|
||||
ZVAL_LONG(zv, (long) period_obj->recurrences);
|
||||
@@ -4945,7 +4955,7 @@ static int php_date_period_initialize_from_hash(php_period_obj *period_obj, Hash
|
||||
}
|
||||
|
||||
period_obj->initialized = 1;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -4962,7 +4972,7 @@ PHP_METHOD(DatePeriod, __set_state)
|
||||
}
|
||||
|
||||
myht = Z_ARRVAL_P(array);
|
||||
|
||||
|
||||
object_init_ex(return_value, date_ce_period);
|
||||
period_obj = zend_object_store_get_object(return_value TSRMLS_CC);
|
||||
if (!php_date_period_initialize_from_hash(period_obj, myht TSRMLS_CC)) {
|
||||
|
||||
@@ -14,17 +14,17 @@ var_dump($di);
|
||||
--EXPECTF--
|
||||
object(DateInterval)#%d (15) {
|
||||
["y"]=>
|
||||
int(2)
|
||||
int(-1)
|
||||
["m"]=>
|
||||
int(0)
|
||||
int(-1)
|
||||
["d"]=>
|
||||
int(0)
|
||||
int(-1)
|
||||
["h"]=>
|
||||
int(6)
|
||||
int(-1)
|
||||
["i"]=>
|
||||
int(8)
|
||||
int(-1)
|
||||
["s"]=>
|
||||
int(0)
|
||||
int(-1)
|
||||
["weekday"]=>
|
||||
int(10)
|
||||
["weekday_behavior"]=>
|
||||
|
||||
@@ -14,17 +14,17 @@ var_dump($di);
|
||||
--EXPECTF--
|
||||
object(DateInterval)#%d (15) {
|
||||
["y"]=>
|
||||
int(2)
|
||||
int(-1)
|
||||
["m"]=>
|
||||
int(0)
|
||||
int(-1)
|
||||
["d"]=>
|
||||
int(0)
|
||||
int(-1)
|
||||
["h"]=>
|
||||
int(6)
|
||||
int(-1)
|
||||
["i"]=>
|
||||
int(8)
|
||||
int(-1)
|
||||
["s"]=>
|
||||
int(0)
|
||||
int(-1)
|
||||
["weekday"]=>
|
||||
int(10)
|
||||
["weekday_behavior"]=>
|
||||
|
||||
+121
-108
@@ -74,7 +74,7 @@
|
||||
#include "php_ini.h"
|
||||
#include "ext/standard/php_string.h"
|
||||
#include "ext/standard/php_image.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/info.h"
|
||||
|
||||
/* needed for ssize_t definition */
|
||||
#include <sys/types.h>
|
||||
@@ -161,7 +161,7 @@ ZEND_BEGIN_MODULE_GLOBALS(exif)
|
||||
char * encode_jis;
|
||||
char * decode_jis_be;
|
||||
char * decode_jis_le;
|
||||
ZEND_END_MODULE_GLOBALS(exif)
|
||||
ZEND_END_MODULE_GLOBALS(exif)
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(exif)
|
||||
|
||||
@@ -170,7 +170,7 @@ ZEND_DECLARE_MODULE_GLOBALS(exif)
|
||||
#else
|
||||
#define EXIF_G(v) (exif_globals.v)
|
||||
#endif
|
||||
|
||||
|
||||
/* {{{ PHP_INI
|
||||
*/
|
||||
|
||||
@@ -213,7 +213,7 @@ PHP_INI_BEGIN()
|
||||
STD_PHP_INI_ENTRY("exif.decode_jis_intel", "JIS", PHP_INI_ALL, OnUpdateDecode, decode_jis_le, zend_exif_globals, exif_globals)
|
||||
PHP_INI_END()
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ PHP_GINIT_FUNCTION
|
||||
*/
|
||||
static PHP_GINIT_FUNCTION(exif)
|
||||
@@ -233,9 +233,9 @@ PHP_MINIT_FUNCTION(exif)
|
||||
{
|
||||
REGISTER_INI_ENTRIES();
|
||||
if (zend_hash_exists(&module_registry, "mbstring", sizeof("mbstring"))) {
|
||||
REGISTER_LONG_CONSTANT("EXIF_USE_MBSTRING", 1, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("EXIF_USE_MBSTRING", 1, CONST_CS | CONST_PERSISTENT);
|
||||
} else {
|
||||
REGISTER_LONG_CONSTANT("EXIF_USE_MBSTRING", 0, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("EXIF_USE_MBSTRING", 0, CONST_CS | CONST_PERSISTENT);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ zend_module_entry exif_module_entry = {
|
||||
exif_module_deps,
|
||||
"exif",
|
||||
exif_functions,
|
||||
PHP_MINIT(exif),
|
||||
PHP_MINIT(exif),
|
||||
PHP_MSHUTDOWN(exif),
|
||||
NULL, NULL,
|
||||
PHP_MINFO(exif),
|
||||
@@ -278,7 +278,7 @@ zend_module_entry exif_module_entry = {
|
||||
NULL,
|
||||
NULL,
|
||||
STANDARD_MODULE_PROPERTIES_EX
|
||||
#else
|
||||
#else
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
#endif
|
||||
};
|
||||
@@ -667,73 +667,73 @@ static tag_info_array tag_table_IFD = {
|
||||
{ 0x0213, "YCbCrPositioning"},
|
||||
{ 0x0214, "ReferenceBlackWhite"},
|
||||
{ 0x02BC, "ExtensibleMetadataPlatform"}, /* XAP: Extensible Authoring Publishing, obsoleted by XMP: Extensible Metadata Platform */
|
||||
{ 0x0301, "Gamma"},
|
||||
{ 0x0302, "ICCProfileDescriptor"},
|
||||
{ 0x0303, "SRGBRenderingIntent"},
|
||||
{ 0x0320, "ImageTitle"},
|
||||
{ 0x5001, "ResolutionXUnit"},
|
||||
{ 0x5002, "ResolutionYUnit"},
|
||||
{ 0x5003, "ResolutionXLengthUnit"},
|
||||
{ 0x5004, "ResolutionYLengthUnit"},
|
||||
{ 0x5005, "PrintFlags"},
|
||||
{ 0x5006, "PrintFlagsVersion"},
|
||||
{ 0x5007, "PrintFlagsCrop"},
|
||||
{ 0x5008, "PrintFlagsBleedWidth"},
|
||||
{ 0x5009, "PrintFlagsBleedWidthScale"},
|
||||
{ 0x500A, "HalftoneLPI"},
|
||||
{ 0x500B, "HalftoneLPIUnit"},
|
||||
{ 0x500C, "HalftoneDegree"},
|
||||
{ 0x500D, "HalftoneShape"},
|
||||
{ 0x500E, "HalftoneMisc"},
|
||||
{ 0x500F, "HalftoneScreen"},
|
||||
{ 0x5010, "JPEGQuality"},
|
||||
{ 0x5011, "GridSize"},
|
||||
{ 0x5012, "ThumbnailFormat"},
|
||||
{ 0x5013, "ThumbnailWidth"},
|
||||
{ 0x5014, "ThumbnailHeight"},
|
||||
{ 0x5015, "ThumbnailColorDepth"},
|
||||
{ 0x5016, "ThumbnailPlanes"},
|
||||
{ 0x5017, "ThumbnailRawBytes"},
|
||||
{ 0x5018, "ThumbnailSize"},
|
||||
{ 0x5019, "ThumbnailCompressedSize"},
|
||||
{ 0x501A, "ColorTransferFunction"},
|
||||
{ 0x501B, "ThumbnailData"},
|
||||
{ 0x5020, "ThumbnailImageWidth"},
|
||||
{ 0x5021, "ThumbnailImageHeight"},
|
||||
{ 0x5022, "ThumbnailBitsPerSample"},
|
||||
{ 0x5023, "ThumbnailCompression"},
|
||||
{ 0x5024, "ThumbnailPhotometricInterp"},
|
||||
{ 0x5025, "ThumbnailImageDescription"},
|
||||
{ 0x5026, "ThumbnailEquipMake"},
|
||||
{ 0x5027, "ThumbnailEquipModel"},
|
||||
{ 0x5028, "ThumbnailStripOffsets"},
|
||||
{ 0x5029, "ThumbnailOrientation"},
|
||||
{ 0x502A, "ThumbnailSamplesPerPixel"},
|
||||
{ 0x502B, "ThumbnailRowsPerStrip"},
|
||||
{ 0x502C, "ThumbnailStripBytesCount"},
|
||||
{ 0x502D, "ThumbnailResolutionX"},
|
||||
{ 0x502E, "ThumbnailResolutionY"},
|
||||
{ 0x502F, "ThumbnailPlanarConfig"},
|
||||
{ 0x5030, "ThumbnailResolutionUnit"},
|
||||
{ 0x5031, "ThumbnailTransferFunction"},
|
||||
{ 0x5032, "ThumbnailSoftwareUsed"},
|
||||
{ 0x5033, "ThumbnailDateTime"},
|
||||
{ 0x5034, "ThumbnailArtist"},
|
||||
{ 0x5035, "ThumbnailWhitePoint"},
|
||||
{ 0x5036, "ThumbnailPrimaryChromaticities"},
|
||||
{ 0x5037, "ThumbnailYCbCrCoefficients"},
|
||||
{ 0x5038, "ThumbnailYCbCrSubsampling"},
|
||||
{ 0x5039, "ThumbnailYCbCrPositioning"},
|
||||
{ 0x503A, "ThumbnailRefBlackWhite"},
|
||||
{ 0x503B, "ThumbnailCopyRight"},
|
||||
{ 0x5090, "LuminanceTable"},
|
||||
{ 0x5091, "ChrominanceTable"},
|
||||
{ 0x5100, "FrameDelay"},
|
||||
{ 0x5101, "LoopCount"},
|
||||
{ 0x5110, "PixelUnit"},
|
||||
{ 0x5111, "PixelPerUnitX"},
|
||||
{ 0x5112, "PixelPerUnitY"},
|
||||
{ 0x5113, "PaletteHistogram"},
|
||||
{ 0x0301, "Gamma"},
|
||||
{ 0x0302, "ICCProfileDescriptor"},
|
||||
{ 0x0303, "SRGBRenderingIntent"},
|
||||
{ 0x0320, "ImageTitle"},
|
||||
{ 0x5001, "ResolutionXUnit"},
|
||||
{ 0x5002, "ResolutionYUnit"},
|
||||
{ 0x5003, "ResolutionXLengthUnit"},
|
||||
{ 0x5004, "ResolutionYLengthUnit"},
|
||||
{ 0x5005, "PrintFlags"},
|
||||
{ 0x5006, "PrintFlagsVersion"},
|
||||
{ 0x5007, "PrintFlagsCrop"},
|
||||
{ 0x5008, "PrintFlagsBleedWidth"},
|
||||
{ 0x5009, "PrintFlagsBleedWidthScale"},
|
||||
{ 0x500A, "HalftoneLPI"},
|
||||
{ 0x500B, "HalftoneLPIUnit"},
|
||||
{ 0x500C, "HalftoneDegree"},
|
||||
{ 0x500D, "HalftoneShape"},
|
||||
{ 0x500E, "HalftoneMisc"},
|
||||
{ 0x500F, "HalftoneScreen"},
|
||||
{ 0x5010, "JPEGQuality"},
|
||||
{ 0x5011, "GridSize"},
|
||||
{ 0x5012, "ThumbnailFormat"},
|
||||
{ 0x5013, "ThumbnailWidth"},
|
||||
{ 0x5014, "ThumbnailHeight"},
|
||||
{ 0x5015, "ThumbnailColorDepth"},
|
||||
{ 0x5016, "ThumbnailPlanes"},
|
||||
{ 0x5017, "ThumbnailRawBytes"},
|
||||
{ 0x5018, "ThumbnailSize"},
|
||||
{ 0x5019, "ThumbnailCompressedSize"},
|
||||
{ 0x501A, "ColorTransferFunction"},
|
||||
{ 0x501B, "ThumbnailData"},
|
||||
{ 0x5020, "ThumbnailImageWidth"},
|
||||
{ 0x5021, "ThumbnailImageHeight"},
|
||||
{ 0x5022, "ThumbnailBitsPerSample"},
|
||||
{ 0x5023, "ThumbnailCompression"},
|
||||
{ 0x5024, "ThumbnailPhotometricInterp"},
|
||||
{ 0x5025, "ThumbnailImageDescription"},
|
||||
{ 0x5026, "ThumbnailEquipMake"},
|
||||
{ 0x5027, "ThumbnailEquipModel"},
|
||||
{ 0x5028, "ThumbnailStripOffsets"},
|
||||
{ 0x5029, "ThumbnailOrientation"},
|
||||
{ 0x502A, "ThumbnailSamplesPerPixel"},
|
||||
{ 0x502B, "ThumbnailRowsPerStrip"},
|
||||
{ 0x502C, "ThumbnailStripBytesCount"},
|
||||
{ 0x502D, "ThumbnailResolutionX"},
|
||||
{ 0x502E, "ThumbnailResolutionY"},
|
||||
{ 0x502F, "ThumbnailPlanarConfig"},
|
||||
{ 0x5030, "ThumbnailResolutionUnit"},
|
||||
{ 0x5031, "ThumbnailTransferFunction"},
|
||||
{ 0x5032, "ThumbnailSoftwareUsed"},
|
||||
{ 0x5033, "ThumbnailDateTime"},
|
||||
{ 0x5034, "ThumbnailArtist"},
|
||||
{ 0x5035, "ThumbnailWhitePoint"},
|
||||
{ 0x5036, "ThumbnailPrimaryChromaticities"},
|
||||
{ 0x5037, "ThumbnailYCbCrCoefficients"},
|
||||
{ 0x5038, "ThumbnailYCbCrSubsampling"},
|
||||
{ 0x5039, "ThumbnailYCbCrPositioning"},
|
||||
{ 0x503A, "ThumbnailRefBlackWhite"},
|
||||
{ 0x503B, "ThumbnailCopyRight"},
|
||||
{ 0x5090, "LuminanceTable"},
|
||||
{ 0x5091, "ChrominanceTable"},
|
||||
{ 0x5100, "FrameDelay"},
|
||||
{ 0x5101, "LoopCount"},
|
||||
{ 0x5110, "PixelUnit"},
|
||||
{ 0x5111, "PixelPerUnitX"},
|
||||
{ 0x5112, "PixelPerUnitY"},
|
||||
{ 0x5113, "PaletteHistogram"},
|
||||
{ 0x1000, "RelatedImageFileFormat"},
|
||||
{ 0x800D, "ImageID"},
|
||||
{ 0x80E3, "Matteing"}, /* obsoleted by ExtraSamples */
|
||||
@@ -939,7 +939,7 @@ static tag_info_array tag_table_VND_NIKON = {
|
||||
{ 0x000b, "Converter"},
|
||||
TAG_TABLE_END
|
||||
};
|
||||
|
||||
|
||||
static tag_info_array tag_table_VND_NIKON_990 = {
|
||||
{ 0x0001, "Version"},
|
||||
{ 0x0002, "ISOSetting"},
|
||||
@@ -958,7 +958,7 @@ static tag_info_array tag_table_VND_NIKON_990 = {
|
||||
{ 0x0010, "DataDump"},
|
||||
TAG_TABLE_END
|
||||
};
|
||||
|
||||
|
||||
static tag_info_array tag_table_VND_OLYMPUS = {
|
||||
{ 0x0200, "SpecialMode"},
|
||||
{ 0x0201, "JPEGQuality"},
|
||||
@@ -1224,7 +1224,7 @@ char * exif_dump_data(int *dump_free, int format, int components, int length, in
|
||||
if (components > 0) {
|
||||
dump = erealloc(dump, len + 2 + 1);
|
||||
snprintf(dump + len, 2 + 1, ", ");
|
||||
len += 2;
|
||||
len += 2;
|
||||
components--;
|
||||
} else{
|
||||
break;
|
||||
@@ -1574,7 +1574,7 @@ typedef struct {
|
||||
static void exif_error_docref(const char *docref EXIFERR_DC, const image_info_type *ImageInfo, int type, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, format);
|
||||
#ifdef EXIF_DEBUG
|
||||
{
|
||||
@@ -2627,7 +2627,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
|
||||
*pszEncoding = estrdup((const char*)szValuePtr);
|
||||
szValuePtr = szValuePtr+8;
|
||||
ByteCount -= 8;
|
||||
/* First try to detect BOM: ZERO WIDTH NOBREAK SPACE (FEFF 16)
|
||||
/* First try to detect BOM: ZERO WIDTH NOBREAK SPACE (FEFF 16)
|
||||
* since we have no encoding support for the BOM yet we skip that.
|
||||
*/
|
||||
if (!memcmp(szValuePtr, "\xFE\xFF", 2)) {
|
||||
@@ -2645,8 +2645,8 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
|
||||
}
|
||||
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
|
||||
if (zend_multibyte_encoding_converter(
|
||||
(unsigned char**)pszInfoPtr,
|
||||
&len,
|
||||
(unsigned char**)pszInfoPtr,
|
||||
&len,
|
||||
(unsigned char*)szValuePtr,
|
||||
ByteCount,
|
||||
zend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC),
|
||||
@@ -2666,8 +2666,8 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
|
||||
ByteCount -= 8;
|
||||
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
|
||||
if (zend_multibyte_encoding_converter(
|
||||
(unsigned char**)pszInfoPtr,
|
||||
&len,
|
||||
(unsigned char**)pszInfoPtr,
|
||||
&len,
|
||||
(unsigned char*)szValuePtr,
|
||||
ByteCount,
|
||||
zend_multibyte_fetch_encoding(ImageInfo->encode_jis TSRMLS_CC),
|
||||
@@ -2701,12 +2701,12 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
|
||||
* Process unicode field in IFD. */
|
||||
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
|
||||
{
|
||||
xp_field->tag = tag;
|
||||
xp_field->tag = tag;
|
||||
xp_field->value = NULL;
|
||||
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
|
||||
if (zend_multibyte_encoding_converter(
|
||||
(unsigned char**)&xp_field->value,
|
||||
&xp_field->size,
|
||||
(unsigned char**)&xp_field->value,
|
||||
&xp_field->size,
|
||||
(unsigned char*)szValuePtr,
|
||||
ByteCount,
|
||||
zend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC),
|
||||
@@ -2731,7 +2731,7 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
|
||||
if (i==sizeof(maker_note_array)/sizeof(maker_note_type))
|
||||
return FALSE;
|
||||
maker_note = maker_note_array+i;
|
||||
|
||||
|
||||
/*exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "check (%s,%s)", maker_note->make?maker_note->make:"", maker_note->model?maker_note->model:"");*/
|
||||
if (maker_note->make && (!ImageInfo->make || strcmp(maker_note->make, ImageInfo->make)))
|
||||
continue;
|
||||
@@ -2852,9 +2852,9 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
|
||||
offset_val = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel);
|
||||
/* If its bigger than 4 bytes, the dir entry contains an offset. */
|
||||
value_ptr = offset_base+offset_val;
|
||||
/*
|
||||
/*
|
||||
dir_entry is ImageInfo->file.list[sn].data+2+i*12
|
||||
offset_base is ImageInfo->file.list[sn].data-dir_offset
|
||||
offset_base is ImageInfo->file.list[sn].data-dir_offset
|
||||
dir_entry - offset_base is dir_offset+2+i*12
|
||||
*/
|
||||
if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry || offset_val < (size_t)(dir_entry-offset_base)) {
|
||||
@@ -2925,18 +2925,18 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
|
||||
case TAG_COMP_IMAGE_WIDTH:
|
||||
ImageInfo->Thumbnail.width = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel TSRMLS_CC);
|
||||
break;
|
||||
|
||||
|
||||
case TAG_IMAGEHEIGHT:
|
||||
case TAG_COMP_IMAGE_HEIGHT:
|
||||
ImageInfo->Thumbnail.height = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel TSRMLS_CC);
|
||||
break;
|
||||
|
||||
|
||||
case TAG_STRIP_OFFSETS:
|
||||
case TAG_JPEG_INTERCHANGE_FORMAT:
|
||||
/* accept both formats */
|
||||
ImageInfo->Thumbnail.offset = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel TSRMLS_CC);
|
||||
break;
|
||||
|
||||
|
||||
case TAG_STRIP_BYTE_COUNTS:
|
||||
if (ImageInfo->FileType == IMAGE_FILETYPE_TIFF_II || ImageInfo->FileType == IMAGE_FILETYPE_TIFF_MM) {
|
||||
ImageInfo->Thumbnail.filetype = ImageInfo->FileType;
|
||||
@@ -2946,7 +2946,7 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
|
||||
}
|
||||
ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel TSRMLS_CC);
|
||||
break;
|
||||
|
||||
|
||||
case TAG_JPEG_INTERCHANGE_FORMAT_LEN:
|
||||
if (ImageInfo->Thumbnail.filetype == IMAGE_FILETYPE_UNKNOWN) {
|
||||
ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_JPEG;
|
||||
@@ -2964,16 +2964,16 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
|
||||
if (length<byte_count-1) {
|
||||
/* When there are any characters after the first NUL */
|
||||
ImageInfo->CopyrightPhotographer = estrdup(value_ptr);
|
||||
ImageInfo->CopyrightEditor = estrdup(value_ptr+length+1);
|
||||
spprintf(&ImageInfo->Copyright, 0, "%s, %s", value_ptr, value_ptr+length+1);
|
||||
ImageInfo->CopyrightEditor = estrndup(value_ptr+length+1, byte_count-length-1);
|
||||
spprintf(&ImageInfo->Copyright, 0, "%s, %s", ImageInfo->CopyrightPhotographer, ImageInfo->CopyrightEditor);
|
||||
/* format = TAG_FMT_UNDEFINED; this musn't be ASCII */
|
||||
/* but we are not supposed to change this */
|
||||
/* keep in mind that image_info does not store editor value */
|
||||
} else {
|
||||
ImageInfo->Copyright = estrdup(value_ptr);
|
||||
ImageInfo->Copyright = estrndup(value_ptr, byte_count);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case TAG_USERCOMMENT:
|
||||
ImageInfo->UserCommentLength = exif_process_user_comment(ImageInfo, &(ImageInfo->UserComment), &(ImageInfo->UserCommentEncoding), value_ptr, byte_count TSRMLS_CC);
|
||||
@@ -3061,10 +3061,10 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
|
||||
break;
|
||||
|
||||
case TAG_MAKE:
|
||||
ImageInfo->make = estrdup(value_ptr);
|
||||
ImageInfo->make = estrndup(value_ptr, byte_count);
|
||||
break;
|
||||
case TAG_MODEL:
|
||||
ImageInfo->model = estrdup(value_ptr);
|
||||
ImageInfo->model = estrndup(value_ptr, byte_count);
|
||||
break;
|
||||
|
||||
case TAG_MAKER_NOTE:
|
||||
@@ -3134,6 +3134,11 @@ static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start,
|
||||
|
||||
ImageInfo->sections_found |= FOUND_IFD0;
|
||||
|
||||
if ((dir_start + 2) >= (offset_base+IFDlength)) {
|
||||
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel);
|
||||
|
||||
if ((dir_start+2+NumDirEntries*12) > (offset_base+IFDlength)) {
|
||||
@@ -3157,6 +3162,10 @@ static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start,
|
||||
* Hack to make it process IDF1 I hope
|
||||
* There are 2 IDFs, the second one holds the keys (0x0201 and 0x0202) to the thumbnail
|
||||
*/
|
||||
if ((dir_start+2+12*de + 4) >= (offset_base+IFDlength)) {
|
||||
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size");
|
||||
return FALSE;
|
||||
}
|
||||
NextDirOffset = php_ifd_get32u(dir_start+2+12*de, ImageInfo->motorola_intel);
|
||||
if (NextDirOffset) {
|
||||
/* the next line seems false but here IFDlength means length of all IFDs */
|
||||
@@ -3206,9 +3215,13 @@ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf,
|
||||
}
|
||||
|
||||
/* Check the next two values for correctness. */
|
||||
if (length < 8) {
|
||||
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF start (1)");
|
||||
return;
|
||||
}
|
||||
exif_value_2a = php_ifd_get16u(CharBuf+2, ImageInfo->motorola_intel);
|
||||
offset_of_ifd = php_ifd_get32u(CharBuf+4, ImageInfo->motorola_intel);
|
||||
if ( exif_value_2a != 0x2a || offset_of_ifd < 0x08) {
|
||||
if (exif_value_2a != 0x2a || offset_of_ifd < 0x08) {
|
||||
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF start (1)");
|
||||
return;
|
||||
}
|
||||
@@ -3414,7 +3427,7 @@ static int exif_scan_JPEG_header(image_info_type *ImageInfo TSRMLS_DC)
|
||||
if ((itemlen - 2) < 6) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
exif_process_SOFn(Data, marker, &sof_info);
|
||||
ImageInfo->Width = sof_info.width;
|
||||
ImageInfo->Height = sof_info.height;
|
||||
@@ -3459,21 +3472,21 @@ static int exif_scan_thumbnail(image_info_type *ImageInfo TSRMLS_DC)
|
||||
}
|
||||
for (;;) {
|
||||
pos += length;
|
||||
if (pos>=ImageInfo->Thumbnail.size)
|
||||
if (pos>=ImageInfo->Thumbnail.size)
|
||||
return FALSE;
|
||||
c = data[pos++];
|
||||
if (pos>=ImageInfo->Thumbnail.size)
|
||||
if (pos>=ImageInfo->Thumbnail.size)
|
||||
return FALSE;
|
||||
if (c != 0xFF) {
|
||||
return FALSE;
|
||||
}
|
||||
n = 8;
|
||||
while ((c = data[pos++]) == 0xFF && n--) {
|
||||
if (pos+3>=ImageInfo->Thumbnail.size)
|
||||
if (pos+3>=ImageInfo->Thumbnail.size)
|
||||
return FALSE;
|
||||
/* +3 = pos++ of next check when reaching marker + 2 bytes for length */
|
||||
}
|
||||
if (c == 0xFF)
|
||||
if (c == 0xFF)
|
||||
return FALSE;
|
||||
marker = c;
|
||||
length = php_jpg_get16(data+pos);
|
||||
@@ -3787,7 +3800,7 @@ static int exif_scan_FILE_header(image_info_type *ImageInfo TSRMLS_DC)
|
||||
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "File has TIFF/II format");
|
||||
#endif
|
||||
ImageInfo->sections_found |= FOUND_IFD0;
|
||||
if (exif_process_IFD_in_TIFF(ImageInfo,
|
||||
if (exif_process_IFD_in_TIFF(ImageInfo,
|
||||
php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel),
|
||||
SECTION_IFD0 TSRMLS_CC)) {
|
||||
ret = TRUE;
|
||||
@@ -3967,7 +3980,7 @@ PHP_FUNCTION(exif_read_data)
|
||||
sections_str = exif_get_sectionlist(ImageInfo.sections_found TSRMLS_CC);
|
||||
|
||||
#ifdef EXIF_DEBUG
|
||||
if (sections_str)
|
||||
if (sections_str)
|
||||
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections found: %s", sections_str[0] ? sections_str : "None");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
--TEST--
|
||||
Bug #72094: Out of bounds heap read access in exif header processing
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||
--FILE--
|
||||
<?php
|
||||
print_r(exif_read_data(__DIR__ . '/bug72094_1.jpg'));
|
||||
print_r(exif_read_data(__DIR__ . '/bug72094_2.jpg'));
|
||||
print_r(exif_read_data(__DIR__ . '/bug72094_3.jpg'));
|
||||
print_r(exif_read_data(__DIR__ . '/bug72094_4.jpg'));
|
||||
?>
|
||||
DONE
|
||||
--EXPECTF--
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x8298=Copyright ): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Illegal IFD offset in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): File structure corrupted in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Invalid JPEG file in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_2.jpg): Illegal IFD size in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_2.jpg): File structure corrupted in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_2.jpg): Invalid JPEG file in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Illegal IFD size in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): File structure corrupted in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Invalid JPEG file in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_4.jpg): Invalid TIFF start (1) in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_4.jpg): File structure corrupted in %s/bug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_4.jpg): Invalid JPEG file in %s/bug72094.php on line %d
|
||||
DONE
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -414,7 +414,7 @@ file_check_mem(struct magic_set *ms, unsigned int level)
|
||||
size_t len;
|
||||
|
||||
if (level >= ms->c.len) {
|
||||
len = (ms->c.len += 20) * sizeof(*ms->c.li);
|
||||
len = (ms->c.len = 20 + level) * sizeof(*ms->c.li);
|
||||
ms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ?
|
||||
emalloc(len) :
|
||||
erealloc(ms->c.li, len));
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
Bug #71527 Buffer over-write in finfo_open with malformed magic file
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!class_exists('finfo'))
|
||||
die('skip no fileinfo extension');
|
||||
--ENV--
|
||||
USE_ZEND_ALLOC=0
|
||||
--FILE--
|
||||
<?php
|
||||
$finfo = finfo_open(FILEINFO_NONE, dirname(__FILE__) . DIRECTORY_SEPARATOR . "bug71527.magic");
|
||||
$info = finfo_file($finfo, __FILE__);
|
||||
var_dump($info);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: finfo_open(): Failed to load magic database at '%sbug71527.magic'. in %sbug71527.php on line %d
|
||||
|
||||
Warning: finfo_file() expects parameter 1 to be resource, boolean given in %sbug71527.php on line %d
|
||||
bool(false)
|
||||
+3
-2
@@ -3045,10 +3045,11 @@ PHP_FUNCTION(imagegammacorrect)
|
||||
for (x = 0; x < gdImageSX(im); x++) {
|
||||
c = gdImageGetPixel(im, x, y);
|
||||
gdImageSetPixel(im, x, y,
|
||||
gdTrueColor(
|
||||
gdTrueColorAlpha(
|
||||
(int) ((pow((pow((gdTrueColorGetRed(c) / 255.0), input)), 1.0 / output) * 255) + .5),
|
||||
(int) ((pow((pow((gdTrueColorGetGreen(c) / 255.0), input)), 1.0 / output) * 255) + .5),
|
||||
(int) ((pow((pow((gdTrueColorGetBlue(c) / 255.0), input)), 1.0 / output) * 255) + .5)
|
||||
(int) ((pow((pow((gdTrueColorGetBlue(c) / 255.0), input)), 1.0 / output) * 255) + .5),
|
||||
gdTrueColorGetAlpha(c)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
+17
-9
@@ -133,6 +133,10 @@ gdImagePtr gdImageCreate (int sx, int sy)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (overflow2(sizeof(unsigned char *), sx)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
im = (gdImage *) gdCalloc(1, sizeof(gdImage));
|
||||
|
||||
/* Row-major ever since gd 1.3 */
|
||||
@@ -1098,12 +1102,12 @@ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
|
||||
int thick = im->thick;
|
||||
|
||||
if (color == gdAntiAliased) {
|
||||
/*
|
||||
/*
|
||||
gdAntiAliased passed as color: use the much faster, much cheaper
|
||||
and equally attractive gdImageAALine implementation. That
|
||||
clips too, so don't clip twice.
|
||||
*/
|
||||
gdImageAALine(im, x1, y1, x2, y2, im->AA_color);
|
||||
gdImageAALine(im, x1, y1, x2, y2, im->AA_color);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1774,9 +1778,13 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
|
||||
|
||||
if (x >= im->sx) {
|
||||
x = im->sx - 1;
|
||||
} else if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
if (y >= im->sy) {
|
||||
y = im->sy - 1;
|
||||
} else if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
|
||||
for (i = x; i >= 0; i--) {
|
||||
@@ -1876,7 +1884,7 @@ void gdImageFill(gdImagePtr im, int x, int y, int nc)
|
||||
return;
|
||||
}
|
||||
|
||||
alphablending_bak = im->alphaBlendingFlag;
|
||||
alphablending_bak = im->alphaBlendingFlag;
|
||||
im->alphaBlendingFlag = 0;
|
||||
|
||||
if (nc==gdTiled){
|
||||
@@ -1888,7 +1896,7 @@ void gdImageFill(gdImagePtr im, int x, int y, int nc)
|
||||
wx2=im->sx;wy2=im->sy;
|
||||
oc = gdImageGetPixel(im, x, y);
|
||||
if (oc==nc || x<0 || x>wx2 || y<0 || y>wy2) {
|
||||
im->alphaBlendingFlag = alphablending_bak;
|
||||
im->alphaBlendingFlag = alphablending_bak;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1951,7 +1959,7 @@ skip: for (x++; x<=x2 && (gdImageGetPixel(im, x, y)!=oc); x++);
|
||||
efree(stack);
|
||||
|
||||
done:
|
||||
im->alphaBlendingFlag = alphablending_bak;
|
||||
im->alphaBlendingFlag = alphablending_bak;
|
||||
}
|
||||
|
||||
static void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc)
|
||||
@@ -2057,7 +2065,7 @@ void gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
|
||||
|
||||
x1ul = x1 - half;
|
||||
y1ul = y1 - half;
|
||||
|
||||
|
||||
x2lr = x2 + half;
|
||||
y2lr = y2 + half;
|
||||
|
||||
@@ -2255,7 +2263,7 @@ void gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int s
|
||||
int tox, toy;
|
||||
int ncR, ncG, ncB;
|
||||
toy = dstY;
|
||||
|
||||
|
||||
for (y = srcY; y < (srcY + h); y++) {
|
||||
tox = dstX;
|
||||
for (x = srcX; x < (srcX + w); x++) {
|
||||
@@ -2352,7 +2360,7 @@ void gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int
|
||||
int colorMap[gdMaxColors];
|
||||
/* Stretch vectors */
|
||||
int *stx, *sty;
|
||||
|
||||
|
||||
if (overflow2(sizeof(int), srcW)) {
|
||||
return;
|
||||
}
|
||||
@@ -2897,7 +2905,7 @@ int gdAlphaBlend (int dst, int src) {
|
||||
src_weight = gdAlphaTransparent - src_alpha;
|
||||
dst_weight = (gdAlphaTransparent - dst_alpha) * src_alpha / gdAlphaMax;
|
||||
tot_weight = src_weight + dst_weight;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* What red, green and blue result values will we use? */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -138,16 +138,29 @@ static int _gd2GetHeader(gdIOCtxPtr in, int *sx, int *sy, int *cs, int *vers, in
|
||||
if (gd2_compressed(*fmt)) {
|
||||
nc = (*ncx) * (*ncy);
|
||||
GD2_DBG(php_gd_error("Reading %d chunk index entries", nc));
|
||||
if (overflow2(sizeof(t_chunk_info), nc)) {
|
||||
goto fail1;
|
||||
}
|
||||
sidx = sizeof(t_chunk_info) * nc;
|
||||
if (sidx <= 0) {
|
||||
goto fail1;
|
||||
}
|
||||
cidx = gdCalloc(sidx, 1);
|
||||
if (cidx == NULL) {
|
||||
goto fail1;
|
||||
}
|
||||
|
||||
for (i = 0; i < nc; i++) {
|
||||
if (gdGetInt(&cidx[i].offset, in) != 1) {
|
||||
gdFree(cidx);
|
||||
goto fail1;
|
||||
}
|
||||
if (gdGetInt(&cidx[i].size, in) != 1) {
|
||||
gdFree(cidx);
|
||||
goto fail1;
|
||||
}
|
||||
if (cidx[i].offset < 0 || cidx[i].size < 0) {
|
||||
gdFree(cidx);
|
||||
goto fail1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
downscaling using the fixed point implementations are usually much faster
|
||||
than the existing gdImageCopyResampled while having a similar or better
|
||||
quality.
|
||||
|
||||
For image rotations, the optimized versions have a lazy antialiasing for
|
||||
|
||||
For image rotations, the optimized versions have a lazy antialiasing for
|
||||
the edges of the images. For a much better antialiased result, the affine
|
||||
function is recommended.
|
||||
*/
|
||||
@@ -633,7 +633,7 @@ static inline int _color_blend (const int dst, const int src)
|
||||
}
|
||||
}
|
||||
|
||||
static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor)
|
||||
static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor)
|
||||
{
|
||||
const gdFixed f_127 = gd_itofx(127);
|
||||
register int c = src->tpixels[y][x];
|
||||
@@ -934,9 +934,6 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi
|
||||
double dTotalWeight = 0.0;
|
||||
int iSrc;
|
||||
|
||||
res->ContribRow[u].Left = iLeft;
|
||||
res->ContribRow[u].Right = iRight;
|
||||
|
||||
/* Cut edge points to fit in filter window in case of spill-off */
|
||||
if (iRight - iLeft + 1 > windows_size) {
|
||||
if (iLeft < ((int)src_size - 1 / 2)) {
|
||||
@@ -946,6 +943,9 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi
|
||||
}
|
||||
}
|
||||
|
||||
res->ContribRow[u].Left = iLeft;
|
||||
res->ContribRow[u].Right = iRight;
|
||||
|
||||
for (iSrc = iLeft; iSrc <= iRight; iSrc++) {
|
||||
dTotalWeight += (res->ContribRow[u].Weights[iSrc-iLeft] = scale_f_d * (*pFilter)(scale_f_d * (dCenter - (double)iSrc)));
|
||||
}
|
||||
@@ -1049,6 +1049,9 @@ static inline void _gdScaleVert (const gdImagePtr pSrc, const unsigned int src_w
|
||||
}
|
||||
|
||||
contrib = _gdContributionsCalc(dst_height, src_height, (double)(dst_height) / (double)(src_height), pSrc->interpolation);
|
||||
if (contrib == NULL) {
|
||||
return;
|
||||
}
|
||||
/* scale each column */
|
||||
for (u = 0; u < dst_width - 1; u++) {
|
||||
_gdScaleCol(pSrc, src_width, pDst, dst_width, dst_height, u, contrib);
|
||||
@@ -1070,12 +1073,12 @@ gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_widt
|
||||
|
||||
dst = gdImageCreateTrueColor(new_width, new_height);
|
||||
if (dst == NULL) {
|
||||
gdFree(tmp_im);
|
||||
gdImageDestroy(tmp_im);
|
||||
return NULL;
|
||||
}
|
||||
gdImageSetInterpolationMethod(dst, src->interpolation_id);
|
||||
_gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height);
|
||||
gdFree(tmp_im);
|
||||
gdImageDestroy(tmp_im);
|
||||
|
||||
return dst;
|
||||
}
|
||||
@@ -1093,7 +1096,7 @@ gdImagePtr Scale(const gdImagePtr src, const unsigned int src_width, const unsig
|
||||
_gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height);
|
||||
_gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height);
|
||||
|
||||
gdFree(tmp_im);
|
||||
gdImageDestroy(tmp_im);
|
||||
return dst;
|
||||
}
|
||||
|
||||
@@ -2162,7 +2165,7 @@ gdImagePtr gdImageRotateInterpolated(const gdImagePtr src, const float angle, in
|
||||
images can be done at a later point.
|
||||
*/
|
||||
if (src->trueColor == 0) {
|
||||
if (bgcolor >= 0) {
|
||||
if (bgcolor < gdMaxColors) {
|
||||
bgcolor = gdTrueColorAlpha(src->red[bgcolor], src->green[bgcolor], src->blue[bgcolor], src->alpha[bgcolor]);
|
||||
}
|
||||
gdImagePaletteToTrueColor(src);
|
||||
@@ -2273,7 +2276,7 @@ int gdTransformAffineGetImage(gdImagePtr *dst,
|
||||
if (!src->trueColor) {
|
||||
gdImagePaletteToTrueColor(src);
|
||||
}
|
||||
|
||||
|
||||
/* Translate to dst origin (0,0) */
|
||||
gdAffineTranslate(m, -bbox.x, -bbox.y);
|
||||
gdAffineConcat(m, affine, m);
|
||||
@@ -2332,7 +2335,7 @@ int gdTransformAffineCopy(gdImagePtr dst,
|
||||
if (src->interpolation_id == GD_BILINEAR_FIXED || src->interpolation_id == GD_BICUBIC_FIXED || src->interpolation_id == GD_NEAREST_NEIGHBOUR) {
|
||||
interpolation_id_bak = src->interpolation_id;
|
||||
interpolation_bak = src->interpolation;
|
||||
|
||||
|
||||
gdImageSetInterpolationMethod(src, GD_BICUBIC);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
* If it is not working, it's not Thomas G. Lane's fault.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
SETTING THIS ONE CAUSES STRIPED IMAGE
|
||||
to be done: solve this
|
||||
#define ORIGINAL_LIB_JPEG_REVERSE_ODD_ROWS
|
||||
@@ -152,7 +152,7 @@
|
||||
* color space, and repeatedly splits the "largest" remaining box until we
|
||||
* have as many boxes as desired colors. Then the mean color in each
|
||||
* remaining box becomes one of the possible output colors.
|
||||
*
|
||||
*
|
||||
* The second pass over the image maps each input pixel to the closest output
|
||||
* color (optionally after applying a Floyd-Steinberg dithering correction).
|
||||
* This mapping is logically trivial, but making it go fast enough requires
|
||||
@@ -1320,16 +1320,16 @@ pass2_no_dither (j_decompress_ptr cinfo,
|
||||
#else
|
||||
r = gdTrueColorGetRed (*inptr);
|
||||
g = gdTrueColorGetGreen (*inptr);
|
||||
/*
|
||||
/*
|
||||
2.0.24: inptr must not be incremented until after
|
||||
transparency check, if any. Thanks to "Super Pikeman."
|
||||
transparency check, if any. Thanks to "Super Pikeman."
|
||||
*/
|
||||
b = gdTrueColorGetBlue (*inptr);
|
||||
|
||||
/* If the pixel is transparent, we assign it the palette index that
|
||||
* will later be added at the end of the palette as the transparent
|
||||
* index. */
|
||||
if ((oim->transparent >= 0) && (oim->transparent == *(inptr - 1)))
|
||||
if ((oim->transparent >= 0) && (oim->transparent == *inptr))
|
||||
{
|
||||
*outptr++ = nim->colorsTotal;
|
||||
inptr++;
|
||||
@@ -1795,7 +1795,7 @@ static void gdImageTrueColorToPaletteBody (gdImagePtr oim, int dither, int color
|
||||
}
|
||||
} else {
|
||||
nim = oim;
|
||||
}
|
||||
}
|
||||
if (!oim->trueColor)
|
||||
{
|
||||
/* (Almost) nothing to do! */
|
||||
@@ -2004,7 +2004,7 @@ static void gdImageTrueColorToPaletteBody (gdImagePtr oim, int dither, int color
|
||||
}
|
||||
|
||||
/* Success! Get rid of the truecolor image data. */
|
||||
if (!cimP) {
|
||||
if (!cimP) {
|
||||
oim->trueColor = 0;
|
||||
/* Junk the truecolor pixels */
|
||||
for (i = 0; i < oim->sy; i++)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Bug #61221 - imagegammacorrect function loses alpha channel
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$imagew = 50;
|
||||
$imageh = 50;
|
||||
$img = imagecreatetruecolor($imagew, $imageh);
|
||||
$blacktransparent = imagecolorallocatealpha($img, 0, 0, 0, 127);
|
||||
$redsolid = imagecolorallocate($img, 255, 0, 0);
|
||||
imagefill($img, 0, 0, $blacktransparent);
|
||||
imageline($img, $imagew / 2, 0, $imagew / 2, $imageh - 1, $redsolid);
|
||||
imageline($img, 0, $imageh / 2, $imagew - 1, $imageh / 2, $redsolid);
|
||||
imagegammacorrect($img, 1, 1);
|
||||
$color = imagecolorat($img, 0, 0);
|
||||
var_dump($color === $blacktransparent);
|
||||
imagedestroy($img);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #66387 (Stack overflow with imagefilltoborder)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available!');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$im = imagecreatetruecolor(20, 20);
|
||||
$c = imagecolorallocate($im, 255, 0, 0);
|
||||
imagefilltoborder($im, 0, -999355, $c, $c);
|
||||
echo "ready\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
ready
|
||||
@@ -0,0 +1,13 @@
|
||||
--TEST--
|
||||
Bug #70976 (Memory Read via gdImageRotateInterpolated Array Index Out of Bounds)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$img = imagerotate(imagecreate(10,10),45,0x7ffffff9);
|
||||
var_dump($img);
|
||||
?>
|
||||
--EXPECTF--
|
||||
resource(5) of type (gd)
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Bug #71912 (libgd: signedness vulnerability)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imagecreatefromgd2')) die('skip imagecreatefromgd2() not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
imagecreatefromgd2(__DIR__."/invalid_neg_size.gd2");
|
||||
?>
|
||||
OK
|
||||
--EXPECTF--
|
||||
|
||||
Warning: imagecreatefromgd2(): '%s/invalid_neg_size.gd2' is not a valid GD2 file in %s/bug71912.php on line %d
|
||||
OK
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #72227: imagescale out-of-bounds read
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die("skip gd extension not available\n");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$img = imagecreatetruecolor ( 100, 100);
|
||||
imagescale($img, 13, 1, IMG_BICUBIC);
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
DONE
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #72298: pass2_no_dither out-of-bounds access
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die("skip gd extension not available\n");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$img = imagecreatetruecolor (1 , 1);
|
||||
imagecolortransparent($img, 0);
|
||||
imagetruecolortopalette($img, false, 4);
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
DONE
|
||||
@@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
Bug #72339 Integer Overflow in _gd2GetHeader() resulting in heap overflow
|
||||
--SKIPIF--
|
||||
<?php if (!function_exists("imagecreatefromgd2")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$fname = dirname(__FILE__) . DIRECTORY_SEPARATOR . "bug72339.gd";
|
||||
|
||||
$fh = fopen($fname, "w");
|
||||
fwrite($fh, "gd2\x00");
|
||||
fwrite($fh, pack("n", 2));
|
||||
fwrite($fh, pack("n", 1));
|
||||
fwrite($fh, pack("n", 1));
|
||||
fwrite($fh, pack("n", 0x40));
|
||||
fwrite($fh, pack("n", 2));
|
||||
fwrite($fh, pack("n", 0x5AA0)); // Chunks Wide
|
||||
fwrite($fh, pack("n", 0x5B00)); // Chunks Vertically
|
||||
fwrite($fh, str_repeat("\x41\x41\x41\x41", 0x1000000)); // overflow data
|
||||
fclose($fh);
|
||||
|
||||
$im = imagecreatefromgd2($fname);
|
||||
|
||||
if ($im) {
|
||||
imagedestroy($im);
|
||||
}
|
||||
unlink($fname);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: imagecreatefromgd2(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
|
||||
in %sbug72339.php on line %d
|
||||
|
||||
Warning: imagecreatefromgd2(): '%sbug72339.gd' is not a valid GD2 file in %sbug72339.php on line %d
|
||||
Binary file not shown.
@@ -336,7 +336,7 @@ PHP_HASH_API void PHP_HAVAL128Final(unsigned char *digest, PHP_HAVAL_CTX * conte
|
||||
|
||||
/* Pad out to 118 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x7f);
|
||||
padLen = (index < 118) ? (118 - index) : (246 - index);
|
||||
PHP_HAVALUpdate(context, PADDING, padLen);
|
||||
|
||||
@@ -390,7 +390,7 @@ PHP_HASH_API void PHP_HAVAL160Final(unsigned char *digest, PHP_HAVAL_CTX * conte
|
||||
|
||||
/* Pad out to 118 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x7f);
|
||||
padLen = (index < 118) ? (118 - index) : (246 - index);
|
||||
PHP_HAVALUpdate(context, PADDING, padLen);
|
||||
|
||||
@@ -444,7 +444,7 @@ PHP_HASH_API void PHP_HAVAL192Final(unsigned char *digest, PHP_HAVAL_CTX * conte
|
||||
|
||||
/* Pad out to 118 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x7f);
|
||||
padLen = (index < 118) ? (118 - index) : (246 - index);
|
||||
PHP_HAVALUpdate(context, PADDING, padLen);
|
||||
|
||||
@@ -484,7 +484,7 @@ PHP_HASH_API void PHP_HAVAL224Final(unsigned char *digest, PHP_HAVAL_CTX * conte
|
||||
|
||||
/* Pad out to 118 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x7f);
|
||||
padLen = (index < 118) ? (118 - index) : (246 - index);
|
||||
PHP_HAVALUpdate(context, PADDING, padLen);
|
||||
|
||||
@@ -525,7 +525,7 @@ PHP_HASH_API void PHP_HAVAL256Final(unsigned char *digest, PHP_HAVAL_CTX * conte
|
||||
|
||||
/* Pad out to 118 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x7f);
|
||||
padLen = (index < 118) ? (118 - index) : (246 - index);
|
||||
PHP_HAVALUpdate(context, PADDING, padLen);
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Bug #70312 HAVAL gives wrong hashes in specific cases
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("hash")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(hash('haval128,5', '1234567890123456789012345678901234567890123456789012345678901234'));
|
||||
var_dump(hash('haval160,5', '1234567890123456789012345678901234567890123456789012345678901234'));
|
||||
var_dump(hash('haval192,5', '1234567890123456789012345678901234567890123456789012345678901234'));
|
||||
var_dump(hash('haval224,5', '1234567890123456789012345678901234567890123456789012345678901234'));
|
||||
var_dump(hash('haval256,5', '1234567890123456789012345678901234567890123456789012345678901234'));
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(32) "f3f0d23819b87228b4b70ee350afaa9d"
|
||||
string(40) "aded6485e137f11d7292212ba3fa961714df0564"
|
||||
string(48) "e53da2b16269fe732e9a898a96707a9f28404d7333b02286"
|
||||
string(56) "c574fb307f0817b514b9bb2e7c4bfaffb7ad667aca3c8b523fefcf10"
|
||||
string(64) "fb73c19300b14d5cb393d929bf005e6c2d459a4c9c009e9813af1d2d3637ee8f"
|
||||
@@ -64,7 +64,7 @@ unlink($file);
|
||||
adler32: ff87222e
|
||||
crc32: 61664d33
|
||||
gost: d9e65f0c0c2ef944e4f8a01f4a46365c4f33a2853756878182a7f03e1490a4cd
|
||||
haval128,3: 8bb81269aca8b7f87829020d76a4e841
|
||||
haval128,3: c25962b13383c3ed9f13817c8f2ae7d6
|
||||
md2: 70f791c0d8fa9edd7d08e32fcba8c354
|
||||
md4: a9d034b16bb290c57a645afd6f14cd3b
|
||||
md5: 704bf818448f5bbb94061332d2c889aa
|
||||
|
||||
@@ -45,7 +45,7 @@ echo "sha256(raw): " . bin2hex(hash_hmac('sha256', $content, $key, TRUE)) . "\n"
|
||||
adler32: 12c803f7
|
||||
crc32: 96859101
|
||||
gost: a4a3c80bdf3f8665bf07376a34dc9c1b11af7c813f4928f62e39f0c0dc564dad
|
||||
haval128,3: 82cd0f4bd36729b5c80c33efa8c13ac5
|
||||
haval128,3: 4d1318607f0406bd1b7bd50907772672
|
||||
md2: 6d111dab563025e4cb5f4425c991fa12
|
||||
md4: 10cdbfe843000c623f8b8da0d5d20b0b
|
||||
md5: 2a632783e2812cf23de100d7d6a463ae
|
||||
|
||||
@@ -73,7 +73,7 @@ unlink($file);
|
||||
adler32: 0f8c02f9
|
||||
crc32: f2a60b9c
|
||||
gost: 94c39a40d5db852a8dc3d24e37eebf2d53e3d711457c59cd02b614f792a9d918
|
||||
haval128,3: e8fcff647f1a675acb429130fb94a17e
|
||||
haval128,3: f1cea637451097d790354a86de3f54a3
|
||||
md2: a685475e600314bb549ab4f33c3b27cb
|
||||
md4: cbc6bff781f48f57378d3effa27553e4
|
||||
md5: 8bddf39dd1c566c27acc7fa85ec36acf
|
||||
|
||||
+2
-2
@@ -186,8 +186,8 @@ int main() {
|
||||
AC_DEFINE([ICONV_BROKEN_IGNORE],1,[Whether iconv supports IGNORE])
|
||||
],[
|
||||
AC_MSG_RESULT(no, cross-compiling)
|
||||
PHP_DEFINE([ICONV_SUPPORTS_ERRNO],0,[ext/iconv])
|
||||
AC_DEFINE([ICONV_SUPPORTS_ERRNO],0,[Whether iconv supports IGNORE])
|
||||
PHP_DEFINE([ICONV_BROKEN_IGNORE],0,[ext/iconv])
|
||||
AC_DEFINE([ICONV_BROKEN_IGNORE],0,[Whether iconv supports IGNORE])
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([if your cpp allows macro usage in include lines])
|
||||
|
||||
@@ -112,7 +112,7 @@ PHP_FUNCTION(grapheme_strpos)
|
||||
int haystack_len, needle_len;
|
||||
unsigned char *found;
|
||||
long loffset = 0;
|
||||
int32_t offset = 0;
|
||||
int32_t offset = 0, noffset = 0;
|
||||
int ret_pos;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", (char **)&haystack, &haystack_len, (char **)&needle, &needle_len, &loffset) == FAILURE) {
|
||||
@@ -132,6 +132,7 @@ PHP_FUNCTION(grapheme_strpos)
|
||||
|
||||
/* we checked that it will fit: */
|
||||
offset = (int32_t) loffset;
|
||||
noffset = offset >= 0 ? offset : haystack_len + offset;
|
||||
|
||||
/* the offset is 'grapheme count offset' so it still might be invalid - we'll check it later */
|
||||
|
||||
@@ -146,7 +147,7 @@ PHP_FUNCTION(grapheme_strpos)
|
||||
/* quick check to see if the string might be there
|
||||
* I realize that 'offset' is 'grapheme count offset' but will work in spite of that
|
||||
*/
|
||||
found = (unsigned char *)php_memnstr((char *)haystack + offset, (char *)needle, needle_len, (char *)haystack + haystack_len);
|
||||
found = (unsigned char *)php_memnstr((char *)haystack + noffset, (char *)needle, needle_len, (char *)haystack + haystack_len);
|
||||
|
||||
/* if it isn't there the we are done */
|
||||
if (!found) {
|
||||
@@ -214,12 +215,13 @@ PHP_FUNCTION(grapheme_stripos)
|
||||
is_ascii = ( grapheme_ascii_check(haystack, haystack_len) >= 0 );
|
||||
|
||||
if ( is_ascii ) {
|
||||
int32_t noffset = offset >= 0 ? offset : haystack_len + offset;
|
||||
needle_dup = (unsigned char *)estrndup((char *)needle, needle_len);
|
||||
php_strtolower((char *)needle_dup, needle_len);
|
||||
haystack_dup = (unsigned char *)estrndup((char *)haystack, haystack_len);
|
||||
php_strtolower((char *)haystack_dup, haystack_len);
|
||||
|
||||
found = (unsigned char*) php_memnstr((char *)haystack_dup + offset, (char *)needle_dup, needle_len, (char *)haystack_dup + haystack_len);
|
||||
found = (unsigned char*) php_memnstr((char *)haystack_dup + noffset, (char *)needle_dup, needle_len, (char *)haystack_dup + haystack_len);
|
||||
|
||||
efree(haystack_dup);
|
||||
efree(needle_dup);
|
||||
@@ -537,7 +539,7 @@ PHP_FUNCTION(grapheme_substr)
|
||||
efree(ustr);
|
||||
}
|
||||
ubrk_close(bi);
|
||||
RETURN_EMPTY_STRING();
|
||||
RETURN_EMPTY_STRING();
|
||||
}
|
||||
|
||||
/* find the end point of the string to return */
|
||||
@@ -576,7 +578,7 @@ PHP_FUNCTION(grapheme_substr)
|
||||
sub_str_end_pos = ustr_len;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(sub_str_start_pos > sub_str_end_pos) {
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: length is beyond start", 1 TSRMLS_CC );
|
||||
|
||||
|
||||
+118
-117
@@ -65,26 +65,26 @@ ZEND_EXTERN_MODULE_GLOBALS( intl )
|
||||
*/
|
||||
static const char * const LOC_GRANDFATHERED[] = {
|
||||
"art-lojban", "i-klingon", "i-lux", "i-navajo", "no-bok", "no-nyn",
|
||||
"cel-gaulish", "en-GB-oed", "i-ami",
|
||||
"i-bnn", "i-default", "i-enochian",
|
||||
"i-mingo", "i-pwn", "i-tao",
|
||||
"cel-gaulish", "en-GB-oed", "i-ami",
|
||||
"i-bnn", "i-default", "i-enochian",
|
||||
"i-mingo", "i-pwn", "i-tao",
|
||||
"i-tay", "i-tsu", "sgn-BE-fr",
|
||||
"sgn-BE-nl", "sgn-CH-de", "zh-cmn",
|
||||
"zh-cmn-Hans", "zh-cmn-Hant", "zh-gan" ,
|
||||
"zh-guoyu", "zh-hakka", "zh-min",
|
||||
"zh-min-nan", "zh-wuu", "zh-xiang",
|
||||
"zh-min-nan", "zh-wuu", "zh-xiang",
|
||||
"zh-yue", NULL
|
||||
};
|
||||
|
||||
/* Based on IANA registry at the time of writing this code
|
||||
* This array lists the preferred values for the grandfathered tags if applicable
|
||||
* This is in sync with the array LOC_GRANDFATHERED
|
||||
* This is in sync with the array LOC_GRANDFATHERED
|
||||
* e.g. the offsets of the grandfathered tags match the offset of the preferred value
|
||||
*/
|
||||
static const int LOC_PREFERRED_GRANDFATHERED_LEN = 6;
|
||||
static const char * const LOC_PREFERRED_GRANDFATHERED[] = {
|
||||
"jbo", "tlh", "lb",
|
||||
"nv", "nb", "nn",
|
||||
"nv", "nb", "nn",
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -122,7 +122,7 @@ static int16_t findOffset(const char* const* list, const char* key)
|
||||
/*}}}*/
|
||||
|
||||
static char* getPreferredTag(const char* gf_tag)
|
||||
{
|
||||
{
|
||||
char* result = NULL;
|
||||
int grOffset = 0;
|
||||
|
||||
@@ -141,15 +141,15 @@ static char* getPreferredTag(const char* gf_tag)
|
||||
}
|
||||
|
||||
/* {{{
|
||||
* returns the position of next token for lookup
|
||||
* returns the position of next token for lookup
|
||||
* or -1 if no token
|
||||
* strtokr equivalent search for token in reverse direction
|
||||
* strtokr equivalent search for token in reverse direction
|
||||
*/
|
||||
static int getStrrtokenPos(char* str, int savedPos)
|
||||
{
|
||||
int result =-1;
|
||||
int i;
|
||||
|
||||
|
||||
for(i=savedPos-1; i>=0; i--) {
|
||||
if(isIDSeparator(*(str+i)) ){
|
||||
/* delimiter found; check for singleton */
|
||||
@@ -171,7 +171,7 @@ static int getStrrtokenPos(char* str, int savedPos)
|
||||
/* }}} */
|
||||
|
||||
/* {{{
|
||||
* returns the position of a singleton if present
|
||||
* returns the position of a singleton if present
|
||||
* returns -1 if no singleton
|
||||
* strtok equivalent search for singleton
|
||||
*/
|
||||
@@ -180,7 +180,7 @@ static int getSingletonPos(const char* str)
|
||||
int result =-1;
|
||||
int i=0;
|
||||
int len = 0;
|
||||
|
||||
|
||||
if( str && ((len=strlen(str))>0) ){
|
||||
for( i=0; i<len ; i++){
|
||||
if( isIDSeparator(*(str+i)) ){
|
||||
@@ -198,7 +198,7 @@ static int getSingletonPos(const char* str)
|
||||
}
|
||||
}
|
||||
}/* end of for */
|
||||
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ PHP_NAMED_FUNCTION(zif_locale_get_default)
|
||||
PHP_NAMED_FUNCTION(zif_locale_set_default)
|
||||
{
|
||||
char* locale_name = NULL;
|
||||
int len=0;
|
||||
int len=0;
|
||||
|
||||
if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
|
||||
&locale_name ,&len ) == FAILURE)
|
||||
@@ -240,14 +240,14 @@ PHP_NAMED_FUNCTION(zif_locale_set_default)
|
||||
len = strlen(locale_name);
|
||||
}
|
||||
|
||||
zend_alter_ini_entry(LOCALE_INI_NAME, sizeof(LOCALE_INI_NAME), locale_name, len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
|
||||
zend_alter_ini_entry(LOCALE_INI_NAME, sizeof(LOCALE_INI_NAME), locale_name, len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{
|
||||
* Gets the value from ICU
|
||||
* Gets the value from ICU
|
||||
* common code shared by get_primary_language,get_script or get_region or get_variant
|
||||
* result = 0 if error, 1 if successful , -1 if no value
|
||||
*/
|
||||
@@ -284,7 +284,7 @@ static char* get_icu_value_internal( const char* loc_name , char* tag_name, int*
|
||||
}
|
||||
}
|
||||
|
||||
singletonPos = getSingletonPos( loc_name );
|
||||
singletonPos = getSingletonPos( loc_name );
|
||||
if( singletonPos == 0){
|
||||
/* singleton at start of script, region , variant etc.
|
||||
* or invalid singleton at start of language */
|
||||
@@ -299,7 +299,7 @@ static char* get_icu_value_internal( const char* loc_name , char* tag_name, int*
|
||||
} /* end of if != LOC_CANONICAL_TAG */
|
||||
|
||||
if( mod_loc_name == NULL){
|
||||
mod_loc_name = estrdup(loc_name );
|
||||
mod_loc_name = estrdup(loc_name );
|
||||
}
|
||||
|
||||
/* Proceed to ICU */
|
||||
@@ -326,6 +326,7 @@ static char* get_icu_value_internal( const char* loc_name , char* tag_name, int*
|
||||
if( U_FAILURE( status ) ) {
|
||||
if( status == U_BUFFER_OVERFLOW_ERROR ) {
|
||||
status = U_ZERO_ERROR;
|
||||
buflen++; /* add space for \0 */
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -366,7 +367,7 @@ static char* get_icu_value_internal( const char* loc_name , char* tag_name, int*
|
||||
* Gets the value from ICU , called when PHP userspace function is called
|
||||
* common code shared by get_primary_language,get_script or get_region or get_variant
|
||||
*/
|
||||
static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
|
||||
static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
|
||||
const char* loc_name = NULL;
|
||||
@@ -422,37 +423,37 @@ static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto static string Locale::getScript($locale)
|
||||
* gets the script for the $locale
|
||||
/* {{{ proto static string Locale::getScript($locale)
|
||||
* gets the script for the $locale
|
||||
}}} */
|
||||
/* {{{ proto static string locale_get_script($locale)
|
||||
* gets the script for the $locale
|
||||
/* {{{ proto static string locale_get_script($locale)
|
||||
* gets the script for the $locale
|
||||
*/
|
||||
PHP_FUNCTION( locale_get_script )
|
||||
PHP_FUNCTION( locale_get_script )
|
||||
{
|
||||
get_icu_value_src_php( LOC_SCRIPT_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto static string Locale::getRegion($locale)
|
||||
* gets the region for the $locale
|
||||
/* {{{ proto static string Locale::getRegion($locale)
|
||||
* gets the region for the $locale
|
||||
}}} */
|
||||
/* {{{ proto static string locale_get_region($locale)
|
||||
* gets the region for the $locale
|
||||
/* {{{ proto static string locale_get_region($locale)
|
||||
* gets the region for the $locale
|
||||
*/
|
||||
PHP_FUNCTION( locale_get_region )
|
||||
PHP_FUNCTION( locale_get_region )
|
||||
{
|
||||
get_icu_value_src_php( LOC_REGION_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto static string Locale::getPrimaryLanguage($locale)
|
||||
* gets the primary language for the $locale
|
||||
/* {{{ proto static string Locale::getPrimaryLanguage($locale)
|
||||
* gets the primary language for the $locale
|
||||
}}} */
|
||||
/* {{{ proto static string locale_get_primary_language($locale)
|
||||
* gets the primary language for the $locale
|
||||
/* {{{ proto static string locale_get_primary_language($locale)
|
||||
* gets the primary language for the $locale
|
||||
*/
|
||||
PHP_FUNCTION(locale_get_primary_language )
|
||||
PHP_FUNCTION(locale_get_primary_language )
|
||||
{
|
||||
get_icu_value_src_php( LOC_LANG_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );
|
||||
}
|
||||
@@ -460,9 +461,9 @@ PHP_FUNCTION(locale_get_primary_language )
|
||||
|
||||
|
||||
/* {{{
|
||||
* common code shared by display_xyz functions to get the value from ICU
|
||||
* common code shared by display_xyz functions to get the value from ICU
|
||||
}}} */
|
||||
static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
|
||||
static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
const char* loc_name = NULL;
|
||||
int loc_name_len = 0;
|
||||
@@ -488,7 +489,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
|
||||
intl_error_reset( NULL TSRMLS_CC );
|
||||
|
||||
if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
|
||||
&loc_name, &loc_name_len ,
|
||||
&loc_name, &loc_name_len ,
|
||||
&disp_loc_name ,&disp_loc_name_len ) == FAILURE)
|
||||
{
|
||||
spprintf(&msg , 0, "locale_get_display_%s : unable to parse input params", tag_name );
|
||||
@@ -525,7 +526,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
|
||||
if( mod_loc_name==NULL ){
|
||||
mod_loc_name = estrdup( loc_name );
|
||||
}
|
||||
|
||||
|
||||
/* Check if disp_loc_name passed , if not use default locale */
|
||||
if( !disp_loc_name){
|
||||
disp_loc_name = estrdup(intl_locale_get_default(TSRMLS_C));
|
||||
@@ -604,7 +605,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
|
||||
/* {{{ proto static string get_display_name($locale[, $in_locale = null])
|
||||
* gets the name for the $locale in $in_locale or default_locale
|
||||
*/
|
||||
PHP_FUNCTION(locale_get_display_name)
|
||||
PHP_FUNCTION(locale_get_display_name)
|
||||
{
|
||||
get_icu_disp_value_src_php( DISP_NAME , INTERNAL_FUNCTION_PARAM_PASSTHRU );
|
||||
}
|
||||
@@ -616,7 +617,7 @@ PHP_FUNCTION(locale_get_display_name)
|
||||
/* {{{ proto static string get_display_language($locale[, $in_locale = null])
|
||||
* gets the language for the $locale in $in_locale or default_locale
|
||||
*/
|
||||
PHP_FUNCTION(locale_get_display_language)
|
||||
PHP_FUNCTION(locale_get_display_language)
|
||||
{
|
||||
get_icu_disp_value_src_php( LOC_LANG_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );
|
||||
}
|
||||
@@ -628,7 +629,7 @@ PHP_FUNCTION(locale_get_display_language)
|
||||
/* {{{ proto static string get_display_script($locale, $in_locale = null)
|
||||
* gets the script for the $locale in $in_locale or default_locale
|
||||
*/
|
||||
PHP_FUNCTION(locale_get_display_script)
|
||||
PHP_FUNCTION(locale_get_display_script)
|
||||
{
|
||||
get_icu_disp_value_src_php( LOC_SCRIPT_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );
|
||||
}
|
||||
@@ -640,7 +641,7 @@ PHP_FUNCTION(locale_get_display_script)
|
||||
/* {{{ proto static string get_display_region($locale, $in_locale = null)
|
||||
* gets the region for the $locale in $in_locale or default_locale
|
||||
*/
|
||||
PHP_FUNCTION(locale_get_display_region)
|
||||
PHP_FUNCTION(locale_get_display_region)
|
||||
{
|
||||
get_icu_disp_value_src_php( LOC_REGION_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );
|
||||
}
|
||||
@@ -654,7 +655,7 @@ PHP_FUNCTION(locale_get_display_region)
|
||||
* proto static string get_display_variant($locale, $in_locale = null)
|
||||
* gets the variant for the $locale in $in_locale or default_locale
|
||||
*/
|
||||
PHP_FUNCTION(locale_get_display_variant)
|
||||
PHP_FUNCTION(locale_get_display_variant)
|
||||
{
|
||||
get_icu_disp_value_src_php( LOC_VARIANT_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );
|
||||
}
|
||||
@@ -667,7 +668,7 @@ PHP_FUNCTION(locale_get_display_variant)
|
||||
/* {{{ proto static array locale_get_keywords(string $locale) {
|
||||
* return an associative array containing keyword-value
|
||||
* pairs for this locale. The keys are keys to the array (doh!)
|
||||
*/
|
||||
*/
|
||||
PHP_FUNCTION( locale_get_keywords )
|
||||
{
|
||||
UEnumeration* e = NULL;
|
||||
@@ -679,10 +680,10 @@ PHP_FUNCTION( locale_get_keywords )
|
||||
const char* loc_name = NULL;
|
||||
int loc_name_len = 0;
|
||||
|
||||
/*
|
||||
ICU expects the buffer to be allocated before calling the function
|
||||
and so the buffer size has been explicitly specified
|
||||
ICU uloc.h #define ULOC_KEYWORD_AND_VALUES_CAPACITY 100
|
||||
/*
|
||||
ICU expects the buffer to be allocated before calling the function
|
||||
and so the buffer size has been explicitly specified
|
||||
ICU uloc.h #define ULOC_KEYWORD_AND_VALUES_CAPACITY 100
|
||||
hence the kw_value buffer size is 100
|
||||
*/
|
||||
char* kw_value = NULL;
|
||||
@@ -721,7 +722,7 @@ PHP_FUNCTION( locale_get_keywords )
|
||||
kw_value_len=uloc_getKeywordValue( loc_name,kw_key, kw_value, kw_value_len+1 , &status );
|
||||
} else if(!U_FAILURE(status)) {
|
||||
kw_value = erealloc( kw_value , kw_value_len+1);
|
||||
}
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "locale_get_keywords: Error encountered while getting the keyword value for the keyword", 0 TSRMLS_CC );
|
||||
if( kw_value){
|
||||
@@ -740,10 +741,10 @@ PHP_FUNCTION( locale_get_keywords )
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto static string Locale::canonicalize($locale)
|
||||
* @return string the canonicalized locale
|
||||
/* {{{ proto static string Locale::canonicalize($locale)
|
||||
* @return string the canonicalized locale
|
||||
* }}} */
|
||||
/* {{{ proto static string locale_canonicalize(Locale $loc, string $locale)
|
||||
/* {{{ proto static string locale_canonicalize(Locale $loc, string $locale)
|
||||
* @param string $locale The locale string to canonicalize
|
||||
*/
|
||||
PHP_FUNCTION(locale_canonicalize)
|
||||
@@ -752,10 +753,10 @@ PHP_FUNCTION(locale_canonicalize)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ append_key_value
|
||||
/* {{{ append_key_value
|
||||
* Internal function which is called from locale_compose
|
||||
* gets the value for the key_name and appends to the loc_name
|
||||
* returns 1 if successful , -1 if not found ,
|
||||
* returns 1 if successful , -1 if not found ,
|
||||
* 0 if array element is not a string , -2 if buffer-overflow
|
||||
*/
|
||||
static int append_key_value(smart_str* loc_name, HashTable* hash_arr, char* key_name)
|
||||
@@ -767,7 +768,7 @@ static int append_key_value(smart_str* loc_name, HashTable* hash_arr, char* key_
|
||||
/* element value is not a string */
|
||||
return FAILURE;
|
||||
}
|
||||
if(strcmp(key_name, LOC_LANG_TAG) != 0 &&
|
||||
if(strcmp(key_name, LOC_LANG_TAG) != 0 &&
|
||||
strcmp(key_name, LOC_GRANDFATHERED_LANG_TAG)!=0 ) {
|
||||
/* not lang or grandfathered tag */
|
||||
smart_str_appendl(loc_name, SEPARATOR , sizeof(SEPARATOR)-1);
|
||||
@@ -792,11 +793,11 @@ static void add_prefix(smart_str* loc_name, char* key_name)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ append_multiple_key_values
|
||||
/* {{{ append_multiple_key_values
|
||||
* Internal function which is called from locale_compose
|
||||
* gets the multiple values for the key_name and appends to the loc_name
|
||||
* used for 'variant','extlang','private'
|
||||
* returns 1 if successful , -1 if not found ,
|
||||
* used for 'variant','extlang','private'
|
||||
* returns 1 if successful , -1 if not found ,
|
||||
* 0 if array element is not a string , -2 if buffer-overflow
|
||||
*/
|
||||
static int append_multiple_key_values(smart_str* loc_name, HashTable* hash_arr, char* key_name TSRMLS_DC)
|
||||
@@ -850,8 +851,8 @@ static int append_multiple_key_values(smart_str* loc_name, HashTable* hash_arr,
|
||||
|
||||
/* Multiple variant values as variant0, variant1 ,variant2 */
|
||||
isFirstSubtag = 0;
|
||||
for( i=0 ; i< max_value; i++ ){
|
||||
snprintf( cur_key_name , 30, "%s%d", key_name , i);
|
||||
for( i=0 ; i< max_value; i++ ){
|
||||
snprintf( cur_key_name , 30, "%s%d", key_name , i);
|
||||
if( zend_hash_find( hash_arr , cur_key_name , strlen(cur_key_name) + 1,(void **)&ele_value ) == SUCCESS ){
|
||||
if( Z_TYPE_PP(ele_value)!= IS_STRING ){
|
||||
/* variant is not a string */
|
||||
@@ -873,7 +874,7 @@ static int append_multiple_key_values(smart_str* loc_name, HashTable* hash_arr,
|
||||
|
||||
/*{{{
|
||||
* If applicable sets error message and aborts locale_compose gracefully
|
||||
* returns 0 if locale_compose needs to be aborted
|
||||
* returns 0 if locale_compose needs to be aborted
|
||||
* otherwise returns 1
|
||||
*/
|
||||
static int handleAppendResult( int result, smart_str* loc_name TSRMLS_DC)
|
||||
@@ -890,11 +891,11 @@ static int handleAppendResult( int result, smart_str* loc_name TSRMLS_DC)
|
||||
/* }}} */
|
||||
|
||||
#define RETURN_SMART_STR(s) smart_str_0((s)); RETURN_STRINGL((s)->c, (s)->len, 0)
|
||||
/* {{{ proto static string Locale::composeLocale($array)
|
||||
* Creates a locale by combining the parts of locale-ID passed
|
||||
/* {{{ proto static string Locale::composeLocale($array)
|
||||
* Creates a locale by combining the parts of locale-ID passed
|
||||
* }}} */
|
||||
/* {{{ proto static string compose_locale($array)
|
||||
* Creates a locale by combining the parts of locale-ID passed
|
||||
/* {{{ proto static string compose_locale($array)
|
||||
* Creates a locale by combining the parts of locale-ID passed
|
||||
* }}} */
|
||||
PHP_FUNCTION(locale_compose)
|
||||
{
|
||||
@@ -920,7 +921,7 @@ PHP_FUNCTION(locale_compose)
|
||||
RETURN_FALSE;
|
||||
|
||||
/* Check for grandfathered first */
|
||||
result = append_key_value(loc_name, hash_arr, LOC_GRANDFATHERED_LANG_TAG);
|
||||
result = append_key_value(loc_name, hash_arr, LOC_GRANDFATHERED_LANG_TAG);
|
||||
if( result == SUCCESS){
|
||||
RETURN_SMART_STR(loc_name);
|
||||
}
|
||||
@@ -929,7 +930,7 @@ PHP_FUNCTION(locale_compose)
|
||||
}
|
||||
|
||||
/* Not grandfathered */
|
||||
result = append_key_value(loc_name, hash_arr , LOC_LANG_TAG);
|
||||
result = append_key_value(loc_name, hash_arr , LOC_LANG_TAG);
|
||||
if( result == LOC_NOT_FOUND ){
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"locale_compose: parameter array does not contain 'language' tag.", 0 TSRMLS_CC );
|
||||
@@ -947,11 +948,11 @@ PHP_FUNCTION(locale_compose)
|
||||
}
|
||||
|
||||
/* Script */
|
||||
result = append_key_value(loc_name, hash_arr , LOC_SCRIPT_TAG);
|
||||
result = append_key_value(loc_name, hash_arr , LOC_SCRIPT_TAG);
|
||||
if( !handleAppendResult( result, loc_name TSRMLS_CC)){
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Region */
|
||||
result = append_key_value( loc_name, hash_arr , LOC_REGION_TAG);
|
||||
if( !handleAppendResult( result, loc_name TSRMLS_CC)){
|
||||
@@ -959,7 +960,7 @@ PHP_FUNCTION(locale_compose)
|
||||
}
|
||||
|
||||
/* Variant */
|
||||
result = append_multiple_key_values( loc_name, hash_arr , LOC_VARIANT_TAG TSRMLS_CC);
|
||||
result = append_multiple_key_values( loc_name, hash_arr , LOC_VARIANT_TAG TSRMLS_CC);
|
||||
if( !handleAppendResult( result, loc_name TSRMLS_CC)){
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -985,16 +986,16 @@ static char* get_private_subtags(const char* loc_name)
|
||||
{
|
||||
char* result =NULL;
|
||||
int singletonPos = 0;
|
||||
int len =0;
|
||||
int len =0;
|
||||
const char* mod_loc_name =NULL;
|
||||
|
||||
if( loc_name && (len = strlen(loc_name)>0 ) ){
|
||||
mod_loc_name = loc_name ;
|
||||
mod_loc_name = loc_name ;
|
||||
len = strlen(mod_loc_name);
|
||||
while( (singletonPos = getSingletonPos(mod_loc_name))!= -1){
|
||||
|
||||
if( singletonPos!=-1){
|
||||
if( (*(mod_loc_name+singletonPos)=='x') || (*(mod_loc_name+singletonPos)=='X') ){
|
||||
if( singletonPos!=-1){
|
||||
if( (*(mod_loc_name+singletonPos)=='x') || (*(mod_loc_name+singletonPos)=='X') ){
|
||||
/* private subtag start found */
|
||||
if( singletonPos + 2 == len){
|
||||
/* loc_name ends with '-x-' ; return NULL */
|
||||
@@ -1019,7 +1020,7 @@ static char* get_private_subtags(const char* loc_name)
|
||||
|
||||
} /* end of while */
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -1044,20 +1045,20 @@ static int add_array_entry(const char* loc_name, zval* hash_arr, char* key_name
|
||||
} else {
|
||||
key_value = get_icu_value_internal( loc_name , key_name , &result,1 );
|
||||
}
|
||||
if( (strcmp(key_name , LOC_PRIVATE_TAG)==0) ||
|
||||
if( (strcmp(key_name , LOC_PRIVATE_TAG)==0) ||
|
||||
( strcmp(key_name , LOC_VARIANT_TAG)==0) ){
|
||||
if( result > 0 && key_value){
|
||||
/* Tokenize on the "_" or "-" */
|
||||
token = php_strtok_r( key_value , DELIMITER ,&last_ptr);
|
||||
token = php_strtok_r( key_value , DELIMITER ,&last_ptr);
|
||||
if( cur_key_name ){
|
||||
efree( cur_key_name);
|
||||
}
|
||||
cur_key_name = (char*)ecalloc( 25, 25);
|
||||
sprintf( cur_key_name , "%s%d", key_name , cnt++);
|
||||
sprintf( cur_key_name , "%s%d", key_name , cnt++);
|
||||
add_assoc_string( hash_arr, cur_key_name , token ,TRUE );
|
||||
/* tokenize on the "_" or "-" and stop at singleton if any */
|
||||
while( (token = php_strtok_r(NULL , DELIMITER , &last_ptr)) && (strlen(token)>1) ){
|
||||
sprintf( cur_key_name , "%s%d", key_name , cnt++);
|
||||
sprintf( cur_key_name , "%s%d", key_name , cnt++);
|
||||
add_assoc_string( hash_arr, cur_key_name , token , TRUE );
|
||||
}
|
||||
/*
|
||||
@@ -1077,16 +1078,16 @@ static int add_array_entry(const char* loc_name, zval* hash_arr, char* key_name
|
||||
}
|
||||
/*if( key_name != LOC_PRIVATE_TAG && key_value){*/
|
||||
if( key_value){
|
||||
efree(key_value);
|
||||
efree(key_value);
|
||||
}
|
||||
return cur_result;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto static array Locale::parseLocale($locale)
|
||||
/* {{{ proto static array Locale::parseLocale($locale)
|
||||
* parses a locale-id into an array the different parts of it
|
||||
}}} */
|
||||
/* {{{ proto static array parse_locale($locale)
|
||||
/* {{{ proto static array parse_locale($locale)
|
||||
* parses a locale-id into an array the different parts of it
|
||||
*/
|
||||
PHP_FUNCTION(locale_parse)
|
||||
@@ -1144,7 +1145,7 @@ PHP_FUNCTION(locale_get_all_variants)
|
||||
char* saved_ptr = NULL;
|
||||
|
||||
intl_error_reset( NULL TSRMLS_CC );
|
||||
|
||||
|
||||
if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
|
||||
&loc_name, &loc_name_len ) == FAILURE)
|
||||
{
|
||||
@@ -1162,15 +1163,15 @@ PHP_FUNCTION(locale_get_all_variants)
|
||||
array_init( return_value );
|
||||
|
||||
/* If the locale is grandfathered, stop, no variants */
|
||||
if( findOffset( LOC_GRANDFATHERED , loc_name ) >= 0 ){
|
||||
if( findOffset( LOC_GRANDFATHERED , loc_name ) >= 0 ){
|
||||
/* ("Grandfathered Tag. No variants."); */
|
||||
}
|
||||
else {
|
||||
else {
|
||||
/* Call ICU variant */
|
||||
variant = get_icu_value_internal( loc_name , LOC_VARIANT_TAG , &result ,0);
|
||||
if( result > 0 && variant){
|
||||
/* Tokenize on the "_" or "-" */
|
||||
token = php_strtok_r( variant , DELIMITER , &saved_ptr);
|
||||
token = php_strtok_r( variant , DELIMITER , &saved_ptr);
|
||||
add_next_index_stringl( return_value, token , strlen(token) ,TRUE );
|
||||
/* tokenize on the "_" or "-" and stop at singleton if any */
|
||||
while( (token = php_strtok_r(NULL , DELIMITER, &saved_ptr)) && (strlen(token)>1) ){
|
||||
@@ -1181,7 +1182,7 @@ PHP_FUNCTION(locale_get_all_variants)
|
||||
efree( variant );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
@@ -1220,11 +1221,11 @@ static int strToMatch(const char* str ,char *retstr)
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto static boolean Locale::filterMatches(string $langtag, string $locale[, bool $canonicalize])
|
||||
* Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm
|
||||
* Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm
|
||||
*/
|
||||
/* }}} */
|
||||
/* {{{ proto boolean locale_filter_matches(string $langtag, string $locale[, bool $canonicalize])
|
||||
* Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm
|
||||
* Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm
|
||||
*/
|
||||
PHP_FUNCTION(locale_filter_matches)
|
||||
{
|
||||
@@ -1243,13 +1244,13 @@ PHP_FUNCTION(locale_filter_matches)
|
||||
char* cur_lang_tag = NULL;
|
||||
char* cur_loc_range = NULL;
|
||||
|
||||
zend_bool boolCanonical = 0;
|
||||
zend_bool boolCanonical = 0;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
intl_error_reset( NULL TSRMLS_CC );
|
||||
|
||||
|
||||
if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "ss|b",
|
||||
&lang_tag, &lang_tag_len , &loc_range , &loc_range_len ,
|
||||
&lang_tag, &lang_tag_len , &loc_range , &loc_range_len ,
|
||||
&boolCanonical) == FAILURE)
|
||||
{
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
@@ -1270,7 +1271,7 @@ PHP_FUNCTION(locale_filter_matches)
|
||||
/* canonicalize loc_range */
|
||||
can_loc_range=get_icu_value_internal( loc_range , LOC_CANONICALIZE_TAG , &result , 0);
|
||||
if( result ==0) {
|
||||
intl_error_set( NULL, status,
|
||||
intl_error_set( NULL, status,
|
||||
"locale_filter_matches : unable to canonicalize loc_range" , 0 TSRMLS_CC );
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -1278,7 +1279,7 @@ PHP_FUNCTION(locale_filter_matches)
|
||||
/* canonicalize lang_tag */
|
||||
can_lang_tag = get_icu_value_internal( lang_tag , LOC_CANONICALIZE_TAG , &result , 0);
|
||||
if( result ==0) {
|
||||
intl_error_set( NULL, status,
|
||||
intl_error_set( NULL, status,
|
||||
"locale_filter_matches : unable to canonicalize lang_tag" , 0 TSRMLS_CC );
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -1306,11 +1307,11 @@ PHP_FUNCTION(locale_filter_matches)
|
||||
|
||||
/* check if prefix */
|
||||
token = strstr( cur_lang_tag , cur_loc_range );
|
||||
|
||||
|
||||
if( token && (token==cur_lang_tag) ){
|
||||
/* check if the char. after match is SEPARATOR */
|
||||
chrcheck = token + (strlen(cur_loc_range));
|
||||
if( isIDSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
|
||||
if( isIDSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
|
||||
if( cur_lang_tag){
|
||||
efree( cur_lang_tag );
|
||||
}
|
||||
@@ -1346,7 +1347,7 @@ PHP_FUNCTION(locale_filter_matches)
|
||||
else{
|
||||
/* Convert to lower case for case-insensitive comparison */
|
||||
cur_lang_tag = ecalloc( 1, strlen(lang_tag ) + 1);
|
||||
|
||||
|
||||
result = strToMatch( lang_tag , cur_lang_tag);
|
||||
if( result == 0) {
|
||||
efree( cur_lang_tag );
|
||||
@@ -1362,11 +1363,11 @@ PHP_FUNCTION(locale_filter_matches)
|
||||
|
||||
/* check if prefix */
|
||||
token = strstr( cur_lang_tag , cur_loc_range );
|
||||
|
||||
|
||||
if( token && (token==cur_lang_tag) ){
|
||||
/* check if the char. after match is SEPARATOR */
|
||||
chrcheck = token + (strlen(cur_loc_range));
|
||||
if( isIDSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
|
||||
if( isIDSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
|
||||
if( cur_lang_tag){
|
||||
efree( cur_lang_tag );
|
||||
}
|
||||
@@ -1393,7 +1394,7 @@ PHP_FUNCTION(locale_filter_matches)
|
||||
static void array_cleanup( char* arr[] , int arr_size)
|
||||
{
|
||||
int i=0;
|
||||
for( i=0; i< arr_size; i++ ){
|
||||
for( i=0; i< arr_size; i++ ){
|
||||
if( arr[i*2] ){
|
||||
efree( arr[i*2]);
|
||||
}
|
||||
@@ -1403,7 +1404,7 @@ static void array_cleanup( char* arr[] , int arr_size)
|
||||
|
||||
#define LOOKUP_CLEAN_RETURN(value) array_cleanup(cur_arr, cur_arr_len); return (value)
|
||||
/* {{{
|
||||
* returns the lookup result to lookup_loc_range_src_php
|
||||
* returns the lookup result to lookup_loc_range_src_php
|
||||
* internal function
|
||||
*/
|
||||
static char* lookup_loc_range(const char* loc_range, HashTable* hash_arr, int canonicalize TSRMLS_DC)
|
||||
@@ -1427,7 +1428,7 @@ static char* lookup_loc_range(const char* loc_range, HashTable* hash_arr, int ca
|
||||
for(zend_hash_internal_pointer_reset(hash_arr);
|
||||
zend_hash_has_more_elements(hash_arr) == SUCCESS;
|
||||
zend_hash_move_forward(hash_arr)) {
|
||||
|
||||
|
||||
if (zend_hash_get_current_data(hash_arr, (void**)&ele_value) == FAILURE) {
|
||||
/* Should never actually fail since the key is known to exist.*/
|
||||
continue;
|
||||
@@ -1436,7 +1437,7 @@ static char* lookup_loc_range(const char* loc_range, HashTable* hash_arr, int ca
|
||||
/* element value is not a string */
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: locale array element is not a string", 0 TSRMLS_CC);
|
||||
LOOKUP_CLEAN_RETURN(NULL);
|
||||
}
|
||||
}
|
||||
cur_arr[cur_arr_len*2] = estrndup(Z_STRVAL_PP(ele_value), Z_STRLEN_PP(ele_value));
|
||||
result = strToMatch(Z_STRVAL_PP(ele_value), cur_arr[cur_arr_len*2]);
|
||||
if(result == 0) {
|
||||
@@ -1444,12 +1445,12 @@ static char* lookup_loc_range(const char* loc_range, HashTable* hash_arr, int ca
|
||||
LOOKUP_CLEAN_RETURN(NULL);
|
||||
}
|
||||
cur_arr[cur_arr_len*2+1] = Z_STRVAL_PP(ele_value);
|
||||
cur_arr_len++ ;
|
||||
cur_arr_len++ ;
|
||||
} /* end of for */
|
||||
|
||||
/* Canonicalize array elements */
|
||||
if(canonicalize) {
|
||||
for(i=0; i<cur_arr_len; i++) {
|
||||
for(i=0; i<cur_arr_len; i++) {
|
||||
lang_tag = get_icu_value_internal(cur_arr[i*2], LOC_CANONICALIZE_TAG, &result, 0);
|
||||
if(result != 1 || lang_tag == NULL || !lang_tag[0]) {
|
||||
if(lang_tag) {
|
||||
@@ -1459,7 +1460,7 @@ static char* lookup_loc_range(const char* loc_range, HashTable* hash_arr, int ca
|
||||
LOOKUP_CLEAN_RETURN(NULL);
|
||||
}
|
||||
cur_arr[i*2] = erealloc(cur_arr[i*2], strlen(lang_tag)+1);
|
||||
result = strToMatch(lang_tag, cur_arr[i*2]);
|
||||
result = strToMatch(lang_tag, cur_arr[i*2]);
|
||||
efree(lang_tag);
|
||||
if(result == 0) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag" , 0 TSRMLS_CC);
|
||||
@@ -1482,11 +1483,11 @@ static char* lookup_loc_range(const char* loc_range, HashTable* hash_arr, int ca
|
||||
} else {
|
||||
loc_range = can_loc_range;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_loc_range = ecalloc(1, strlen(loc_range)+1);
|
||||
/* convert to lower and replace hyphens */
|
||||
result = strToMatch(loc_range, cur_loc_range);
|
||||
result = strToMatch(loc_range, cur_loc_range);
|
||||
if(can_loc_range) {
|
||||
efree(can_loc_range);
|
||||
}
|
||||
@@ -1498,8 +1499,8 @@ static char* lookup_loc_range(const char* loc_range, HashTable* hash_arr, int ca
|
||||
/* Lookup for the lang_tag match */
|
||||
saved_pos = strlen(cur_loc_range);
|
||||
while(saved_pos > 0) {
|
||||
for(i=0; i< cur_arr_len; i++){
|
||||
if(cur_arr[i*2] != NULL && strlen(cur_arr[i*2]) == saved_pos && strncmp(cur_loc_range, cur_arr[i*2], saved_pos) == 0) {
|
||||
for(i=0; i< cur_arr_len; i++){
|
||||
if(cur_arr[i*2] != NULL && strlen(cur_arr[i*2]) == saved_pos && strncmp(cur_loc_range, cur_arr[i*2], saved_pos) == 0) {
|
||||
/* Match found */
|
||||
return_value = estrdup(canonicalize?cur_arr[i*2]:cur_arr[i*2+1]);
|
||||
efree(cur_loc_range);
|
||||
@@ -1515,14 +1516,14 @@ static char* lookup_loc_range(const char* loc_range, HashTable* hash_arr, int ca
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string Locale::lookup(array $langtag, string $locale[, bool $canonicalize[, string $default = null]])
|
||||
/* {{{ proto string Locale::lookup(array $langtag, string $locale[, bool $canonicalize[, string $default = null]])
|
||||
* Searchs the items in $langtag for the best match to the language
|
||||
* range
|
||||
* range
|
||||
*/
|
||||
/* }}} */
|
||||
/* {{{ proto string locale_lookup(array $langtag, string $locale[, bool $canonicalize[, string $default = null]])
|
||||
* Searchs the items in $langtag for the best match to the language
|
||||
* range
|
||||
* range
|
||||
*/
|
||||
PHP_FUNCTION(locale_lookup)
|
||||
{
|
||||
@@ -1552,8 +1553,8 @@ PHP_FUNCTION(locale_lookup)
|
||||
|
||||
if( !hash_arr || zend_hash_num_elements( hash_arr ) == 0 ) {
|
||||
RETURN_EMPTY_STRING();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
result = lookup_loc_range(loc_range, hash_arr, boolCanonical TSRMLS_CC);
|
||||
if(result == NULL || result[0] == '\0') {
|
||||
if( fallback_loc ) {
|
||||
@@ -1590,10 +1591,10 @@ PHP_FUNCTION(locale_accept_from_http)
|
||||
"locale_accept_from_http: unable to parse input parameters", 0 TSRMLS_CC );
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
available = ures_openAvailableLocales(NULL, &status);
|
||||
INTL_CHECK_STATUS(status, "locale_accept_from_http: failed to retrieve locale list");
|
||||
len = uloc_acceptLanguageFromHTTP(resultLocale, INTL_MAX_LOCALE_LEN,
|
||||
len = uloc_acceptLanguageFromHTTP(resultLocale, INTL_MAX_LOCALE_LEN,
|
||||
&outResult, http_accept, available, &status);
|
||||
uenum_close(available);
|
||||
INTL_CHECK_STATUS(status, "locale_accept_from_http: failed to find acceptable locale");
|
||||
|
||||
@@ -12,7 +12,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
setlocale(LC_ALL, 'de_DE');
|
||||
setlocale(LC_ALL, 'de_DE.UTF-8');
|
||||
$fmt = new NumberFormatter( 'sl_SI.UTF-8', NumberFormatter::DECIMAL);
|
||||
$num = "1.234.567,891";
|
||||
$res_str = $fmt->parse($num)."\n";
|
||||
@@ -26,5 +26,5 @@ ut_run();
|
||||
?>
|
||||
--EXPECT--
|
||||
1234567,891
|
||||
de_DE
|
||||
de_DE.UTF-8
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #72061: Out-of-bounds reads in zif_grapheme_stripos with negative offset
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(grapheme_stripos(str_repeat("ABCD", 16384), "A", -201));
|
||||
var_dump(grapheme_strpos(str_repeat("ABCD", 16384), "A", -201));
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
int(65336)
|
||||
int(65336)
|
||||
DONE
|
||||
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
Bug #72241: get_icu_value_internal out-of-bounds read
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$var1=str_repeat("A", 1000);
|
||||
$out = locale_get_primary_language($var1);
|
||||
echo strlen($out) . PHP_EOL;
|
||||
echo unpack('H*', $out)[1] . PHP_EOL;
|
||||
--EXPECT--
|
||||
1000
|
||||
61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* Unicode support
|
||||
*
|
||||
* Portions copyright (c) 1999,2000,2001 by the PHP3 internationalization team.
|
||||
@@ -137,7 +137,7 @@ mbfl_buffer_converter_new(
|
||||
mbfl_buffer_converter *
|
||||
mbfl_buffer_converter_new2(
|
||||
const mbfl_encoding *from,
|
||||
const mbfl_encoding *to,
|
||||
const mbfl_encoding *to,
|
||||
int buf_initsz)
|
||||
{
|
||||
mbfl_buffer_converter *convd;
|
||||
@@ -339,7 +339,7 @@ mbfl_buffer_converter_result(mbfl_buffer_converter *convd, mbfl_string *result)
|
||||
}
|
||||
|
||||
mbfl_string *
|
||||
mbfl_buffer_converter_feed_result(mbfl_buffer_converter *convd, mbfl_string *string,
|
||||
mbfl_buffer_converter_feed_result(mbfl_buffer_converter *convd, mbfl_string *string,
|
||||
mbfl_string *result)
|
||||
{
|
||||
if (convd == NULL || string == NULL || result == NULL) {
|
||||
@@ -535,7 +535,7 @@ const mbfl_encoding *mbfl_encoding_detector_judge2(mbfl_encoding_detector *ident
|
||||
}
|
||||
n--;
|
||||
}
|
||||
|
||||
|
||||
/* fallback judge */
|
||||
if (!encoding) {
|
||||
n = identd->filter_list_size - 1;
|
||||
@@ -702,7 +702,7 @@ mbfl_identify_encoding(mbfl_string *string, enum mbfl_no_encoding *elist, int el
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cleanup */
|
||||
/* dtors should be called in reverse order */
|
||||
i = num; while (--i >= 0) {
|
||||
@@ -785,7 +785,7 @@ mbfl_identify_encoding2(mbfl_string *string, const mbfl_encoding **elist, int el
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cleanup */
|
||||
/* dtors should be called in reverse order */
|
||||
i = num; while (--i >= 0) {
|
||||
@@ -844,7 +844,7 @@ mbfl_strlen(mbfl_string *string)
|
||||
} else {
|
||||
/* wchar filter */
|
||||
mbfl_convert_filter *filter = mbfl_convert_filter_new(
|
||||
string->no_encoding,
|
||||
string->no_encoding,
|
||||
mbfl_no_encoding_wchar,
|
||||
filter_count_output, 0, &len);
|
||||
if (filter == NULL) {
|
||||
@@ -865,7 +865,7 @@ mbfl_strlen(mbfl_string *string)
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* strpos
|
||||
*/
|
||||
@@ -931,7 +931,7 @@ retry:
|
||||
/*
|
||||
* oddlen
|
||||
*/
|
||||
int
|
||||
int
|
||||
mbfl_oddlen(mbfl_string *string)
|
||||
{
|
||||
int len, n, m, k;
|
||||
@@ -1071,7 +1071,7 @@ mbfl_strpos(
|
||||
++result;
|
||||
} else if ((c & 0xc0) != 0x80) {
|
||||
++result;
|
||||
}
|
||||
}
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
@@ -1116,7 +1116,7 @@ mbfl_strpos(
|
||||
qe = needle_u8_val + needle_u8_len;
|
||||
if (offset < 0) {
|
||||
if (-offset > needle_len) {
|
||||
offset += needle_len;
|
||||
offset += needle_len;
|
||||
while (offset < 0) {
|
||||
unsigned char c;
|
||||
if (p <= e) {
|
||||
@@ -1158,7 +1158,7 @@ mbfl_strpos(
|
||||
++result;
|
||||
} else if ((c & 0xc0) != 0x80) {
|
||||
++result;
|
||||
}
|
||||
}
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
@@ -1501,7 +1501,7 @@ mbfl_strcut(
|
||||
if (encoding->flag & (MBFL_ENCTYPE_WCS2BE | MBFL_ENCTYPE_WCS2LE)) {
|
||||
from &= -2;
|
||||
|
||||
if (from + length >= string->len) {
|
||||
if (length >= string->len - from) {
|
||||
length = string->len - from;
|
||||
}
|
||||
|
||||
@@ -1510,14 +1510,14 @@ mbfl_strcut(
|
||||
} else if (encoding->flag & (MBFL_ENCTYPE_WCS4BE | MBFL_ENCTYPE_WCS4LE)) {
|
||||
from &= -4;
|
||||
|
||||
if (from + length >= string->len) {
|
||||
if (length >= string->len - from) {
|
||||
length = string->len - from;
|
||||
}
|
||||
|
||||
start = string->val + from;
|
||||
end = start + (length & -4);
|
||||
} else if ((encoding->flag & MBFL_ENCTYPE_SBCS)) {
|
||||
if (from + length >= string->len) {
|
||||
if (length >= string->len - from) {
|
||||
length = string->len - from;
|
||||
}
|
||||
|
||||
@@ -1539,7 +1539,7 @@ mbfl_strcut(
|
||||
start = p;
|
||||
|
||||
/* search end position */
|
||||
if ((start - string->val) + length >= (int)string->len) {
|
||||
if (length >= (int)string->len - (start - string->val)) {
|
||||
end = string->val + string->len;
|
||||
} else {
|
||||
for (q = p + length; p < q; p += (m = mbtab[*p]));
|
||||
@@ -2024,7 +2024,7 @@ mbfl_ja_jp_hantozen(
|
||||
mbfl_no_encoding_wchar,
|
||||
(int(*)(int, void*))next_filter->filter_function,
|
||||
(int(*)(void*))next_filter->filter_flush,
|
||||
next_filter);
|
||||
next_filter);
|
||||
if (encoder == NULL) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
+32
-33
@@ -32,7 +32,7 @@
|
||||
#include "ext/standard/info.h"
|
||||
#include "php_mbregex.h"
|
||||
#include "mbstring.h"
|
||||
|
||||
|
||||
#include "php_onig_compat.h" /* must come prior to the oniguruma header */
|
||||
#include <oniguruma.h>
|
||||
#undef UChar
|
||||
@@ -55,7 +55,7 @@ struct _zend_mb_regex_globals {
|
||||
#define MBREX(g) (MBSTRG(mb_regex_globals)->g)
|
||||
|
||||
/* {{{ static void php_mb_regex_free_cache() */
|
||||
static void php_mb_regex_free_cache(php_mb_regex_t **pre)
|
||||
static void php_mb_regex_free_cache(php_mb_regex_t **pre)
|
||||
{
|
||||
onig_free(*pre);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ static int _php_mb_regex_globals_ctor(zend_mb_regex_globals *pglobals TSRMLS_DC)
|
||||
/* }}} */
|
||||
|
||||
/* {{{ _php_mb_regex_globals_dtor */
|
||||
static void _php_mb_regex_globals_dtor(zend_mb_regex_globals *pglobals TSRMLS_DC)
|
||||
static void _php_mb_regex_globals_dtor(zend_mb_regex_globals *pglobals TSRMLS_DC)
|
||||
{
|
||||
zend_hash_destroy(&pglobals->ht_rc);
|
||||
}
|
||||
@@ -466,7 +466,7 @@ static php_mb_regex_t *php_mbregex_compile_pattern(const char *pattern, int patl
|
||||
retval = *rc;
|
||||
}
|
||||
out:
|
||||
return retval;
|
||||
return retval;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -483,7 +483,7 @@ static size_t _php_mb_regex_get_option_string(char *str, size_t len, OnigOptionT
|
||||
--len_left;
|
||||
*(p++) = 'i';
|
||||
}
|
||||
++len_req;
|
||||
++len_req;
|
||||
}
|
||||
|
||||
if ((option & ONIG_OPTION_EXTEND) != 0) {
|
||||
@@ -491,7 +491,7 @@ static size_t _php_mb_regex_get_option_string(char *str, size_t len, OnigOptionT
|
||||
--len_left;
|
||||
*(p++) = 'x';
|
||||
}
|
||||
++len_req;
|
||||
++len_req;
|
||||
}
|
||||
|
||||
if ((option & (ONIG_OPTION_MULTILINE | ONIG_OPTION_SINGLELINE)) ==
|
||||
@@ -500,14 +500,14 @@ static size_t _php_mb_regex_get_option_string(char *str, size_t len, OnigOptionT
|
||||
--len_left;
|
||||
*(p++) = 'p';
|
||||
}
|
||||
++len_req;
|
||||
++len_req;
|
||||
} else {
|
||||
if ((option & ONIG_OPTION_MULTILINE) != 0) {
|
||||
if (len_left > 0) {
|
||||
--len_left;
|
||||
*(p++) = 'm';
|
||||
}
|
||||
++len_req;
|
||||
++len_req;
|
||||
}
|
||||
|
||||
if ((option & ONIG_OPTION_SINGLELINE) != 0) {
|
||||
@@ -515,22 +515,22 @@ static size_t _php_mb_regex_get_option_string(char *str, size_t len, OnigOptionT
|
||||
--len_left;
|
||||
*(p++) = 's';
|
||||
}
|
||||
++len_req;
|
||||
++len_req;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((option & ONIG_OPTION_FIND_LONGEST) != 0) {
|
||||
if (len_left > 0) {
|
||||
--len_left;
|
||||
*(p++) = 'l';
|
||||
}
|
||||
++len_req;
|
||||
++len_req;
|
||||
}
|
||||
if ((option & ONIG_OPTION_FIND_NOT_EMPTY) != 0) {
|
||||
if (len_left > 0) {
|
||||
--len_left;
|
||||
*(p++) = 'n';
|
||||
}
|
||||
++len_req;
|
||||
++len_req;
|
||||
}
|
||||
|
||||
c = 0;
|
||||
@@ -566,7 +566,7 @@ static size_t _php_mb_regex_get_option_string(char *str, size_t len, OnigOptionT
|
||||
--len_left;
|
||||
*(p++) = '\0';
|
||||
}
|
||||
++len_req;
|
||||
++len_req;
|
||||
if (len < len_req) {
|
||||
return len_req;
|
||||
}
|
||||
@@ -577,11 +577,11 @@ static size_t _php_mb_regex_get_option_string(char *str, size_t len, OnigOptionT
|
||||
|
||||
/* {{{ _php_mb_regex_init_options */
|
||||
static void
|
||||
_php_mb_regex_init_options(const char *parg, int narg, OnigOptionType *option, OnigSyntaxType **syntax, int *eval)
|
||||
_php_mb_regex_init_options(const char *parg, int narg, OnigOptionType *option, OnigSyntaxType **syntax, int *eval)
|
||||
{
|
||||
int n;
|
||||
char c;
|
||||
int optm = 0;
|
||||
int optm = 0;
|
||||
|
||||
*syntax = ONIG_SYNTAX_RUBY;
|
||||
|
||||
@@ -636,13 +636,13 @@ _php_mb_regex_init_options(const char *parg, int narg, OnigOptionType *option, O
|
||||
*syntax = ONIG_SYNTAX_POSIX_EXTENDED;
|
||||
break;
|
||||
case 'e':
|
||||
if (eval != NULL) *eval = 1;
|
||||
if (eval != NULL) *eval = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (option != NULL) *option|=optm;
|
||||
if (option != NULL) *option|=optm;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@@ -860,11 +860,11 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
|
||||
} else {
|
||||
/* FIXME: this code is not multibyte aware! */
|
||||
convert_to_long_ex(arg_pattern_zval);
|
||||
pat_buf[0] = (char)Z_LVAL_PP(arg_pattern_zval);
|
||||
pat_buf[0] = (char)Z_LVAL_PP(arg_pattern_zval);
|
||||
pat_buf[1] = '\0';
|
||||
|
||||
arg_pattern = pat_buf;
|
||||
arg_pattern_len = 1;
|
||||
arg_pattern_len = 1;
|
||||
}
|
||||
/* create regex pattern buffer */
|
||||
re = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, options, MBREX(current_mbctype), syntax TSRMLS_CC);
|
||||
@@ -934,7 +934,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (eval) {
|
||||
zval v;
|
||||
/* null terminate buffer */
|
||||
@@ -953,32 +953,31 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
|
||||
eval_buf.len = 0;
|
||||
zval_dtor(&v);
|
||||
} else if (is_callable) {
|
||||
zval *retval_ptr;
|
||||
zval *retval_ptr = NULL;
|
||||
zval **args[1];
|
||||
zval *subpats;
|
||||
int i;
|
||||
|
||||
|
||||
MAKE_STD_ZVAL(subpats);
|
||||
array_init(subpats);
|
||||
|
||||
|
||||
for (i = 0; i < regs->num_regs; i++) {
|
||||
add_next_index_stringl(subpats, string + regs->beg[i], regs->end[i] - regs->beg[i], 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
args[0] = &subpats;
|
||||
/* null terminate buffer */
|
||||
smart_str_0(&eval_buf);
|
||||
|
||||
|
||||
arg_replace_fci.param_count = 1;
|
||||
arg_replace_fci.params = args;
|
||||
arg_replace_fci.retval_ptr_ptr = &retval_ptr;
|
||||
if (zend_call_function(&arg_replace_fci, &arg_replace_fci_cache TSRMLS_CC) == SUCCESS && arg_replace_fci.retval_ptr_ptr) {
|
||||
if (zend_call_function(&arg_replace_fci, &arg_replace_fci_cache TSRMLS_CC) == SUCCESS && arg_replace_fci.retval_ptr_ptr && retval_ptr) {
|
||||
convert_to_string_ex(&retval_ptr);
|
||||
smart_str_appendl(&out_buf, Z_STRVAL_P(retval_ptr), Z_STRLEN_P(retval_ptr));
|
||||
eval_buf.len = 0;
|
||||
zval_ptr_dtor(&retval_ptr);
|
||||
} else {
|
||||
efree(description);
|
||||
if (!EG(exception)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call custom replacement function");
|
||||
}
|
||||
@@ -991,7 +990,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
|
||||
pos = (OnigUChar *)string + n;
|
||||
} else {
|
||||
if (pos < string_lim) {
|
||||
smart_str_appendl(&out_buf, pos, 1);
|
||||
smart_str_appendl(&out_buf, pos, 1);
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
@@ -1013,7 +1012,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
|
||||
smart_str_free(&eval_buf);
|
||||
|
||||
if (err <= -2) {
|
||||
smart_str_free(&out_buf);
|
||||
smart_str_free(&out_buf);
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
smart_str_appendc(&out_buf, '\0');
|
||||
@@ -1063,7 +1062,7 @@ PHP_FUNCTION(mb_split)
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
count--;
|
||||
@@ -1317,7 +1316,7 @@ PHP_FUNCTION(mb_ereg_search_init)
|
||||
if (zend_parse_parameters(argc TSRMLS_CC, "z|ss", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (argc > 1 && arg_pattern_len == 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty pattern");
|
||||
RETURN_FALSE;
|
||||
@@ -1416,7 +1415,7 @@ PHP_FUNCTION(mb_ereg_search_setpos)
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_mb_regex_set_options */
|
||||
static void _php_mb_regex_set_options(OnigOptionType options, OnigSyntaxType *syntax, OnigOptionType *prev_options, OnigSyntaxType **prev_syntax TSRMLS_DC)
|
||||
static void _php_mb_regex_set_options(OnigOptionType options, OnigSyntaxType *syntax, OnigOptionType *prev_options, OnigSyntaxType **prev_syntax TSRMLS_DC)
|
||||
{
|
||||
if (prev_options != NULL) {
|
||||
*prev_options = MBREX(regex_default_options);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Bug #72402: _php_mb_regex_ereg_replace_exec - double free
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
function throwit() {
|
||||
throw new Exception('it');
|
||||
}
|
||||
$var10 = "throwit";
|
||||
try {
|
||||
$var14 = mb_ereg_replace_callback("", $var10, "");
|
||||
} catch(Exception $e) {}
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
DONE
|
||||
+50
-42
@@ -44,7 +44,7 @@
|
||||
|
||||
static int le_mcrypt;
|
||||
|
||||
typedef struct _php_mcrypt {
|
||||
typedef struct _php_mcrypt {
|
||||
MCRYPT td;
|
||||
zend_bool init;
|
||||
} php_mcrypt;
|
||||
@@ -292,7 +292,7 @@ ZEND_DECLARE_MODULE_GLOBALS(mcrypt)
|
||||
|
||||
zend_module_entry mcrypt_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"mcrypt",
|
||||
"mcrypt",
|
||||
mcrypt_functions,
|
||||
PHP_MINIT(mcrypt), PHP_MSHUTDOWN(mcrypt),
|
||||
NULL, NULL,
|
||||
@@ -376,7 +376,7 @@ ZEND_GET_MODULE(mcrypt)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &mcryptind) == FAILURE) { \
|
||||
return; \
|
||||
} \
|
||||
ZEND_FETCH_RESOURCE (pm, php_mcrypt *, &mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
ZEND_FETCH_RESOURCE (pm, php_mcrypt *, &mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
|
||||
#define MCRYPT_GET_MODE_DIR_ARGS(DIRECTORY) \
|
||||
char *dir = NULL; \
|
||||
@@ -407,7 +407,7 @@ PHP_INI_END()
|
||||
static void php_mcrypt_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
php_mcrypt *pm = (php_mcrypt *) rsrc->ptr;
|
||||
if (pm) {
|
||||
if (pm) {
|
||||
mcrypt_generic_deinit(pm->td);
|
||||
mcrypt_module_close(pm->td);
|
||||
efree(pm);
|
||||
@@ -548,7 +548,7 @@ PHP_MINFO_FUNCTION(mcrypt) /* {{{ */
|
||||
smart_str_free(&tmp1);
|
||||
smart_str_free(&tmp2);
|
||||
php_info_print_table_end();
|
||||
|
||||
|
||||
DISPLAY_INI_ENTRIES();
|
||||
}
|
||||
/* }}} */
|
||||
@@ -563,17 +563,17 @@ PHP_FUNCTION(mcrypt_module_open)
|
||||
int mode_len, mode_dir_len;
|
||||
MCRYPT td;
|
||||
php_mcrypt *pm;
|
||||
|
||||
|
||||
if (zend_parse_parameters (ZEND_NUM_ARGS() TSRMLS_CC, "ssss",
|
||||
&cipher, &cipher_len, &cipher_dir, &cipher_dir_len,
|
||||
&mode, &mode_len, &mode_dir, &mode_dir_len)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
td = mcrypt_module_open (
|
||||
cipher,
|
||||
cipher_dir_len > 0 ? cipher_dir : MCG(algorithms_dir),
|
||||
mode,
|
||||
mode,
|
||||
mode_dir_len > 0 ? mode_dir : MCG(modes_dir)
|
||||
);
|
||||
|
||||
@@ -600,7 +600,7 @@ PHP_FUNCTION(mcrypt_generic_init)
|
||||
int max_key_size, key_size, iv_size;
|
||||
php_mcrypt *pm;
|
||||
int result = 0;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &mcryptind, &key, &key_len, &iv, &iv_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
@@ -679,7 +679,7 @@ PHP_FUNCTION(mcrypt_generic)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &mcryptind, &data, &data_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ZEND_FETCH_RESOURCE(pm, php_mcrypt *, &mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
PHP_MCRYPT_INIT_CHECK
|
||||
|
||||
@@ -692,6 +692,10 @@ PHP_FUNCTION(mcrypt_generic)
|
||||
if (mcrypt_enc_is_block_mode(pm->td) == 1) { /* It's a block algorithm */
|
||||
block_size = mcrypt_enc_get_block_size(pm->td);
|
||||
data_size = (((data_len - 1) / block_size) + 1) * block_size;
|
||||
if (data_size <= 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Integer overflow in data size");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
data_s = emalloc(data_size + 1);
|
||||
memset(data_s, 0, data_size);
|
||||
memcpy(data_s, data, data_len);
|
||||
@@ -701,7 +705,7 @@ PHP_FUNCTION(mcrypt_generic)
|
||||
memset(data_s, 0, data_size);
|
||||
memcpy(data_s, data, data_len);
|
||||
}
|
||||
|
||||
|
||||
mcrypt_generic(pm->td, data_s, data_size);
|
||||
data_s[data_size] = '\0';
|
||||
|
||||
@@ -720,11 +724,11 @@ PHP_FUNCTION(mdecrypt_generic)
|
||||
php_mcrypt *pm;
|
||||
char* data_s;
|
||||
int block_size, data_size;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &mcryptind, &data, &data_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ZEND_FETCH_RESOURCE(pm, php_mcrypt * , &mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
PHP_MCRYPT_INIT_CHECK
|
||||
|
||||
@@ -737,6 +741,10 @@ PHP_FUNCTION(mdecrypt_generic)
|
||||
if (mcrypt_enc_is_block_mode(pm->td) == 1) { /* It's a block algorithm */
|
||||
block_size = mcrypt_enc_get_block_size(pm->td);
|
||||
data_size = (((data_len - 1) / block_size) + 1) * block_size;
|
||||
if (data_size <= 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Integer overflow in data size");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
data_s = emalloc(data_size + 1);
|
||||
memset(data_s, 0, data_size);
|
||||
memcpy(data_s, data, data_len);
|
||||
@@ -746,7 +754,7 @@ PHP_FUNCTION(mdecrypt_generic)
|
||||
memset(data_s, 0, data_size);
|
||||
memcpy(data_s, data, data_len);
|
||||
}
|
||||
|
||||
|
||||
mdecrypt_generic(pm->td, data_s, data_size);
|
||||
|
||||
RETVAL_STRINGL(data_s, data_size, 1);
|
||||
@@ -760,7 +768,7 @@ PHP_FUNCTION(mcrypt_enc_get_supported_key_sizes)
|
||||
{
|
||||
int i, count = 0;
|
||||
int *key_sizes;
|
||||
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
array_init(return_value);
|
||||
|
||||
@@ -829,7 +837,7 @@ PHP_FUNCTION(mcrypt_enc_is_block_algorithm)
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
if (mcrypt_enc_is_block_algorithm(pm->td) == 1) {
|
||||
RETURN_TRUE
|
||||
RETURN_TRUE
|
||||
} else {
|
||||
RETURN_FALSE
|
||||
}
|
||||
@@ -908,7 +916,7 @@ PHP_FUNCTION(mcrypt_enc_get_modes_name)
|
||||
PHP_FUNCTION(mcrypt_module_self_test)
|
||||
{
|
||||
MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir);
|
||||
|
||||
|
||||
if (mcrypt_module_self_test(module, dir) == 0) {
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
@@ -922,7 +930,7 @@ PHP_FUNCTION(mcrypt_module_self_test)
|
||||
PHP_FUNCTION(mcrypt_module_is_block_algorithm_mode)
|
||||
{
|
||||
MCRYPT_GET_MODE_DIR_ARGS(modes_dir)
|
||||
|
||||
|
||||
if (mcrypt_module_is_block_algorithm_mode(module, dir) == 1) {
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
@@ -936,7 +944,7 @@ PHP_FUNCTION(mcrypt_module_is_block_algorithm_mode)
|
||||
PHP_FUNCTION(mcrypt_module_is_block_algorithm)
|
||||
{
|
||||
MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir)
|
||||
|
||||
|
||||
if (mcrypt_module_is_block_algorithm(module, dir) == 1) {
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
@@ -950,7 +958,7 @@ PHP_FUNCTION(mcrypt_module_is_block_algorithm)
|
||||
PHP_FUNCTION(mcrypt_module_is_block_mode)
|
||||
{
|
||||
MCRYPT_GET_MODE_DIR_ARGS(modes_dir)
|
||||
|
||||
|
||||
if (mcrypt_module_is_block_mode(module, dir) == 1) {
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
@@ -964,7 +972,7 @@ PHP_FUNCTION(mcrypt_module_is_block_mode)
|
||||
PHP_FUNCTION(mcrypt_module_get_algo_block_size)
|
||||
{
|
||||
MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir)
|
||||
|
||||
|
||||
RETURN_LONG(mcrypt_module_get_algo_block_size(module, dir));
|
||||
}
|
||||
/* }}} */
|
||||
@@ -974,7 +982,7 @@ PHP_FUNCTION(mcrypt_module_get_algo_block_size)
|
||||
PHP_FUNCTION(mcrypt_module_get_algo_key_size)
|
||||
{
|
||||
MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir);
|
||||
|
||||
|
||||
RETURN_LONG(mcrypt_module_get_algo_key_size(module, dir));
|
||||
}
|
||||
/* }}} */
|
||||
@@ -985,7 +993,7 @@ PHP_FUNCTION(mcrypt_module_get_supported_key_sizes)
|
||||
{
|
||||
int i, count = 0;
|
||||
int *key_sizes;
|
||||
|
||||
|
||||
MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir)
|
||||
array_init(return_value);
|
||||
|
||||
@@ -1011,7 +1019,7 @@ PHP_FUNCTION(mcrypt_list_algorithms)
|
||||
&lib_dir, &lib_dir_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
array_init(return_value);
|
||||
modules = mcrypt_list_algorithms(lib_dir, &count);
|
||||
|
||||
@@ -1058,7 +1066,7 @@ PHP_FUNCTION(mcrypt_get_key_size)
|
||||
{
|
||||
char *cipher;
|
||||
char *module;
|
||||
int cipher_len, module_len;
|
||||
int cipher_len, module_len;
|
||||
char *cipher_dir_string;
|
||||
char *module_dir_string;
|
||||
MCRYPT td;
|
||||
@@ -1069,7 +1077,7 @@ PHP_FUNCTION(mcrypt_get_key_size)
|
||||
&cipher, &cipher_len, &module, &module_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
td = mcrypt_module_open(cipher, cipher_dir_string, module, module_dir_string);
|
||||
if (td != MCRYPT_FAILED) {
|
||||
RETVAL_LONG(mcrypt_enc_get_key_size(td));
|
||||
@@ -1087,7 +1095,7 @@ PHP_FUNCTION(mcrypt_get_block_size)
|
||||
{
|
||||
char *cipher;
|
||||
char *module;
|
||||
int cipher_len, module_len;
|
||||
int cipher_len, module_len;
|
||||
char *cipher_dir_string;
|
||||
char *module_dir_string;
|
||||
MCRYPT td;
|
||||
@@ -1098,7 +1106,7 @@ PHP_FUNCTION(mcrypt_get_block_size)
|
||||
&cipher, &cipher_len, &module, &module_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
td = mcrypt_module_open(cipher, cipher_dir_string, module, module_dir_string);
|
||||
if (td != MCRYPT_FAILED) {
|
||||
RETVAL_LONG(mcrypt_enc_get_block_size(td));
|
||||
@@ -1116,7 +1124,7 @@ PHP_FUNCTION(mcrypt_get_iv_size)
|
||||
{
|
||||
char *cipher;
|
||||
char *module;
|
||||
int cipher_len, module_len;
|
||||
int cipher_len, module_len;
|
||||
char *cipher_dir_string;
|
||||
char *module_dir_string;
|
||||
MCRYPT td;
|
||||
@@ -1127,7 +1135,7 @@ PHP_FUNCTION(mcrypt_get_iv_size)
|
||||
&cipher, &cipher_len, &module, &module_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
td = mcrypt_module_open(cipher, cipher_dir_string, module, module_dir_string);
|
||||
if (td != MCRYPT_FAILED) {
|
||||
RETVAL_LONG(mcrypt_enc_get_iv_size(td));
|
||||
@@ -1217,7 +1225,7 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons
|
||||
} else { /* dertermine smallest supported key > length of requested key */
|
||||
use_key_length = max_key_length; /* start with max key length */
|
||||
for (i = 0; i < count; i++) {
|
||||
if (key_length_sizes[i] >= key_len &&
|
||||
if (key_length_sizes[i] >= key_len &&
|
||||
key_length_sizes[i] < use_key_length)
|
||||
{
|
||||
use_key_length = key_length_sizes[i];
|
||||
@@ -1228,11 +1236,11 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons
|
||||
memcpy(key_s, key, MIN(key_len, use_key_length));
|
||||
}
|
||||
mcrypt_free (key_length_sizes);
|
||||
|
||||
|
||||
/* Check IV */
|
||||
iv_s = NULL;
|
||||
iv_size = mcrypt_enc_get_iv_size (td);
|
||||
|
||||
|
||||
/* IV is required */
|
||||
if (mcrypt_enc_mode_has_iv(td) == 1) {
|
||||
if (argc == 5) {
|
||||
@@ -1272,7 +1280,7 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons
|
||||
} else {
|
||||
mdecrypt_generic(td, data_s, data_size);
|
||||
}
|
||||
|
||||
|
||||
RETVAL_STRINGL(data_s, data_size, 1);
|
||||
|
||||
/* freeing vars */
|
||||
@@ -1294,9 +1302,9 @@ PHP_FUNCTION(mcrypt_encrypt)
|
||||
zval **mode;
|
||||
char *cipher, *key, *data, *iv = NULL;
|
||||
int cipher_len, key_len, data_len, iv_len = 0;
|
||||
|
||||
|
||||
MCRYPT_GET_CRYPT_ARGS
|
||||
|
||||
|
||||
convert_to_string_ex(mode);
|
||||
|
||||
php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, Z_STRVAL_PP(mode), iv, iv_len, ZEND_NUM_ARGS(), MCRYPT_ENCRYPT, return_value TSRMLS_CC);
|
||||
@@ -1312,7 +1320,7 @@ PHP_FUNCTION(mcrypt_decrypt)
|
||||
int cipher_len, key_len, data_len, iv_len = 0;
|
||||
|
||||
MCRYPT_GET_CRYPT_ARGS
|
||||
|
||||
|
||||
convert_to_string_ex(mode);
|
||||
|
||||
php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, Z_STRVAL_PP(mode), iv, iv_len, ZEND_NUM_ARGS(), MCRYPT_DECRYPT, return_value TSRMLS_CC);
|
||||
@@ -1326,7 +1334,7 @@ PHP_FUNCTION(mcrypt_ecb)
|
||||
zval **mode;
|
||||
char *cipher, *key, *data, *iv = NULL;
|
||||
int cipher_len, key_len, data_len, iv_len = 0;
|
||||
|
||||
|
||||
MCRYPT_GET_CRYPT_ARGS
|
||||
|
||||
convert_to_long_ex(mode);
|
||||
@@ -1358,7 +1366,7 @@ PHP_FUNCTION(mcrypt_cfb)
|
||||
zval **mode;
|
||||
char *cipher, *key, *data, *iv = NULL;
|
||||
int cipher_len, key_len, data_len, iv_len = 0;
|
||||
|
||||
|
||||
MCRYPT_GET_CRYPT_ARGS
|
||||
|
||||
convert_to_long_ex(mode);
|
||||
@@ -1374,7 +1382,7 @@ PHP_FUNCTION(mcrypt_ofb)
|
||||
zval **mode;
|
||||
char *cipher, *key, *data, *iv = NULL;
|
||||
int cipher_len, key_len, data_len, iv_len = 0;
|
||||
|
||||
|
||||
MCRYPT_GET_CRYPT_ARGS
|
||||
|
||||
convert_to_long_ex(mode);
|
||||
@@ -1400,9 +1408,9 @@ PHP_FUNCTION(mcrypt_create_iv)
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create an IV with a size of less than 1 or greater than %d", INT_MAX);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
iv = ecalloc(size + 1, 1);
|
||||
|
||||
|
||||
if (source == RANDOM || source == URANDOM) {
|
||||
#if PHP_WIN32
|
||||
/* random/urandom equivalent on Windows */
|
||||
|
||||
+37
-23
@@ -400,7 +400,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_server_option)(MYSQLND_CONN_DATA * const c
|
||||
|
||||
int2store(buffer, (unsigned int) option);
|
||||
ret = conn->m->simple_command(conn, COM_SET_OPTION, buffer, sizeof(buffer), PROT_EOF_PACKET, FALSE, TRUE TSRMLS_CC);
|
||||
|
||||
|
||||
conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC);
|
||||
}
|
||||
DBG_RETURN(ret);
|
||||
@@ -464,27 +464,41 @@ mysqlnd_switch_to_ssl_if_needed(
|
||||
}
|
||||
|
||||
#ifdef MYSQLND_SSL_SUPPORTED
|
||||
if ((greet_packet->server_capabilities & CLIENT_SSL) && (mysql_flags & CLIENT_SSL)) {
|
||||
zend_bool verify = mysql_flags & CLIENT_SSL_VERIFY_SERVER_CERT? TRUE:FALSE;
|
||||
DBG_INF("Switching to SSL");
|
||||
if (!PACKET_WRITE(auth_packet, conn)) {
|
||||
CONN_SET_STATE(conn, CONN_QUIT_SENT);
|
||||
conn->m->send_close(conn TSRMLS_CC);
|
||||
SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
||||
goto end;
|
||||
}
|
||||
if (mysql_flags & CLIENT_SSL) {
|
||||
zend_bool server_has_ssl = (greet_packet->server_capabilities & CLIENT_SSL)? TRUE:FALSE;
|
||||
if (server_has_ssl == FALSE) {
|
||||
goto close_conn;
|
||||
} else {
|
||||
zend_bool verify = mysql_flags & CLIENT_SSL_VERIFY_SERVER_CERT? TRUE:FALSE;
|
||||
DBG_INF("Switching to SSL");
|
||||
if (!PACKET_WRITE(auth_packet, conn)) {
|
||||
goto close_conn;
|
||||
}
|
||||
|
||||
conn->net->data->m.set_client_option(conn->net, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char *) &verify TSRMLS_CC);
|
||||
conn->net->data->m.set_client_option(conn->net, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char *) &verify TSRMLS_CC);
|
||||
|
||||
if (FAIL == conn->net->data->m.enable_ssl(conn->net TSRMLS_CC)) {
|
||||
goto end;
|
||||
if (FAIL == conn->net->data->m.enable_ssl(conn->net TSRMLS_CC)) {
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
auth_packet->client_flags &= ~CLIENT_SSL;
|
||||
if (!PACKET_WRITE(auth_packet, conn)) {
|
||||
goto close_conn;
|
||||
}
|
||||
#endif
|
||||
ret = PASS;
|
||||
end:
|
||||
PACKET_FREE(auth_packet);
|
||||
DBG_RETURN(ret);
|
||||
|
||||
close_conn:
|
||||
CONN_SET_STATE(conn, CONN_QUIT_SENT);
|
||||
conn->m->send_close(conn TSRMLS_CC);
|
||||
SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
||||
PACKET_FREE(auth_packet);
|
||||
DBG_RETURN(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -1563,7 +1577,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, sqlstate)(const MYSQLND_CONN_DATA * const conn
|
||||
|
||||
|
||||
/* {{{ mysqlnd_old_escape_string */
|
||||
PHPAPI ulong
|
||||
PHPAPI ulong
|
||||
mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC)
|
||||
{
|
||||
DBG_ENTER("mysqlnd_old_escape_string");
|
||||
@@ -1725,7 +1739,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, char **me
|
||||
|
||||
if (PASS == (ret = PACKET_READ(stats_header, conn))) {
|
||||
/* will be freed by Zend, thus don't use the mnd_ allocator */
|
||||
*message = estrndup(stats_header->message, stats_header->message_len);
|
||||
*message = estrndup(stats_header->message, stats_header->message_len);
|
||||
*message_len = stats_header->message_len;
|
||||
DBG_INF(*message);
|
||||
}
|
||||
@@ -1851,7 +1865,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, shutdown)(MYSQLND_CONN_DATA * const conn, uint
|
||||
|
||||
conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC);
|
||||
}
|
||||
DBG_RETURN(ret);
|
||||
DBG_RETURN(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -2350,7 +2364,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c
|
||||
ret = FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
new_charset_name = mnd_pestrdup(value, conn->persistent);
|
||||
if (!new_charset_name) {
|
||||
goto oom;
|
||||
@@ -2429,11 +2443,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c
|
||||
default:
|
||||
ret = FAIL;
|
||||
}
|
||||
conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC);
|
||||
conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC);
|
||||
DBG_RETURN(ret);
|
||||
oom:
|
||||
SET_OOM_ERROR(*conn->error_info);
|
||||
conn->m->local_tx_end(conn, this_func, FAIL TSRMLS_CC);
|
||||
conn->m->local_tx_end(conn, this_func, FAIL TSRMLS_CC);
|
||||
end:
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
@@ -2510,7 +2524,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option_2d)(MYSQLND_CONN_DATA * cons
|
||||
DBG_RETURN(ret);
|
||||
oom:
|
||||
SET_OOM_ERROR(*conn->error_info);
|
||||
conn->m->local_tx_end(conn, this_func, FAIL TSRMLS_CC);
|
||||
conn->m->local_tx_end(conn, this_func, FAIL TSRMLS_CC);
|
||||
end:
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
@@ -2551,7 +2565,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, use_result)(MYSQLND_CONN_DATA * const conn TSR
|
||||
conn->current_result = NULL;
|
||||
} while (0);
|
||||
|
||||
conn->m->local_tx_end(conn, this_func, result == NULL? FAIL:PASS TSRMLS_CC);
|
||||
conn->m->local_tx_end(conn, this_func, result == NULL? FAIL:PASS TSRMLS_CC);
|
||||
}
|
||||
|
||||
DBG_RETURN(result);
|
||||
@@ -2591,7 +2605,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, store_result)(MYSQLND_CONN_DATA * const conn T
|
||||
conn->current_result = NULL;
|
||||
} while (0);
|
||||
|
||||
conn->m->local_tx_end(conn, this_func, result == NULL? FAIL:PASS TSRMLS_CC);
|
||||
conn->m->local_tx_end(conn, this_func, result == NULL? FAIL:PASS TSRMLS_CC);
|
||||
}
|
||||
DBG_RETURN(result);
|
||||
}
|
||||
@@ -2620,7 +2634,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_autocommit)(MYSQLND_CONN_DATA * conn, unsi
|
||||
|
||||
if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) {
|
||||
ret = conn->m->query(conn, (mode) ? "SET AUTOCOMMIT=1":"SET AUTOCOMMIT=0", sizeof("SET AUTOCOMMIT=1") - 1 TSRMLS_CC);
|
||||
conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC);
|
||||
conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC);
|
||||
}
|
||||
|
||||
DBG_RETURN(ret);
|
||||
|
||||
@@ -5136,7 +5136,6 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
|
||||
long buffer_length;
|
||||
unsigned char *buffer = NULL;
|
||||
zval *zstrong_result_returned = NULL;
|
||||
int strong_result = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|z", &buffer_length, &zstrong_result_returned) == FAILURE) {
|
||||
return;
|
||||
@@ -5154,7 +5153,6 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
|
||||
buffer = emalloc(buffer_length + 1);
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
strong_result = 1;
|
||||
/* random/urandom equivalent on Windows */
|
||||
if (php_win32_get_random_bytes(buffer, (size_t) buffer_length) == FAILURE){
|
||||
efree(buffer);
|
||||
@@ -5164,7 +5162,7 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#else
|
||||
if ((strong_result = RAND_pseudo_bytes(buffer, buffer_length)) < 0) {
|
||||
if (RAND_bytes(buffer, buffer_length) <= 0) {
|
||||
efree(buffer);
|
||||
if (zstrong_result_returned) {
|
||||
ZVAL_BOOL(zstrong_result_returned, 0);
|
||||
@@ -5177,7 +5175,7 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
|
||||
RETVAL_STRINGL((char *)buffer, buffer_length, 0);
|
||||
|
||||
if (zstrong_result_returned) {
|
||||
ZVAL_BOOL(zstrong_result_returned, strong_result);
|
||||
ZVAL_BOOL(zstrong_result_returned, 1);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -1,6 +1,182 @@
|
||||
ChangeLog for PCRE
|
||||
------------------
|
||||
|
||||
Note that the PCRE 8.xx series (PCRE1) is now in a bugfix-only state. All
|
||||
development is happening in the PCRE2 10.xx series.
|
||||
|
||||
Version 8.38 23-November-2015
|
||||
-----------------------------
|
||||
|
||||
1. If a group that contained a recursive back reference also contained a
|
||||
forward reference subroutine call followed by a non-forward-reference
|
||||
subroutine call, for example /.((?2)(?R)\1)()/, pcre2_compile() failed to
|
||||
compile correct code, leading to undefined behaviour or an internally
|
||||
detected error. This bug was discovered by the LLVM fuzzer.
|
||||
|
||||
2. Quantification of certain items (e.g. atomic back references) could cause
|
||||
incorrect code to be compiled when recursive forward references were
|
||||
involved. For example, in this pattern: /(?1)()((((((\1++))\x85)+)|))/.
|
||||
This bug was discovered by the LLVM fuzzer.
|
||||
|
||||
3. A repeated conditional group whose condition was a reference by name caused
|
||||
a buffer overflow if there was more than one group with the given name.
|
||||
This bug was discovered by the LLVM fuzzer.
|
||||
|
||||
4. A recursive back reference by name within a group that had the same name as
|
||||
another group caused a buffer overflow. For example:
|
||||
/(?J)(?'d'(?'d'\g{d}))/. This bug was discovered by the LLVM fuzzer.
|
||||
|
||||
5. A forward reference by name to a group whose number is the same as the
|
||||
current group, for example in this pattern: /(?|(\k'Pm')|(?'Pm'))/, caused
|
||||
a buffer overflow at compile time. This bug was discovered by the LLVM
|
||||
fuzzer.
|
||||
|
||||
6. A lookbehind assertion within a set of mutually recursive subpatterns could
|
||||
provoke a buffer overflow. This bug was discovered by the LLVM fuzzer.
|
||||
|
||||
7. Another buffer overflow bug involved duplicate named groups with a
|
||||
reference between their definition, with a group that reset capture
|
||||
numbers, for example: /(?J:(?|(?'R')(\k'R')|((?'R'))))/. This has been
|
||||
fixed by always allowing for more memory, even if not needed. (A proper fix
|
||||
is implemented in PCRE2, but it involves more refactoring.)
|
||||
|
||||
8. There was no check for integer overflow in subroutine calls such as (?123).
|
||||
|
||||
9. The table entry for \l in EBCDIC environments was incorrect, leading to its
|
||||
being treated as a literal 'l' instead of causing an error.
|
||||
|
||||
10. There was a buffer overflow if pcre_exec() was called with an ovector of
|
||||
size 1. This bug was found by american fuzzy lop.
|
||||
|
||||
11. If a non-capturing group containing a conditional group that could match
|
||||
an empty string was repeated, it was not identified as matching an empty
|
||||
string itself. For example: /^(?:(?(1)x|)+)+$()/.
|
||||
|
||||
12. In an EBCDIC environment, pcretest was mishandling the escape sequences
|
||||
\a and \e in test subject lines.
|
||||
|
||||
13. In an EBCDIC environment, \a in a pattern was converted to the ASCII
|
||||
instead of the EBCDIC value.
|
||||
|
||||
14. The handling of \c in an EBCDIC environment has been revised so that it is
|
||||
now compatible with the specification in Perl's perlebcdic page.
|
||||
|
||||
15. The EBCDIC character 0x41 is a non-breaking space, equivalent to 0xa0 in
|
||||
ASCII/Unicode. This has now been added to the list of characters that are
|
||||
recognized as white space in EBCDIC.
|
||||
|
||||
16. When PCRE was compiled without UCP support, the use of \p and \P gave an
|
||||
error (correctly) when used outside a class, but did not give an error
|
||||
within a class.
|
||||
|
||||
17. \h within a class was incorrectly compiled in EBCDIC environments.
|
||||
|
||||
18. A pattern with an unmatched closing parenthesis that contained a backward
|
||||
assertion which itself contained a forward reference caused buffer
|
||||
overflow. And example pattern is: /(?=di(?<=(?1))|(?=(.))))/.
|
||||
|
||||
19. JIT should return with error when the compiled pattern requires more stack
|
||||
space than the maximum.
|
||||
|
||||
20. A possessively repeated conditional group that could match an empty string,
|
||||
for example, /(?(R))*+/, was incorrectly compiled.
|
||||
|
||||
21. Fix infinite recursion in the JIT compiler when certain patterns such as
|
||||
/(?:|a|){100}x/ are analysed.
|
||||
|
||||
22. Some patterns with character classes involving [: and \\ were incorrectly
|
||||
compiled and could cause reading from uninitialized memory or an incorrect
|
||||
error diagnosis.
|
||||
|
||||
23. Pathological patterns containing many nested occurrences of [: caused
|
||||
pcre_compile() to run for a very long time.
|
||||
|
||||
24. A conditional group with only one branch has an implicit empty alternative
|
||||
branch and must therefore be treated as potentially matching an empty
|
||||
string.
|
||||
|
||||
25. If (?R was followed by - or + incorrect behaviour happened instead of a
|
||||
diagnostic.
|
||||
|
||||
26. Arrange to give up on finding the minimum matching length for overly
|
||||
complex patterns.
|
||||
|
||||
27. Similar to (4) above: in a pattern with duplicated named groups and an
|
||||
occurrence of (?| it is possible for an apparently non-recursive back
|
||||
reference to become recursive if a later named group with the relevant
|
||||
number is encountered. This could lead to a buffer overflow. Wen Guanxing
|
||||
from Venustech ADLAB discovered this bug.
|
||||
|
||||
28. If pcregrep was given the -q option with -c or -l, or when handling a
|
||||
binary file, it incorrectly wrote output to stdout.
|
||||
|
||||
29. The JIT compiler did not restore the control verb head in case of *THEN
|
||||
control verbs. This issue was found by Karl Skomski with a custom LLVM
|
||||
fuzzer.
|
||||
|
||||
30. Error messages for syntax errors following \g and \k were giving inaccurate
|
||||
offsets in the pattern.
|
||||
|
||||
31. Added a check for integer overflow in conditions (?(<digits>) and
|
||||
(?(R<digits>). This omission was discovered by Karl Skomski with the LLVM
|
||||
fuzzer.
|
||||
|
||||
32. Handling recursive references such as (?2) when the reference is to a group
|
||||
later in the pattern uses code that is very hacked about and error-prone.
|
||||
It has been re-written for PCRE2. Here in PCRE1, a check has been added to
|
||||
give an internal error if it is obvious that compiling has gone wrong.
|
||||
|
||||
33. The JIT compiler should not check repeats after a {0,1} repeat byte code.
|
||||
This issue was found by Karl Skomski with a custom LLVM fuzzer.
|
||||
|
||||
34. The JIT compiler should restore the control chain for empty possessive
|
||||
repeats. This issue was found by Karl Skomski with a custom LLVM fuzzer.
|
||||
|
||||
35. Match limit check added to JIT recursion. This issue was found by Karl
|
||||
Skomski with a custom LLVM fuzzer.
|
||||
|
||||
36. Yet another case similar to 27 above has been circumvented by an
|
||||
unconditional allocation of extra memory. This issue is fixed "properly" in
|
||||
PCRE2 by refactoring the way references are handled. Wen Guanxing
|
||||
from Venustech ADLAB discovered this bug.
|
||||
|
||||
37. Fix two assertion fails in JIT. These issues were found by Karl Skomski
|
||||
with a custom LLVM fuzzer.
|
||||
|
||||
38. Fixed a corner case of range optimization in JIT.
|
||||
|
||||
39. An incorrect error "overran compiling workspace" was given if there were
|
||||
exactly enough group forward references such that the last one extended
|
||||
into the workspace safety margin. The next one would have expanded the
|
||||
workspace. The test for overflow was not including the safety margin.
|
||||
|
||||
40. A match limit issue is fixed in JIT which was found by Karl Skomski
|
||||
with a custom LLVM fuzzer.
|
||||
|
||||
41. Remove the use of /dev/null in testdata/testinput2, because it doesn't
|
||||
work under Windows. (Why has it taken so long for anyone to notice?)
|
||||
|
||||
42. In a character class such as [\W\p{Any}] where both a negative-type escape
|
||||
("not a word character") and a property escape were present, the property
|
||||
escape was being ignored.
|
||||
|
||||
43. Fix crash caused by very long (*MARK) or (*THEN) names.
|
||||
|
||||
44. A sequence such as [[:punct:]b] that is, a POSIX character class followed
|
||||
by a single ASCII character in a class item, was incorrectly compiled in
|
||||
UCP mode. The POSIX class got lost, but only if the single character
|
||||
followed it.
|
||||
|
||||
45. [:punct:] in UCP mode was matching some characters in the range 128-255
|
||||
that should not have been matched.
|
||||
|
||||
46. If [:^ascii:] or [:^xdigit:] or [:^cntrl:] are present in a non-negated
|
||||
class, all characters with code points greater than 255 are in the class.
|
||||
When a Unicode property was also in the class (if PCRE_UCP is set, escapes
|
||||
such as \w are turned into Unicode properties), wide characters were not
|
||||
correctly handled, and could fail to match.
|
||||
|
||||
|
||||
Version 8.37 28-April-2015
|
||||
--------------------------
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
News about PCRE releases
|
||||
------------------------
|
||||
|
||||
Release 8.38 23-November-2015
|
||||
-----------------------------
|
||||
|
||||
This is bug-fix release. Note that this library (now called PCRE1) is now being
|
||||
maintained for bug fixes only. New projects are advised to use the new PCRE2
|
||||
libraries.
|
||||
|
||||
|
||||
Release 8.37 28-April-2015
|
||||
--------------------------
|
||||
|
||||
|
||||
@@ -234,8 +234,8 @@ them both to 0; an emulation function will be used. */
|
||||
#define LINK_SIZE 2
|
||||
#endif
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
/* This is ignored unless you are using libtool. */
|
||||
#ifndef LT_OBJDIR
|
||||
#define LT_OBJDIR ".libs/"
|
||||
#endif
|
||||
@@ -314,7 +314,7 @@ them both to 0; an emulation function will be used. */
|
||||
#define PACKAGE_NAME "PCRE"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "PCRE 8.37"
|
||||
#define PACKAGE_STRING "PCRE 8.38"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "pcre"
|
||||
@@ -323,7 +323,7 @@ them both to 0; an emulation function will be used. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "8.37"
|
||||
#define PACKAGE_VERSION "8.38"
|
||||
|
||||
/* to make a symbol visible */
|
||||
/* #undef PCRECPP_EXP_DECL */
|
||||
@@ -439,7 +439,7 @@ them both to 0; an emulation function will be used. */
|
||||
|
||||
/* Version number of package */
|
||||
#ifndef VERSION
|
||||
#define VERSION "8.37"
|
||||
#define VERSION "8.38"
|
||||
#endif
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
@@ -451,4 +451,3 @@ them both to 0; an emulation function will be used. */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
+1076
-1052
File diff suppressed because it is too large.
Load diff
@@ -42,9 +42,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
/* The current PCRE version information. */
|
||||
|
||||
#define PCRE_MAJOR 8
|
||||
#define PCRE_MINOR 36
|
||||
#define PCRE_MINOR 38
|
||||
#define PCRE_PRERELEASE
|
||||
#define PCRE_DATE 2014-09-26
|
||||
#define PCRE_DATE 2015-11-23
|
||||
|
||||
/* When an application links to a PCRE DLL in Windows, the symbols that are
|
||||
imported have to be identified as such. When building PCRE, the appropriate
|
||||
|
||||
+235
-99
@@ -174,7 +174,7 @@ static const short int escapes[] = {
|
||||
-ESC_Z, CHAR_LEFT_SQUARE_BRACKET,
|
||||
CHAR_BACKSLASH, CHAR_RIGHT_SQUARE_BRACKET,
|
||||
CHAR_CIRCUMFLEX_ACCENT, CHAR_UNDERSCORE,
|
||||
CHAR_GRAVE_ACCENT, 7,
|
||||
CHAR_GRAVE_ACCENT, ESC_a,
|
||||
-ESC_b, 0,
|
||||
-ESC_d, ESC_e,
|
||||
ESC_f, 0,
|
||||
@@ -202,9 +202,9 @@ static const short int escapes[] = {
|
||||
/* 68 */ 0, 0, '|', ',', '%', '_', '>', '?',
|
||||
/* 70 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 78 */ 0, '`', ':', '#', '@', '\'', '=', '"',
|
||||
/* 80 */ 0, 7, -ESC_b, 0, -ESC_d, ESC_e, ESC_f, 0,
|
||||
/* 80 */ 0, ESC_a, -ESC_b, 0, -ESC_d, ESC_e, ESC_f, 0,
|
||||
/* 88 */-ESC_h, 0, 0, '{', 0, 0, 0, 0,
|
||||
/* 90 */ 0, 0, -ESC_k, 'l', 0, ESC_n, 0, -ESC_p,
|
||||
/* 90 */ 0, 0, -ESC_k, 0, 0, ESC_n, 0, -ESC_p,
|
||||
/* 98 */ 0, ESC_r, 0, '}', 0, 0, 0, 0,
|
||||
/* A0 */ 0, '~', -ESC_s, ESC_tee, 0,-ESC_v, -ESC_w, 0,
|
||||
/* A8 */ 0,-ESC_z, 0, 0, 0, '[', 0, 0,
|
||||
@@ -219,6 +219,12 @@ static const short int escapes[] = {
|
||||
/* F0 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* F8 */ 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
/* We also need a table of characters that may follow \c in an EBCDIC
|
||||
environment for characters 0-31. */
|
||||
|
||||
static unsigned char ebcdic_escape_c[] = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -458,7 +464,7 @@ static const char error_texts[] =
|
||||
"range out of order in character class\0"
|
||||
"nothing to repeat\0"
|
||||
/* 10 */
|
||||
"operand of unlimited repeat could match the empty string\0" /** DEAD **/
|
||||
"internal error: invalid forward reference offset\0"
|
||||
"internal error: unexpected repeat\0"
|
||||
"unrecognized character after (? or (?-\0"
|
||||
"POSIX named classes are supported only within a class\0"
|
||||
@@ -527,7 +533,11 @@ static const char error_texts[] =
|
||||
"different names for subpatterns of the same number are not allowed\0"
|
||||
"(*MARK) must have an argument\0"
|
||||
"this version of PCRE is not compiled with Unicode property support\0"
|
||||
#ifndef EBCDIC
|
||||
"\\c must be followed by an ASCII character\0"
|
||||
#else
|
||||
"\\c must be followed by a letter or one of [\\]^_?\0"
|
||||
#endif
|
||||
"\\k is not followed by a braced, angle-bracketed, or quoted name\0"
|
||||
/* 70 */
|
||||
"internal error: unknown opcode in find_fixedlength()\0"
|
||||
@@ -1425,7 +1435,16 @@ else
|
||||
c ^= 0x40;
|
||||
#else /* EBCDIC coding */
|
||||
if (c >= CHAR_a && c <= CHAR_z) c += 64;
|
||||
c ^= 0xC0;
|
||||
if (c == CHAR_QUESTION_MARK)
|
||||
c = ('\\' == 188 && '`' == 74)? 0x5f : 0xff;
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
if (c == ebcdic_escape_c[i]) break;
|
||||
}
|
||||
if (i < 32) c = i; else *errorcodeptr = ERR68;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -1799,7 +1818,7 @@ for (;;)
|
||||
case OP_ASSERTBACK:
|
||||
case OP_ASSERTBACK_NOT:
|
||||
do cc += GET(cc, 1); while (*cc == OP_ALT);
|
||||
cc += PRIV(OP_lengths)[*cc];
|
||||
cc += 1 + LINK_SIZE;
|
||||
break;
|
||||
|
||||
/* Skip over things that don't match chars */
|
||||
@@ -2487,7 +2506,7 @@ for (code = first_significant_code(code + PRIV(OP_lengths)[*code], TRUE);
|
||||
if (c == OP_BRA || c == OP_BRAPOS ||
|
||||
c == OP_CBRA || c == OP_CBRAPOS ||
|
||||
c == OP_ONCE || c == OP_ONCE_NC ||
|
||||
c == OP_COND)
|
||||
c == OP_COND || c == OP_SCOND)
|
||||
{
|
||||
BOOL empty_branch;
|
||||
if (GET(code, 1) == 0) return TRUE; /* Hit unclosed bracket */
|
||||
@@ -3886,11 +3905,11 @@ didn't consider this to be a POSIX class. Likewise for [:1234:].
|
||||
The problem in trying to be exactly like Perl is in the handling of escapes. We
|
||||
have to be sure that [abc[:x\]pqr] is *not* treated as containing a POSIX
|
||||
class, but [abc[:x\]pqr:]] is (so that an error can be generated). The code
|
||||
below handles the special case of \], but does not try to do any other escape
|
||||
processing. This makes it different from Perl for cases such as [:l\ower:]
|
||||
where Perl recognizes it as the POSIX class "lower" but PCRE does not recognize
|
||||
"l\ower". This is a lesser evil than not diagnosing bad classes when Perl does,
|
||||
I think.
|
||||
below handles the special cases \\ and \], but does not try to do any other
|
||||
escape processing. This makes it different from Perl for cases such as
|
||||
[:l\ower:] where Perl recognizes it as the POSIX class "lower" but PCRE does
|
||||
not recognize "l\ower". This is a lesser evil than not diagnosing bad classes
|
||||
when Perl does, I think.
|
||||
|
||||
A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not.
|
||||
It seems that the appearance of a nested POSIX class supersedes an apparent
|
||||
@@ -3917,21 +3936,16 @@ pcre_uchar terminator; /* Don't combine these lines; the Solaris cc */
|
||||
terminator = *(++ptr); /* compiler warns about "non-constant" initializer. */
|
||||
for (++ptr; *ptr != CHAR_NULL; ptr++)
|
||||
{
|
||||
if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
|
||||
if (*ptr == CHAR_BACKSLASH &&
|
||||
(ptr[1] == CHAR_RIGHT_SQUARE_BRACKET ||
|
||||
ptr[1] == CHAR_BACKSLASH))
|
||||
ptr++;
|
||||
else if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
|
||||
else
|
||||
else if ((*ptr == CHAR_LEFT_SQUARE_BRACKET && ptr[1] == terminator) ||
|
||||
*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
|
||||
else if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
|
||||
{
|
||||
if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
|
||||
{
|
||||
*endptr = ptr;
|
||||
return TRUE;
|
||||
}
|
||||
if (*ptr == CHAR_LEFT_SQUARE_BRACKET &&
|
||||
(ptr[1] == CHAR_COLON || ptr[1] == CHAR_DOT ||
|
||||
ptr[1] == CHAR_EQUALS_SIGN) &&
|
||||
check_posix_syntax(ptr, endptr))
|
||||
return FALSE;
|
||||
*endptr = ptr;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
@@ -3985,11 +3999,12 @@ have their offsets adjusted. That one of the jobs of this function. Before it
|
||||
is called, the partially compiled regex must be temporarily terminated with
|
||||
OP_END.
|
||||
|
||||
This function has been extended with the possibility of forward references for
|
||||
recursions and subroutine calls. It must also check the list of such references
|
||||
for the group we are dealing with. If it finds that one of the recursions in
|
||||
the current group is on this list, it adjusts the offset in the list, not the
|
||||
value in the reference (which is a group number).
|
||||
This function has been extended to cope with forward references for recursions
|
||||
and subroutine calls. It must check the list of such references for the
|
||||
group we are dealing with. If it finds that one of the recursions in the
|
||||
current group is on this list, it does not adjust the value in the reference
|
||||
(which is a group number). After the group has been scanned, all the offsets in
|
||||
the forward reference list for the group are adjusted.
|
||||
|
||||
Arguments:
|
||||
group points to the start of the group
|
||||
@@ -4005,29 +4020,21 @@ static void
|
||||
adjust_recurse(pcre_uchar *group, int adjust, BOOL utf, compile_data *cd,
|
||||
size_t save_hwm_offset)
|
||||
{
|
||||
int offset;
|
||||
pcre_uchar *hc;
|
||||
pcre_uchar *ptr = group;
|
||||
|
||||
while ((ptr = (pcre_uchar *)find_recurse(ptr, utf)) != NULL)
|
||||
{
|
||||
int offset;
|
||||
pcre_uchar *hc;
|
||||
|
||||
/* See if this recursion is on the forward reference list. If so, adjust the
|
||||
reference. */
|
||||
|
||||
for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset; hc < cd->hwm;
|
||||
hc += LINK_SIZE)
|
||||
{
|
||||
offset = (int)GET(hc, 0);
|
||||
if (cd->start_code + offset == ptr + 1)
|
||||
{
|
||||
PUT(hc, 0, offset + adjust);
|
||||
break;
|
||||
}
|
||||
if (cd->start_code + offset == ptr + 1) break;
|
||||
}
|
||||
|
||||
/* Otherwise, adjust the recursion offset if it's after the start of this
|
||||
group. */
|
||||
/* If we have not found this recursion on the forward reference list, adjust
|
||||
the recursion's offset if it's after the start of this group. */
|
||||
|
||||
if (hc >= cd->hwm)
|
||||
{
|
||||
@@ -4037,6 +4044,15 @@ while ((ptr = (pcre_uchar *)find_recurse(ptr, utf)) != NULL)
|
||||
|
||||
ptr += 1 + LINK_SIZE;
|
||||
}
|
||||
|
||||
/* Now adjust all forward reference offsets for the group. */
|
||||
|
||||
for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset; hc < cd->hwm;
|
||||
hc += LINK_SIZE)
|
||||
{
|
||||
offset = (int)GET(hc, 0);
|
||||
PUT(hc, 0, offset + adjust);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4465,7 +4481,7 @@ const pcre_uchar *tempptr;
|
||||
const pcre_uchar *nestptr = NULL;
|
||||
pcre_uchar *previous = NULL;
|
||||
pcre_uchar *previous_callout = NULL;
|
||||
size_t save_hwm_offset = 0;
|
||||
size_t item_hwm_offset = 0;
|
||||
pcre_uint8 classbits[32];
|
||||
|
||||
/* We can fish out the UTF-8 setting once and for all into a BOOL, but we
|
||||
@@ -4623,8 +4639,7 @@ for (;; ptr++)
|
||||
/* In the real compile phase, just check the workspace used by the forward
|
||||
reference list. */
|
||||
|
||||
else if (cd->hwm > cd->start_workspace + cd->workspace_size -
|
||||
WORK_SIZE_SAFETY_MARGIN)
|
||||
else if (cd->hwm > cd->start_workspace + cd->workspace_size)
|
||||
{
|
||||
*errorcodeptr = ERR52;
|
||||
goto FAILED;
|
||||
@@ -4767,6 +4782,7 @@ for (;; ptr++)
|
||||
zeroreqchar = reqchar;
|
||||
zeroreqcharflags = reqcharflags;
|
||||
previous = code;
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
*code++ = ((options & PCRE_DOTALL) != 0)? OP_ALLANY: OP_ANY;
|
||||
break;
|
||||
|
||||
@@ -4818,6 +4834,7 @@ for (;; ptr++)
|
||||
/* Handle a real character class. */
|
||||
|
||||
previous = code;
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
|
||||
/* PCRE supports POSIX class stuff inside a class. Perl gives an error if
|
||||
they are encountered at the top level, so we'll do that too. */
|
||||
@@ -4923,9 +4940,10 @@ for (;; ptr++)
|
||||
(which is on the stack). We have to remember that there was XCLASS data,
|
||||
however. */
|
||||
|
||||
if (class_uchardata > class_uchardata_base) xclass = TRUE;
|
||||
|
||||
if (lengthptr != NULL && class_uchardata > class_uchardata_base)
|
||||
{
|
||||
xclass = TRUE;
|
||||
*lengthptr += (int)(class_uchardata - class_uchardata_base);
|
||||
class_uchardata = class_uchardata_base;
|
||||
}
|
||||
@@ -5028,10 +5046,26 @@ for (;; ptr++)
|
||||
ptr = tempptr + 1;
|
||||
continue;
|
||||
|
||||
/* For all other POSIX classes, no special action is taken in UCP
|
||||
mode. Fall through to the non_UCP case. */
|
||||
/* For the other POSIX classes (ascii, xdigit) we are going to fall
|
||||
through to the non-UCP case and build a bit map for characters with
|
||||
code points less than 256. If we are in a negated POSIX class
|
||||
within a non-negated overall class, characters with code points
|
||||
greater than 255 must all match. In the special case where we have
|
||||
not yet generated any xclass data, and this is the final item in
|
||||
the overall class, we need do nothing: later on, the opcode
|
||||
OP_NCLASS will be used to indicate that characters greater than 255
|
||||
are acceptable. If we have already seen an xclass item or one may
|
||||
follow (we have to assume that it might if this is not the end of
|
||||
the class), explicitly match all wide codepoints. */
|
||||
|
||||
default:
|
||||
if (!negate_class && local_negate &&
|
||||
(xclass || tempptr[2] != CHAR_RIGHT_SQUARE_BRACKET))
|
||||
{
|
||||
*class_uchardata++ = XCL_RANGE;
|
||||
class_uchardata += PRIV(ord2utf)(0x100, class_uchardata);
|
||||
class_uchardata += PRIV(ord2utf)(0x10ffff, class_uchardata);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -5195,9 +5229,9 @@ for (;; ptr++)
|
||||
cd, PRIV(vspace_list));
|
||||
continue;
|
||||
|
||||
#ifdef SUPPORT_UCP
|
||||
case ESC_p:
|
||||
case ESC_P:
|
||||
#ifdef SUPPORT_UCP
|
||||
{
|
||||
BOOL negated;
|
||||
unsigned int ptype = 0, pdata = 0;
|
||||
@@ -5211,6 +5245,9 @@ for (;; ptr++)
|
||||
class_has_8bitchar--; /* Undo! */
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
*errorcodeptr = ERR45;
|
||||
goto FAILED;
|
||||
#endif
|
||||
/* Unrecognized escapes are faulted if PCRE is running in its
|
||||
strict mode. By default, for compatibility with Perl, they are
|
||||
@@ -5367,16 +5404,20 @@ for (;; ptr++)
|
||||
CLASS_SINGLE_CHARACTER:
|
||||
if (class_one_char < 2) class_one_char++;
|
||||
|
||||
/* If class_one_char is 1, we have the first single character in the
|
||||
class, and there have been no prior ranges, or XCLASS items generated by
|
||||
escapes. If this is the final character in the class, we can optimize by
|
||||
turning the item into a 1-character OP_CHAR[I] if it's positive, or
|
||||
OP_NOT[I] if it's negative. In the positive case, it can cause firstchar
|
||||
to be set. Otherwise, there can be no first char if this item is first,
|
||||
whatever repeat count may follow. In the case of reqchar, save the
|
||||
previous value for reinstating. */
|
||||
/* If xclass_has_prop is false and class_one_char is 1, we have the first
|
||||
single character in the class, and there have been no prior ranges, or
|
||||
XCLASS items generated by escapes. If this is the final character in the
|
||||
class, we can optimize by turning the item into a 1-character OP_CHAR[I]
|
||||
if it's positive, or OP_NOT[I] if it's negative. In the positive case, it
|
||||
can cause firstchar to be set. Otherwise, there can be no first char if
|
||||
this item is first, whatever repeat count may follow. In the case of
|
||||
reqchar, save the previous value for reinstating. */
|
||||
|
||||
if (!inescq && class_one_char == 1 && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
|
||||
if (!inescq &&
|
||||
#ifdef SUPPORT_UCP
|
||||
!xclass_has_prop &&
|
||||
#endif
|
||||
class_one_char == 1 && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
|
||||
{
|
||||
ptr++;
|
||||
zeroreqchar = reqchar;
|
||||
@@ -5492,9 +5533,10 @@ for (;; ptr++)
|
||||
actual compiled code. */
|
||||
|
||||
#ifdef SUPPORT_UTF
|
||||
if (xclass && (!should_flip_negation || (options & PCRE_UCP) != 0))
|
||||
if (xclass && (xclass_has_prop || !should_flip_negation ||
|
||||
(options & PCRE_UCP) != 0))
|
||||
#elif !defined COMPILE_PCRE8
|
||||
if (xclass && !should_flip_negation)
|
||||
if (xclass && (xclass_has_prop || !should_flip_negation))
|
||||
#endif
|
||||
#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
|
||||
{
|
||||
@@ -5930,7 +5972,7 @@ for (;; ptr++)
|
||||
{
|
||||
register int i;
|
||||
int len = (int)(code - previous);
|
||||
size_t base_hwm_offset = save_hwm_offset;
|
||||
size_t base_hwm_offset = item_hwm_offset;
|
||||
pcre_uchar *bralink = NULL;
|
||||
pcre_uchar *brazeroptr = NULL;
|
||||
|
||||
@@ -5985,7 +6027,7 @@ for (;; ptr++)
|
||||
if (repeat_max <= 1) /* Covers 0, 1, and unlimited */
|
||||
{
|
||||
*code = OP_END;
|
||||
adjust_recurse(previous, 1, utf, cd, save_hwm_offset);
|
||||
adjust_recurse(previous, 1, utf, cd, item_hwm_offset);
|
||||
memmove(previous + 1, previous, IN_UCHARS(len));
|
||||
code++;
|
||||
if (repeat_max == 0)
|
||||
@@ -6009,7 +6051,7 @@ for (;; ptr++)
|
||||
{
|
||||
int offset;
|
||||
*code = OP_END;
|
||||
adjust_recurse(previous, 2 + LINK_SIZE, utf, cd, save_hwm_offset);
|
||||
adjust_recurse(previous, 2 + LINK_SIZE, utf, cd, item_hwm_offset);
|
||||
memmove(previous + 2 + LINK_SIZE, previous, IN_UCHARS(len));
|
||||
code += 2 + LINK_SIZE;
|
||||
*previous++ = OP_BRAZERO + repeat_type;
|
||||
@@ -6254,6 +6296,12 @@ for (;; ptr++)
|
||||
while (*scode == OP_ALT);
|
||||
}
|
||||
|
||||
/* A conditional group with only one branch has an implicit empty
|
||||
alternative branch. */
|
||||
|
||||
if (*bracode == OP_COND && bracode[GET(bracode,1)] != OP_ALT)
|
||||
*bracode = OP_SCOND;
|
||||
|
||||
/* Handle possessive quantifiers. */
|
||||
|
||||
if (possessive_quantifier)
|
||||
@@ -6267,11 +6315,11 @@ for (;; ptr++)
|
||||
{
|
||||
int nlen = (int)(code - bracode);
|
||||
*code = OP_END;
|
||||
adjust_recurse(bracode, 1 + LINK_SIZE, utf, cd, save_hwm_offset);
|
||||
adjust_recurse(bracode, 1 + LINK_SIZE, utf, cd, item_hwm_offset);
|
||||
memmove(bracode + 1 + LINK_SIZE, bracode, IN_UCHARS(nlen));
|
||||
code += 1 + LINK_SIZE;
|
||||
nlen += 1 + LINK_SIZE;
|
||||
*bracode = OP_BRAPOS;
|
||||
*bracode = (*bracode == OP_COND)? OP_BRAPOS : OP_SBRAPOS;
|
||||
*code++ = OP_KETRPOS;
|
||||
PUTINC(code, 0, nlen);
|
||||
PUT(bracode, 1, nlen);
|
||||
@@ -6401,7 +6449,7 @@ for (;; ptr++)
|
||||
else
|
||||
{
|
||||
*code = OP_END;
|
||||
adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, save_hwm_offset);
|
||||
adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, item_hwm_offset);
|
||||
memmove(tempcode + 1 + LINK_SIZE, tempcode, IN_UCHARS(len));
|
||||
code += 1 + LINK_SIZE;
|
||||
len += 1 + LINK_SIZE;
|
||||
@@ -6450,7 +6498,7 @@ for (;; ptr++)
|
||||
|
||||
default:
|
||||
*code = OP_END;
|
||||
adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, save_hwm_offset);
|
||||
adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, item_hwm_offset);
|
||||
memmove(tempcode + 1 + LINK_SIZE, tempcode, IN_UCHARS(len));
|
||||
code += 1 + LINK_SIZE;
|
||||
len += 1 + LINK_SIZE;
|
||||
@@ -6586,9 +6634,17 @@ for (;; ptr++)
|
||||
goto FAILED;
|
||||
}
|
||||
setverb = *code++ = verbs[i].op_arg;
|
||||
*code++ = arglen;
|
||||
memcpy(code, arg, IN_UCHARS(arglen));
|
||||
code += arglen;
|
||||
if (lengthptr != NULL) /* In pass 1 just add in the length */
|
||||
{ /* to avoid potential workspace */
|
||||
*lengthptr += arglen; /* overflow. */
|
||||
*code++ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*code++ = arglen;
|
||||
memcpy(code, arg, IN_UCHARS(arglen));
|
||||
code += arglen;
|
||||
}
|
||||
*code++ = 0;
|
||||
}
|
||||
|
||||
@@ -6623,7 +6679,7 @@ for (;; ptr++)
|
||||
newoptions = options;
|
||||
skipbytes = 0;
|
||||
bravalue = OP_CBRA;
|
||||
save_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
reset_bracount = FALSE;
|
||||
|
||||
/* Deal with the extended parentheses; all are introduced by '?', and the
|
||||
@@ -6641,6 +6697,7 @@ for (;; ptr++)
|
||||
/* ------------------------------------------------------------ */
|
||||
case CHAR_VERTICAL_LINE: /* Reset capture count for each branch */
|
||||
reset_bracount = TRUE;
|
||||
cd->dupgroups = TRUE; /* Record (?| encountered */
|
||||
/* Fall through */
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@@ -6741,6 +6798,12 @@ for (;; ptr++)
|
||||
{
|
||||
while (IS_DIGIT(*ptr))
|
||||
{
|
||||
if (recno > INT_MAX / 10 - 1) /* Integer overflow */
|
||||
{
|
||||
while (IS_DIGIT(*ptr)) ptr++;
|
||||
*errorcodeptr = ERR61;
|
||||
goto FAILED;
|
||||
}
|
||||
recno = recno * 10 + (int)(*ptr - CHAR_0);
|
||||
ptr++;
|
||||
}
|
||||
@@ -6769,7 +6832,7 @@ for (;; ptr++)
|
||||
ptr++;
|
||||
}
|
||||
namelen = (int)(ptr - name);
|
||||
if (lengthptr != NULL) *lengthptr += IMM2_SIZE;
|
||||
if (lengthptr != NULL) skipbytes += IMM2_SIZE;
|
||||
}
|
||||
|
||||
/* Check the terminator */
|
||||
@@ -6875,6 +6938,11 @@ for (;; ptr++)
|
||||
*errorcodeptr = ERR15;
|
||||
goto FAILED;
|
||||
}
|
||||
if (recno > INT_MAX / 10 - 1) /* Integer overflow */
|
||||
{
|
||||
*errorcodeptr = ERR61;
|
||||
goto FAILED;
|
||||
}
|
||||
recno = recno * 10 + name[i] - CHAR_0;
|
||||
}
|
||||
if (recno == 0) recno = RREF_ANY;
|
||||
@@ -7151,6 +7219,7 @@ for (;; ptr++)
|
||||
if (lengthptr != NULL)
|
||||
{
|
||||
named_group *ng;
|
||||
recno = 0;
|
||||
|
||||
if (namelen == 0)
|
||||
{
|
||||
@@ -7168,20 +7237,6 @@ for (;; ptr++)
|
||||
goto FAILED;
|
||||
}
|
||||
|
||||
/* The name table does not exist in the first pass; instead we must
|
||||
scan the list of names encountered so far in order to get the
|
||||
number. If the name is not found, set the value to 0 for a forward
|
||||
reference. */
|
||||
|
||||
ng = cd->named_groups;
|
||||
for (i = 0; i < cd->names_found; i++, ng++)
|
||||
{
|
||||
if (namelen == ng->length &&
|
||||
STRNCMP_UC_UC(name, ng->name, namelen) == 0)
|
||||
break;
|
||||
}
|
||||
recno = (i < cd->names_found)? ng->number : 0;
|
||||
|
||||
/* Count named back references. */
|
||||
|
||||
if (!is_recurse) cd->namedrefcount++;
|
||||
@@ -7191,6 +7246,56 @@ for (;; ptr++)
|
||||
16-bit data item. */
|
||||
|
||||
*lengthptr += IMM2_SIZE;
|
||||
|
||||
/* If this is a forward reference and we are within a (?|...) group,
|
||||
the reference may end up as the number of a group which we are
|
||||
currently inside, that is, it could be a recursive reference. In the
|
||||
real compile this will be picked up and the reference wrapped with
|
||||
OP_ONCE to make it atomic, so we must space in case this occurs. */
|
||||
|
||||
/* In fact, this can happen for a non-forward reference because
|
||||
another group with the same number might be created later. This
|
||||
issue is fixed "properly" in PCRE2. As PCRE1 is now in maintenance
|
||||
only mode, we finesse the bug by allowing more memory always. */
|
||||
|
||||
*lengthptr += 2 + 2*LINK_SIZE;
|
||||
|
||||
/* It is even worse than that. The current reference may be to an
|
||||
existing named group with a different number (so apparently not
|
||||
recursive) but which later on is also attached to a group with the
|
||||
current number. This can only happen if $(| has been previous
|
||||
encountered. In that case, we allow yet more memory, just in case.
|
||||
(Again, this is fixed "properly" in PCRE2. */
|
||||
|
||||
if (cd->dupgroups) *lengthptr += 4 + 4*LINK_SIZE;
|
||||
|
||||
/* Otherwise, check for recursion here. The name table does not exist
|
||||
in the first pass; instead we must scan the list of names encountered
|
||||
so far in order to get the number. If the name is not found, leave
|
||||
the value of recno as 0 for a forward reference. */
|
||||
|
||||
else
|
||||
{
|
||||
ng = cd->named_groups;
|
||||
for (i = 0; i < cd->names_found; i++, ng++)
|
||||
{
|
||||
if (namelen == ng->length &&
|
||||
STRNCMP_UC_UC(name, ng->name, namelen) == 0)
|
||||
{
|
||||
open_capitem *oc;
|
||||
recno = ng->number;
|
||||
if (is_recurse) break;
|
||||
for (oc = cd->open_caps; oc != NULL; oc = oc->next)
|
||||
{
|
||||
if (oc->number == recno)
|
||||
{
|
||||
oc->flag = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* In the real compile, search the name table. We check the name
|
||||
@@ -7237,8 +7342,6 @@ for (;; ptr++)
|
||||
for (i++; i < cd->names_found; i++)
|
||||
{
|
||||
if (STRCMP_UC_UC(slot + IMM2_SIZE, cslot + IMM2_SIZE) != 0) break;
|
||||
|
||||
|
||||
count++;
|
||||
cslot += cd->name_entry_size;
|
||||
}
|
||||
@@ -7247,6 +7350,7 @@ for (;; ptr++)
|
||||
{
|
||||
if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
|
||||
previous = code;
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
*code++ = ((options & PCRE_CASELESS) != 0)? OP_DNREFI : OP_DNREF;
|
||||
PUT2INC(code, 0, index);
|
||||
PUT2INC(code, 0, count);
|
||||
@@ -7284,9 +7388,14 @@ for (;; ptr++)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
case CHAR_R: /* Recursion */
|
||||
ptr++; /* Same as (?0) */
|
||||
/* Fall through */
|
||||
case CHAR_R: /* Recursion, same as (?0) */
|
||||
recno = 0;
|
||||
if (*(++ptr) != CHAR_RIGHT_PARENTHESIS)
|
||||
{
|
||||
*errorcodeptr = ERR29;
|
||||
goto FAILED;
|
||||
}
|
||||
goto HANDLE_RECURSION;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@@ -7323,7 +7432,15 @@ for (;; ptr++)
|
||||
|
||||
recno = 0;
|
||||
while(IS_DIGIT(*ptr))
|
||||
{
|
||||
if (recno > INT_MAX / 10 - 1) /* Integer overflow */
|
||||
{
|
||||
while (IS_DIGIT(*ptr)) ptr++;
|
||||
*errorcodeptr = ERR61;
|
||||
goto FAILED;
|
||||
}
|
||||
recno = recno * 10 + *ptr++ - CHAR_0;
|
||||
}
|
||||
|
||||
if (*ptr != (pcre_uchar)terminator)
|
||||
{
|
||||
@@ -7360,6 +7477,7 @@ for (;; ptr++)
|
||||
HANDLE_RECURSION:
|
||||
|
||||
previous = code;
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
called = cd->start_code;
|
||||
|
||||
/* When we are actually compiling, find the bracket that is being
|
||||
@@ -7561,7 +7679,11 @@ for (;; ptr++)
|
||||
previous = NULL;
|
||||
cd->iscondassert = FALSE;
|
||||
}
|
||||
else previous = code;
|
||||
else
|
||||
{
|
||||
previous = code;
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
}
|
||||
|
||||
*code = bravalue;
|
||||
tempcode = code;
|
||||
@@ -7809,7 +7931,7 @@ for (;; ptr++)
|
||||
const pcre_uchar *p;
|
||||
pcre_uint32 cf;
|
||||
|
||||
save_hwm_offset = cd->hwm - cd->start_workspace; /* Normally this is set when '(' is read */
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace; /* Normally this is set when '(' is read */
|
||||
terminator = (*(++ptr) == CHAR_LESS_THAN_SIGN)?
|
||||
CHAR_GREATER_THAN_SIGN : CHAR_APOSTROPHE;
|
||||
|
||||
@@ -7838,7 +7960,7 @@ for (;; ptr++)
|
||||
if (*p != (pcre_uchar)terminator)
|
||||
{
|
||||
*errorcodeptr = ERR57;
|
||||
break;
|
||||
goto FAILED;
|
||||
}
|
||||
ptr++;
|
||||
goto HANDLE_NUMERICAL_RECURSION;
|
||||
@@ -7853,7 +7975,7 @@ for (;; ptr++)
|
||||
ptr[1] != CHAR_APOSTROPHE && ptr[1] != CHAR_LEFT_CURLY_BRACKET))
|
||||
{
|
||||
*errorcodeptr = ERR69;
|
||||
break;
|
||||
goto FAILED;
|
||||
}
|
||||
is_recurse = FALSE;
|
||||
terminator = (*(++ptr) == CHAR_LESS_THAN_SIGN)?
|
||||
@@ -7877,6 +7999,7 @@ for (;; ptr++)
|
||||
HANDLE_REFERENCE:
|
||||
if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
|
||||
previous = code;
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
*code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF;
|
||||
PUT2INC(code, 0, recno);
|
||||
cd->backref_map |= (recno < 32)? (1 << recno) : 1;
|
||||
@@ -7906,6 +8029,7 @@ for (;; ptr++)
|
||||
if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr))
|
||||
goto FAILED;
|
||||
previous = code;
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
*code++ = ((escape == ESC_p) != negated)? OP_PROP : OP_NOTPROP;
|
||||
*code++ = ptype;
|
||||
*code++ = pdata;
|
||||
@@ -7946,6 +8070,7 @@ for (;; ptr++)
|
||||
|
||||
{
|
||||
previous = (escape > ESC_b && escape < ESC_Z)? code : NULL;
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
*code++ = (!utf && escape == ESC_C)? OP_ALLANY : escape;
|
||||
}
|
||||
}
|
||||
@@ -7989,6 +8114,7 @@ for (;; ptr++)
|
||||
|
||||
ONE_CHAR:
|
||||
previous = code;
|
||||
item_hwm_offset = cd->hwm - cd->start_workspace;
|
||||
|
||||
/* For caseless UTF-8 mode when UCP support is available, check whether
|
||||
this character has more than one other case. If so, generate a special
|
||||
@@ -9164,6 +9290,7 @@ cd->names_found = 0;
|
||||
cd->name_entry_size = 0;
|
||||
cd->name_table = NULL;
|
||||
cd->dupnames = FALSE;
|
||||
cd->dupgroups = FALSE;
|
||||
cd->namedrefcount = 0;
|
||||
cd->start_code = cworkspace;
|
||||
cd->hwm = cworkspace;
|
||||
@@ -9336,6 +9463,16 @@ if (cd->hwm > cd->start_workspace)
|
||||
int offset, recno;
|
||||
cd->hwm -= LINK_SIZE;
|
||||
offset = GET(cd->hwm, 0);
|
||||
|
||||
/* Check that the hwm handling hasn't gone wrong. This whole area is
|
||||
rewritten in PCRE2 because there are some obscure cases. */
|
||||
|
||||
if (offset == 0 || codestart[offset-1] != OP_RECURSE)
|
||||
{
|
||||
errorcode = ERR10;
|
||||
break;
|
||||
}
|
||||
|
||||
recno = GET(codestart, offset);
|
||||
if (recno != prev_recno)
|
||||
{
|
||||
@@ -9366,7 +9503,7 @@ used in this code because at least one compiler gives a warning about loss of
|
||||
"const" attribute if the cast (pcre_uchar *)codestart is used directly in the
|
||||
function call. */
|
||||
|
||||
if ((options & PCRE_NO_AUTO_POSSESS) == 0)
|
||||
if (errorcode == 0 && (options & PCRE_NO_AUTO_POSSESS) == 0)
|
||||
{
|
||||
pcre_uchar *temp = (pcre_uchar *)codestart;
|
||||
auto_possessify(temp, utf, cd);
|
||||
@@ -9380,7 +9517,7 @@ OP_RECURSE that are not fixed length get a diagnosic with a useful offset. The
|
||||
exceptional ones forgo this. We scan the pattern to check that they are fixed
|
||||
length, and set their lengths. */
|
||||
|
||||
if (cd->check_lookbehind)
|
||||
if (errorcode == 0 && cd->check_lookbehind)
|
||||
{
|
||||
pcre_uchar *cc = (pcre_uchar *)codestart;
|
||||
|
||||
@@ -9593,4 +9730,3 @@ return (pcre32 *)re;
|
||||
}
|
||||
|
||||
/* End of pcre_compile.c */
|
||||
|
||||
@@ -688,7 +688,7 @@ the alternative names that are used. */
|
||||
#define foc number
|
||||
#define save_mark data
|
||||
|
||||
/* These statements are here to stop the compiler complaining about uninitialized
|
||||
/* These statements are here to stop the compiler complaining about unitialized
|
||||
variables. */
|
||||
|
||||
#ifdef SUPPORT_UCP
|
||||
@@ -6685,7 +6685,8 @@ if (md->offset_vector != NULL)
|
||||
register int *iend = iptr - re->top_bracket;
|
||||
if (iend < md->offset_vector + 2) iend = md->offset_vector + 2;
|
||||
while (--iptr >= iend) *iptr = -1;
|
||||
md->offset_vector[0] = md->offset_vector[1] = -1;
|
||||
if (offsetcount > 0) md->offset_vector[0] = -1;
|
||||
if (offsetcount > 1) md->offset_vector[1] = -1;
|
||||
}
|
||||
|
||||
/* Set up the first character to match, if available. The first_char value is
|
||||
|
||||
@@ -988,7 +988,7 @@ other. NOTE: The values also appear in pcre_jit_compile.c. */
|
||||
#ifndef EBCDIC
|
||||
|
||||
#define HSPACE_LIST \
|
||||
CHAR_HT, CHAR_SPACE, 0xa0, \
|
||||
CHAR_HT, CHAR_SPACE, CHAR_NBSP, \
|
||||
0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, \
|
||||
0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202f, 0x205f, 0x3000, \
|
||||
NOTACHAR
|
||||
@@ -1014,7 +1014,7 @@ other. NOTE: The values also appear in pcre_jit_compile.c. */
|
||||
#define HSPACE_BYTE_CASES \
|
||||
case CHAR_HT: \
|
||||
case CHAR_SPACE: \
|
||||
case 0xa0 /* NBSP */
|
||||
case CHAR_NBSP
|
||||
|
||||
#define HSPACE_CASES \
|
||||
HSPACE_BYTE_CASES: \
|
||||
@@ -1041,11 +1041,12 @@ other. NOTE: The values also appear in pcre_jit_compile.c. */
|
||||
/* ------ EBCDIC environments ------ */
|
||||
|
||||
#else
|
||||
#define HSPACE_LIST CHAR_HT, CHAR_SPACE
|
||||
#define HSPACE_LIST CHAR_HT, CHAR_SPACE, CHAR_NBSP, NOTACHAR
|
||||
|
||||
#define HSPACE_BYTE_CASES \
|
||||
case CHAR_HT: \
|
||||
case CHAR_SPACE
|
||||
case CHAR_SPACE: \
|
||||
case CHAR_NBSP
|
||||
|
||||
#define HSPACE_CASES HSPACE_BYTE_CASES
|
||||
|
||||
@@ -1219,6 +1220,7 @@ same code point. */
|
||||
|
||||
#define CHAR_ESC '\047'
|
||||
#define CHAR_DEL '\007'
|
||||
#define CHAR_NBSP '\x41'
|
||||
#define STR_ESC "\047"
|
||||
#define STR_DEL "\007"
|
||||
|
||||
@@ -1233,6 +1235,7 @@ a positive value. */
|
||||
#define CHAR_NEL ((unsigned char)'\x85')
|
||||
#define CHAR_ESC '\033'
|
||||
#define CHAR_DEL '\177'
|
||||
#define CHAR_NBSP ((unsigned char)'\xa0')
|
||||
|
||||
#define STR_LF "\n"
|
||||
#define STR_NL STR_LF
|
||||
@@ -1610,6 +1613,7 @@ only. */
|
||||
#define CHAR_VERTICAL_LINE '\174'
|
||||
#define CHAR_RIGHT_CURLY_BRACKET '\175'
|
||||
#define CHAR_TILDE '\176'
|
||||
#define CHAR_NBSP ((unsigned char)'\xa0')
|
||||
|
||||
#define STR_HT "\011"
|
||||
#define STR_VT "\013"
|
||||
@@ -1766,6 +1770,10 @@ only. */
|
||||
|
||||
/* Escape items that are just an encoding of a particular data value. */
|
||||
|
||||
#ifndef ESC_a
|
||||
#define ESC_a CHAR_BEL
|
||||
#endif
|
||||
|
||||
#ifndef ESC_e
|
||||
#define ESC_e CHAR_ESC
|
||||
#endif
|
||||
@@ -2450,6 +2458,7 @@ typedef struct compile_data {
|
||||
BOOL had_pruneorskip; /* (*PRUNE) or (*SKIP) encountered */
|
||||
BOOL check_lookbehind; /* Lookbehinds need later checking */
|
||||
BOOL dupnames; /* Duplicate names exist */
|
||||
BOOL dupgroups; /* Duplicate groups exist: (?| found */
|
||||
BOOL iscondassert; /* Next assert is a condition */
|
||||
int nltype; /* Newline type */
|
||||
int nllen; /* Newline string length */
|
||||
|
||||
@@ -1064,6 +1064,7 @@ pcre_uchar *alternative;
|
||||
pcre_uchar *end = NULL;
|
||||
int private_data_ptr = *private_data_start;
|
||||
int space, size, bracketlen;
|
||||
BOOL repeat_check = TRUE;
|
||||
|
||||
while (cc < ccend)
|
||||
{
|
||||
@@ -1071,9 +1072,10 @@ while (cc < ccend)
|
||||
size = 0;
|
||||
bracketlen = 0;
|
||||
if (private_data_ptr > SLJIT_MAX_LOCAL_SIZE)
|
||||
return;
|
||||
break;
|
||||
|
||||
if (*cc == OP_ONCE || *cc == OP_ONCE_NC || *cc == OP_BRA || *cc == OP_CBRA || *cc == OP_COND)
|
||||
if (repeat_check && (*cc == OP_ONCE || *cc == OP_ONCE_NC || *cc == OP_BRA || *cc == OP_CBRA || *cc == OP_COND))
|
||||
{
|
||||
if (detect_repeat(common, cc))
|
||||
{
|
||||
/* These brackets are converted to repeats, so no global
|
||||
@@ -1081,6 +1083,8 @@ while (cc < ccend)
|
||||
if (cc >= end)
|
||||
end = bracketend(cc);
|
||||
}
|
||||
}
|
||||
repeat_check = TRUE;
|
||||
|
||||
switch(*cc)
|
||||
{
|
||||
@@ -1136,6 +1140,13 @@ while (cc < ccend)
|
||||
bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
|
||||
break;
|
||||
|
||||
case OP_BRAZERO:
|
||||
case OP_BRAMINZERO:
|
||||
case OP_BRAPOSZERO:
|
||||
repeat_check = FALSE;
|
||||
size = 1;
|
||||
break;
|
||||
|
||||
CASE_ITERATOR_PRIVATE_DATA_1
|
||||
space = 1;
|
||||
size = -2;
|
||||
@@ -1162,12 +1173,17 @@ while (cc < ccend)
|
||||
size = 1;
|
||||
break;
|
||||
|
||||
CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
|
||||
case OP_TYPEUPTO:
|
||||
if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)
|
||||
space = 2;
|
||||
size = 1 + IMM2_SIZE;
|
||||
break;
|
||||
|
||||
case OP_TYPEMINUPTO:
|
||||
space = 2;
|
||||
size = 1 + IMM2_SIZE;
|
||||
break;
|
||||
|
||||
case OP_CLASS:
|
||||
case OP_NCLASS:
|
||||
size += 1 + 32 / sizeof(pcre_uchar);
|
||||
@@ -1316,6 +1332,13 @@ while (cc < ccend)
|
||||
cc += 1 + LINK_SIZE + IMM2_SIZE;
|
||||
break;
|
||||
|
||||
case OP_THEN:
|
||||
stack_restore = TRUE;
|
||||
if (common->control_head_ptr != 0)
|
||||
*needs_control_head = TRUE;
|
||||
cc ++;
|
||||
break;
|
||||
|
||||
default:
|
||||
stack_restore = TRUE;
|
||||
/* Fall through. */
|
||||
@@ -2220,6 +2243,7 @@ while (current != NULL)
|
||||
SLJIT_ASSERT_STOP();
|
||||
break;
|
||||
}
|
||||
SLJIT_ASSERT(current > (sljit_sw*)current[-1]);
|
||||
current = (sljit_sw*)current[-1];
|
||||
}
|
||||
return -1;
|
||||
@@ -3209,7 +3233,7 @@ bytes[len] = byte;
|
||||
bytes[0] = len;
|
||||
}
|
||||
|
||||
static int scan_prefix(compiler_common *common, pcre_uchar *cc, pcre_uint32 *chars, pcre_uint8 *bytes, int max_chars)
|
||||
static int scan_prefix(compiler_common *common, pcre_uchar *cc, pcre_uint32 *chars, pcre_uint8 *bytes, int max_chars, pcre_uint32 *rec_count)
|
||||
{
|
||||
/* Recursive function, which scans prefix literals. */
|
||||
BOOL last, any, caseless;
|
||||
@@ -3227,9 +3251,14 @@ pcre_uchar othercase[1];
|
||||
repeat = 1;
|
||||
while (TRUE)
|
||||
{
|
||||
if (*rec_count == 0)
|
||||
return 0;
|
||||
(*rec_count)--;
|
||||
|
||||
last = TRUE;
|
||||
any = FALSE;
|
||||
caseless = FALSE;
|
||||
|
||||
switch (*cc)
|
||||
{
|
||||
case OP_CHARI:
|
||||
@@ -3291,7 +3320,7 @@ while (TRUE)
|
||||
#ifdef SUPPORT_UTF
|
||||
if (common->utf && HAS_EXTRALEN(*cc)) len += GET_EXTRALEN(*cc);
|
||||
#endif
|
||||
max_chars = scan_prefix(common, cc + len, chars, bytes, max_chars);
|
||||
max_chars = scan_prefix(common, cc + len, chars, bytes, max_chars, rec_count);
|
||||
if (max_chars == 0)
|
||||
return consumed;
|
||||
last = FALSE;
|
||||
@@ -3314,7 +3343,7 @@ while (TRUE)
|
||||
alternative = cc + GET(cc, 1);
|
||||
while (*alternative == OP_ALT)
|
||||
{
|
||||
max_chars = scan_prefix(common, alternative + 1 + LINK_SIZE, chars, bytes, max_chars);
|
||||
max_chars = scan_prefix(common, alternative + 1 + LINK_SIZE, chars, bytes, max_chars, rec_count);
|
||||
if (max_chars == 0)
|
||||
return consumed;
|
||||
alternative += GET(alternative, 1);
|
||||
@@ -3556,6 +3585,7 @@ int i, max, from;
|
||||
int range_right = -1, range_len = 3 - 1;
|
||||
sljit_ub *update_table = NULL;
|
||||
BOOL in_range;
|
||||
pcre_uint32 rec_count;
|
||||
|
||||
for (i = 0; i < MAX_N_CHARS; i++)
|
||||
{
|
||||
@@ -3564,7 +3594,8 @@ for (i = 0; i < MAX_N_CHARS; i++)
|
||||
bytes[i * MAX_N_BYTES] = 0;
|
||||
}
|
||||
|
||||
max = scan_prefix(common, common->start, chars, bytes, MAX_N_CHARS);
|
||||
rec_count = 10000;
|
||||
max = scan_prefix(common, common->start, chars, bytes, MAX_N_CHARS, &rec_count);
|
||||
|
||||
if (max <= 1)
|
||||
return FALSE;
|
||||
@@ -4311,8 +4342,10 @@ switch(length)
|
||||
case 4:
|
||||
if ((ranges[1] - ranges[0]) == (ranges[3] - ranges[2])
|
||||
&& (ranges[0] | (ranges[2] - ranges[0])) == ranges[2]
|
||||
&& (ranges[1] & (ranges[2] - ranges[0])) == 0
|
||||
&& is_powerof2(ranges[2] - ranges[0]))
|
||||
{
|
||||
SLJIT_ASSERT((ranges[0] & (ranges[2] - ranges[0])) == 0 && (ranges[2] & ranges[3] & (ranges[2] - ranges[0])) != 0);
|
||||
OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[0]);
|
||||
if (ranges[2] + 1 != ranges[3])
|
||||
{
|
||||
@@ -4900,9 +4933,10 @@ else if ((cc[-1] & XCL_MAP) != 0)
|
||||
if (!check_class_ranges(common, (const pcre_uint8 *)cc, FALSE, TRUE, list))
|
||||
{
|
||||
#ifdef COMPILE_PCRE8
|
||||
SLJIT_ASSERT(common->utf);
|
||||
jump = NULL;
|
||||
if (common->utf)
|
||||
#endif
|
||||
jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
|
||||
jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
|
||||
|
||||
OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
|
||||
OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
|
||||
@@ -4911,7 +4945,10 @@ else if ((cc[-1] & XCL_MAP) != 0)
|
||||
OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
|
||||
add_jump(compiler, list, JUMP(SLJIT_NOT_ZERO));
|
||||
|
||||
JUMPHERE(jump);
|
||||
#ifdef COMPILE_PCRE8
|
||||
if (common->utf)
|
||||
#endif
|
||||
JUMPHERE(jump);
|
||||
}
|
||||
|
||||
OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
|
||||
@@ -5219,7 +5256,7 @@ while (*cc != XCL_END)
|
||||
OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_LESS_EQUAL);
|
||||
|
||||
SET_CHAR_OFFSET(0);
|
||||
OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xff);
|
||||
OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x7f);
|
||||
OP_FLAGS(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL);
|
||||
|
||||
SET_TYPE_OFFSET(ucp_Pc);
|
||||
@@ -7665,6 +7702,10 @@ while (*cc != OP_KETRPOS)
|
||||
OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
|
||||
}
|
||||
|
||||
/* Even if the match is empty, we need to reset the control head. */
|
||||
if (needs_control_head)
|
||||
OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
|
||||
|
||||
if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)
|
||||
add_jump(compiler, &emptymatch, CMP(SLJIT_EQUAL, TMP1, 0, STR_PTR, 0));
|
||||
|
||||
@@ -7692,6 +7733,10 @@ while (*cc != OP_KETRPOS)
|
||||
OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw), STR_PTR, 0);
|
||||
}
|
||||
|
||||
/* Even if the match is empty, we need to reset the control head. */
|
||||
if (needs_control_head)
|
||||
OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
|
||||
|
||||
if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)
|
||||
add_jump(compiler, &emptymatch, CMP(SLJIT_EQUAL, TMP1, 0, STR_PTR, 0));
|
||||
|
||||
@@ -7704,9 +7749,6 @@ while (*cc != OP_KETRPOS)
|
||||
}
|
||||
}
|
||||
|
||||
if (needs_control_head)
|
||||
OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
|
||||
|
||||
JUMPTO(SLJIT_JUMP, loop);
|
||||
flush_stubs(common);
|
||||
|
||||
@@ -8441,8 +8483,7 @@ while (cc < ccend)
|
||||
OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), STR_PTR, 0);
|
||||
}
|
||||
BACKTRACK_AS(braminzero_backtrack)->matchingpath = LABEL();
|
||||
if (cc[1] > OP_ASSERTBACK_NOT)
|
||||
count_match(common);
|
||||
count_match(common);
|
||||
break;
|
||||
|
||||
case OP_ONCE:
|
||||
@@ -9624,7 +9665,7 @@ static SLJIT_INLINE void compile_recurse(compiler_common *common)
|
||||
DEFINE_COMPILER;
|
||||
pcre_uchar *cc = common->start + common->currententry->start;
|
||||
pcre_uchar *ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : IMM2_SIZE);
|
||||
pcre_uchar *ccend = bracketend(cc);
|
||||
pcre_uchar *ccend = bracketend(cc) - (1 + LINK_SIZE);
|
||||
BOOL needs_control_head;
|
||||
int framesize = get_framesize(common, cc, NULL, TRUE, &needs_control_head);
|
||||
int private_data_size = get_private_data_copy_length(common, ccbegin, ccend, needs_control_head);
|
||||
@@ -9648,6 +9689,7 @@ set_jumps(common->currententry->calls, common->currententry->entry);
|
||||
|
||||
sljit_emit_fast_enter(compiler, TMP2, 0);
|
||||
allocate_stack(common, private_data_size + framesize + alternativesize);
|
||||
count_match(common);
|
||||
OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(private_data_size + framesize + alternativesize - 1), TMP2, 0);
|
||||
copy_private_data(common, ccbegin, ccend, TRUE, private_data_size + framesize + alternativesize, framesize + alternativesize, needs_control_head);
|
||||
if (needs_control_head)
|
||||
@@ -9992,6 +10034,7 @@ OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack));
|
||||
OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, limit_match));
|
||||
OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, base));
|
||||
OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, limit));
|
||||
OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
|
||||
OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LIMIT_MATCH, TMP1, 0);
|
||||
|
||||
if (mode == JIT_PARTIAL_SOFT_COMPILE)
|
||||
|
||||
@@ -71,6 +71,7 @@ Arguments:
|
||||
startcode pointer to start of the whole pattern's code
|
||||
options the compiling options
|
||||
recurses chain of recurse_check to catch mutual recursion
|
||||
countptr pointer to call count (to catch over complexity)
|
||||
|
||||
Returns: the minimum length
|
||||
-1 if \C in UTF-8 mode or (*ACCEPT) was encountered
|
||||
@@ -80,7 +81,8 @@ Returns: the minimum length
|
||||
|
||||
static int
|
||||
find_minlength(const REAL_PCRE *re, const pcre_uchar *code,
|
||||
const pcre_uchar *startcode, int options, recurse_check *recurses)
|
||||
const pcre_uchar *startcode, int options, recurse_check *recurses,
|
||||
int *countptr)
|
||||
{
|
||||
int length = -1;
|
||||
/* PCRE_UTF16 has the same value as PCRE_UTF8. */
|
||||
@@ -90,6 +92,8 @@ recurse_check this_recurse;
|
||||
register int branchlength = 0;
|
||||
register pcre_uchar *cc = (pcre_uchar *)code + 1 + LINK_SIZE;
|
||||
|
||||
if ((*countptr)++ > 1000) return -1; /* too complex */
|
||||
|
||||
if (*code == OP_CBRA || *code == OP_SCBRA ||
|
||||
*code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += IMM2_SIZE;
|
||||
|
||||
@@ -131,7 +135,7 @@ for (;;)
|
||||
case OP_SBRAPOS:
|
||||
case OP_ONCE:
|
||||
case OP_ONCE_NC:
|
||||
d = find_minlength(re, cc, startcode, options, recurses);
|
||||
d = find_minlength(re, cc, startcode, options, recurses, countptr);
|
||||
if (d < 0) return d;
|
||||
branchlength += d;
|
||||
do cc += GET(cc, 1); while (*cc == OP_ALT);
|
||||
@@ -415,7 +419,8 @@ for (;;)
|
||||
int dd;
|
||||
this_recurse.prev = recurses;
|
||||
this_recurse.group = cs;
|
||||
dd = find_minlength(re, cs, startcode, options, &this_recurse);
|
||||
dd = find_minlength(re, cs, startcode, options, &this_recurse,
|
||||
countptr);
|
||||
if (dd < d) d = dd;
|
||||
}
|
||||
}
|
||||
@@ -451,7 +456,8 @@ for (;;)
|
||||
{
|
||||
this_recurse.prev = recurses;
|
||||
this_recurse.group = cs;
|
||||
d = find_minlength(re, cs, startcode, options, &this_recurse);
|
||||
d = find_minlength(re, cs, startcode, options, &this_recurse,
|
||||
countptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -514,7 +520,7 @@ for (;;)
|
||||
this_recurse.prev = recurses;
|
||||
this_recurse.group = cs;
|
||||
branchlength += find_minlength(re, cs, startcode, options,
|
||||
&this_recurse);
|
||||
&this_recurse, countptr);
|
||||
}
|
||||
}
|
||||
cc += 1 + LINK_SIZE;
|
||||
@@ -1453,6 +1459,7 @@ pcre32_study(const pcre32 *external_re, int options, const char **errorptr)
|
||||
#endif
|
||||
{
|
||||
int min;
|
||||
int count = 0;
|
||||
BOOL bits_set = FALSE;
|
||||
pcre_uint8 start_bits[32];
|
||||
PUBL(extra) *extra = NULL;
|
||||
@@ -1539,7 +1546,7 @@ if ((re->options & PCRE_ANCHORED) == 0 &&
|
||||
|
||||
/* Find the minimum length of subject string. */
|
||||
|
||||
switch(min = find_minlength(re, code, code, re->options, NULL))
|
||||
switch(min = find_minlength(re, code, code, re->options, NULL, &count))
|
||||
{
|
||||
case -2: *errorptr = "internal error: missing capturing bracket"; return NULL;
|
||||
case -3: *errorptr = "internal error: opcode not recognized"; return NULL;
|
||||
|
||||
@@ -246,7 +246,7 @@ while ((t = *data++) != XCL_END)
|
||||
|
||||
case PT_PXPUNCT:
|
||||
if ((PRIV(ucp_gentype)[prop->chartype] == ucp_P ||
|
||||
(c < 256 && PRIV(ucp_gentype)[prop->chartype] == ucp_S)) == isprop)
|
||||
(c < 128 && PRIV(ucp_gentype)[prop->chartype] == ucp_S)) == isprop)
|
||||
return !negated;
|
||||
break;
|
||||
|
||||
|
||||
@@ -96,6 +96,15 @@
|
||||
#define SLJIT_EXECUTABLE_ALLOCATOR 1
|
||||
#endif
|
||||
|
||||
/* Force cdecl calling convention even if a better calling
|
||||
convention (e.g. fastcall) is supported by the C compiler.
|
||||
If this option is enabled, C functions without
|
||||
SLJIT_CALL can also be called from JIT code. */
|
||||
#ifndef SLJIT_USE_CDECL_CALLING_CONVENTION
|
||||
/* Disabled by default */
|
||||
#define SLJIT_USE_CDECL_CALLING_CONVENTION 0
|
||||
#endif
|
||||
|
||||
/* Return with error when an invalid argument is passed. */
|
||||
#ifndef SLJIT_ARGUMENT_CHECKS
|
||||
/* Disabled by default */
|
||||
|
||||
@@ -468,7 +468,12 @@ typedef double sljit_d;
|
||||
|
||||
#ifndef SLJIT_CALL
|
||||
|
||||
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
|
||||
#if (defined SLJIT_USE_CDECL_CALLING_CONVENTION && SLJIT_USE_CDECL_CALLING_CONVENTION)
|
||||
|
||||
/* Force cdecl. */
|
||||
#define SLJIT_CALL
|
||||
|
||||
#elif (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
|
||||
|
||||
#if defined(__GNUC__) && !defined(__APPLE__)
|
||||
|
||||
@@ -608,6 +613,12 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
|
||||
#define SLJIT_LOCALS_OFFSET_BASE ((23 + 1) * sizeof(sljit_sw))
|
||||
#endif
|
||||
|
||||
#elif (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
|
||||
|
||||
#define SLJIT_NUMBER_OF_REGISTERS 10
|
||||
#define SLJIT_NUMBER_OF_SAVED_REGISTERS 5
|
||||
#define SLJIT_LOCALS_OFFSET_BASE 0
|
||||
|
||||
#elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
|
||||
|
||||
#define SLJIT_NUMBER_OF_REGISTERS 0
|
||||
|
||||
@@ -845,8 +845,8 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *comp
|
||||
}
|
||||
|
||||
static SLJIT_CONST char* op0_names[] = {
|
||||
(char*)"breakpoint", (char*)"nop",
|
||||
(char*)"lumul", (char*)"lsmul", (char*)"ludiv", (char*)"lsdiv",
|
||||
(char*)"breakpoint", (char*)"nop", (char*)"lumul", (char*)"lsmul",
|
||||
(char*)"udivmod", (char*)"sdivmod", (char*)"udivi", (char*)"sdivi"
|
||||
};
|
||||
|
||||
static SLJIT_CONST char* op1_names[] = {
|
||||
@@ -1036,7 +1036,7 @@ static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op0(struct sljit_compiler
|
||||
{
|
||||
#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
|
||||
CHECK_ARGUMENT((op >= SLJIT_BREAKPOINT && op <= SLJIT_LSMUL)
|
||||
|| ((op & ~SLJIT_INT_OP) >= SLJIT_LUDIV && (op & ~SLJIT_INT_OP) <= SLJIT_LSDIV));
|
||||
|| ((op & ~SLJIT_INT_OP) >= SLJIT_UDIVMOD && (op & ~SLJIT_INT_OP) <= SLJIT_SDIVI));
|
||||
CHECK_ARGUMENT(op < SLJIT_LUMUL || compiler->scratches >= 2);
|
||||
#endif
|
||||
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
|
||||
@@ -1447,6 +1447,8 @@ static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op_flags(struct sljit_com
|
||||
|
||||
static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset)
|
||||
{
|
||||
SLJIT_UNUSED_ARG(offset);
|
||||
|
||||
#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
|
||||
FUNCTION_CHECK_DST(dst, dstw);
|
||||
#endif
|
||||
@@ -1462,6 +1464,8 @@ static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_local_base(struct sljit_co
|
||||
|
||||
static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw init_value)
|
||||
{
|
||||
SLJIT_UNUSED_ARG(init_value);
|
||||
|
||||
#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
|
||||
FUNCTION_CHECK_DST(dst, dstw);
|
||||
#endif
|
||||
|
||||
@@ -687,7 +687,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
|
||||
#define SLJIT_OP0_BASE 0
|
||||
|
||||
/* Flags: - (never set any flags)
|
||||
Note: breakpoint instruction is not supported by all architectures (namely ppc)
|
||||
Note: breakpoint instruction is not supported by all architectures (e.g. ppc)
|
||||
It falls back to SLJIT_NOP in those cases. */
|
||||
#define SLJIT_BREAKPOINT (SLJIT_OP0_BASE + 0)
|
||||
/* Flags: - (never set any flags)
|
||||
@@ -696,24 +696,42 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
|
||||
#define SLJIT_NOP (SLJIT_OP0_BASE + 1)
|
||||
/* Flags: - (may destroy flags)
|
||||
Unsigned multiplication of SLJIT_R0 and SLJIT_R1.
|
||||
Result goes to SLJIT_R1:SLJIT_R0 (high:low) word */
|
||||
Result is placed into SLJIT_R1:SLJIT_R0 (high:low) word */
|
||||
#define SLJIT_LUMUL (SLJIT_OP0_BASE + 2)
|
||||
/* Flags: - (may destroy flags)
|
||||
Signed multiplication of SLJIT_R0 and SLJIT_R1.
|
||||
Result goes to SLJIT_R1:SLJIT_R0 (high:low) word */
|
||||
Result is placed into SLJIT_R1:SLJIT_R0 (high:low) word */
|
||||
#define SLJIT_LSMUL (SLJIT_OP0_BASE + 3)
|
||||
/* Flags: I - (may destroy flags)
|
||||
Unsigned divide of the value in SLJIT_R0 by the value in SLJIT_R1.
|
||||
The result is placed in SLJIT_R0 and the remainder goes to SLJIT_R1.
|
||||
Note: if SLJIT_R1 contains 0, the behaviour is undefined. */
|
||||
#define SLJIT_LUDIV (SLJIT_OP0_BASE + 4)
|
||||
#define SLJIT_ILUDIV (SLJIT_LUDIV | SLJIT_INT_OP)
|
||||
The result is placed into SLJIT_R0 and the remainder into SLJIT_R1.
|
||||
Note: if SLJIT_R1 is 0, the behaviour is undefined. */
|
||||
#define SLJIT_UDIVMOD (SLJIT_OP0_BASE + 4)
|
||||
#define SLJIT_IUDIVMOD (SLJIT_UDIVMOD | SLJIT_INT_OP)
|
||||
/* Flags: I - (may destroy flags)
|
||||
Signed divide of the value in SLJIT_R0 by the value in SLJIT_R1.
|
||||
The result is placed in SLJIT_R0 and the remainder goes to SLJIT_R1.
|
||||
Note: if SLJIT_R1 contains 0, the behaviour is undefined. */
|
||||
#define SLJIT_LSDIV (SLJIT_OP0_BASE + 5)
|
||||
#define SLJIT_ILSDIV (SLJIT_LSDIV | SLJIT_INT_OP)
|
||||
The result is placed into SLJIT_R0 and the remainder into SLJIT_R1.
|
||||
Note: if SLJIT_R1 is 0, the behaviour is undefined.
|
||||
Note: if SLJIT_R1 is -1 and SLJIT_R0 is integer min (0x800..00),
|
||||
the behaviour is undefined. */
|
||||
#define SLJIT_SDIVMOD (SLJIT_OP0_BASE + 5)
|
||||
#define SLJIT_ISDIVMOD (SLJIT_SDIVMOD | SLJIT_INT_OP)
|
||||
/* Flags: I - (may destroy flags)
|
||||
Unsigned divide of the value in SLJIT_R0 by the value in SLJIT_R1.
|
||||
The result is placed into SLJIT_R0. SLJIT_R1 preserves its value.
|
||||
Note: if SLJIT_R1 is 0, the behaviour is undefined.
|
||||
Note: SLJIT_SDIV is single precision divide. */
|
||||
#define SLJIT_UDIVI (SLJIT_OP0_BASE + 6)
|
||||
#define SLJIT_IUDIVI (SLJIT_UDIVI | SLJIT_INT_OP)
|
||||
/* Flags: I - (may destroy flags)
|
||||
Signed divide of the value in SLJIT_R0 by the value in SLJIT_R1.
|
||||
The result is placed into SLJIT_R0. SLJIT_R1 preserves its value.
|
||||
Note: if SLJIT_R1 is 0, the behaviour is undefined.
|
||||
Note: if SLJIT_R1 is -1 and SLJIT_R0 is integer min (0x800..00),
|
||||
the behaviour is undefined.
|
||||
Note: SLJIT_SDIV is single precision divide. */
|
||||
#define SLJIT_SDIVI (SLJIT_OP0_BASE + 7)
|
||||
#define SLJIT_ISDIVI (SLJIT_SDIVI | SLJIT_INT_OP)
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op);
|
||||
|
||||
@@ -851,34 +869,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
|
||||
sljit_si src1, sljit_sw src1w,
|
||||
sljit_si src2, sljit_sw src2w);
|
||||
|
||||
/* The following function is a helper function for sljit_emit_op_custom.
|
||||
It returns with the real machine register index ( >=0 ) of any SLJIT_R,
|
||||
SLJIT_S and SLJIT_SP registers.
|
||||
|
||||
Note: it returns with -1 for virtual registers (only on x86-32). */
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg);
|
||||
|
||||
/* The following function is a helper function for sljit_emit_op_custom.
|
||||
It returns with the real machine register index of any SLJIT_FLOAT register.
|
||||
|
||||
Note: the index is always an even number on ARM (except ARM-64), MIPS, and SPARC. */
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg);
|
||||
|
||||
/* Any instruction can be inserted into the instruction stream by
|
||||
sljit_emit_op_custom. It has a similar purpose as inline assembly.
|
||||
The size parameter must match to the instruction size of the target
|
||||
architecture:
|
||||
|
||||
x86: 0 < size <= 15. The instruction argument can be byte aligned.
|
||||
Thumb2: if size == 2, the instruction argument must be 2 byte aligned.
|
||||
if size == 4, the instruction argument must be 4 byte aligned.
|
||||
Otherwise: size must be 4 and instruction argument must be 4 byte aligned. */
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
|
||||
void *instruction, sljit_si size);
|
||||
|
||||
/* Returns with non-zero if fpu is available. */
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void);
|
||||
@@ -1196,4 +1186,64 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_function_context(void** func_ptr, struct
|
||||
|
||||
#endif /* !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) */
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* CPU specific functions */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
/* The following function is a helper function for sljit_emit_op_custom.
|
||||
It returns with the real machine register index ( >=0 ) of any SLJIT_R,
|
||||
SLJIT_S and SLJIT_SP registers.
|
||||
|
||||
Note: it returns with -1 for virtual registers (only on x86-32). */
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg);
|
||||
|
||||
/* The following function is a helper function for sljit_emit_op_custom.
|
||||
It returns with the real machine register index of any SLJIT_FLOAT register.
|
||||
|
||||
Note: the index is always an even number on ARM (except ARM-64), MIPS, and SPARC. */
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg);
|
||||
|
||||
/* Any instruction can be inserted into the instruction stream by
|
||||
sljit_emit_op_custom. It has a similar purpose as inline assembly.
|
||||
The size parameter must match to the instruction size of the target
|
||||
architecture:
|
||||
|
||||
x86: 0 < size <= 15. The instruction argument can be byte aligned.
|
||||
Thumb2: if size == 2, the instruction argument must be 2 byte aligned.
|
||||
if size == 4, the instruction argument must be 4 byte aligned.
|
||||
Otherwise: size must be 4 and instruction argument must be 4 byte aligned. */
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
|
||||
void *instruction, sljit_si size);
|
||||
|
||||
#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
|
||||
|
||||
/* Returns with non-zero if sse2 is available. */
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_sse2_available(void);
|
||||
|
||||
/* Returns with non-zero if cmov instruction is available. */
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_cmov_available(void);
|
||||
|
||||
/* Emit a conditional mov instruction on x86 CPUs. This instruction
|
||||
moves src to destination, if the condition is satisfied. Unlike
|
||||
other arithmetic instructions, destination must be a register.
|
||||
Before such instructions are emitted, cmov support should be
|
||||
checked by sljit_x86_is_cmov_available function.
|
||||
type must be between SLJIT_EQUAL and SLJIT_S_ORDERED
|
||||
dst_reg must be a valid register and it can be combined
|
||||
with SLJIT_INT_OP to perform 32 bit arithmetic
|
||||
Flags: I - (never set any flags)
|
||||
*/
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_emit_cmov(struct sljit_compiler *compiler,
|
||||
sljit_si type,
|
||||
sljit_si dst_reg,
|
||||
sljit_si src, sljit_sw srcw);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _SLJIT_LIR_H_ */
|
||||
@@ -1833,18 +1833,33 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
| (reg_map[SLJIT_R0] << 8)
|
||||
| reg_map[TMP_REG1]);
|
||||
#endif
|
||||
case SLJIT_LUDIV:
|
||||
case SLJIT_LSDIV:
|
||||
if (compiler->scratches >= 3)
|
||||
case SLJIT_UDIVMOD:
|
||||
case SLJIT_SDIVMOD:
|
||||
case SLJIT_UDIVI:
|
||||
case SLJIT_SDIVI:
|
||||
SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
|
||||
SLJIT_COMPILE_ASSERT(reg_map[2] == 1 && reg_map[3] == 2, bad_register_mapping);
|
||||
|
||||
if ((op >= SLJIT_UDIVI) && (compiler->scratches >= 3)) {
|
||||
FAIL_IF(push_inst(compiler, 0xe52d2008 /* str r2, [sp, #-8]! */));
|
||||
FAIL_IF(push_inst(compiler, 0xe58d1004 /* str r1, [sp, #4] */));
|
||||
}
|
||||
else if ((op >= SLJIT_UDIVI) || (compiler->scratches >= 3))
|
||||
FAIL_IF(push_inst(compiler, 0xe52d0008 | (op >= SLJIT_UDIVI ? 0x1000 : 0x2000) /* str r1/r2, [sp, #-8]! */));
|
||||
|
||||
#if defined(__GNUC__)
|
||||
FAIL_IF(sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM,
|
||||
(op == SLJIT_LUDIV ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
|
||||
((op | 0x2) == SLJIT_UDIVI ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
|
||||
#else
|
||||
#error "Software divmod functions are needed"
|
||||
#endif
|
||||
if (compiler->scratches >= 3)
|
||||
return push_inst(compiler, 0xe49d2008 /* ldr r2, [sp], #8 */);
|
||||
|
||||
if ((op >= SLJIT_UDIVI) && (compiler->scratches >= 3)) {
|
||||
FAIL_IF(push_inst(compiler, 0xe59d1004 /* ldr r1, [sp, #4] */));
|
||||
FAIL_IF(push_inst(compiler, 0xe49d2008 /* ldr r2, [sp], #8 */));
|
||||
}
|
||||
else if ((op >= SLJIT_UDIVI) || (compiler->scratches >= 3))
|
||||
return push_inst(compiler, 0xe49d0008 | (op >= SLJIT_UDIVI ? 0x1000 : 0x2000) /* ldr r1/r2, [sp], #8 */);
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1087,14 +1087,20 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
|
||||
saved_regs_size += sizeof(sljit_sw);
|
||||
}
|
||||
local_size -= saved_regs_size + SLJIT_LOCALS_OFFSET;
|
||||
FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
|
||||
if (saved_regs_size > 0)
|
||||
FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
|
||||
}
|
||||
|
||||
tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
|
||||
prev = -1;
|
||||
for (i = SLJIT_S0; i >= tmp; i--) {
|
||||
if (prev == -1) {
|
||||
prev = i;
|
||||
if (!(offs & (1 << 15))) {
|
||||
prev = i;
|
||||
continue;
|
||||
}
|
||||
FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
|
||||
offs += 1 << 15;
|
||||
continue;
|
||||
}
|
||||
FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
|
||||
@@ -1104,7 +1110,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
|
||||
|
||||
for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
|
||||
if (prev == -1) {
|
||||
prev = i;
|
||||
if (!(offs & (1 << 15))) {
|
||||
prev = i;
|
||||
continue;
|
||||
}
|
||||
FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
|
||||
offs += 1 << 15;
|
||||
continue;
|
||||
}
|
||||
FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
|
||||
@@ -1112,8 +1123,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
|
||||
prev = -1;
|
||||
}
|
||||
|
||||
if (prev != -1)
|
||||
FAIL_IF(push_inst(compiler, STRI | RT(prev) | RN(TMP_SP) | (offs >> 5)));
|
||||
SLJIT_ASSERT(prev == -1);
|
||||
|
||||
if (compiler->local_size > (63 * sizeof(sljit_sw))) {
|
||||
/* The local_size is already adjusted by the saved registers. */
|
||||
@@ -1188,7 +1198,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
|
||||
prev = -1;
|
||||
for (i = SLJIT_S0; i >= tmp; i--) {
|
||||
if (prev == -1) {
|
||||
prev = i;
|
||||
if (!(offs & (1 << 15))) {
|
||||
prev = i;
|
||||
continue;
|
||||
}
|
||||
FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
|
||||
offs += 1 << 15;
|
||||
continue;
|
||||
}
|
||||
FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
|
||||
@@ -1198,7 +1213,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
|
||||
|
||||
for (i = compiler->scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
|
||||
if (prev == -1) {
|
||||
prev = i;
|
||||
if (!(offs & (1 << 15))) {
|
||||
prev = i;
|
||||
continue;
|
||||
}
|
||||
FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
|
||||
offs += 1 << 15;
|
||||
continue;
|
||||
}
|
||||
FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
|
||||
@@ -1206,13 +1226,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
|
||||
prev = -1;
|
||||
}
|
||||
|
||||
if (prev != -1)
|
||||
FAIL_IF(push_inst(compiler, LDRI | RT(prev) | RN(TMP_SP) | (offs >> 5)));
|
||||
SLJIT_ASSERT(prev == -1);
|
||||
|
||||
if (compiler->local_size <= (63 * sizeof(sljit_sw))) {
|
||||
FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
|
||||
| RN(TMP_SP) | (((local_size >> 3) & 0x7f) << 15)));
|
||||
} else {
|
||||
} else if (saved_regs_size > 0) {
|
||||
FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
|
||||
}
|
||||
|
||||
@@ -1242,12 +1261,15 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
FAIL_IF(push_inst(compiler, ORR | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0)));
|
||||
FAIL_IF(push_inst(compiler, MADD | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO)));
|
||||
return push_inst(compiler, (op == SLJIT_LUMUL ? UMULH : SMULH) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1));
|
||||
case SLJIT_LUDIV:
|
||||
case SLJIT_LSDIV:
|
||||
case SLJIT_UDIVMOD:
|
||||
case SLJIT_SDIVMOD:
|
||||
FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0)));
|
||||
FAIL_IF(push_inst(compiler, ((op == SLJIT_LUDIV ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1)));
|
||||
FAIL_IF(push_inst(compiler, ((op == SLJIT_UDIVMOD ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1)));
|
||||
FAIL_IF(push_inst(compiler, (MADD ^ inv_bits) | RD(SLJIT_R1) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO)));
|
||||
return push_inst(compiler, (SUB ^ inv_bits) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1));
|
||||
case SLJIT_UDIVI:
|
||||
case SLJIT_SDIVI:
|
||||
return push_inst(compiler, ((op == SLJIT_UDIVI ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1));
|
||||
}
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
|
||||
@@ -1239,6 +1239,9 @@ extern int __aeabi_idivmod(int numerator, int denominator);
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
|
||||
{
|
||||
sljit_sw saved_reg_list[3];
|
||||
sljit_sw saved_reg_count;
|
||||
|
||||
CHECK_ERROR();
|
||||
CHECK(check_sljit_emit_op0(compiler, op));
|
||||
|
||||
@@ -1255,24 +1258,53 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
| (reg_map[SLJIT_R0] << 12)
|
||||
| (reg_map[SLJIT_R0] << 16)
|
||||
| reg_map[SLJIT_R1]);
|
||||
case SLJIT_LUDIV:
|
||||
case SLJIT_LSDIV:
|
||||
if (compiler->scratches >= 4) {
|
||||
FAIL_IF(push_inst32(compiler, 0xf84d2d04 /* str r2, [sp, #-4]! */));
|
||||
FAIL_IF(push_inst32(compiler, 0xf84dcd04 /* str ip, [sp, #-4]! */));
|
||||
} else if (compiler->scratches >= 3)
|
||||
FAIL_IF(push_inst32(compiler, 0xf84d2d08 /* str r2, [sp, #-8]! */));
|
||||
case SLJIT_UDIVMOD:
|
||||
case SLJIT_SDIVMOD:
|
||||
case SLJIT_UDIVI:
|
||||
case SLJIT_SDIVI:
|
||||
SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
|
||||
SLJIT_COMPILE_ASSERT(reg_map[2] == 1 && reg_map[3] == 2 && reg_map[4] == 12, bad_register_mapping);
|
||||
|
||||
saved_reg_count = 0;
|
||||
if (compiler->scratches >= 4)
|
||||
saved_reg_list[saved_reg_count++] = 12;
|
||||
if (compiler->scratches >= 3)
|
||||
saved_reg_list[saved_reg_count++] = 2;
|
||||
if (op >= SLJIT_UDIVI)
|
||||
saved_reg_list[saved_reg_count++] = 1;
|
||||
|
||||
if (saved_reg_count > 0) {
|
||||
FAIL_IF(push_inst32(compiler, 0xf84d0d00 | (saved_reg_count >= 3 ? 16 : 8)
|
||||
| (saved_reg_list[0] << 12) /* str rX, [sp, #-8/-16]! */));
|
||||
if (saved_reg_count >= 2) {
|
||||
SLJIT_ASSERT(saved_reg_list[1] < 8);
|
||||
FAIL_IF(push_inst16(compiler, 0x9001 | (saved_reg_list[1] << 8) /* str rX, [sp, #4] */));
|
||||
}
|
||||
if (saved_reg_count >= 3) {
|
||||
SLJIT_ASSERT(saved_reg_list[2] < 8);
|
||||
FAIL_IF(push_inst16(compiler, 0x9002 | (saved_reg_list[2] << 8) /* str rX, [sp, #8] */));
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
FAIL_IF(sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM,
|
||||
(op == SLJIT_LUDIV ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
|
||||
((op | 0x2) == SLJIT_UDIVI ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
|
||||
#else
|
||||
#error "Software divmod functions are needed"
|
||||
#endif
|
||||
if (compiler->scratches >= 4) {
|
||||
FAIL_IF(push_inst32(compiler, 0xf85dcb04 /* ldr ip, [sp], #4 */));
|
||||
return push_inst32(compiler, 0xf85d2b04 /* ldr r2, [sp], #4 */);
|
||||
} else if (compiler->scratches >= 3)
|
||||
return push_inst32(compiler, 0xf85d2b08 /* ldr r2, [sp], #8 */);
|
||||
|
||||
if (saved_reg_count > 0) {
|
||||
if (saved_reg_count >= 3) {
|
||||
SLJIT_ASSERT(saved_reg_list[2] < 8);
|
||||
FAIL_IF(push_inst16(compiler, 0x9802 | (saved_reg_list[2] << 8) /* ldr rX, [sp, #8] */));
|
||||
}
|
||||
if (saved_reg_count >= 2) {
|
||||
SLJIT_ASSERT(saved_reg_list[1] < 8);
|
||||
FAIL_IF(push_inst16(compiler, 0x9801 | (saved_reg_list[1] << 8) /* ldr rX, [sp, #4] */));
|
||||
}
|
||||
return push_inst32(compiler, 0xf85d0b00 | (saved_reg_count >= 3 ? 16 : 8)
|
||||
| (saved_reg_list[0] << 12) /* ldr rX, [sp], #8/16 */);
|
||||
}
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1053,8 +1053,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
#endif
|
||||
FAIL_IF(push_inst(compiler, MFLO | D(SLJIT_R0), DR(SLJIT_R0)));
|
||||
return push_inst(compiler, MFHI | D(SLJIT_R1), DR(SLJIT_R1));
|
||||
case SLJIT_LUDIV:
|
||||
case SLJIT_LSDIV:
|
||||
case SLJIT_UDIVMOD:
|
||||
case SLJIT_SDIVMOD:
|
||||
case SLJIT_UDIVI:
|
||||
case SLJIT_SDIVI:
|
||||
SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
|
||||
#if !(defined SLJIT_MIPS_R1 && SLJIT_MIPS_R1)
|
||||
FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));
|
||||
FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));
|
||||
@@ -1062,15 +1065,15 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
|
||||
#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
|
||||
if (int_op)
|
||||
FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
|
||||
FAIL_IF(push_inst(compiler, ((op | 0x2) == SLJIT_UDIVI ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
|
||||
else
|
||||
FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DDIVU : DDIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
|
||||
FAIL_IF(push_inst(compiler, ((op | 0x2) == SLJIT_UDIVI ? DDIVU : DDIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
|
||||
#else
|
||||
FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
|
||||
FAIL_IF(push_inst(compiler, ((op | 0x2) == SLJIT_UDIVI ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
|
||||
#endif
|
||||
|
||||
FAIL_IF(push_inst(compiler, MFLO | D(SLJIT_R0), DR(SLJIT_R0)));
|
||||
return push_inst(compiler, MFHI | D(SLJIT_R1), DR(SLJIT_R1));
|
||||
return (op >= SLJIT_UDIVI) ? SLJIT_SUCCESS : push_inst(compiler, MFHI | D(SLJIT_R1), DR(SLJIT_R1));
|
||||
}
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
|
||||
@@ -1267,22 +1267,23 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
|
||||
return push_inst(compiler, (op == SLJIT_LUMUL ? MULHWU : MULHW) | D(SLJIT_R1) | A(TMP_REG1) | B(SLJIT_R1));
|
||||
#endif
|
||||
case SLJIT_LUDIV:
|
||||
case SLJIT_LSDIV:
|
||||
case SLJIT_UDIVMOD:
|
||||
case SLJIT_SDIVMOD:
|
||||
FAIL_IF(push_inst(compiler, OR | S(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R0)));
|
||||
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
|
||||
if (int_op) {
|
||||
FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVWU : DIVW) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
|
||||
FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
|
||||
} else {
|
||||
FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVDU : DIVD) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
|
||||
FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
|
||||
}
|
||||
return push_inst(compiler, SUBF | D(SLJIT_R1) | A(SLJIT_R1) | B(TMP_REG1));
|
||||
FAIL_IF(push_inst(compiler, (int_op ? (op == SLJIT_UDIVMOD ? DIVWU : DIVW) : (op == SLJIT_UDIVMOD ? DIVDU : DIVD)) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1)));
|
||||
FAIL_IF(push_inst(compiler, (int_op ? MULLW : MULLD) | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
|
||||
#else
|
||||
FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVWU : DIVW) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
|
||||
FAIL_IF(push_inst(compiler, (op == SLJIT_UDIVMOD ? DIVWU : DIVW) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1)));
|
||||
FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
|
||||
#endif
|
||||
return push_inst(compiler, SUBF | D(SLJIT_R1) | A(SLJIT_R1) | B(TMP_REG1));
|
||||
case SLJIT_UDIVI:
|
||||
case SLJIT_SDIVI:
|
||||
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
|
||||
return push_inst(compiler, (int_op ? (op == SLJIT_UDIVI ? DIVWU : DIVW) : (op == SLJIT_UDIVI ? DIVDU : DIVD)) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1));
|
||||
#else
|
||||
return push_inst(compiler, (op == SLJIT_UDIVI ? DIVWU : DIVW) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -777,20 +777,25 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
#else
|
||||
#error "Implementation required"
|
||||
#endif
|
||||
case SLJIT_LUDIV:
|
||||
case SLJIT_LSDIV:
|
||||
case SLJIT_UDIVMOD:
|
||||
case SLJIT_SDIVMOD:
|
||||
case SLJIT_UDIVI:
|
||||
case SLJIT_SDIVI:
|
||||
SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
|
||||
#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
|
||||
if (op == SLJIT_LUDIV)
|
||||
if ((op | 0x2) == SLJIT_UDIVI)
|
||||
FAIL_IF(push_inst(compiler, WRY | S1(0), MOVABLE_INS));
|
||||
else {
|
||||
FAIL_IF(push_inst(compiler, SRA | D(TMP_REG1) | S1(SLJIT_R0) | IMM(31), DR(TMP_REG1)));
|
||||
FAIL_IF(push_inst(compiler, WRY | S1(TMP_REG1), MOVABLE_INS));
|
||||
}
|
||||
FAIL_IF(push_inst(compiler, OR | D(TMP_REG2) | S1(0) | S2(SLJIT_R0), DR(TMP_REG2)));
|
||||
FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? UDIV : SDIV) | D(SLJIT_R0) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R0)));
|
||||
if (op <= SLJIT_SDIVMOD)
|
||||
FAIL_IF(push_inst(compiler, OR | D(TMP_REG2) | S1(0) | S2(SLJIT_R0), DR(TMP_REG2)));
|
||||
FAIL_IF(push_inst(compiler, ((op | 0x2) == SLJIT_UDIVI ? UDIV : SDIV) | D(SLJIT_R0) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R0)));
|
||||
if (op >= SLJIT_UDIVI)
|
||||
return SLJIT_SUCCESS;
|
||||
FAIL_IF(push_inst(compiler, SMUL | D(SLJIT_R1) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R1)));
|
||||
FAIL_IF(push_inst(compiler, SUB | D(SLJIT_R1) | S1(TMP_REG2) | S2(SLJIT_R1), DR(SLJIT_R1)));
|
||||
return SLJIT_SUCCESS;
|
||||
return push_inst(compiler, SUB | D(SLJIT_R1) | S1(TMP_REG2) | S2(SLJIT_R1), DR(SLJIT_R1));
|
||||
#else
|
||||
#error "Implementation required"
|
||||
#endif
|
||||
|
||||
@@ -35,21 +35,21 @@
|
||||
#define SIMM_16BIT_MIN (-0x8000)
|
||||
#define SIMM_17BIT_MAX (0xffff)
|
||||
#define SIMM_17BIT_MIN (-0x10000)
|
||||
#define SIMM_32BIT_MIN (-0x80000000)
|
||||
#define SIMM_32BIT_MAX (0x7fffffff)
|
||||
#define SIMM_48BIT_MIN (0x800000000000L)
|
||||
#define SIMM_32BIT_MIN (-0x7fffffff - 1)
|
||||
#define SIMM_48BIT_MAX (0x7fffffff0000L)
|
||||
#define SIMM_48BIT_MIN (-0x800000000000L)
|
||||
#define IMM16(imm) ((imm) & 0xffff)
|
||||
|
||||
#define UIMM_16BIT_MAX (0xffff)
|
||||
|
||||
#define TMP_REG1 (SLJIT_NO_REGISTERS + 1)
|
||||
#define TMP_REG2 (SLJIT_NO_REGISTERS + 2)
|
||||
#define TMP_REG3 (SLJIT_NO_REGISTERS + 3)
|
||||
#define ADDR_TMP (SLJIT_NO_REGISTERS + 4)
|
||||
#define TMP_REG1 (SLJIT_NUMBER_OF_REGISTERS + 2)
|
||||
#define TMP_REG2 (SLJIT_NUMBER_OF_REGISTERS + 3)
|
||||
#define TMP_REG3 (SLJIT_NUMBER_OF_REGISTERS + 4)
|
||||
#define ADDR_TMP (SLJIT_NUMBER_OF_REGISTERS + 5)
|
||||
#define PIC_ADDR_REG TMP_REG2
|
||||
|
||||
static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 5] = {
|
||||
static SLJIT_CONST sljit_ub reg_map[SLJIT_NUMBER_OF_REGISTERS + 6] = {
|
||||
63, 0, 1, 2, 3, 4, 30, 31, 32, 33, 34, 54, 5, 16, 6, 7
|
||||
};
|
||||
|
||||
@@ -58,11 +58,6 @@ static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 5] = {
|
||||
#define TMP_REG2_mapped 16
|
||||
#define TMP_REG3_mapped 6
|
||||
#define ADDR_TMP_mapped 7
|
||||
#define SLJIT_SAVED_REG1_mapped 30
|
||||
#define SLJIT_SAVED_REG2_mapped 31
|
||||
#define SLJIT_SAVED_REG3_mapped 32
|
||||
#define SLJIT_SAVED_EREG1_mapped 33
|
||||
#define SLJIT_SAVED_EREG2_mapped 34
|
||||
|
||||
/* Flags are keept in volatile registers. */
|
||||
#define EQUAL_FLAG 8
|
||||
@@ -399,6 +394,9 @@ static sljit_si push_inst(struct sljit_compiler *compiler, sljit_ins ins)
|
||||
#define SUB(dst, srca, srcb) \
|
||||
push_3_buffer(compiler, TILEGX_OPC_SUB, dst, srca, srcb, __LINE__)
|
||||
|
||||
#define MUL(dst, srca, srcb) \
|
||||
push_3_buffer(compiler, TILEGX_OPC_MULX, dst, srca, srcb, __LINE__)
|
||||
|
||||
#define NOR(dst, srca, srcb) \
|
||||
push_3_buffer(compiler, TILEGX_OPC_NOR, dst, srca, srcb, __LINE__)
|
||||
|
||||
@@ -547,8 +545,8 @@ const struct Format* compute_format()
|
||||
|
||||
const struct Format* match = NULL;
|
||||
const struct Format *b = NULL;
|
||||
unsigned int i = 0;
|
||||
for (i; i < sizeof formats / sizeof formats[0]; i++) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof formats / sizeof formats[0]; i++) {
|
||||
b = &formats[i];
|
||||
if ((b->pipe_mask & compatible_pipes) == b->pipe_mask) {
|
||||
match = b;
|
||||
@@ -625,7 +623,6 @@ tilegx_bundle_bits get_bundle_bit(struct jit_instr *inst)
|
||||
|
||||
static sljit_si update_buffer(struct sljit_compiler *compiler)
|
||||
{
|
||||
int count;
|
||||
int i;
|
||||
int orig_index = inst_buf_index;
|
||||
struct jit_instr inst0 = inst_buf[0];
|
||||
@@ -738,8 +735,10 @@ static sljit_si update_buffer(struct sljit_compiler *compiler)
|
||||
|
||||
static sljit_si flush_buffer(struct sljit_compiler *compiler)
|
||||
{
|
||||
while (inst_buf_index != 0)
|
||||
update_buffer(compiler);
|
||||
while (inst_buf_index != 0) {
|
||||
FAIL_IF(update_buffer(compiler));
|
||||
}
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
|
||||
static sljit_si push_4_buffer(struct sljit_compiler *compiler, tilegx_mnemonic opc, int op0, int op1, int op2, int op3, int line)
|
||||
@@ -787,6 +786,7 @@ static sljit_si push_3_buffer(struct sljit_compiler *compiler, tilegx_mnemonic o
|
||||
case TILEGX_OPC_ADD:
|
||||
case TILEGX_OPC_AND:
|
||||
case TILEGX_OPC_SUB:
|
||||
case TILEGX_OPC_MULX:
|
||||
case TILEGX_OPC_OR:
|
||||
case TILEGX_OPC_XOR:
|
||||
case TILEGX_OPC_NOR:
|
||||
@@ -905,7 +905,6 @@ static SLJIT_INLINE sljit_ins * detect_jump_type(struct sljit_jump *jump, sljit_
|
||||
sljit_sw diff;
|
||||
sljit_uw target_addr;
|
||||
sljit_ins *inst;
|
||||
sljit_ins saved_inst;
|
||||
|
||||
if (jump->flags & SLJIT_REWRITABLE_JUMP)
|
||||
return code_ptr;
|
||||
@@ -1009,7 +1008,7 @@ SLJIT_API_FUNC_ATTRIBUTE void * sljit_generate_code(struct sljit_compiler *compi
|
||||
struct sljit_const *const_;
|
||||
|
||||
CHECK_ERROR_PTR();
|
||||
check_sljit_generate_code(compiler);
|
||||
CHECK_PTR(check_sljit_generate_code(compiler));
|
||||
reverse_buf(compiler);
|
||||
|
||||
code = (sljit_ins *)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
|
||||
@@ -1178,13 +1177,13 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
|
||||
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
|
||||
{
|
||||
sljit_ins base;
|
||||
sljit_ins bundle = 0;
|
||||
|
||||
sljit_si i, tmp;
|
||||
|
||||
CHECK_ERROR();
|
||||
check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
|
||||
CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
|
||||
set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
|
||||
|
||||
local_size += (saveds + 1) * sizeof(sljit_sw);
|
||||
local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
|
||||
local_size = (local_size + 7) & ~7;
|
||||
compiler->local_size = local_size;
|
||||
|
||||
@@ -1200,56 +1199,52 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
|
||||
local_size = 0;
|
||||
}
|
||||
|
||||
/* Save the return address. */
|
||||
FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 8));
|
||||
FAIL_IF(ST_ADD(ADDR_TMP_mapped, RA, -8));
|
||||
|
||||
if (saveds >= 1)
|
||||
FAIL_IF(ST_ADD(ADDR_TMP_mapped, SLJIT_SAVED_REG1_mapped, -8));
|
||||
/* Save the S registers. */
|
||||
tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
|
||||
for (i = SLJIT_S0; i >= tmp; i--) {
|
||||
FAIL_IF(ST_ADD(ADDR_TMP_mapped, reg_map[i], -8));
|
||||
}
|
||||
|
||||
if (saveds >= 2)
|
||||
FAIL_IF(ST_ADD(ADDR_TMP_mapped, SLJIT_SAVED_REG2_mapped, -8));
|
||||
/* Save the R registers that need to be reserved. */
|
||||
for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
|
||||
FAIL_IF(ST_ADD(ADDR_TMP_mapped, reg_map[i], -8));
|
||||
}
|
||||
|
||||
if (saveds >= 3)
|
||||
FAIL_IF(ST_ADD(ADDR_TMP_mapped, SLJIT_SAVED_REG3_mapped, -8));
|
||||
|
||||
if (saveds >= 4)
|
||||
FAIL_IF(ST_ADD(ADDR_TMP_mapped, SLJIT_SAVED_EREG1_mapped, -8));
|
||||
|
||||
if (saveds >= 5)
|
||||
FAIL_IF(ST_ADD(ADDR_TMP_mapped, SLJIT_SAVED_EREG2_mapped, -8));
|
||||
|
||||
if (args >= 1)
|
||||
FAIL_IF(ADD(SLJIT_SAVED_REG1_mapped, 0, ZERO));
|
||||
|
||||
if (args >= 2)
|
||||
FAIL_IF(ADD(SLJIT_SAVED_REG2_mapped, 1, ZERO));
|
||||
|
||||
if (args >= 3)
|
||||
FAIL_IF(ADD(SLJIT_SAVED_REG3_mapped, 2, ZERO));
|
||||
/* Move the arguments to S registers. */
|
||||
for (i = 0; i < args; i++) {
|
||||
FAIL_IF(ADD(reg_map[SLJIT_S0 - i], i, ZERO));
|
||||
}
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
|
||||
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
|
||||
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
|
||||
{
|
||||
CHECK_ERROR_VOID();
|
||||
check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
|
||||
CHECK_ERROR();
|
||||
CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
|
||||
set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
|
||||
|
||||
local_size += (saveds + 1) * sizeof(sljit_sw);
|
||||
local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
|
||||
compiler->local_size = (local_size + 7) & ~7;
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
|
||||
{
|
||||
sljit_si local_size;
|
||||
sljit_ins base;
|
||||
int addr_initialized = 0;
|
||||
sljit_si i, tmp;
|
||||
sljit_si saveds;
|
||||
|
||||
CHECK_ERROR();
|
||||
check_sljit_emit_return(compiler, op, src, srcw);
|
||||
CHECK(check_sljit_emit_return(compiler, op, src, srcw));
|
||||
|
||||
FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
|
||||
|
||||
@@ -1263,50 +1258,20 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
|
||||
local_size = 0;
|
||||
}
|
||||
|
||||
/* Restore the return address. */
|
||||
FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 8));
|
||||
FAIL_IF(LD(RA, ADDR_TMP_mapped));
|
||||
FAIL_IF(LD_ADD(RA, ADDR_TMP_mapped, -8));
|
||||
|
||||
if (compiler->saveds >= 5) {
|
||||
FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 48));
|
||||
addr_initialized = 1;
|
||||
|
||||
FAIL_IF(LD_ADD(SLJIT_SAVED_EREG2_mapped, ADDR_TMP_mapped, 8));
|
||||
/* Restore the S registers. */
|
||||
saveds = compiler->saveds;
|
||||
tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
|
||||
for (i = SLJIT_S0; i >= tmp; i--) {
|
||||
FAIL_IF(LD_ADD(reg_map[i], ADDR_TMP_mapped, -8));
|
||||
}
|
||||
|
||||
if (compiler->saveds >= 4) {
|
||||
if (addr_initialized == 0) {
|
||||
FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 40));
|
||||
addr_initialized = 1;
|
||||
}
|
||||
|
||||
FAIL_IF(LD_ADD(SLJIT_SAVED_EREG1_mapped, ADDR_TMP_mapped, 8));
|
||||
}
|
||||
|
||||
if (compiler->saveds >= 3) {
|
||||
if (addr_initialized == 0) {
|
||||
FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 32));
|
||||
addr_initialized = 1;
|
||||
}
|
||||
|
||||
FAIL_IF(LD_ADD(SLJIT_SAVED_REG3_mapped, ADDR_TMP_mapped, 8));
|
||||
}
|
||||
|
||||
if (compiler->saveds >= 2) {
|
||||
if (addr_initialized == 0) {
|
||||
FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 24));
|
||||
addr_initialized = 1;
|
||||
}
|
||||
|
||||
FAIL_IF(LD_ADD(SLJIT_SAVED_REG2_mapped, ADDR_TMP_mapped, 8));
|
||||
}
|
||||
|
||||
if (compiler->saveds >= 1) {
|
||||
if (addr_initialized == 0) {
|
||||
FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 16));
|
||||
/* addr_initialized = 1; no need to initialize as it's the last one. */
|
||||
}
|
||||
|
||||
FAIL_IF(LD_ADD(SLJIT_SAVED_REG1_mapped, ADDR_TMP_mapped, 8));
|
||||
/* Restore the R registers that need to be reserved. */
|
||||
for (i = compiler->scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
|
||||
FAIL_IF(LD_ADD(reg_map[i], ADDR_TMP_mapped, -8));
|
||||
}
|
||||
|
||||
if (compiler->local_size <= SIMM_16BIT_MAX)
|
||||
@@ -1585,7 +1550,7 @@ static SLJIT_INLINE sljit_si emit_op_mem2(struct sljit_compiler *compiler, sljit
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
|
||||
{
|
||||
CHECK_ERROR();
|
||||
check_sljit_emit_fast_enter(compiler, dst, dstw);
|
||||
CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
|
||||
ADJUST_LOCAL_OFFSET(dst, dstw);
|
||||
|
||||
/* For UNUSED dst. Uncommon, but possible. */
|
||||
@@ -1602,7 +1567,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
|
||||
{
|
||||
CHECK_ERROR();
|
||||
check_sljit_emit_fast_return(compiler, src, srcw);
|
||||
CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
|
||||
ADJUST_LOCAL_OFFSET(src, srcw);
|
||||
|
||||
if (FAST_IS_REG(src))
|
||||
@@ -1636,9 +1601,11 @@ static SLJIT_INLINE sljit_si emit_single_op(struct sljit_compiler *compiler, slj
|
||||
if (op == SLJIT_MOV_SI)
|
||||
return BFEXTS(reg_map[dst], reg_map[src2], 0, 31);
|
||||
|
||||
return BFEXTU(reg_map[dst], reg_map[src2], 0, 31);
|
||||
} else if (dst != src2)
|
||||
SLJIT_ASSERT_STOP();
|
||||
return BFEXTU(reg_map[dst], reg_map[src2], 0, 31);
|
||||
} else if (dst != src2) {
|
||||
SLJIT_ASSERT(src2 == 0);
|
||||
return ADD(reg_map[dst], reg_map[src2], ZERO);
|
||||
}
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
|
||||
@@ -1650,8 +1617,10 @@ static SLJIT_INLINE sljit_si emit_single_op(struct sljit_compiler *compiler, slj
|
||||
return BFEXTS(reg_map[dst], reg_map[src2], 0, 7);
|
||||
|
||||
return BFEXTU(reg_map[dst], reg_map[src2], 0, 7);
|
||||
} else if (dst != src2)
|
||||
SLJIT_ASSERT_STOP();
|
||||
} else if (dst != src2) {
|
||||
SLJIT_ASSERT(src2 == 0);
|
||||
return ADD(reg_map[dst], reg_map[src2], ZERO);
|
||||
}
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
|
||||
@@ -1663,8 +1632,10 @@ static SLJIT_INLINE sljit_si emit_single_op(struct sljit_compiler *compiler, slj
|
||||
return BFEXTS(reg_map[dst], reg_map[src2], 0, 15);
|
||||
|
||||
return BFEXTU(reg_map[dst], reg_map[src2], 0, 15);
|
||||
} else if (dst != src2)
|
||||
SLJIT_ASSERT_STOP();
|
||||
} else if (dst != src2) {
|
||||
SLJIT_ASSERT(src2 == 0);
|
||||
return ADD(reg_map[dst], reg_map[src2], ZERO);
|
||||
}
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
|
||||
@@ -1811,7 +1782,6 @@ static SLJIT_INLINE sljit_si emit_single_op(struct sljit_compiler *compiler, slj
|
||||
else {
|
||||
/* Rare ocasion. */
|
||||
FAIL_IF(ADD(TMP_EREG2, reg_map[src1], ZERO));
|
||||
|
||||
overflow_ra = TMP_EREG2;
|
||||
}
|
||||
}
|
||||
@@ -1903,6 +1873,17 @@ static SLJIT_INLINE sljit_si emit_single_op(struct sljit_compiler *compiler, slj
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
|
||||
case SLJIT_MUL:
|
||||
if (flags & SRC2_IMM) {
|
||||
FAIL_IF(load_immediate(compiler, TMP_REG2_mapped, src2));
|
||||
src2 = TMP_REG2;
|
||||
flags &= ~SRC2_IMM;
|
||||
}
|
||||
|
||||
FAIL_IF(MUL(reg_map[dst], reg_map[src1], reg_map[src2]));
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
|
||||
#define EMIT_LOGICAL(op_imm, op_norm) \
|
||||
if (flags & SRC2_IMM) { \
|
||||
FAIL_IF(load_immediate(compiler, ADDR_TMP_mapped, src2)); \
|
||||
@@ -1950,8 +1931,8 @@ static SLJIT_INLINE sljit_si emit_single_op(struct sljit_compiler *compiler, slj
|
||||
} else { \
|
||||
if (op & SLJIT_SET_E) \
|
||||
FAIL_IF(push_3_buffer( \
|
||||
compiler, op_imm, reg_map[dst], reg_map[src1], \
|
||||
src2 & 0x3F, __LINE__)); \
|
||||
compiler, op_norm, EQUAL_FLAG, reg_map[src1], \
|
||||
reg_map[src2], __LINE__)); \
|
||||
if (CHECK_FLAGS(SLJIT_SET_E)) \
|
||||
FAIL_IF(push_3_buffer( \
|
||||
compiler, op_norm, reg_map[dst], reg_map[src1], \
|
||||
@@ -2105,66 +2086,61 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
|
||||
{
|
||||
sljit_si sugg_dst_ar, dst_ar;
|
||||
sljit_si flags = GET_ALL_FLAGS(op);
|
||||
sljit_si mem_type = (op & SLJIT_INT_OP) ? (INT_DATA | SIGNED_DATA) : WORD_DATA;
|
||||
|
||||
CHECK_ERROR();
|
||||
check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
|
||||
CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
|
||||
ADJUST_LOCAL_OFFSET(dst, dstw);
|
||||
|
||||
if (dst == SLJIT_UNUSED)
|
||||
return SLJIT_SUCCESS;
|
||||
|
||||
op = GET_OPCODE(op);
|
||||
if (op == SLJIT_MOV_SI || op == SLJIT_MOV_UI)
|
||||
mem_type = INT_DATA | SIGNED_DATA;
|
||||
sugg_dst_ar = reg_map[(op < SLJIT_ADD && FAST_IS_REG(dst)) ? dst : TMP_REG2];
|
||||
|
||||
compiler->cache_arg = 0;
|
||||
compiler->cache_argw = 0;
|
||||
if (op >= SLJIT_ADD && (src & SLJIT_MEM)) {
|
||||
ADJUST_LOCAL_OFFSET(src, srcw);
|
||||
FAIL_IF(emit_op_mem2(compiler, WORD_DATA | LOAD_DATA, TMP_REG1_mapped, src, srcw, dst, dstw));
|
||||
FAIL_IF(emit_op_mem2(compiler, mem_type | LOAD_DATA, TMP_REG1_mapped, src, srcw, dst, dstw));
|
||||
src = TMP_REG1;
|
||||
srcw = 0;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case SLJIT_C_EQUAL:
|
||||
case SLJIT_C_NOT_EQUAL:
|
||||
switch (type & 0xff) {
|
||||
case SLJIT_EQUAL:
|
||||
case SLJIT_NOT_EQUAL:
|
||||
FAIL_IF(CMPLTUI(sugg_dst_ar, EQUAL_FLAG, 1));
|
||||
dst_ar = sugg_dst_ar;
|
||||
break;
|
||||
case SLJIT_C_LESS:
|
||||
case SLJIT_C_GREATER_EQUAL:
|
||||
case SLJIT_C_FLOAT_LESS:
|
||||
case SLJIT_C_FLOAT_GREATER_EQUAL:
|
||||
case SLJIT_LESS:
|
||||
case SLJIT_GREATER_EQUAL:
|
||||
dst_ar = ULESS_FLAG;
|
||||
break;
|
||||
case SLJIT_C_GREATER:
|
||||
case SLJIT_C_LESS_EQUAL:
|
||||
case SLJIT_C_FLOAT_GREATER:
|
||||
case SLJIT_C_FLOAT_LESS_EQUAL:
|
||||
case SLJIT_GREATER:
|
||||
case SLJIT_LESS_EQUAL:
|
||||
dst_ar = UGREATER_FLAG;
|
||||
break;
|
||||
case SLJIT_C_SIG_LESS:
|
||||
case SLJIT_C_SIG_GREATER_EQUAL:
|
||||
case SLJIT_SIG_LESS:
|
||||
case SLJIT_SIG_GREATER_EQUAL:
|
||||
dst_ar = LESS_FLAG;
|
||||
break;
|
||||
case SLJIT_C_SIG_GREATER:
|
||||
case SLJIT_C_SIG_LESS_EQUAL:
|
||||
case SLJIT_SIG_GREATER:
|
||||
case SLJIT_SIG_LESS_EQUAL:
|
||||
dst_ar = GREATER_FLAG;
|
||||
break;
|
||||
case SLJIT_C_OVERFLOW:
|
||||
case SLJIT_C_NOT_OVERFLOW:
|
||||
case SLJIT_OVERFLOW:
|
||||
case SLJIT_NOT_OVERFLOW:
|
||||
dst_ar = OVERFLOW_FLAG;
|
||||
break;
|
||||
case SLJIT_C_MUL_OVERFLOW:
|
||||
case SLJIT_C_MUL_NOT_OVERFLOW:
|
||||
case SLJIT_MUL_OVERFLOW:
|
||||
case SLJIT_MUL_NOT_OVERFLOW:
|
||||
FAIL_IF(CMPLTUI(sugg_dst_ar, OVERFLOW_FLAG, 1));
|
||||
dst_ar = sugg_dst_ar;
|
||||
type ^= 0x1; /* Flip type bit for the XORI below. */
|
||||
break;
|
||||
case SLJIT_C_FLOAT_EQUAL:
|
||||
case SLJIT_C_FLOAT_NOT_EQUAL:
|
||||
dst_ar = EQUAL_FLAG;
|
||||
break;
|
||||
|
||||
default:
|
||||
SLJIT_ASSERT_STOP();
|
||||
@@ -2180,11 +2156,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
|
||||
if (op >= SLJIT_ADD) {
|
||||
if (TMP_REG2_mapped != dst_ar)
|
||||
FAIL_IF(ADD(TMP_REG2_mapped, dst_ar, ZERO));
|
||||
return emit_op(compiler, op | flags, CUMULATIVE_OP | LOGICAL_OP | IMM_OP | ALT_KEEP_CACHE, dst, dstw, src, srcw, TMP_REG2, 0);
|
||||
return emit_op(compiler, op | flags, mem_type | CUMULATIVE_OP | LOGICAL_OP | IMM_OP | ALT_KEEP_CACHE, dst, dstw, src, srcw, TMP_REG2, 0);
|
||||
}
|
||||
|
||||
if (dst & SLJIT_MEM)
|
||||
return emit_op_mem(compiler, WORD_DATA, dst_ar, dst, dstw);
|
||||
return emit_op_mem(compiler, mem_type, dst_ar, dst, dstw);
|
||||
|
||||
if (sugg_dst_ar != dst_ar)
|
||||
return ADD(sugg_dst_ar, dst_ar, ZERO);
|
||||
@@ -2194,7 +2170,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op) {
|
||||
CHECK_ERROR();
|
||||
check_sljit_emit_op0(compiler, op);
|
||||
CHECK(check_sljit_emit_op0(compiler, op));
|
||||
|
||||
op = GET_OPCODE(op);
|
||||
switch (op) {
|
||||
@@ -2204,10 +2180,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
case SLJIT_BREAKPOINT:
|
||||
return PI(BPT);
|
||||
|
||||
case SLJIT_UMUL:
|
||||
case SLJIT_SMUL:
|
||||
case SLJIT_UDIV:
|
||||
case SLJIT_SDIV:
|
||||
case SLJIT_LUMUL:
|
||||
case SLJIT_LSMUL:
|
||||
case SLJIT_UDIVI:
|
||||
case SLJIT_SDIVI:
|
||||
SLJIT_ASSERT_STOP();
|
||||
}
|
||||
|
||||
@@ -2217,7 +2193,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op, sljit_si dst, sljit_sw dstw, sljit_si src, sljit_sw srcw)
|
||||
{
|
||||
CHECK_ERROR();
|
||||
check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
|
||||
CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
|
||||
ADJUST_LOCAL_OFFSET(dst, dstw);
|
||||
ADJUST_LOCAL_OFFSET(src, srcw);
|
||||
|
||||
@@ -2273,7 +2249,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
|
||||
return emit_op(compiler, SLJIT_SUB | GET_ALL_FLAGS(op), IMM_OP, dst, dstw, SLJIT_IMM, 0, src, srcw);
|
||||
|
||||
case SLJIT_CLZ:
|
||||
return emit_op(compiler, op, 0, dst, dstw, TMP_REG1, 0, src, srcw);
|
||||
return emit_op(compiler, op, (op & SLJIT_INT_OP) ? INT_DATA : WORD_DATA, dst, dstw, TMP_REG1, 0, src, srcw);
|
||||
}
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
@@ -2282,7 +2258,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op, sljit_si dst, sljit_sw dstw, sljit_si src1, sljit_sw src1w, sljit_si src2, sljit_sw src2w)
|
||||
{
|
||||
CHECK_ERROR();
|
||||
check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
|
||||
CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
|
||||
ADJUST_LOCAL_OFFSET(dst, dstw);
|
||||
ADJUST_LOCAL_OFFSET(src1, src1w);
|
||||
ADJUST_LOCAL_OFFSET(src2, src2w);
|
||||
@@ -2325,7 +2301,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label * sljit_emit_label(struct sljit_comp
|
||||
flush_buffer(compiler);
|
||||
|
||||
CHECK_ERROR_PTR();
|
||||
check_sljit_emit_label(compiler);
|
||||
CHECK_PTR(check_sljit_emit_label(compiler));
|
||||
|
||||
if (compiler->last_label && compiler->last_label->size == compiler->size)
|
||||
return compiler->last_label;
|
||||
@@ -2344,7 +2320,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compil
|
||||
flush_buffer(compiler);
|
||||
|
||||
CHECK_ERROR();
|
||||
check_sljit_emit_ijump(compiler, type, src, srcw);
|
||||
CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
|
||||
ADJUST_LOCAL_OFFSET(src, srcw);
|
||||
|
||||
if (FAST_IS_REG(src)) {
|
||||
@@ -2404,8 +2380,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compil
|
||||
|
||||
return SLJIT_SUCCESS;
|
||||
|
||||
} else if (src & SLJIT_MEM)
|
||||
} else if (src & SLJIT_MEM) {
|
||||
FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, TMP_REG2, 0, TMP_REG1, 0, src, srcw));
|
||||
flush_buffer(compiler);
|
||||
}
|
||||
|
||||
FAIL_IF(JR_SOLO(reg_map[src_r]));
|
||||
|
||||
@@ -2432,7 +2410,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump * sljit_emit_jump(struct sljit_compil
|
||||
flush_buffer(compiler);
|
||||
|
||||
CHECK_ERROR_PTR();
|
||||
check_sljit_emit_jump(compiler, type);
|
||||
CHECK_PTR(check_sljit_emit_jump(compiler, type));
|
||||
|
||||
jump = (struct sljit_jump *)ensure_abuf(compiler, sizeof(struct sljit_jump));
|
||||
PTR_FAIL_IF(!jump);
|
||||
@@ -2440,48 +2418,42 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump * sljit_emit_jump(struct sljit_compil
|
||||
type &= 0xff;
|
||||
|
||||
switch (type) {
|
||||
case SLJIT_C_EQUAL:
|
||||
case SLJIT_C_FLOAT_NOT_EQUAL:
|
||||
case SLJIT_EQUAL:
|
||||
BR_NZ(EQUAL_FLAG);
|
||||
break;
|
||||
case SLJIT_C_NOT_EQUAL:
|
||||
case SLJIT_C_FLOAT_EQUAL:
|
||||
case SLJIT_NOT_EQUAL:
|
||||
BR_Z(EQUAL_FLAG);
|
||||
break;
|
||||
case SLJIT_C_LESS:
|
||||
case SLJIT_C_FLOAT_LESS:
|
||||
case SLJIT_LESS:
|
||||
BR_Z(ULESS_FLAG);
|
||||
break;
|
||||
case SLJIT_C_GREATER_EQUAL:
|
||||
case SLJIT_C_FLOAT_GREATER_EQUAL:
|
||||
case SLJIT_GREATER_EQUAL:
|
||||
BR_NZ(ULESS_FLAG);
|
||||
break;
|
||||
case SLJIT_C_GREATER:
|
||||
case SLJIT_C_FLOAT_GREATER:
|
||||
case SLJIT_GREATER:
|
||||
BR_Z(UGREATER_FLAG);
|
||||
break;
|
||||
case SLJIT_C_LESS_EQUAL:
|
||||
case SLJIT_C_FLOAT_LESS_EQUAL:
|
||||
case SLJIT_LESS_EQUAL:
|
||||
BR_NZ(UGREATER_FLAG);
|
||||
break;
|
||||
case SLJIT_C_SIG_LESS:
|
||||
case SLJIT_SIG_LESS:
|
||||
BR_Z(LESS_FLAG);
|
||||
break;
|
||||
case SLJIT_C_SIG_GREATER_EQUAL:
|
||||
case SLJIT_SIG_GREATER_EQUAL:
|
||||
BR_NZ(LESS_FLAG);
|
||||
break;
|
||||
case SLJIT_C_SIG_GREATER:
|
||||
case SLJIT_SIG_GREATER:
|
||||
BR_Z(GREATER_FLAG);
|
||||
break;
|
||||
case SLJIT_C_SIG_LESS_EQUAL:
|
||||
case SLJIT_SIG_LESS_EQUAL:
|
||||
BR_NZ(GREATER_FLAG);
|
||||
break;
|
||||
case SLJIT_C_OVERFLOW:
|
||||
case SLJIT_C_MUL_OVERFLOW:
|
||||
case SLJIT_OVERFLOW:
|
||||
case SLJIT_MUL_OVERFLOW:
|
||||
BR_Z(OVERFLOW_FLAG);
|
||||
break;
|
||||
case SLJIT_C_NOT_OVERFLOW:
|
||||
case SLJIT_C_MUL_NOT_OVERFLOW:
|
||||
case SLJIT_NOT_OVERFLOW:
|
||||
case SLJIT_MUL_NOT_OVERFLOW:
|
||||
BR_NZ(OVERFLOW_FLAG);
|
||||
break;
|
||||
default:
|
||||
@@ -2536,7 +2508,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const * sljit_emit_const(struct sljit_comp
|
||||
flush_buffer(compiler);
|
||||
|
||||
CHECK_ERROR_PTR();
|
||||
check_sljit_emit_const(compiler, dst, dstw, init_value);
|
||||
CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
|
||||
ADJUST_LOCAL_OFFSET(dst, dstw);
|
||||
|
||||
const_ = (struct sljit_const *)ensure_abuf(compiler, sizeof(struct sljit_const));
|
||||
@@ -2572,3 +2544,18 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_consta
|
||||
inst[3] = (inst[3] & ~(0xFFFFL << 43)) | ((new_constant & 0xFFFFL) << 43);
|
||||
SLJIT_CACHE_FLUSH(inst, inst + 4);
|
||||
}
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
|
||||
{
|
||||
CHECK_REG_INDEX(check_sljit_get_register_index(reg));
|
||||
return reg_map[reg];
|
||||
}
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
|
||||
void *instruction, sljit_si size)
|
||||
{
|
||||
CHECK_ERROR();
|
||||
CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
|
||||
return SLJIT_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,9 @@ static sljit_si cpu_has_sse2 = -1;
|
||||
#endif
|
||||
static sljit_si cpu_has_cmov = -1;
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
#ifdef _WIN32_WCE
|
||||
#include <cmnintrin.h>
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
@@ -742,8 +744,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
break;
|
||||
case SLJIT_LUMUL:
|
||||
case SLJIT_LSMUL:
|
||||
case SLJIT_LUDIV:
|
||||
case SLJIT_LSDIV:
|
||||
case SLJIT_UDIVMOD:
|
||||
case SLJIT_SDIVMOD:
|
||||
case SLJIT_UDIVI:
|
||||
case SLJIT_SDIVI:
|
||||
compiler->flags_saved = 0;
|
||||
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
|
||||
#ifdef _WIN64
|
||||
@@ -761,9 +765,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
#endif
|
||||
compiler->mode32 = op & SLJIT_INT_OP;
|
||||
#endif
|
||||
SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
|
||||
|
||||
op = GET_OPCODE(op);
|
||||
if (op == SLJIT_LUDIV) {
|
||||
if ((op | 0x2) == SLJIT_UDIVI) {
|
||||
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || defined(_WIN64)
|
||||
EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0);
|
||||
inst = emit_x86_instruction(compiler, 1, SLJIT_R1, 0, SLJIT_R1, 0);
|
||||
@@ -774,7 +779,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
*inst = XOR_r_rm;
|
||||
}
|
||||
|
||||
if (op == SLJIT_LSDIV) {
|
||||
if ((op | 0x2) == SLJIT_SDIVI) {
|
||||
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || defined(_WIN64)
|
||||
EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0);
|
||||
#endif
|
||||
@@ -805,10 +810,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
FAIL_IF(!inst);
|
||||
INC_SIZE(2);
|
||||
*inst++ = GROUP_F7;
|
||||
*inst = MOD_REG | ((op >= SLJIT_LUDIV) ? reg_map[TMP_REG1] : reg_map[SLJIT_R1]);
|
||||
*inst = MOD_REG | ((op >= SLJIT_UDIVMOD) ? reg_map[TMP_REG1] : reg_map[SLJIT_R1]);
|
||||
#else
|
||||
#ifdef _WIN64
|
||||
size = (!compiler->mode32 || op >= SLJIT_LUDIV) ? 3 : 2;
|
||||
size = (!compiler->mode32 || op >= SLJIT_UDIVMOD) ? 3 : 2;
|
||||
#else
|
||||
size = (!compiler->mode32) ? 3 : 2;
|
||||
#endif
|
||||
@@ -817,11 +822,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
INC_SIZE(size);
|
||||
#ifdef _WIN64
|
||||
if (!compiler->mode32)
|
||||
*inst++ = REX_W | ((op >= SLJIT_LUDIV) ? REX_B : 0);
|
||||
else if (op >= SLJIT_LUDIV)
|
||||
*inst++ = REX_W | ((op >= SLJIT_UDIVMOD) ? REX_B : 0);
|
||||
else if (op >= SLJIT_UDIVMOD)
|
||||
*inst++ = REX_B;
|
||||
*inst++ = GROUP_F7;
|
||||
*inst = MOD_REG | ((op >= SLJIT_LUDIV) ? reg_lmap[TMP_REG1] : reg_lmap[SLJIT_R1]);
|
||||
*inst = MOD_REG | ((op >= SLJIT_UDIVMOD) ? reg_lmap[TMP_REG1] : reg_lmap[SLJIT_R1]);
|
||||
#else
|
||||
if (!compiler->mode32)
|
||||
*inst++ = REX_W;
|
||||
@@ -836,15 +841,21 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
|
||||
case SLJIT_LSMUL:
|
||||
*inst |= IMUL;
|
||||
break;
|
||||
case SLJIT_LUDIV:
|
||||
case SLJIT_UDIVMOD:
|
||||
case SLJIT_UDIVI:
|
||||
*inst |= DIV;
|
||||
break;
|
||||
case SLJIT_LSDIV:
|
||||
case SLJIT_SDIVMOD:
|
||||
case SLJIT_SDIVI:
|
||||
*inst |= IDIV;
|
||||
break;
|
||||
}
|
||||
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && !defined(_WIN64)
|
||||
EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0);
|
||||
if (op <= SLJIT_SDIVMOD)
|
||||
EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0);
|
||||
#else
|
||||
if (op >= SLJIT_UDIVI)
|
||||
EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -1905,60 +1916,62 @@ static sljit_si emit_test_binary(struct sljit_compiler *compiler,
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (FAST_IS_REG(src1)) {
|
||||
if (!(src1 & SLJIT_IMM)) {
|
||||
if (src2 & SLJIT_IMM) {
|
||||
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
|
||||
if (IS_HALFWORD(src2w) || compiler->mode32) {
|
||||
inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, 0);
|
||||
inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
|
||||
FAIL_IF(!inst);
|
||||
*inst = GROUP_F7;
|
||||
}
|
||||
else {
|
||||
FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
|
||||
inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src1, 0);
|
||||
inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src1, src1w);
|
||||
FAIL_IF(!inst);
|
||||
*inst = TEST_rm_r;
|
||||
}
|
||||
#else
|
||||
inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, 0);
|
||||
inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
|
||||
FAIL_IF(!inst);
|
||||
*inst = GROUP_F7;
|
||||
#endif
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
else {
|
||||
else if (FAST_IS_REG(src1)) {
|
||||
inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
|
||||
FAIL_IF(!inst);
|
||||
*inst = TEST_rm_r;
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (FAST_IS_REG(src2)) {
|
||||
if (!(src2 & SLJIT_IMM)) {
|
||||
if (src1 & SLJIT_IMM) {
|
||||
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
|
||||
if (IS_HALFWORD(src1w) || compiler->mode32) {
|
||||
inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, 0);
|
||||
inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, src2w);
|
||||
FAIL_IF(!inst);
|
||||
*inst = GROUP_F7;
|
||||
}
|
||||
else {
|
||||
FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src1w));
|
||||
inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src2, 0);
|
||||
inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src2, src2w);
|
||||
FAIL_IF(!inst);
|
||||
*inst = TEST_rm_r;
|
||||
}
|
||||
#else
|
||||
inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, 0);
|
||||
inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, src2w);
|
||||
FAIL_IF(!inst);
|
||||
*inst = GROUP_F7;
|
||||
#endif
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
else {
|
||||
else if (FAST_IS_REG(src2)) {
|
||||
inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
|
||||
FAIL_IF(!inst);
|
||||
*inst = TEST_rm_r;
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
|
||||
EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
|
||||
@@ -2923,3 +2936,69 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_consta
|
||||
{
|
||||
*(sljit_sw*)addr = new_constant;
|
||||
}
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_sse2_available(void)
|
||||
{
|
||||
#if (defined SLJIT_DETECT_SSE2 && SLJIT_DETECT_SSE2)
|
||||
if (cpu_has_sse2 == -1)
|
||||
get_cpu_features();
|
||||
return cpu_has_sse2;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_cmov_available(void)
|
||||
{
|
||||
if (cpu_has_cmov == -1)
|
||||
get_cpu_features();
|
||||
return cpu_has_cmov;
|
||||
}
|
||||
|
||||
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_emit_cmov(struct sljit_compiler *compiler,
|
||||
sljit_si type,
|
||||
sljit_si dst_reg,
|
||||
sljit_si src, sljit_sw srcw)
|
||||
{
|
||||
sljit_ub* inst;
|
||||
|
||||
CHECK_ERROR();
|
||||
#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
|
||||
CHECK_ARGUMENT(sljit_x86_is_cmov_available());
|
||||
CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_INT_OP)));
|
||||
CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_D_ORDERED);
|
||||
CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(dst_reg & ~SLJIT_INT_OP));
|
||||
FUNCTION_CHECK_SRC(src, srcw);
|
||||
#endif
|
||||
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
|
||||
if (SLJIT_UNLIKELY(!!compiler->verbose)) {
|
||||
fprintf(compiler->verbose, " x86_cmov%s %s%s, ",
|
||||
!(dst_reg & SLJIT_INT_OP) ? "" : ".i",
|
||||
JUMP_PREFIX(type), jump_names[type & 0xff]);
|
||||
sljit_verbose_reg(compiler, dst_reg & ~SLJIT_INT_OP);
|
||||
fprintf(compiler->verbose, ", ");
|
||||
sljit_verbose_param(compiler, src, srcw);
|
||||
fprintf(compiler->verbose, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
ADJUST_LOCAL_OFFSET(src, srcw);
|
||||
CHECK_EXTRA_REGS(src, srcw, (void)0);
|
||||
|
||||
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
|
||||
compiler->mode32 = dst_reg & SLJIT_INT_OP;
|
||||
#endif
|
||||
dst_reg &= ~SLJIT_INT_OP;
|
||||
|
||||
if (SLJIT_UNLIKELY(src & SLJIT_IMM)) {
|
||||
EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw);
|
||||
src = TMP_REG1;
|
||||
srcw = 0;
|
||||
}
|
||||
|
||||
inst = emit_x86_instruction(compiler, 2, dst_reg, 0, src, srcw);
|
||||
FAIL_IF(!inst);
|
||||
*inst++ = GROUP_0F;
|
||||
*inst = get_jump_code(type & 0xff) - 0x40;
|
||||
return SLJIT_SUCCESS;
|
||||
}
|
||||
Vendored
+12
@@ -743,3 +743,15 @@ RC=0
|
||||
---------------------------- Test 106 -----------------------------
|
||||
a
|
||||
RC=0
|
||||
---------------------------- Test 107 -----------------------------
|
||||
1:0,1
|
||||
2:0,1
|
||||
2:1,1
|
||||
2:2,1
|
||||
2:3,1
|
||||
2:4,1
|
||||
RC=0
|
||||
---------------------------- Test 108 ------------------------------
|
||||
RC=0
|
||||
---------------------------- Test 109 -----------------------------
|
||||
RC=0
|
||||
Vendored
+13
@@ -5720,4 +5720,17 @@ AbcdCBefgBhiBqz
|
||||
/[\Q]a\E]+/
|
||||
aa]]
|
||||
|
||||
/(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
|
||||
1234abcd
|
||||
|
||||
/(\2)(\1)/
|
||||
|
||||
"Z*(|d*){216}"
|
||||
|
||||
"(?1)(?#?'){8}(a)"
|
||||
baaaaaaaaac
|
||||
|
||||
"(?|(\k'Pm')|(?'Pm'))"
|
||||
abcd
|
||||
|
||||
/-- End of testinput1 --/
|
||||
+4
@@ -134,4 +134,8 @@ is required for these tests. --/
|
||||
|
||||
/(((a\2)|(a*)\g<-1>))*a?/B
|
||||
|
||||
/((?+1)(\1))/B
|
||||
|
||||
/.((?2)(?R)\1)()/B
|
||||
|
||||
/-- End of testinput11 --/
|
||||
+17
@@ -8,6 +8,8 @@ and a couple of things that are different with JIT. --/
|
||||
|
||||
/(?(?C1)(?=a)a)/S!+I
|
||||
|
||||
/b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*Line truncated
|
||||
|
||||
/abc/S+I>testsavedregex
|
||||
|
||||
<testsavedregex
|
||||
@@ -87,4 +89,19 @@ and a couple of things that are different with JIT. --/
|
||||
/^12345678abcd/mS++
|
||||
12345678abcd
|
||||
|
||||
/-- Test pattern compilation --/
|
||||
|
||||
/(?:a|b|c|d|e)(?R)/S++
|
||||
|
||||
/(?:a|b|c|d|e)(?R)(?R)/S++
|
||||
|
||||
/(a(?:a|b|c|d|e)b){8,16}/S++
|
||||
|
||||
/(?:|a|){100}x/S++
|
||||
|
||||
/(x(?1)){4}/S++
|
||||
|
||||
/(.|.)*?bx/
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax
|
||||
|
||||
/-- End of testinput12 --/
|
||||
+2
@@ -340,4 +340,6 @@ not matter. --/
|
||||
|
||||
/[^\s]*\s* [^\W]+\W+ [^\d]*?\d0 [^\d\w]{4,6}?\w*A/BZ
|
||||
|
||||
/(?'ABC'[bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar]([bar](*THEN:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))/
|
||||
|
||||
/-- End of testinput14 --/
|
||||
+2
@@ -304,4 +304,6 @@
|
||||
/^[\x{1234}\x{4321}]{2,4}?/
|
||||
\x{1234}\x{1234}\x{1234}
|
||||
|
||||
/(*THEN:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALine truncated
|
||||
|
||||
/-- End of testinput17 --/
|
||||
Vendored
+139
@@ -1380,6 +1380,8 @@
|
||||
1X
|
||||
123456\P
|
||||
|
||||
//KF>testsavedregex
|
||||
|
||||
/abc/IS>testsavedregex
|
||||
<testsavedregex
|
||||
abc
|
||||
@@ -4078,4 +4080,141 @@ backtracking verbs. --/
|
||||
|
||||
/\x{whatever}/
|
||||
|
||||
"((?=(?(?=(?(?=(?(?=()))))))))"
|
||||
a
|
||||
|
||||
"(?(?=)==)(((((((((?=)))))))))"
|
||||
a
|
||||
|
||||
/^(?:(a)|b)(?(1)A|B)/I
|
||||
aA123\O3
|
||||
aA123\O6
|
||||
|
||||
'^(?:(?<AA>a)|b)(?(<AA>)A|B)'
|
||||
aA123\O3
|
||||
aA123\O6
|
||||
|
||||
'^(?<AA>)(?:(?<AA>a)|b)(?(<AA>)A|B)'J
|
||||
aA123\O3
|
||||
aA123\O6
|
||||
|
||||
'^(?:(?<AA>X)|)(?:(?<AA>a)|b)\k{AA}'J
|
||||
aa123\O3
|
||||
aa123\O6
|
||||
|
||||
/(?<N111>(?J)(?<N111>1(111111)11|)1|1|)(?(<N111>)1)/
|
||||
|
||||
/(?(?=0)?)+/
|
||||
|
||||
/(?(?=0)(?=00)?00765)/
|
||||
00765
|
||||
|
||||
/(?(?=0)(?=00)?00765|(?!3).56)/
|
||||
00765
|
||||
456
|
||||
** Failers
|
||||
356
|
||||
|
||||
'^(a)*+(\w)'
|
||||
g
|
||||
g\O3
|
||||
|
||||
'^(?:a)*+(\w)'
|
||||
g
|
||||
g\O3
|
||||
|
||||
//C
|
||||
\O\C+
|
||||
|
||||
"((?2){0,1999}())?"
|
||||
|
||||
/((?+1)(\1))/BZ
|
||||
|
||||
/(?(?!)a|b)/
|
||||
bbb
|
||||
aaa
|
||||
|
||||
"((?2)+)((?1))"
|
||||
|
||||
"(?(?<E>.*!.*)?)"
|
||||
|
||||
"X((?2)()*+){2}+"BZ
|
||||
|
||||
"X((?2)()*+){2}"BZ
|
||||
|
||||
"(?<=((?2))((?1)))"
|
||||
|
||||
/(?<=\Ka)/g+
|
||||
aaaaa
|
||||
|
||||
/(?<=\Ka)/G+
|
||||
aaaaa
|
||||
|
||||
/((?2){73}(?2))((?1))/
|
||||
|
||||
/.((?2)(?R)\1)()/BZ
|
||||
|
||||
/(?1)()((((((\1++))\x85)+)|))/
|
||||
|
||||
/(\9*+(?2);\3++()2|)++{/
|
||||
|
||||
/\V\x85\9*+((?2)\3++()2)*:2/
|
||||
|
||||
/(((?(R)){0,2}) (?''((?'R')((?'R')))))/J
|
||||
|
||||
/(((?(X)){0,2}) (?''((?'X')((?'X')))))/J
|
||||
|
||||
/(((?(R)){0,2}) (?''((?'X')((?'R')))))/
|
||||
|
||||
"(?J)(?'d'(?'d'\g{d}))"
|
||||
|
||||
".*?\h.+.\.+\R*?\xd(?i)(?=!(?=b`b`b`\`b\xa9b!)`\a`bbbbbbbbbbbbb`bbbbbbbbbbbb*R\x85bbbbbbb\C?{((?2)(?))((
|
||||
\H){8(?<=(?1){29}\xa8bbbb\x16\xd\xc6^($(?<! )(\xa9H4){4}h}1)B))\x15')"
|
||||
|
||||
"(?J:(?|(?'R')(\k'R')|((?'R'))))"
|
||||
|
||||
/(?<=|(\,\$(?73591620449005828816)\xa8.{7}){6}\x09)/
|
||||
|
||||
//
|
||||
\O1
|
||||
|
||||
/^(?:(?(1)x|)+)+$()/BZ
|
||||
|
||||
/(?=di(?<=(?1))|(?=(.))))/
|
||||
|
||||
/(?(R))*+/BZ
|
||||
|
||||
/[[:\\](?'abc')[a:]/
|
||||
|
||||
"[[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[:::::::::::::::::[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[[[:::E[[[:[:[[:[:::[[:::E[[[:[:[[:'[:::::E[[[:[::::::[[[:[[[[[[[::E[[[:[::::::[[[:[[[[[[[[:[[::[::::[[:::::::[[:[[[[[[[:[[::[:[[:[~"
|
||||
|
||||
/()(?(R)0)*+/BZ
|
||||
|
||||
/(?R-:(?</
|
||||
|
||||
/(?1){3918}(((((0(\k'R'))))(?J)(?'R'(?'R'\3){99})))/I
|
||||
|
||||
/(?J:(?|(:(?|(?'R')(\k'R')|((?'R')))H'Rk'Rf)|s(?'R')))/
|
||||
|
||||
/0(?0)|(1)(*THEN)(*SKIP:0)(*FAIL)/
|
||||
01
|
||||
|
||||
/((?(R8000000000)))/
|
||||
|
||||
/(?(8000000000/
|
||||
|
||||
/(?:ab)?(?:ab)(?:ab)/
|
||||
abab
|
||||
ababab
|
||||
aba
|
||||
|
||||
/((*MARK:A))++a(*SKIP:B)b/
|
||||
aacb
|
||||
|
||||
/(?J:(?|(:(?|(?'R')(\z(?|(?'R')(\k'R')|((?'R')))k'R')|((?'R')))H'Ak'Rf)|s(?'R')))/
|
||||
|
||||
/(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&Line truncated
|
||||
|
||||
/a[[:punct:]b]/BZ
|
||||
|
||||
/-- End of testinput2 --/
|
||||
Vendored
+5
@@ -722,4 +722,9 @@
|
||||
/^#[^\x{ffff}]#[^\x{ffff}]#[^\x{ffff}]#/8
|
||||
#\x{10000}#\x{100}#\x{10ffff}#
|
||||
|
||||
"[\S\V\H]"8
|
||||
|
||||
/\C(\W?ſ)'?{{/8
|
||||
\\C(\\W?ſ)'?{{
|
||||
|
||||
/-- End of testinput4 --/
|
||||
Vendored
+8
@@ -790,4 +790,12 @@
|
||||
|
||||
/[b-d\x{200}-\x{250}]*[ae-h]?#[\x{200}-\x{250}]{0,8}[\x00-\xff]*#[\x{200}-\x{250}]+[a-z]/8BZ
|
||||
|
||||
/[^\xff]*PRUNE:\x{100}abc(xyz(?1))/8DZ
|
||||
|
||||
/(?<=\K\x{17f})/8g+
|
||||
\x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
|
||||
|
||||
/(?<=\K\x{17f})/8G+
|
||||
\x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
|
||||
|
||||
/-- End of testinput5 --/
|
||||
Vendored
+57
@@ -1496,4 +1496,61 @@
|
||||
/^s?c/mi8
|
||||
scat
|
||||
|
||||
/[A-`]/i8
|
||||
abcdefghijklmno
|
||||
|
||||
/\C\X*QT/8
|
||||
Ӆ\x0aT
|
||||
|
||||
/[\pS#moq]/
|
||||
=
|
||||
|
||||
/[[:punct:]]/8W
|
||||
\xc2\xb4
|
||||
\x{b4}
|
||||
|
||||
/[[:^ascii:]]/8W
|
||||
\x{100}
|
||||
\x{200}
|
||||
\x{300}
|
||||
\x{37e}
|
||||
a
|
||||
9
|
||||
g
|
||||
|
||||
/[[:^ascii:]\w]/8W
|
||||
a
|
||||
9
|
||||
g
|
||||
\x{100}
|
||||
\x{200}
|
||||
\x{300}
|
||||
\x{37e}
|
||||
|
||||
/[\w[:^ascii:]]/8W
|
||||
a
|
||||
9
|
||||
g
|
||||
\x{100}
|
||||
\x{200}
|
||||
\x{300}
|
||||
\x{37e}
|
||||
|
||||
/[^[:ascii:]\W]/8W
|
||||
a
|
||||
9
|
||||
g
|
||||
\x{100}
|
||||
\x{200}
|
||||
\x{300}
|
||||
\x{37e}
|
||||
|
||||
/[[:^ascii:]a]/8W
|
||||
a
|
||||
9
|
||||
g
|
||||
\x{100}
|
||||
\x{200}
|
||||
\x{37e}
|
||||
|
||||
/-- End of testinput6 --/
|
||||
Vendored
+15
@@ -838,4 +838,19 @@ of case for anything other than the ASCII letters. --/
|
||||
/^s?c/mi8I
|
||||
scat
|
||||
|
||||
/[\W\p{Any}]/BZ
|
||||
abc
|
||||
123
|
||||
|
||||
/[\W\pL]/BZ
|
||||
abc
|
||||
** Failers
|
||||
123
|
||||
|
||||
/a[[:punct:]b]/WBZ
|
||||
|
||||
/a[[:punct:]b]/8WBZ
|
||||
|
||||
/a[b[:punct:]]/8WBZ
|
||||
|
||||
/-- End of testinput7 --/
|
||||
Vendored
+4
@@ -4837,4 +4837,8 @@
|
||||
'\A(?:[^\"]++|\"(?:[^\"]++|\"\")*+\")++'
|
||||
NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
|
||||
|
||||
/(?(?!)a|b)/
|
||||
bbb
|
||||
aaa
|
||||
|
||||
/-- End of testinput8 --/
|
||||
+3
@@ -29,13 +29,16 @@ in EBCDIC, but can be specified as escapes. --/
|
||||
|
||||
/^A\ˆ/
|
||||
A B
|
||||
A\x41B
|
||||
|
||||
/-- Test \H --/
|
||||
|
||||
/^A\È/
|
||||
AB
|
||||
A\x42B
|
||||
** Fail
|
||||
A B
|
||||
A\x41B
|
||||
|
||||
/-- Test \R --/
|
||||
|
||||
|
||||
+23
@@ -9411,4 +9411,27 @@ No match
|
||||
aa]]
|
||||
0: aa]]
|
||||
|
||||
/(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
|
||||
1234abcd
|
||||
0:
|
||||
1: <unset>
|
||||
2: <unset>
|
||||
3: <unset>
|
||||
4: <unset>
|
||||
5:
|
||||
|
||||
/(\2)(\1)/
|
||||
|
||||
"Z*(|d*){216}"
|
||||
|
||||
"(?1)(?#?'){8}(a)"
|
||||
baaaaaaaaac
|
||||
0: aaaaaaaaa
|
||||
1: a
|
||||
|
||||
"(?|(\k'Pm')|(?'Pm'))"
|
||||
abcd
|
||||
0:
|
||||
1:
|
||||
|
||||
/-- End of testinput1 --/
|
||||
Loaded 100 of 271 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user