mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-11 11:10:49 +00:00
Compare commits
574
Commits
php-7.0.6
...
php-5.6.29
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4e4201c1c | ||
|
|
840d1b11aa | ||
|
|
b2db415d92 | ||
|
|
864f3bda5a | ||
|
|
e64d104a9b | ||
|
|
331db73eab | ||
|
|
66fd44209d | ||
|
|
9e89e72feb | ||
|
|
2d19c92fc2 | ||
|
|
f0f68c7274 | ||
|
|
9befad6fc2 | ||
|
|
3e45385903 | ||
|
|
0796db97d4 | ||
|
|
644e290fcd | ||
|
|
d36d4c70d3 | ||
|
|
850c1095ab | ||
|
|
1d352645fc | ||
|
|
4805be1db6 | ||
|
|
0da5cb5fb6 | ||
|
|
55980684f6 | ||
|
|
e44deba1e9 | ||
|
|
c2d6ffb85f | ||
|
|
c4f1c20d80 | ||
|
|
49030f2a25 | ||
|
|
eba5e276c7 | ||
|
|
aec1a5eccc | ||
|
|
6122526cea | ||
|
|
9849c97b1b | ||
|
|
935d922114 | ||
|
|
8202b97077 | ||
|
|
a91f3d475e | ||
|
|
eb570294a2 | ||
|
|
ecba563f2f | ||
|
|
e922d89f66 | ||
|
|
87673d6e99 | ||
|
|
d6d08f97cd | ||
|
|
33766347cb | ||
|
|
493b2bff02 | ||
|
|
b044a7429e | ||
|
|
617f38b0e0 | ||
|
|
40f7fea897 | ||
|
|
1fd18821e0 | ||
|
|
ccb91cde94 | ||
|
|
99b242a6d0 | ||
|
|
2eacb53fc4 | ||
|
|
863d37ea66 | ||
|
|
6499581af7 | ||
|
|
ef75ddd4f9 | ||
|
|
9b3a1e00ab | ||
|
|
cd13d0260a | ||
|
|
4f5a755b9d | ||
|
|
f74d7d92c8 | ||
|
|
6045de69c7 | ||
|
|
6558559bcc | ||
|
|
86e603a664 | ||
|
|
e1f5b6d8df | ||
|
|
f7bf9650aa | ||
|
|
cc08cbc84d | ||
|
|
43ccf23d70 | ||
|
|
689a9b8def | ||
|
|
082d1f2375 | ||
|
|
c1112ff323 | ||
|
|
21452a5401 | ||
|
|
85a22a0af0 | ||
|
|
96a8cf8e1b | ||
|
|
8822f7c9f0 | ||
|
|
8259130b6b | ||
|
|
4165d97606 | ||
|
|
256b150a96 | ||
|
|
fc989fc6e7 | ||
|
|
b92216b97d | ||
|
|
3c5742ebd7 | ||
|
|
b061fa909d | ||
|
|
bc3a0b82b8 | ||
|
|
1c468ee044 | ||
|
|
07546496b1 | ||
|
|
d946d10293 | ||
|
|
d3eb58332a | ||
|
|
a10d03ac16 | ||
|
|
085dfca02b | ||
|
|
8ea01d5f19 | ||
|
|
631173aa5c | ||
|
|
ef801b9bf9 | ||
|
|
40e7baab3c | ||
|
|
f9d4b1a3f1 | ||
|
|
9acfb1a3a5 | ||
|
|
c0219b323e | ||
|
|
91fd4bf000 | ||
|
|
e72165bb86 | ||
|
|
da7e89cde8 | ||
|
|
29e2a204fb | ||
|
|
703c247c7d | ||
|
|
6a544f2d1e | ||
|
|
1f5412982c | ||
|
|
40b8105cca | ||
|
|
99bf19c177 | ||
|
|
4f0960a800 | ||
|
|
66baefec44 | ||
|
|
1c0e9126fb | ||
|
|
0e6fe3a4c9 | ||
|
|
e1709b7e58 | ||
|
|
c696bc8cfa | ||
|
|
c596b02a5b | ||
|
|
8f5eda4bf6 | ||
|
|
709731797c | ||
|
|
c7936ead8f | ||
|
|
1da79a6c6e | ||
|
|
075aa911ff | ||
|
|
28887fe41b | ||
|
|
f9a699f6c3 | ||
|
|
9a2a45c1df | ||
|
|
a22175b06f | ||
|
|
807004a446 | ||
|
|
726c5999eb | ||
|
|
49c3fa43ad | ||
|
|
4397306b32 | ||
|
|
33a8af0510 | ||
|
|
4dd70b6e2f | ||
|
|
fc2cadca2d | ||
|
|
56fa36b0a8 | ||
|
|
1ed4b13fb6 | ||
|
|
6682673070 | ||
|
|
01c7c6b152 | ||
|
|
ac07008bb7 | ||
|
|
46df064261 | ||
|
|
3c117d4136 | ||
|
|
55237fe153 | ||
|
|
1d7484077a | ||
|
|
7bfb7b62b1 | ||
|
|
36df4f8419 | ||
|
|
09eb6ed35e | ||
|
|
05baa92727 | ||
|
|
c43ecfd798 | ||
|
|
248f8c3a91 | ||
|
|
fc31d6fed4 | ||
|
|
8fd0e0285f | ||
|
|
363c2524dd | ||
|
|
28f80baf3c | ||
|
|
33d0ef0fef | ||
|
|
c4cca4c20e | ||
|
|
f5a9592ad8 | ||
|
|
6a7cc8ff85 | ||
|
|
7381d4c00e | ||
|
|
ecb7f58a06 | ||
|
|
b88393f08a | ||
|
|
65c8caafa8 | ||
|
|
6d55ba2656 | ||
|
|
ba5ac0d360 | ||
|
|
223266e4e4 | ||
|
|
19866fb76c | ||
|
|
39f45e208c | ||
|
|
0cbf634657 | ||
|
|
fcdc30b347 | ||
|
|
6d0e773292 | ||
|
|
6ef987e012 | ||
|
|
38455293f7 | ||
|
|
dc09f30933 | ||
|
|
326a4e38fb | ||
|
|
6c9d37d059 | ||
|
|
669fda00b7 | ||
|
|
c42a7f2f3f | ||
|
|
23e721fc93 | ||
|
|
cb91a51b00 | ||
|
|
38553e853b | ||
|
|
b1f33db39f | ||
|
|
8c700076d7 | ||
|
|
fb1c46f013 | ||
|
|
8bbd0952e5 | ||
|
|
5880428dac | ||
|
|
dad793630d | ||
|
|
3a35d43ad9 | ||
|
|
a25f6f89cd | ||
|
|
8aad3131a1 | ||
|
|
dd6da58fac | ||
|
|
0045d16863 | ||
|
|
b92cb6b238 | ||
|
|
1abbcc8cc5 | ||
|
|
9834978a8b | ||
|
|
5c38fbe543 | ||
|
|
39423e425d | ||
|
|
cee363d609 | ||
|
|
84d495055d | ||
|
|
b578580e88 | ||
|
|
d1fbc98ff6 | ||
|
|
b7259b71b4 | ||
|
|
d582241368 | ||
|
|
9513187dee | ||
|
|
bca913d70a | ||
|
|
c83bdb8e6a | ||
|
|
5efd2a33df | ||
|
|
e576714f6b | ||
|
|
fbb81dd755 | ||
|
|
b2d267d9ee | ||
|
|
314a9f8553 | ||
|
|
747b61808b | ||
|
|
2f10db36af | ||
|
|
af7828a20f | ||
|
|
207dab585a | ||
|
|
c7b4cd1a51 | ||
|
|
ae81e8fc32 | ||
|
|
d787b0ea13 | ||
|
|
295303b590 | ||
|
|
1a840b9af0 | ||
|
|
e2609a38d9 | ||
|
|
c73bcbefbd | ||
|
|
2139918ea6 | ||
|
|
84512a1177 | ||
|
|
bd8112afe0 | ||
|
|
a1ff39ffe5 | ||
|
|
6a232c3604 | ||
|
|
d65adac2be | ||
|
|
9eb5bbd8bd | ||
|
|
226e21b0fe | ||
|
|
b740bb3987 | ||
|
|
52793c14d9 | ||
|
|
e4a006cd3e | ||
|
|
9164dc11e2 | ||
|
|
f682193609 | ||
|
|
21f08a7488 | ||
|
|
057278b759 | ||
|
|
ad76e8a529 | ||
|
|
bc1214f25e | ||
|
|
761d2f629b | ||
|
|
f2d5305097 | ||
|
|
b12ac316eb | ||
|
|
54293d21cb | ||
|
|
a3159d29bb | ||
|
|
48198e4c25 | ||
|
|
abe00908af | ||
|
|
9e00ad2b09 | ||
|
|
4bf5c3187f | ||
|
|
d8b2de164e | ||
|
|
40bd921cea | ||
|
|
35a8ed2f62 | ||
|
|
b9e81e5844 | ||
|
|
24d741d376 | ||
|
|
5f91f692c3 | ||
|
|
cfdeedd985 | ||
|
|
d6a43a8562 | ||
|
|
1cd6bc6463 | ||
|
|
5a34bd6d1e | ||
|
|
1bd103df00 | ||
|
|
a3598dd7c9 | ||
|
|
6dbb1ee46b | ||
|
|
698a691724 | ||
|
|
e018ff094f | ||
|
|
639f7fde6a | ||
|
|
95d09e4b5e | ||
|
|
426aeb2808 | ||
|
|
f1a0b7d690 | ||
|
|
da316b50bd | ||
|
|
8763c6090d | ||
|
|
448c9be157 | ||
|
|
1bb92d5212 | ||
|
|
4a4422740f | ||
|
|
5c7f802e7e | ||
|
|
977cbc2fff | ||
|
|
9f1d962ed6 | ||
|
|
dfadc5a427 | ||
|
|
82df4e2638 | ||
|
|
ae3b2078ea | ||
|
|
7938ebf6c1 | ||
|
|
f19578ad58 | ||
|
|
a38bc7b373 | ||
|
|
243d5fcb1f | ||
|
|
40d237df1f | ||
|
|
283ee1f6dc | ||
|
|
3d51b1d544 | ||
|
|
5e2b8349b4 | ||
|
|
65056e9d6c | ||
|
|
a8515a339d | ||
|
|
d3a8e107ac | ||
|
|
78488a54c8 | ||
|
|
4f861b6071 | ||
|
|
562c17eb4e | ||
|
|
9667ee4f72 | ||
|
|
f15c155363 | ||
|
|
d5796fb298 | ||
|
|
67c2b0a9e8 | ||
|
|
fad3f936ac | ||
|
|
f5622f5c87 | ||
|
|
e95625f47e | ||
|
|
40b3a031b2 | ||
|
|
90c6cbd09b | ||
|
|
c9d3ff0c6e | ||
|
|
14d674442e | ||
|
|
99613431b4 | ||
|
|
e87ac688d5 | ||
|
|
1d32b80903 | ||
|
|
f67ccd4a7b | ||
|
|
5c458c9b02 | ||
|
|
7ab39e2fae | ||
|
|
ced2a80e6f | ||
|
|
c301adbbd1 | ||
|
|
6e886f07a8 | ||
|
|
ee6900c3de | ||
|
|
56cdaecb28 | ||
|
|
d276e6a838 | ||
|
|
0ae8c337a3 | ||
|
|
30a5ed3a79 | ||
|
|
ed16f2fed5 | ||
|
|
315c0536c2 | ||
|
|
cc125f277b | ||
|
|
cce457c68c | ||
|
|
074b86d845 | ||
|
|
4c2e1a13be | ||
|
|
24d8f6ed7c | ||
|
|
64e3e932fc | ||
|
|
0c34d515f1 | ||
|
|
3f842655db | ||
|
|
72ac8cf5ad | ||
|
|
305bddb0ed | ||
|
|
d28f1dae9d | ||
|
|
9cd23ff84f | ||
|
|
04b42b1e05 | ||
|
|
80fee637f4 | ||
|
|
88838dd282 | ||
|
|
9fbd0c1ff1 | ||
|
|
2c16b9cf62 | ||
|
|
65abdb556d | ||
|
|
4fc1bfa93b | ||
|
|
6b116932b2 | ||
|
|
fb4a6dc0f1 | ||
|
|
f2c2a4be9e | ||
|
|
f813f43855 | ||
|
|
8b191921c3 | ||
|
|
c9f21e8319 | ||
|
|
b57a38f584 | ||
|
|
9ebc96116b | ||
|
|
18ba78e988 | ||
|
|
17a53f9e60 | ||
|
|
8ebdb1f5fd | ||
|
|
e8b768dd92 | ||
|
|
9cc0a5a9a9 | ||
|
|
206d45bc17 | ||
|
|
828f911efd | ||
|
|
bd1919504b | ||
|
|
b25009fc2c | ||
|
|
1d69028d2f | ||
|
|
834f7a39be | ||
|
|
48e76abadd | ||
|
|
894df05fe8 | ||
|
|
7521149193 | ||
|
|
df09515089 | ||
|
|
f69362d212 | ||
|
|
47d6ea6332 | ||
|
|
4d0565b5ba | ||
|
|
1a88692692 | ||
|
|
f0a17b3a86 | ||
|
|
9bb5f64871 | ||
|
|
8dc5ffa479 | ||
|
|
928aecc002 | ||
|
|
7b1572b177 | ||
|
|
b61bd1243a | ||
|
|
33c1a55b40 | ||
|
|
2fbce5f51f | ||
|
|
511f07b747 | ||
|
|
0fbcff1b35 | ||
|
|
08ac37bd2a | ||
|
|
1364742be9 | ||
|
|
41131cd41d | ||
|
|
f3feddb5b4 | ||
|
|
e6c48213c2 | ||
|
|
3c3980caa1 | ||
|
|
6cb75fb1e8 | ||
|
|
d1a491acf3 | ||
|
|
eebcbd5de3 | ||
|
|
171c759d79 | ||
|
|
3666cfab97 | ||
|
|
a4aa4f9772 | ||
|
|
1c84b55ade | ||
|
|
d0c98366d0 | ||
|
|
fe1d6feb3d | ||
|
|
8bb3bd04a9 | ||
|
|
3cc4265527 | ||
|
|
eb190b4e91 | ||
|
|
3798eb6fd5 | ||
|
|
aa82e99ed8 | ||
|
|
81406c0c1d | ||
|
|
0218acb7e7 | ||
|
|
a099545bec | ||
|
|
aca4f65c7e | ||
|
|
1896ca4e88 | ||
|
|
822498128b | ||
|
|
5cce0d7c7c | ||
|
|
642e44b98f | ||
|
|
76e249d31c | ||
|
|
17d4f5c2f8 | ||
|
|
15336b44d9 | ||
|
|
403f23b460 | ||
|
|
fb49f137ec | ||
|
|
d2d17e14ee | ||
|
|
f5ccd71d0c | ||
|
|
7903276f4c | ||
|
|
966311e627 | ||
|
|
2552cf248d | ||
|
|
9dd5d96332 | ||
|
|
6a5e1783b7 | ||
|
|
98b9dfaec9 | ||
|
|
219ebcb689 | ||
|
|
51d19891a4 | ||
|
|
6fc7817558 | ||
|
|
bdf1b22da5 | ||
|
|
82637e8187 | ||
|
|
1071a2655f | ||
|
|
78d5783b62 | ||
|
|
0be13d2dc2 | ||
|
|
51b584b159 | ||
|
|
7377f45b61 | ||
|
|
bfc42211d3 | ||
|
|
8b905e337c | ||
|
|
2b7cd813e7 | ||
|
|
0ca1698cf9 | ||
|
|
c1280db28a | ||
|
|
884db2f7be | ||
|
|
b63d41e1e5 | ||
|
|
4c24f170ea | ||
|
|
08777e9615 | ||
|
|
e1ba58f068 | ||
|
|
ac56700125 | ||
|
|
7b2c22696a | ||
|
|
717a043a32 | ||
|
|
9a9ede00bc | ||
|
|
b8487b6a7d | ||
|
|
25bd11cf27 | ||
|
|
1314db7109 | ||
|
|
57940605da | ||
|
|
cab1c3b370 | ||
|
|
b4873e57b4 | ||
|
|
6bd527771c | ||
|
|
02c24be8e4 | ||
|
|
4638ba9c07 | ||
|
|
de1c407348 | ||
|
|
ba980d0a62 | ||
|
|
e3bd360ec9 | ||
|
|
a00350486f | ||
|
|
e6cc30e167 | ||
|
|
155619184f | ||
|
|
c5d9c50897 | ||
|
|
6d7500c14c | ||
|
|
fd93c8601d | ||
|
|
0c7250f260 | ||
|
|
5b90a8bd7c | ||
|
|
fc0b0afdc3 | ||
|
|
2af6dded37 | ||
|
|
c9b24ef307 | ||
|
|
7dde353ee7 | ||
|
|
c395c6e5d7 | ||
|
|
b028cacf31 | ||
|
|
e1d2f86a41 | ||
|
|
5f107ab8a6 | ||
|
|
7f428cae88 | ||
|
|
6c5211a0ce | ||
|
|
f6aef68089 | ||
|
|
3f627e580a | ||
|
|
1b4570b79f | ||
|
|
b3f3cd5903 | ||
|
|
4b4275059f | ||
|
|
58797ab895 | ||
|
|
42b2d7fec5 | ||
|
|
b9ec171e7d | ||
|
|
5b597a2e5b | ||
|
|
c4c1993af6 | ||
|
|
e9ac8954be | ||
|
|
7722455726 | ||
|
|
ed0ec66996 | ||
|
|
0c34f53c93 | ||
|
|
84948e6382 | ||
|
|
5f4113edb3 | ||
|
|
8aa511f1fc | ||
|
|
7245bff300 | ||
|
|
88746d60ab | ||
|
|
8267a5fba7 | ||
|
|
fffa1aa0f3 | ||
|
|
248fdfcf73 | ||
|
|
1ab5a1b432 | ||
|
|
4c968c6ddd | ||
|
|
489fd56fe3 | ||
|
|
a44c89e8af | ||
|
|
93e8f59aab | ||
|
|
6f73079ce1 | ||
|
|
f96ebb0986 | ||
|
|
d144590d38 | ||
|
|
0e2447cd11 | ||
|
|
54310d95f9 | ||
|
|
4056edd20d | ||
|
|
1f7cc24df7 | ||
|
|
0307315769 | ||
|
|
c26097c2f1 | ||
|
|
05033c9ebd | ||
|
|
6d3fa654b7 | ||
|
|
62f9d1e3ae | ||
|
|
1d0f128351 | ||
|
|
f80125950c | ||
|
|
2a0ed8a2eb | ||
|
|
eaef8f6db2 | ||
|
|
1b2afd478b | ||
|
|
c05b417718 | ||
|
|
d4615d1118 | ||
|
|
497fe33d6f | ||
|
|
5e9f387175 | ||
|
|
1dfdae6de4 | ||
|
|
2004c25790 | ||
|
|
22336db97f | ||
|
|
72c9324d70 | ||
|
|
6e5958e37d | ||
|
|
54eb659032 | ||
|
|
e623e91e27 | ||
|
|
4dd03651f3 | ||
|
|
ce932f6479 | ||
|
|
0c84740450 | ||
|
|
65a2c451bb | ||
|
|
2464b092eb | ||
|
|
544940c48a | ||
|
|
9a826a3bd9 | ||
|
|
f423e1bb89 | ||
|
|
e955913115 | ||
|
|
7a1aac3343 | ||
|
|
97eff7eb57 | ||
|
|
f43f6fc39b | ||
|
|
0da8b8b801 | ||
|
|
fe6af26e2d | ||
|
|
0815f7f755 | ||
|
|
89e4862e5f | ||
|
|
6b63d80a7a | ||
|
|
90f43caf5b | ||
|
|
41fc3c76e9 | ||
|
|
abd159cce4 | ||
|
|
0ea2bfb30e | ||
|
|
1cc536af5a | ||
|
|
41b159fd11 | ||
|
|
1c7f608071 | ||
|
|
5351151352 | ||
|
|
a387075954 | ||
|
|
95ed19ae28 | ||
|
|
a4abd2bed9 | ||
|
|
20359deae6 | ||
|
|
5c571626e3 | ||
|
|
76a5117da7 | ||
|
|
eeea33db68 | ||
|
|
26f8ee48d6 | ||
|
|
91fd5406bc | ||
|
|
34fc0ec377 | ||
|
|
a23ae0f436 | ||
|
|
b8b2dd1a43 | ||
|
|
a91c3f1dd0 | ||
|
|
6058b78878 | ||
|
|
9649ca1630 | ||
|
|
e70fe1c42e | ||
|
|
227e5d1153 | ||
|
|
0c529b3899 | ||
|
|
a21a997478 | ||
|
|
008f983ba6 | ||
|
|
e315a162da | ||
|
|
61c7a06e7c | ||
|
|
dccda88f27 | ||
|
|
f856734c67 | ||
|
|
9f389cccfd | ||
|
|
082aecfc3a | ||
|
|
d650063a04 | ||
|
|
fd9689745c | ||
|
|
c4f69b6dfd | ||
|
|
c02301b666 | ||
|
|
f061867fd3 | ||
|
|
b15f0ecc0f | ||
|
|
ffc697ac27 | ||
|
|
3a16f511d9 | ||
|
|
6497d40521 | ||
|
|
5142bf27b2 | ||
|
|
d1e81a59a7 | ||
|
|
8f2e6da806 | ||
|
|
f5f94d9c08 | ||
|
|
9f25f736ed | ||
|
|
8a4d164c2b |
No files matched your search
@@ -0,0 +1,16 @@
|
||||
; http://editorconfig.org/
|
||||
|
||||
root = true
|
||||
|
||||
[*.{c,h}]
|
||||
charset = UTF-8
|
||||
end_of_line = LF
|
||||
indent_size = 4
|
||||
indent_style = tab
|
||||
insert_final_newline = true
|
||||
tab_width = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
@@ -135,6 +135,7 @@ tests/*/*.sh
|
||||
*/tests/*/*.sh
|
||||
*/*/tests/*.diff
|
||||
*/*/tests/*.out
|
||||
*/*/tests/*.out.png
|
||||
*/*/tests/*.php
|
||||
*/*/tests/*.exp
|
||||
*/*/tests/*.log
|
||||
|
||||
+3
-3
@@ -181,8 +181,8 @@ STATUS: Working
|
||||
SINCE: 5.1
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: pdo_dblib
|
||||
PRIMARY MAINTAINER: Unknown
|
||||
MAINTENANCE: Odd fixes
|
||||
PRIMARY MAINTAINER: Adam Baratz <adambaratz@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
SINCE: 5.1
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -205,7 +205,7 @@ STATUS: Working
|
||||
SINCE: 5.1
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: pdo_oci
|
||||
PRIMARY MAINTAINER: Unknown
|
||||
PRIMARY MAINTAINER: Christopher Jones <sixd@php.net>
|
||||
MAINTENANCE: Odd fixes
|
||||
STATUS: Working
|
||||
SINCE: 5.1
|
||||
|
||||
+18
-2
@@ -616,6 +616,12 @@ TSRM_API int shmget(int key, int size, int flags)
|
||||
}
|
||||
} else {
|
||||
if (flags & IPC_EXCL) {
|
||||
if (shm_handle) {
|
||||
CloseHandle(shm_handle);
|
||||
}
|
||||
if (info_handle) {
|
||||
CloseHandle(info_handle);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -654,17 +660,27 @@ TSRM_API int shmget(int key, int size, int flags)
|
||||
TSRM_API void *shmat(int key, const void *shmaddr, int flags)
|
||||
{
|
||||
shm_pair *shm = shm_get(key, NULL);
|
||||
int err;
|
||||
|
||||
if (!shm->segment) {
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
shm->addr = MapViewOfFileEx(shm->segment, FILE_MAP_ALL_ACCESS, 0, 0, 0, NULL);
|
||||
|
||||
err = GetLastError();
|
||||
if (err) {
|
||||
/* Catch more errors */
|
||||
if (ERROR_NOT_ENOUGH_MEMORY == err) {
|
||||
_set_errno(ENOMEM);
|
||||
}
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
shm->descriptor->shm_atime = time(NULL);
|
||||
shm->descriptor->shm_lpid = getpid();
|
||||
shm->descriptor->shm_nattch++;
|
||||
|
||||
shm->addr = MapViewOfFileEx(shm->segment, FILE_MAP_ALL_ACCESS, 0, 0, 0, NULL);
|
||||
|
||||
return shm->addr;
|
||||
}
|
||||
|
||||
|
||||
@@ -218,6 +218,9 @@ PHP 5.6 UPGRADE NOTES
|
||||
. CURLOPT_KRBLEVEL
|
||||
. CURLOPT_KRB4LEVEL
|
||||
|
||||
curl_getinfo($ch, CURLINFO_CERTINFO) returns certificate Subject and Issuer
|
||||
as a string (PHP >= 5.6.25)
|
||||
|
||||
- Strings:
|
||||
substr_compare() now allows $length to be zero.
|
||||
pack() and unpack() now support 64-bit format specifiers: q, Q, J and P.
|
||||
@@ -400,6 +403,9 @@ PHP 5.6 UPGRADE NOTES
|
||||
- CURL:
|
||||
CURL_HTTP_VERSION_2_0 and CURL_VERSION_HTTP2 (>= 5.6.8)
|
||||
|
||||
- GD:
|
||||
IMG_WEBP (>= 5.6.25)
|
||||
|
||||
- LDAP:
|
||||
LDAP_ESCAPE_FILTER int(1)
|
||||
LDAP_ESCAPE_DN int(2)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Next free element may overflow in array literals
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$i = PHP_INT_MAX;
|
||||
$array = [$i => 42, new stdClass];
|
||||
var_dump($array);
|
||||
|
||||
const FOO = [PHP_INT_MAX => 42, "foo"];
|
||||
var_dump(FOO);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Cannot add element to the array as the next element is already occupied in %s on line %d
|
||||
array(1) {
|
||||
[%d]=>
|
||||
int(42)
|
||||
}
|
||||
|
||||
Warning: Cannot add element to the array as the next element is already occupied in %s on line %d
|
||||
array(1) {
|
||||
[%d]=>
|
||||
int(42)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
Bug #72496 (declare public method with signature incompatible with parent private method should not throw a warning)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
private function getFoo()
|
||||
{
|
||||
return 'Foo';
|
||||
}
|
||||
|
||||
private function getBar()
|
||||
{
|
||||
return 'Bar';
|
||||
}
|
||||
|
||||
private function getBaz()
|
||||
{
|
||||
return 'Baz';
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo
|
||||
{
|
||||
public function getFoo($extraArgument)
|
||||
{
|
||||
return $extraArgument;
|
||||
}
|
||||
|
||||
protected function getBar($extraArgument)
|
||||
{
|
||||
return $extraArgument;
|
||||
}
|
||||
|
||||
private function getBaz($extraArgument)
|
||||
{
|
||||
return $extraArgument;
|
||||
}
|
||||
}
|
||||
|
||||
echo "OK\n";
|
||||
--EXPECT--
|
||||
OK
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Bug #72907 (null pointer deref, segfault in gc_remove_zval_from_buffer (zend_gc.c:260))
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = 0;
|
||||
|
||||
($a->a = &$E) + ($b = $a->b->i -= 0);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Attempt to modify property of non-object in %sbug72907.php on line %d
|
||||
|
||||
Warning: Attempt to modify property of non-object in %sbug72907.php on line %d
|
||||
|
||||
Warning: Creating default object from empty value in %sbug72907.php on line %d
|
||||
|
||||
Notice: Undefined property: stdClass::$i in %sbug72907.php on line %d
|
||||
@@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Bug #73337 (try/catch not working with two exceptions inside a same operation)
|
||||
--FILE--
|
||||
<?php
|
||||
class d { function __destruct() { throw new Exception; } }
|
||||
try { new d + new d; } catch (Exception $e) { print "Exception properly caught\n"; }
|
||||
?>
|
||||
--EXPECTF--
|
||||
Notice: Object of class d could not be converted to int in %sbug73337.php on line 3
|
||||
|
||||
Notice: Object of class d could not be converted to int in %sbug73337.php on line 3
|
||||
Exception properly caught
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Constexpr arrays should be able to handle resource keys
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
const FOO = [STDIN => 42];
|
||||
var_dump(FOO);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
|
||||
array(1) {
|
||||
[%d]=>
|
||||
int(42)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
--TEST--
|
||||
Testing __debugInfo() magic method with bad returns RESOURCE
|
||||
--INI--
|
||||
allow_url_fopen=1
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -13,5 +13,5 @@ var_dump(gc_collect_cycles());
|
||||
echo "ok\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
||||
int(2)
|
||||
ok
|
||||
+81
-12
@@ -1074,7 +1074,7 @@ static int zval_update_class_constant(zval **pp, int is_static, int offset TSRML
|
||||
*scope = old_scope;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
ce = ce->parent;
|
||||
} while (ce);
|
||||
|
||||
@@ -1279,9 +1279,14 @@ ZEND_API int add_assoc_double_ex(zval *arg, const char *key, uint key_len, doubl
|
||||
ZEND_API int add_assoc_string_ex(zval *arg, const char *key, uint key_len, char *str, int duplicate) /* {{{ */
|
||||
{
|
||||
zval *tmp;
|
||||
size_t _len = strlen(str);
|
||||
|
||||
if (UNEXPECTED(_len > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRING(tmp, str, duplicate);
|
||||
ZVAL_STRINGL(tmp, str, _len, duplicate);
|
||||
|
||||
return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
|
||||
}
|
||||
@@ -1291,6 +1296,10 @@ ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, uint key_len, char
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
if (UNEXPECTED(length > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, str, length, duplicate);
|
||||
|
||||
@@ -1362,6 +1371,11 @@ ZEND_API int add_index_double(zval *arg, ulong index, double d) /* {{{ */
|
||||
ZEND_API int add_index_string(zval *arg, ulong index, const char *str, int duplicate) /* {{{ */
|
||||
{
|
||||
zval *tmp;
|
||||
size_t _len = strlen(str);
|
||||
|
||||
if (UNEXPECTED(_len > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRING(tmp, str, duplicate);
|
||||
@@ -1374,6 +1388,10 @@ ZEND_API int add_index_stringl(zval *arg, ulong index, const char *str, uint len
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
if (UNEXPECTED(length > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, str, length, duplicate);
|
||||
|
||||
@@ -1457,6 +1475,9 @@ ZEND_API int add_next_index_stringl(zval *arg, const char *str, uint length, int
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
if (UNEXPECTED(length > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, str, length, duplicate);
|
||||
|
||||
@@ -1473,9 +1494,14 @@ ZEND_API int add_next_index_zval(zval *arg, zval *value) /* {{{ */
|
||||
ZEND_API int add_get_assoc_string_ex(zval *arg, const char *key, uint key_len, const char *str, void **dest, int duplicate) /* {{{ */
|
||||
{
|
||||
zval *tmp;
|
||||
size_t _len = strlen(str);
|
||||
|
||||
if (UNEXPECTED(_len > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRING(tmp, str, duplicate);
|
||||
ZVAL_STRINGL(tmp, str, _len, duplicate);
|
||||
|
||||
return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), dest);
|
||||
}
|
||||
@@ -1485,6 +1511,10 @@ ZEND_API int add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len,
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
if (UNEXPECTED(length > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, str, length, duplicate);
|
||||
|
||||
@@ -1664,9 +1694,14 @@ ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, co
|
||||
{
|
||||
zval *tmp;
|
||||
zval *z_key;
|
||||
size_t _len = strlen(str);
|
||||
|
||||
if (UNEXPECTED(_len > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRING(tmp, str, duplicate);
|
||||
ZVAL_STRINGL(tmp, str, _len, duplicate);
|
||||
|
||||
MAKE_STD_ZVAL(z_key);
|
||||
ZVAL_STRINGL(z_key, key, key_len-1, 1);
|
||||
@@ -1683,6 +1718,10 @@ ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, c
|
||||
zval *tmp;
|
||||
zval *z_key;
|
||||
|
||||
if (UNEXPECTED(length > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, str, length, duplicate);
|
||||
|
||||
@@ -1766,6 +1805,12 @@ ZEND_API int zend_startup_module_ex(zend_module_entry *module TSRMLS_DC) /* {{{
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int zend_startup_module_int(zend_module_entry *module TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
return (zend_startup_module_ex(module TSRMLS_CC) == SUCCESS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void zend_sort_modules(void *base, size_t count, size_t siz, compare_func_t compare TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
Bucket **b1 = base;
|
||||
@@ -1836,7 +1881,7 @@ ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */
|
||||
module_post_deactivate_handlers = module_request_shutdown_handlers + shutdown_count + 1;
|
||||
module_post_deactivate_handlers[post_deactivate_count] = NULL;
|
||||
startup_count = 0;
|
||||
|
||||
|
||||
for (zend_hash_internal_pointer_reset_ex(&module_registry, &pos);
|
||||
zend_hash_get_current_data_ex(&module_registry, (void *) &module, &pos) == SUCCESS;
|
||||
zend_hash_move_forward_ex(&module_registry, &pos)) {
|
||||
@@ -1882,7 +1927,7 @@ ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */
|
||||
ZEND_API int zend_startup_modules(TSRMLS_D) /* {{{ */
|
||||
{
|
||||
zend_hash_sort(&module_registry, zend_sort_modules, NULL, 0 TSRMLS_CC);
|
||||
zend_hash_apply(&module_registry, (apply_func_t)zend_startup_module_ex TSRMLS_CC);
|
||||
zend_hash_apply(&module_registry, (apply_func_t)zend_startup_module_int TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -2083,7 +2128,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
|
||||
}
|
||||
if (ptr->arg_info) {
|
||||
zend_internal_function_info *info = (zend_internal_function_info*)ptr->arg_info;
|
||||
|
||||
|
||||
internal_function->arg_info = (zend_arg_info*)ptr->arg_info+1;
|
||||
internal_function->num_args = ptr->num_args;
|
||||
/* Currently you cannot denote that the function can accept less arguments than num_args */
|
||||
@@ -2701,7 +2746,7 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca
|
||||
}
|
||||
ret = 1;
|
||||
}
|
||||
} else if (name_len == sizeof("parent") - 1 &&
|
||||
} else if (name_len == sizeof("parent") - 1 &&
|
||||
!memcmp(lcname, "parent", sizeof("parent") - 1)) {
|
||||
if (!EG(scope)) {
|
||||
if (error) *error = estrdup("cannot access parent:: when no class scope is active");
|
||||
@@ -3030,7 +3075,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
|
||||
if (error) {
|
||||
*error = NULL;
|
||||
}
|
||||
|
||||
|
||||
fcc->initialized = 0;
|
||||
fcc->calling_scope = NULL;
|
||||
fcc->called_scope = NULL;
|
||||
@@ -3042,7 +3087,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
|
||||
object_ptr = NULL;
|
||||
}
|
||||
if (object_ptr &&
|
||||
(!EG(objects_store).object_buckets ||
|
||||
(!EG(objects_store).object_buckets ||
|
||||
!EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(object_ptr)].valid)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -3123,7 +3168,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!EG(objects_store).object_buckets ||
|
||||
if (!EG(objects_store).object_buckets ||
|
||||
!EG(objects_store).object_buckets[Z_OBJ_HANDLE_PP(obj)].valid) {
|
||||
return 0;
|
||||
}
|
||||
@@ -3192,7 +3237,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
|
||||
*callable_name = emalloc(*callable_name_len + 1);
|
||||
memcpy(*callable_name, ce->name, ce->name_length);
|
||||
memcpy((*callable_name) + ce->name_length, "::__invoke", sizeof("::__invoke"));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/* break missing intentionally */
|
||||
@@ -3731,6 +3776,30 @@ ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void zend_unset_property(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zval *property;
|
||||
zend_class_entry *old_scope = EG(scope);
|
||||
|
||||
EG(scope) = scope;
|
||||
|
||||
if (!Z_OBJ_HT_P(object)->unset_property) {
|
||||
const char *class_name;
|
||||
zend_uint class_name_len;
|
||||
|
||||
zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
|
||||
|
||||
zend_error(E_CORE_ERROR, "Property %s of class %s cannot be unset", name, class_name);
|
||||
}
|
||||
MAKE_STD_ZVAL(property);
|
||||
ZVAL_STRINGL(property, name, name_length, 1);
|
||||
Z_OBJ_HT_P(object)->unset_property(object, property, 0 TSRMLS_CC);
|
||||
zval_ptr_dtor(&property);
|
||||
|
||||
EG(scope) = old_scope;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
+21
-2
@@ -330,6 +330,7 @@ ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, c
|
||||
ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, int name_length, double value TSRMLS_DC);
|
||||
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value TSRMLS_DC);
|
||||
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value, int value_length TSRMLS_DC);
|
||||
ZEND_API void zend_unset_property(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC);
|
||||
|
||||
ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, int name_length, zval *value TSRMLS_DC);
|
||||
ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, int name_length TSRMLS_DC);
|
||||
@@ -447,7 +448,7 @@ ZEND_API int add_property_zval_ex(zval *arg, const char *key, uint key_len, zval
|
||||
#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key)+1, __d TSRMLS_CC)
|
||||
#define add_property_string(__arg, __key, __str, __duplicate) add_property_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate TSRMLS_CC)
|
||||
#define add_property_stringl(__arg, __key, __str, __length, __duplicate) add_property_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate TSRMLS_CC)
|
||||
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key)+1, __value TSRMLS_CC)
|
||||
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key)+1, __value TSRMLS_CC)
|
||||
|
||||
|
||||
ZEND_API int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, zend_uint param_count, zval *params[] TSRMLS_DC);
|
||||
@@ -458,7 +459,7 @@ ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache;
|
||||
|
||||
/** Build zend_call_info/cache from a zval*
|
||||
*
|
||||
* Caller is responsible to provide a return value, otherwise the we will crash.
|
||||
* Caller is responsible to provide a return value, otherwise the we will crash.
|
||||
* fci->retval_ptr_ptr = NULL;
|
||||
* In order to pass parameters the following members need to be set:
|
||||
* fci->param_count = 0;
|
||||
@@ -578,6 +579,9 @@ END_EXTERN_C()
|
||||
const char *__s=(s); \
|
||||
zval *__z = (z); \
|
||||
Z_STRLEN_P(__z) = strlen(__s); \
|
||||
if (UNEXPECTED(Z_STRLEN_P(__z) < 0)) { \
|
||||
zend_error(E_ERROR, "String size overflow"); \
|
||||
} \
|
||||
Z_STRVAL_P(__z) = (duplicate?estrndup(__s, Z_STRLEN_P(__z)):(char*)__s);\
|
||||
Z_TYPE_P(__z) = IS_STRING; \
|
||||
} while (0)
|
||||
@@ -651,6 +655,21 @@ END_EXTERN_C()
|
||||
} while (0)
|
||||
#define RETURN_ZVAL_FAST(z) { RETVAL_ZVAL_FAST(z); return; }
|
||||
|
||||
/* Check that returned string length fits int */
|
||||
#define RETVAL_STRINGL_CHECK(s, len, dup) do { \
|
||||
size_t __len = (len); \
|
||||
if (UNEXPECTED(__len > INT_MAX)) { \
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "String too long, max is %d", INT_MAX); \
|
||||
if(!(dup)) { \
|
||||
efree((s)); \
|
||||
} \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
RETVAL_STRINGL((s), (int)__len, (dup)); \
|
||||
} while (0)
|
||||
#define RETURN_STRINGL_CHECK(s, len, dup) { RETVAL_STRINGL_CHECK(s, len, dup); return; }
|
||||
|
||||
|
||||
#define SET_VAR_STRING(n, v) { \
|
||||
{ \
|
||||
zval *var; \
|
||||
|
||||
+11
-2
@@ -2578,6 +2578,15 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
|
||||
#endif
|
||||
|
||||
|
||||
ZEND_API void *_safe_emalloc_string(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
size_t str_size = safe_address(nmemb, size, offset);
|
||||
if (UNEXPECTED(str_size > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String allocation overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
return emalloc_rel(str_size);
|
||||
}
|
||||
|
||||
ZEND_API void *_safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
return emalloc_rel(safe_address(nmemb, size, offset));
|
||||
@@ -2726,9 +2735,9 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals TSRMLS_DC)
|
||||
alloc_globals->mm_heap = malloc(sizeof(struct _zend_mm_heap));
|
||||
memset(alloc_globals->mm_heap, 0, sizeof(struct _zend_mm_heap));
|
||||
alloc_globals->mm_heap->use_zend_alloc = 0;
|
||||
alloc_globals->mm_heap->_malloc = malloc;
|
||||
alloc_globals->mm_heap->_malloc = __zend_malloc;
|
||||
alloc_globals->mm_heap->_free = free;
|
||||
alloc_globals->mm_heap->_realloc = realloc;
|
||||
alloc_globals->mm_heap->_realloc = __zend_realloc;
|
||||
} else {
|
||||
alloc_globals->mm_heap = zend_mm_startup();
|
||||
}
|
||||
|
||||
+3
-1
@@ -5,7 +5,7 @@
|
||||
| Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.00 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.zend.com/license/2_00.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
@@ -56,6 +56,7 @@ ZEND_API char *zend_strndup(const char *s, unsigned int length) ZEND_ATTRIBUTE_M
|
||||
|
||||
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE(1);
|
||||
ZEND_API void *_safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
|
||||
ZEND_API void *_safe_emalloc_string(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
|
||||
ZEND_API void *_safe_malloc(size_t nmemb, size_t size, size_t offset) ZEND_ATTRIBUTE_MALLOC;
|
||||
ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE2(1,2);
|
||||
@@ -69,6 +70,7 @@ ZEND_API size_t _zend_mem_block_size(void *ptr TSRMLS_DC ZEND_FILE_LINE_DC ZEND_
|
||||
/* Standard wrapper macros */
|
||||
#define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define safe_emalloc(nmemb, size, offset) _safe_emalloc((nmemb), (size), (offset) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define safe_emalloc_string(nmemb, size, offset) _safe_emalloc_string((nmemb), (size), (offset) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define efree(ptr) _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define ecalloc(nmemb, size) _ecalloc((nmemb), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define erealloc(ptr, size) _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
|
||||
+13
-5
@@ -3252,8 +3252,8 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If both methods are private do not enforce a signature */
|
||||
if ((fe->common.fn_flags & ZEND_ACC_PRIVATE) && (proto->common.fn_flags & ZEND_ACC_PRIVATE)) {
|
||||
/* If the prototype method is private do not enforce a signature */
|
||||
if (proto->common.fn_flags & ZEND_ACC_PRIVATE) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -3637,6 +3637,7 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro
|
||||
{
|
||||
zend_property_info *child_info;
|
||||
zend_class_entry *parent_ce = ce->parent;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (parent_info->flags & (ZEND_ACC_PRIVATE|ZEND_ACC_SHADOW)) {
|
||||
if (zend_hash_quick_find(&ce->properties_info, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) {
|
||||
@@ -3669,7 +3670,8 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro
|
||||
if ((child_info->flags & ZEND_ACC_PPP_MASK) > (parent_info->flags & ZEND_ACC_PPP_MASK)) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::$%s must be %s (as in class %s)%s", ce->name, hash_key->arKey, zend_visibility_string(parent_info->flags), parent_ce->name, (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
|
||||
} else if ((child_info->flags & ZEND_ACC_STATIC) == 0) {
|
||||
zval_ptr_dtor(&(ce->default_properties_table[parent_info->offset]));
|
||||
/* Don't keep default properties in GC (thry may be freed by opcache) */
|
||||
i_zval_ptr_dtor_nogc(ce->default_properties_table[parent_info->offset] ZEND_FILE_LINE_CC TSRMLS_CC);
|
||||
ce->default_properties_table[parent_info->offset] = ce->default_properties_table[child_info->offset];
|
||||
ce->default_properties_table[child_info->offset] = NULL;
|
||||
child_info->offset = parent_info->offset;
|
||||
@@ -5927,7 +5929,7 @@ void zend_do_add_array_element(znode *result, const znode *expr, const znode *of
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void zend_do_add_static_array_element(zval *result, zval *offset, const zval *expr) /* {{{ */
|
||||
void zend_do_add_static_array_element(zval *result, zval *offset, zval *expr) /* {{{ */
|
||||
{
|
||||
if (offset) {
|
||||
switch (Z_TYPE_P(offset)) {
|
||||
@@ -5938,6 +5940,9 @@ void zend_do_add_static_array_element(zval *result, zval *offset, const zval *ex
|
||||
case IS_NULL:
|
||||
zend_symtable_update(Z_ARRVAL_P(result), "", 1, &expr, sizeof(zval *), NULL);
|
||||
break;
|
||||
case IS_RESOURCE:
|
||||
zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_LVAL_P(offset), Z_LVAL_P(offset));
|
||||
/* break missing intentionally */
|
||||
case IS_LONG:
|
||||
case IS_BOOL:
|
||||
zend_hash_index_update(Z_ARRVAL_P(result), Z_LVAL_P(offset), &expr, sizeof(zval *), NULL);
|
||||
@@ -5950,7 +5955,10 @@ void zend_do_add_static_array_element(zval *result, zval *offset, const zval *ex
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL_P(result), &expr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL_P(result), &expr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
+1
-1
@@ -598,7 +598,7 @@ void zend_do_shell_exec(znode *result, const znode *cmd TSRMLS_DC);
|
||||
|
||||
void zend_do_init_array(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC);
|
||||
void zend_do_add_array_element(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC);
|
||||
void zend_do_add_static_array_element(zval *result, zval *offset, const zval *expr);
|
||||
void zend_do_add_static_array_element(zval *result, zval *offset, zval *expr);
|
||||
void zend_do_list_init(TSRMLS_D);
|
||||
void zend_do_list_end(znode *result, znode *expr TSRMLS_DC);
|
||||
void zend_do_add_list_element(const znode *element TSRMLS_DC);
|
||||
|
||||
+27
-11
@@ -229,13 +229,9 @@ 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); \
|
||||
value = zend_read_property(default_exception_ce, object, name, sizeof(name)-1, 1 TSRMLS_CC); \
|
||||
if (value && Z_TYPE_P(value) != IS_NULL && Z_TYPE_P(value) != type) { \
|
||||
zend_unset_property(default_exception_ce, object, name, sizeof(name)-1 TSRMLS_CC); \
|
||||
}
|
||||
|
||||
ZEND_METHOD(exception, __wakeup)
|
||||
@@ -248,7 +244,12 @@ ZEND_METHOD(exception, __wakeup)
|
||||
CHECK_EXC_TYPE("file", IS_STRING);
|
||||
CHECK_EXC_TYPE("line", IS_LONG);
|
||||
CHECK_EXC_TYPE("trace", IS_ARRAY);
|
||||
CHECK_EXC_TYPE("previous", IS_OBJECT);
|
||||
value = zend_read_property(default_exception_ce, object, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
|
||||
if (value && Z_TYPE_P(value) != IS_NULL && (Z_TYPE_P(value) != IS_OBJECT ||
|
||||
!instanceof_function(Z_OBJCE_P(value), default_exception_ce TSRMLS_CC) ||
|
||||
value == object)) {
|
||||
zend_unset_property(default_exception_ce, object, "previous", sizeof("previous")-1 TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -727,7 +728,11 @@ ZEND_METHOD(exception, __toString)
|
||||
zval_dtor(&file);
|
||||
zval_dtor(&line);
|
||||
|
||||
exception = zend_read_property(default_exception_ce, exception, "previous", sizeof("previous")-1, 0 TSRMLS_CC);
|
||||
Z_OBJPROP_P(exception)->nApplyCount++;
|
||||
exception = zend_read_property(default_exception_ce, exception, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
|
||||
if (exception && Z_TYPE_P(exception) == IS_OBJECT && Z_OBJPROP_P(exception)->nApplyCount > 0) {
|
||||
exception = NULL;
|
||||
}
|
||||
|
||||
if (trace) {
|
||||
zval_ptr_dtor(&trace);
|
||||
@@ -736,6 +741,17 @@ ZEND_METHOD(exception, __toString)
|
||||
}
|
||||
zval_dtor(&fname);
|
||||
|
||||
/* Reset apply counts */
|
||||
exception = getThis();
|
||||
while (exception && Z_TYPE_P(exception) == IS_OBJECT && instanceof_function(Z_OBJCE_P(exception), default_exception_ce TSRMLS_CC)) {
|
||||
if(Z_OBJPROP_P(exception)->nApplyCount) {
|
||||
Z_OBJPROP_P(exception)->nApplyCount--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
exception = zend_read_property(default_exception_ce, exception, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
|
||||
}
|
||||
|
||||
/* We store the result in the private property string so we can access
|
||||
* the result in uncaught exception handlers without memleaks. */
|
||||
zend_update_property_string(default_exception_ce, getThis(), "string", sizeof("string")-1, str TSRMLS_CC);
|
||||
@@ -893,11 +909,10 @@ static void zend_error_va(int type, const char *file, uint lineno, const char *f
|
||||
ZEND_API void zend_exception_error(zval *exception, int severity TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_class_entry *ce_exception = Z_OBJCE_P(exception);
|
||||
EG(exception) = NULL;
|
||||
if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) {
|
||||
zval *str, *file, *line;
|
||||
|
||||
EG(exception) = NULL;
|
||||
|
||||
zend_call_method_with_0_params(&exception, ce_exception, NULL, "__tostring", &str);
|
||||
if (!EG(exception)) {
|
||||
if (Z_TYPE_P(str) != IS_STRING) {
|
||||
@@ -936,6 +951,7 @@ ZEND_API void zend_exception_error(zval *exception, int severity TSRMLS_DC) /* {
|
||||
} else {
|
||||
zend_error(severity, "Uncaught exception '%s'", ce_exception->name);
|
||||
}
|
||||
zval_ptr_dtor(&exception);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
+1
-3
@@ -522,9 +522,7 @@ static void zend_assign_to_variable_reference(zval **variable_ptr_ptr, zval **va
|
||||
zval *variable_ptr = *variable_ptr_ptr;
|
||||
zval *value_ptr = *value_ptr_ptr;
|
||||
|
||||
if (variable_ptr == &EG(error_zval) || value_ptr == &EG(error_zval)) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else if (variable_ptr != value_ptr) {
|
||||
if (variable_ptr != value_ptr) {
|
||||
if (!PZVAL_IS_REF(value_ptr)) {
|
||||
/* break it away */
|
||||
Z_DELREF_P(value_ptr);
|
||||
|
||||
@@ -826,7 +826,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
|
||||
if (EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) {
|
||||
*fci->retval_ptr_ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC);
|
||||
} else {
|
||||
const zend_op *current_opline_before_exception = EG(opline_before_exception);
|
||||
|
||||
zend_execute(EG(active_op_array) TSRMLS_CC);
|
||||
EG(opline_before_exception) = current_opline_before_exception;
|
||||
}
|
||||
|
||||
if (!fci->symbol_table && EG(active_symbol_table)) {
|
||||
|
||||
@@ -215,7 +215,7 @@ ZEND_API void zend_objects_store_del_ref_by_handle_ex(zend_object_handle handle,
|
||||
} zend_end_try();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* re-read the object from the object store as the store might have been reallocated in the dtor */
|
||||
obj = &EG(objects_store).object_buckets[handle].bucket.obj;
|
||||
|
||||
@@ -306,8 +306,8 @@ ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC)
|
||||
{
|
||||
zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
|
||||
zend_object_store_bucket *obj_bucket = &EG(objects_store).object_buckets[handle];
|
||||
|
||||
obj_bucket->bucket.obj.handlers = Z_OBJ_HT_P(zobject);;
|
||||
|
||||
obj_bucket->bucket.obj.handlers = Z_OBJ_HT_P(zobject);
|
||||
obj_bucket->destructor_called = 1;
|
||||
}
|
||||
|
||||
|
||||
+14
-2
@@ -1397,7 +1397,13 @@ ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
|
||||
ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2) /* {{{ */
|
||||
{
|
||||
int length = Z_STRLEN_P(op1) + 1;
|
||||
char *buf = str_erealloc(Z_STRVAL_P(op1), length + 1);
|
||||
char *buf;
|
||||
|
||||
if (UNEXPECTED(length < 0)) {
|
||||
zend_error(E_ERROR, "String size overflow");
|
||||
}
|
||||
|
||||
buf = str_erealloc(Z_STRVAL_P(op1), length + 1);
|
||||
|
||||
buf[length - 1] = (char) Z_LVAL_P(op2);
|
||||
buf[length] = 0;
|
||||
@@ -1410,7 +1416,13 @@ ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2)
|
||||
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 = str_erealloc(Z_STRVAL_P(op1), length + 1);
|
||||
char *buf;
|
||||
|
||||
if (UNEXPECTED(length < 0)) {
|
||||
zend_error(E_ERROR, "String size overflow");
|
||||
}
|
||||
|
||||
buf = str_erealloc(Z_STRVAL_P(op1), length + 1);
|
||||
|
||||
memcpy(buf + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
|
||||
buf[length] = 0;
|
||||
|
||||
+1
-1
@@ -2590,7 +2590,7 @@ ZEND_API double zend_hex_strtod(const char *str, const char **endptr)
|
||||
int any = 0;
|
||||
double value = 0;
|
||||
|
||||
if (strlen(str) < 2) {
|
||||
if (s[0] == '\0' || s[1] == '\0') {
|
||||
*endptr = str;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@@ -651,14 +651,14 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{
|
||||
memcmp(path, (*bucket)->path, path_len) == 0) {
|
||||
realpath_cache_bucket *r = *bucket;
|
||||
*bucket = (*bucket)->next;
|
||||
|
||||
|
||||
/* if the pointers match then only subtract the length of the path */
|
||||
if(r->path == r->realpath) {
|
||||
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1;
|
||||
} else {
|
||||
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
|
||||
}
|
||||
|
||||
|
||||
free(r);
|
||||
return;
|
||||
} else {
|
||||
@@ -734,7 +734,7 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p
|
||||
realpath_cache_bucket *r = *bucket;
|
||||
*bucket = (*bucket)->next;
|
||||
|
||||
/* if the pointers match then only subtract the length of the path */
|
||||
/* if the pointers match then only subtract the length of the path */
|
||||
if(r->path == r->realpath) {
|
||||
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1;
|
||||
} else {
|
||||
@@ -919,6 +919,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||
|
||||
pbuffer = (REPARSE_DATA_BUFFER *)do_alloca(MAXIMUM_REPARSE_DATA_BUFFER_SIZE, use_heap_large);
|
||||
if (pbuffer == NULL) {
|
||||
CloseHandle(hLink);
|
||||
return -1;
|
||||
}
|
||||
if(!DeviceIoControl(hLink, FSCTL_GET_REPARSE_POINT, NULL, 0, pbuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &retlength, NULL)) {
|
||||
@@ -1189,7 +1190,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
int add_slash;
|
||||
void *tmp;
|
||||
|
||||
if (path_length == 0 || path_length >= MAXPATHLEN-1) {
|
||||
if (path_length <= 0 || path_length >= MAXPATHLEN-1) {
|
||||
#ifdef TSRM_WIN32
|
||||
# if _MSC_VER < 1300
|
||||
errno = EINVAL;
|
||||
@@ -1895,7 +1896,7 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /*
|
||||
#else /* Unix */
|
||||
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
int command_length;
|
||||
size_t command_length;
|
||||
int dir_length, extra = 0;
|
||||
char *command_line;
|
||||
char *ptr, *dir;
|
||||
|
||||
+12
-6
@@ -1817,11 +1817,14 @@ ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV)
|
||||
if ((OP2_TYPE == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) ||
|
||||
(OP1_TYPE == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
|
||||
}
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
|
||||
if (OP2_TYPE == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
} else if ((OP2_TYPE == IS_VAR && UNEXPECTED(*value_ptr_ptr == &EG(error_zval))) ||
|
||||
(OP1_TYPE == IS_VAR && UNEXPECTED(*variable_ptr_ptr == &EG(error_zval)))) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else {
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
if (OP2_TYPE == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
@@ -3876,7 +3879,10 @@ ZEND_VM_C_LABEL(num_index):
|
||||
}
|
||||
FREE_OP2();
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) && opline->extended_value) {
|
||||
FREE_OP1_VAR_PTR();
|
||||
|
||||
+112
-40
@@ -4119,7 +4119,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -5030,7 +5033,10 @@ num_index:
|
||||
}
|
||||
zval_dtor(free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -5894,7 +5900,10 @@ num_index:
|
||||
}
|
||||
zval_ptr_dtor_nogc(&free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -6614,7 +6623,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -7547,7 +7559,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -9447,7 +9462,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -10314,7 +10332,10 @@ num_index:
|
||||
}
|
||||
zval_dtor(free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -11180,7 +11201,10 @@ num_index:
|
||||
}
|
||||
zval_ptr_dtor_nogc(&free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -11775,7 +11799,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -12624,7 +12651,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -16107,7 +16137,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) {
|
||||
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
|
||||
@@ -18387,7 +18420,10 @@ num_index:
|
||||
}
|
||||
zval_dtor(free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) {
|
||||
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
|
||||
@@ -20408,11 +20444,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL
|
||||
if ((IS_VAR == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) ||
|
||||
(IS_VAR == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
|
||||
}
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
|
||||
if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
} else if ((IS_VAR == IS_VAR && UNEXPECTED(*value_ptr_ptr == &EG(error_zval))) ||
|
||||
(IS_VAR == IS_VAR && UNEXPECTED(*variable_ptr_ptr == &EG(error_zval)))) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else {
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
@@ -20722,7 +20761,10 @@ num_index:
|
||||
}
|
||||
zval_ptr_dtor_nogc(&free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) {
|
||||
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
|
||||
@@ -22162,7 +22204,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) {
|
||||
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
|
||||
@@ -23903,11 +23948,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE
|
||||
if ((IS_CV == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) ||
|
||||
(IS_VAR == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
|
||||
}
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
|
||||
if (IS_CV == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
} else if ((IS_CV == IS_VAR && UNEXPECTED(*value_ptr_ptr == &EG(error_zval))) ||
|
||||
(IS_VAR == IS_VAR && UNEXPECTED(*variable_ptr_ptr == &EG(error_zval)))) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else {
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
if (IS_CV == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
@@ -24214,7 +24262,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) {
|
||||
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
|
||||
@@ -33568,7 +33619,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -35711,7 +35765,10 @@ num_index:
|
||||
}
|
||||
zval_dtor(free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -37721,11 +37778,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE
|
||||
if ((IS_VAR == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) ||
|
||||
(IS_CV == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
|
||||
}
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
|
||||
if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
} else if ((IS_VAR == IS_VAR && UNEXPECTED(*value_ptr_ptr == &EG(error_zval))) ||
|
||||
(IS_CV == IS_VAR && UNEXPECTED(*variable_ptr_ptr == &EG(error_zval)))) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else {
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
@@ -37908,7 +37968,10 @@ num_index:
|
||||
}
|
||||
zval_ptr_dtor_nogc(&free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -39216,7 +39279,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -40929,11 +40995,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER
|
||||
if ((IS_CV == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) ||
|
||||
(IS_CV == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
|
||||
}
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
|
||||
if (IS_CV == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
} else if ((IS_CV == IS_VAR && UNEXPECTED(*value_ptr_ptr == &EG(error_zval))) ||
|
||||
(IS_CV == IS_VAR && UNEXPECTED(*variable_ptr_ptr == &EG(error_zval)))) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else {
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
if (IS_CV == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
@@ -41113,7 +41182,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) {
|
||||
|
||||
|
||||
+2
-2
@@ -119,8 +119,8 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||
|
||||
PHP_MAJOR_VERSION=5
|
||||
PHP_MINOR_VERSION=6
|
||||
PHP_RELEASE_VERSION=21
|
||||
PHP_EXTRA_VERSION="-dev"
|
||||
PHP_RELEASE_VERSION=29
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,10 @@ _bc_new_num_ex (length, scale, persistent)
|
||||
int length, scale, persistent;
|
||||
{
|
||||
bc_num temp;
|
||||
|
||||
/* PHP Change: add length check */
|
||||
if ((size_t)length+(size_t)scale > INT_MAX) {
|
||||
zend_error(E_ERROR, "Result too long, max is %d", INT_MAX);
|
||||
}
|
||||
/* PHP Change: malloc() -> pemalloc(), removed free_list code */
|
||||
temp = (bc_num) safe_pemalloc (1, sizeof(bc_struct)+length, scale, persistent);
|
||||
#if 0
|
||||
|
||||
@@ -41,6 +41,5 @@
|
||||
|
||||
void bc_out_of_memory (void)
|
||||
{
|
||||
(void) fprintf (stderr, "bcmath: out of memory!\n");
|
||||
exit (1);
|
||||
zend_error(E_ERROR, "bcmath: out of memory!");
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Bug 72093: bcpowmod accepts negative scale and corrupts _one_ definition
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded("bcmath")) print "skip";
|
||||
if (substr(PHP_OS, 0, 3) != 'WIN') {
|
||||
die('skip valid only for windows');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(bcpowmod(1, "A", 128, -200));
|
||||
var_dump(bcpowmod(1, 1.2, 1, 1));
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(1) "1"
|
||||
string(3) "0.0"
|
||||
bc math warning: non-zero scale in exponent
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Bug 72093: bcpowmod accepts negative scale and corrupts _one_ definition
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded("bcmath")) print "skip";
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||
die('skip Not valid for windows');
|
||||
}
|
||||
?>
|
||||
--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"
|
||||
+57
-43
@@ -15,7 +15,7 @@
|
||||
| Author: Sterling Hughes <sterling@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -138,29 +138,33 @@ struct php_bz2_stream_data_t {
|
||||
static size_t php_bz2iop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *) stream->abstract;
|
||||
size_t ret;
|
||||
|
||||
ret = BZ2_bzread(self->bz_file, buf, count);
|
||||
int bz2_ret;
|
||||
|
||||
if (ret == 0) {
|
||||
bz2_ret = BZ2_bzread(self->bz_file, buf, count);
|
||||
|
||||
if (bz2_ret < 0) {
|
||||
stream->eof = 1;
|
||||
return -1;
|
||||
}
|
||||
if (bz2_ret == 0) {
|
||||
stream->eof = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return (size_t)bz2_ret;
|
||||
}
|
||||
|
||||
static size_t php_bz2iop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *) stream->abstract;
|
||||
|
||||
return BZ2_bzwrite(self->bz_file, (char*)buf, count);
|
||||
return BZ2_bzwrite(self->bz_file, (char*)buf, count);
|
||||
}
|
||||
|
||||
static int php_bz2iop_close(php_stream *stream, int close_handle TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *)stream->abstract;
|
||||
int ret = EOF;
|
||||
|
||||
|
||||
if (close_handle) {
|
||||
BZ2_bzclose(self->bz_file);
|
||||
}
|
||||
@@ -192,11 +196,11 @@ php_stream_ops php_stream_bz2io_ops = {
|
||||
};
|
||||
|
||||
/* {{{ Bzip2 stream openers */
|
||||
PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz,
|
||||
PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz,
|
||||
const char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self;
|
||||
|
||||
|
||||
self = emalloc(sizeof(*self));
|
||||
|
||||
self->stream = innerstream;
|
||||
@@ -227,7 +231,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
|
||||
virtual_filepath_ex(path, &path_copy, NULL TSRMLS_CC);
|
||||
#else
|
||||
path_copy = path;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (php_check_open_basedir(path_copy TSRMLS_CC)) {
|
||||
#ifdef VIRTUAL_DIR
|
||||
@@ -235,7 +239,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* try and open it directly first */
|
||||
bz_file = BZ2_bzopen(path_copy, mode);
|
||||
|
||||
@@ -246,11 +250,11 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
|
||||
efree(path_copy);
|
||||
#endif
|
||||
path_copy = NULL;
|
||||
|
||||
|
||||
if (bz_file == NULL) {
|
||||
/* that didn't work, so try and get something from the network/wrapper */
|
||||
stream = php_stream_open_wrapper(path, mode, options | STREAM_WILL_CAST, opened_path);
|
||||
|
||||
|
||||
if (stream) {
|
||||
php_socket_t fd;
|
||||
if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **) &fd, REPORT_ERRORS)) {
|
||||
@@ -265,7 +269,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
|
||||
VCWD_UNLINK(*opened_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (bz_file) {
|
||||
retstream = _php_stream_bz2open_from_BZFILE(bz_file, mode, stream STREAMS_REL_CC TSRMLS_CC);
|
||||
if (retstream) {
|
||||
@@ -341,7 +345,7 @@ static PHP_FUNCTION(bzread)
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &bz, &len)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
php_stream_from_zval(stream, &bz);
|
||||
|
||||
if ((len + 1) < 1) {
|
||||
@@ -351,13 +355,13 @@ static PHP_FUNCTION(bzread)
|
||||
|
||||
Z_STRVAL_P(return_value) = emalloc(len + 1);
|
||||
Z_STRLEN_P(return_value) = php_stream_read(stream, Z_STRVAL_P(return_value), len);
|
||||
|
||||
|
||||
if (Z_STRLEN_P(return_value) < 0) {
|
||||
efree(Z_STRVAL_P(return_value));
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not read valid bz2 data from stream");
|
||||
RETURN_FALSE;
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0;
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
}
|
||||
@@ -373,7 +377,7 @@ static PHP_FUNCTION(bzopen)
|
||||
|
||||
BZFILE *bz; /* The compressed file stream */
|
||||
php_stream *stream = NULL;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zs", &file, &mode, &mode_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
@@ -389,15 +393,15 @@ static PHP_FUNCTION(bzopen)
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "filename cannot be empty");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (CHECK_ZVAL_NULL_PATH(*file)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
stream = php_stream_bz2open(NULL,
|
||||
Z_STRVAL_PP(file),
|
||||
mode,
|
||||
REPORT_ERRORS,
|
||||
Z_STRVAL_PP(file),
|
||||
mode,
|
||||
REPORT_ERRORS,
|
||||
NULL);
|
||||
} else if (Z_TYPE_PP(file) == IS_RESOURCE) {
|
||||
/* If it is a resource, than its a stream resource */
|
||||
@@ -406,7 +410,7 @@ static PHP_FUNCTION(bzopen)
|
||||
|
||||
php_stream_from_zval(stream, file);
|
||||
stream_mode_len = strlen(stream->mode);
|
||||
|
||||
|
||||
if (stream_mode_len != 1 && !(stream_mode_len == 2 && memchr(stream->mode, 'b', 2))) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot use stream opened in mode '%s'", stream->mode);
|
||||
RETURN_FALSE;
|
||||
@@ -440,7 +444,7 @@ static PHP_FUNCTION(bzopen)
|
||||
if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_FD, (void *) &fd, REPORT_ERRORS)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
bz = BZ2_bzdopen(fd, mode);
|
||||
|
||||
stream = php_stream_bz2open_from_BZFILE(bz, mode, stream);
|
||||
@@ -494,7 +498,7 @@ static PHP_FUNCTION(bzcompress)
|
||||
work_factor = 0, /* Work factor for compression algorithm */
|
||||
argc; /* Argument count */
|
||||
int source_len; /* Length of the source data */
|
||||
unsigned int dest_len; /* Length of the destination buffer */
|
||||
unsigned int dest_len; /* Length of the destination buffer */
|
||||
|
||||
argc = ZEND_NUM_ARGS();
|
||||
|
||||
@@ -503,19 +507,19 @@ static PHP_FUNCTION(bzcompress)
|
||||
}
|
||||
|
||||
/* Assign them to easy to use variables, dest_len is initially the length of the data
|
||||
+ .01 x length of data + 600 which is the largest size the results of the compression
|
||||
could possibly be, at least that's what the libbz2 docs say (thanks to jeremy@nirvani.net
|
||||
+ .01 x length of data + 600 which is the largest size the results of the compression
|
||||
could possibly be, at least that's what the libbz2 docs say (thanks to jeremy@nirvani.net
|
||||
for pointing this out). */
|
||||
dest_len = (unsigned int) (source_len + (0.01 * source_len) + 600);
|
||||
|
||||
|
||||
/* Allocate the destination buffer */
|
||||
dest = emalloc(dest_len + 1);
|
||||
|
||||
dest = safe_emalloc(dest_len, 1, 1);
|
||||
|
||||
/* Handle the optional arguments */
|
||||
if (argc > 1) {
|
||||
block_size = zblock_size;
|
||||
}
|
||||
|
||||
|
||||
if (argc > 2) {
|
||||
work_factor = zwork_factor;
|
||||
}
|
||||
@@ -529,7 +533,7 @@ static PHP_FUNCTION(bzcompress)
|
||||
so we erealloc() the buffer to the proper size */
|
||||
dest = erealloc(dest, dest_len + 1);
|
||||
dest[dest_len] = 0;
|
||||
RETURN_STRINGL(dest, dest_len, 0);
|
||||
RETURN_STRINGL_CHECK(dest, dest_len, 0);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@@ -565,20 +569,30 @@ static PHP_FUNCTION(bzdecompress)
|
||||
/* in most cases bz2 offers at least 2:1 compression, so we use that as our base */
|
||||
bzs.avail_out = source_len * 2;
|
||||
bzs.next_out = dest = emalloc(bzs.avail_out + 1);
|
||||
|
||||
|
||||
while ((error = BZ2_bzDecompress(&bzs)) == BZ_OK && bzs.avail_in > 0) {
|
||||
/* compression is better then 2:1, need to allocate more memory */
|
||||
bzs.avail_out = source_len;
|
||||
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
|
||||
if (size > INT_MAX) {
|
||||
/* no reason to continue if we're going to drop it anyway */
|
||||
break;
|
||||
}
|
||||
dest = safe_erealloc(dest, 1, bzs.avail_out+1, (size_t) size );
|
||||
bzs.next_out = dest + size;
|
||||
}
|
||||
|
||||
if (error == BZ_STREAM_END || error == BZ_OK) {
|
||||
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
|
||||
dest = safe_erealloc(dest, 1, (size_t) size, 1);
|
||||
dest[size] = '\0';
|
||||
RETVAL_STRINGL(dest, (int) size, 0);
|
||||
if (size > INT_MAX) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Decompressed size too big, max is %d", INT_MAX);
|
||||
efree(dest);
|
||||
RETVAL_LONG(BZ_MEM_ERROR);
|
||||
} else {
|
||||
dest = safe_erealloc(dest, 1, (size_t) size, 1);
|
||||
dest[size] = '\0';
|
||||
RETVAL_STRINGL(dest, (int) size, 0);
|
||||
}
|
||||
} else { /* real error */
|
||||
efree(dest);
|
||||
RETVAL_LONG(error);
|
||||
@@ -591,13 +605,13 @@ static PHP_FUNCTION(bzdecompress)
|
||||
/* {{{ php_bz2_error()
|
||||
The central error handling interface, does the work for bzerrno, bzerrstr and bzerror */
|
||||
static void php_bz2_error(INTERNAL_FUNCTION_PARAMETERS, int opt)
|
||||
{
|
||||
{
|
||||
zval *bzp; /* BZip2 Resource Pointer */
|
||||
php_stream *stream;
|
||||
const char *errstr; /* Error string */
|
||||
int errnum; /* Error number */
|
||||
struct php_bz2_stream_data_t *self;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &bzp) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
@@ -609,10 +623,10 @@ static void php_bz2_error(INTERNAL_FUNCTION_PARAMETERS, int opt)
|
||||
}
|
||||
|
||||
self = (struct php_bz2_stream_data_t *) stream->abstract;
|
||||
|
||||
|
||||
/* Fetch the error information */
|
||||
errstr = BZ2_bzerror(self->bz_file, &errnum);
|
||||
|
||||
|
||||
/* Determine what to return */
|
||||
switch (opt) {
|
||||
case PHP_BZ_ERRNO:
|
||||
@@ -623,7 +637,7 @@ static void php_bz2_error(INTERNAL_FUNCTION_PARAMETERS, int opt)
|
||||
break;
|
||||
case PHP_BZ_ERRBOTH:
|
||||
array_init(return_value);
|
||||
|
||||
|
||||
add_assoc_long (return_value, "errno", errnum);
|
||||
add_assoc_string(return_value, "errstr", (char*)errstr, 1);
|
||||
break;
|
||||
|
||||
@@ -396,7 +396,7 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi
|
||||
zval_copy_ctor(&tmp);
|
||||
convert_to_long(&tmp);
|
||||
if (Z_LVAL(tmp) < 1 || Z_LVAL(tmp) > 9) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter given for number of blocks to allocate. (%ld)", Z_LVAL_PP(tmpzval));
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter given for number of blocks to allocate. (%ld)", Z_LVAL(tmp));
|
||||
} else {
|
||||
blockSize100k = Z_LVAL(tmp);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #72447: Type Confusion in php_bz2_filter_create()
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("bz2")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$input = "AAAAAAAA";
|
||||
$param = array('blocks' => $input);
|
||||
|
||||
$fp = fopen('testfile', 'w');
|
||||
stream_filter_append($fp, 'bzip2.compress', STREAM_FILTER_WRITE, $param);
|
||||
fclose($fp);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: stream_filter_append(): Invalid parameter given for number of blocks to allocate. (0) in %s%ebug72447.php on line %d
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Bug #72613 (Inadequate error handling in bzread())
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("bz2")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$fp = bzopen(__DIR__.'/72613.bz2', 'r');
|
||||
if ($fp === FALSE) {
|
||||
exit("ERROR: bzopen()");
|
||||
}
|
||||
$data = "";
|
||||
while (!feof($fp)) {
|
||||
$res = bzread($fp);
|
||||
if ($res === FALSE) {
|
||||
exit("ERROR: bzread()");
|
||||
}
|
||||
$data .= $res;
|
||||
}
|
||||
bzclose($fp);
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
DONE
|
||||
+17
-7
@@ -359,6 +359,10 @@ PHP_FUNCTION(cal_days_in_month)
|
||||
}
|
||||
else {
|
||||
sdn_next = calendar->to_jd(year + 1, 1, 1);
|
||||
if (cal == CAL_FRENCH && sdn_next == 0) {
|
||||
/* The French calendar ends on 0014-13-05. */
|
||||
sdn_next = 2380953;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,15 +420,21 @@ PHP_FUNCTION(cal_from_jd)
|
||||
add_assoc_long(return_value, "year", year);
|
||||
|
||||
/* day of week */
|
||||
dow = DayOfWeek(jd);
|
||||
add_assoc_long(return_value, "dow", dow);
|
||||
add_assoc_string(return_value, "abbrevdayname", DayNameShort[dow], 1);
|
||||
add_assoc_string(return_value, "dayname", DayNameLong[dow], 1);
|
||||
if (cal != CAL_JEWISH || year > 0) {
|
||||
dow = DayOfWeek(jd);
|
||||
add_assoc_long(return_value, "dow", dow);
|
||||
add_assoc_string(return_value, "abbrevdayname", DayNameShort[dow], 1);
|
||||
add_assoc_string(return_value, "dayname", DayNameLong[dow], 1);
|
||||
} else {
|
||||
add_assoc_null(return_value, "dow");
|
||||
add_assoc_string(return_value, "abbrevdayname", "", 1);
|
||||
add_assoc_string(return_value, "dayname", "", 1);
|
||||
}
|
||||
/* month name */
|
||||
if(cal == CAL_JEWISH) {
|
||||
/* special case for Jewish calendar */
|
||||
add_assoc_string(return_value, "abbrevmonth", JEWISH_MONTH_NAME(year)[month], 1);
|
||||
add_assoc_string(return_value, "monthname", JEWISH_MONTH_NAME(year)[month], 1);
|
||||
add_assoc_string(return_value, "abbrevmonth", (year > 0 ? JEWISH_MONTH_NAME(year)[month] : ""), 1);
|
||||
add_assoc_string(return_value, "monthname", (year > 0 ? JEWISH_MONTH_NAME(year)[month] : ""), 1);
|
||||
} else {
|
||||
add_assoc_string(return_value, "abbrevmonth", calendar->month_name_short[month], 1);
|
||||
add_assoc_string(return_value, "monthname", calendar->month_name_long[month], 1);
|
||||
@@ -737,7 +747,7 @@ PHP_FUNCTION(jdmonthname)
|
||||
break;
|
||||
case CAL_MONTH_JEWISH: /* jewish month */
|
||||
SdnToJewish(julday, &year, &month, &day);
|
||||
monthname = JEWISH_MONTH_NAME(year)[month];
|
||||
monthname = (year > 0 ? JEWISH_MONTH_NAME(year)[month] : "");
|
||||
break;
|
||||
case CAL_MONTH_FRENCH: /* french month */
|
||||
SdnToFrench(julday, &year, &month, &day);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Bug #67976 (cal_days_month() fails for final month of the French calendar)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('calendar')) die('skip ext/calendar required');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(cal_days_in_month(CAL_FRENCH, 13, 14));
|
||||
?>
|
||||
--EXPECT--
|
||||
int(5)
|
||||
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
Bug #71894 (AddressSanitizer: global-buffer-overflow in zif_cal_from_jd)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('calendar')) die('skip ext/calendar required');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(cal_from_jd(347997, CAL_JEWISH));
|
||||
var_dump(jdmonthname(347997,CAL_MONTH_JEWISH));?>
|
||||
--EXPECT--
|
||||
array(9) {
|
||||
["date"]=>
|
||||
string(5) "0/0/0"
|
||||
["month"]=>
|
||||
int(0)
|
||||
["day"]=>
|
||||
int(0)
|
||||
["year"]=>
|
||||
int(0)
|
||||
["dow"]=>
|
||||
NULL
|
||||
["abbrevdayname"]=>
|
||||
string(0) ""
|
||||
["dayname"]=>
|
||||
string(0) ""
|
||||
["abbrevmonth"]=>
|
||||
string(0) ""
|
||||
["monthname"]=>
|
||||
string(0) ""
|
||||
}
|
||||
string(0) ""
|
||||
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
jdtogregorian(): test overflow
|
||||
--CREDITS--
|
||||
neweracracker@gmail.com
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('calendar')) die('skip ext/calendar required');
|
||||
if (PHP_INT_SIZE != 4) die('skip this test is for 32bit platforms only');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
for ($i=536838860; $i<536838870; $i++) {
|
||||
echo $i, ':', jdtogregorian($i), PHP_EOL;
|
||||
}
|
||||
echo 'DONE', PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
536838860:10/11/1465102
|
||||
536838861:10/12/1465102
|
||||
536838862:10/13/1465102
|
||||
536838863:10/14/1465102
|
||||
536838864:10/15/1465102
|
||||
536838865:10/16/1465102
|
||||
536838866:10/17/1465102
|
||||
536838867:0/0/0
|
||||
536838868:0/0/0
|
||||
536838869:0/0/0
|
||||
DONE
|
||||
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
jdtojewish(): test overflow
|
||||
--CREDITS--
|
||||
neweracracker@gmail.com
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('calendar')) die('skip ext/calendar required');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
for ($i=324542840; $i<324542850; $i++) {
|
||||
echo $i, ':', jdtojewish($i), PHP_EOL;
|
||||
}
|
||||
echo 'DONE', PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
324542840:12/7/887605
|
||||
324542841:12/8/887605
|
||||
324542842:12/9/887605
|
||||
324542843:12/10/887605
|
||||
324542844:12/11/887605
|
||||
324542845:12/12/887605
|
||||
324542846:12/13/887605
|
||||
324542847:0/0/0
|
||||
324542848:0/0/0
|
||||
324542849:0/0/0
|
||||
DONE
|
||||
@@ -137,7 +137,10 @@ ZEND_METHOD(CURLFile, setPostFilename)
|
||||
Unserialization handler */
|
||||
ZEND_METHOD(CURLFile, __wakeup)
|
||||
{
|
||||
zend_update_property_string(curl_CURLFile_class, getThis(), "name", sizeof("name")-1, "" TSRMLS_CC);
|
||||
zval *_this = getThis();
|
||||
|
||||
zend_unset_property(curl_CURLFile_class, _this, "name", sizeof("name")-1 TSRMLS_CC);
|
||||
zend_update_property_string(curl_CURLFile_class, _this, "name", sizeof("name")-1, "" TSRMLS_CC);
|
||||
zend_throw_exception(NULL, "Unserialization of CURLFile instances is not allowed", 0 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
+23
-50
@@ -1833,38 +1833,6 @@ static void alloc_curl_handle(php_curl **ch)
|
||||
/* }}} */
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
|
||||
/* {{{ split_certinfo
|
||||
*/
|
||||
static void split_certinfo(char *string, zval *hash)
|
||||
{
|
||||
char *org = estrdup(string);
|
||||
char *s = org;
|
||||
char *split;
|
||||
|
||||
if(org) {
|
||||
do {
|
||||
char *key;
|
||||
char *val;
|
||||
char *tmp;
|
||||
|
||||
split = strstr(s, "; ");
|
||||
if(split)
|
||||
*split = '\0';
|
||||
|
||||
key = s;
|
||||
tmp = memchr(key, '=', 64);
|
||||
if(tmp) {
|
||||
*tmp = '\0';
|
||||
val = tmp+1;
|
||||
add_assoc_string(hash, key, val, 1);
|
||||
}
|
||||
s = split+2;
|
||||
} while(split);
|
||||
efree(org);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ create_certinfo
|
||||
*/
|
||||
static void create_certinfo(struct curl_certinfo *ci, zval *listcode TSRMLS_DC)
|
||||
@@ -1883,22 +1851,13 @@ static void create_certinfo(struct curl_certinfo *ci, zval *listcode TSRMLS_DC)
|
||||
int len;
|
||||
char s[64];
|
||||
char *tmp;
|
||||
strncpy(s, slist->data, 64);
|
||||
tmp = memchr(s, ':', 64);
|
||||
strncpy(s, slist->data, sizeof(s));
|
||||
s[sizeof(s)-1] = '\0';
|
||||
tmp = memchr(s, ':', sizeof(s));
|
||||
if(tmp) {
|
||||
*tmp = '\0';
|
||||
len = strlen(s);
|
||||
if(!strcmp(s, "Subject") || !strcmp(s, "Issuer")) {
|
||||
zval *hash;
|
||||
|
||||
MAKE_STD_ZVAL(hash);
|
||||
array_init(hash);
|
||||
|
||||
split_certinfo(&slist->data[len+1], hash);
|
||||
add_assoc_zval(certhash, s, hash);
|
||||
} else {
|
||||
add_assoc_string(certhash, s, &slist->data[len+1], 1);
|
||||
}
|
||||
add_assoc_string(certhash, s, &slist->data[len+1], 1);
|
||||
} else {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not extract hash key from certificate info");
|
||||
}
|
||||
@@ -1925,7 +1884,9 @@ static void _php_curl_set_default_options(php_curl *ch)
|
||||
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
|
||||
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header);
|
||||
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
|
||||
#if !defined(ZTS)
|
||||
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
|
||||
#endif
|
||||
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
|
||||
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
|
||||
|
||||
@@ -2263,7 +2224,14 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue TSRMLS_DC)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
# if defined(ZTS)
|
||||
if (option == CURLOPT_DNS_USE_GLOBAL_CACHE) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled");
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue));
|
||||
|
||||
break;
|
||||
case CURLOPT_SAFE_UPLOAD:
|
||||
convert_to_long_ex(zvalue);
|
||||
@@ -2547,12 +2515,13 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue TSRMLS_DC)
|
||||
}
|
||||
}
|
||||
|
||||
if (Z_REFCOUNT_P(ch->clone) <= 1) {
|
||||
zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NULL);
|
||||
} else {
|
||||
zend_hash_next_index_insert(ch->to_free->slist, &slist, sizeof(struct curl_slist *), NULL);
|
||||
if (slist) {
|
||||
if (Z_REFCOUNT_P(ch->clone) <= 1) {
|
||||
zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NULL);
|
||||
} else {
|
||||
zend_hash_next_index_insert(ch->to_free->slist, &slist, sizeof(struct curl_slist *), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
error = curl_easy_setopt(ch->cp, option, slist);
|
||||
|
||||
break;
|
||||
@@ -3510,6 +3479,10 @@ PHP_FUNCTION(curl_escape)
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl);
|
||||
|
||||
if ((res = curl_easy_escape(ch->cp, str, str_len))) {
|
||||
if (strlen(res) > INT_MAX) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Escaped string is too long, maximum is %d", INT_MAX);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
RETVAL_STRING(res, 1);
|
||||
curl_free(res);
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
--TEST--
|
||||
Bug #71144 (Sementation fault when using cURL with ZTS)
|
||||
--SKIPIF--
|
||||
<?php include 'skipif.inc'; ?>
|
||||
<?php if (!PHP_ZTS) { print "skip only for zts build"; } ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$ch = curl_init();
|
||||
var_dump(curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, 1));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: curl_setopt(): CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled in %sbug71144.php on line %d
|
||||
bool(false)
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Bug #73147: Use After Free in PHP7 unserialize()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("curl")) {
|
||||
exit("skip curl extension not loaded");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$poc = 'a:1:{i:0;O:8:"CURLFile":1:{s:4:"name";R:1;}}';
|
||||
try {
|
||||
var_dump(unserialize($poc));
|
||||
} catch(Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Unserialization of CURLFile instances is not allowed
|
||||
+126
-1680
File diff suppressed because it is too large.
Load diff
@@ -394,8 +394,12 @@ static timelib_sll timelib_meridian(char **ptr, timelib_sll h)
|
||||
}
|
||||
++*ptr;
|
||||
if (**ptr == '.') {
|
||||
*ptr += 3;
|
||||
} else {
|
||||
++*ptr;
|
||||
}
|
||||
if (**ptr == 'M' || **ptr == 'm') {
|
||||
++*ptr;
|
||||
}
|
||||
if (**ptr == '.') {
|
||||
++*ptr;
|
||||
}
|
||||
return retval;
|
||||
|
||||
+28
-28
@@ -310,33 +310,33 @@ void timelib_dump_rel_time(timelib_rel_time *d)
|
||||
|
||||
timelib_long timelib_parse_tz_cor(char **ptr)
|
||||
{
|
||||
char *begin = *ptr, *end;
|
||||
timelib_long tmp;
|
||||
char *begin = *ptr, *end;
|
||||
timelib_long tmp;
|
||||
|
||||
while (isdigit(**ptr) || **ptr == ':') {
|
||||
++*ptr;
|
||||
}
|
||||
end = *ptr;
|
||||
switch (end - begin) {
|
||||
case 1:
|
||||
case 2:
|
||||
return HOUR(strtol(begin, NULL, 10));
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
if (begin[1] == ':') {
|
||||
tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
|
||||
return tmp;
|
||||
} else if (begin[2] == ':') {
|
||||
tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
|
||||
return tmp;
|
||||
} else {
|
||||
tmp = strtol(begin, NULL, 10);
|
||||
return HOUR(tmp / 100) + tmp % 100;
|
||||
}
|
||||
case 5:
|
||||
tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
|
||||
return tmp;
|
||||
}
|
||||
return 0;
|
||||
while (isdigit(**ptr) || **ptr == ':') {
|
||||
++*ptr;
|
||||
}
|
||||
end = *ptr;
|
||||
switch (end - begin) {
|
||||
case 1: /* H */
|
||||
case 2: /* HH */
|
||||
return HOUR(strtol(begin, NULL, 10));
|
||||
break;
|
||||
case 3: /* H:M */
|
||||
case 4: /* H:MM, HH:M, HHMM */
|
||||
if (begin[1] == ':') {
|
||||
tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
|
||||
return tmp;
|
||||
} else if (begin[2] == ':') {
|
||||
tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
|
||||
return tmp;
|
||||
} else {
|
||||
tmp = strtol(begin, NULL, 10);
|
||||
return HOUR(tmp / 100) + tmp % 100;
|
||||
}
|
||||
case 5: /* HH:MM */
|
||||
tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
|
||||
return tmp;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -38,8 +38,8 @@
|
||||
# define timelib_free free
|
||||
#endif
|
||||
|
||||
#define TIMELIB_VERSION 201502
|
||||
#define TIMELIB_ASCII_VERSION "2015.02"
|
||||
#define TIMELIB_VERSION 201602
|
||||
#define TIMELIB_ASCII_VERSION "2016.02"
|
||||
|
||||
#define TIMELIB_NONE 0x00
|
||||
#define TIMELIB_OVERRIDE_TIME 0x01
|
||||
|
||||
+3415
-3172
File diff suppressed because it is too large.
Load diff
@@ -152,9 +152,17 @@ static void do_adjust_for_weekday(timelib_time* time)
|
||||
current_dow = timelib_day_of_week(time->y, time->m, time->d);
|
||||
if (time->relative.weekday_behavior == 2)
|
||||
{
|
||||
if (time->relative.weekday == 0) {
|
||||
/* To make "this week" work, where the current DOW is a "sunday" */
|
||||
if (current_dow == 0 && time->relative.weekday != 0) {
|
||||
time->relative.weekday = -6;
|
||||
}
|
||||
|
||||
/* To make "sunday this week" work, where the current DOW is not a
|
||||
* "sunday" */
|
||||
if (time->relative.weekday == 0 && current_dow != 0) {
|
||||
time->relative.weekday = 7;
|
||||
}
|
||||
|
||||
time->d -= current_dow;
|
||||
time->d += time->relative.weekday;
|
||||
return;
|
||||
|
||||
+3
-2
@@ -2059,6 +2059,7 @@ static void date_register_classes(TSRMLS_D)
|
||||
date_object_handlers_immutable.clone_obj = date_object_clone_date;
|
||||
date_object_handlers_immutable.compare_objects = date_object_compare_date;
|
||||
date_object_handlers_immutable.get_properties = date_object_get_properties;
|
||||
date_object_handlers_immutable.get_gc = date_object_get_gc;
|
||||
zend_class_implements(date_ce_immutable TSRMLS_CC, 1, date_ce_interface);
|
||||
|
||||
INIT_CLASS_ENTRY(ce_timezone, "DateTimeZone", date_funcs_timezone);
|
||||
@@ -2225,7 +2226,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
|
||||
|
||||
props = zend_std_get_properties(object TSRMLS_CC);
|
||||
|
||||
if (!dateobj->time || GC_G(gc_active)) {
|
||||
if (!dateobj->time) {
|
||||
return props;
|
||||
}
|
||||
|
||||
@@ -4941,7 +4942,7 @@ static HashTable *date_object_get_properties_period(zval *object TSRMLS_DC)
|
||||
|
||||
props = zend_std_get_properties(object TSRMLS_CC);
|
||||
|
||||
if (!period_obj->start || GC_G(gc_active)) {
|
||||
if (!period_obj->start) {
|
||||
return props;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ result = Monday 1983-04-18 01:00:00 CEST
|
||||
wanted = Monday 00:00:00
|
||||
|
||||
Asia/Yerevan
|
||||
ts = Monday 2037-10-19 17:17:17 AMT
|
||||
result = Monday 2037-10-26 00:00:00 AMT
|
||||
ts = Monday 2037-10-19 17:17:17 +04
|
||||
result = Monday 2037-10-26 00:00:00 +04
|
||||
wanted = Monday 00:00:00
|
||||
|
||||
America/Curacao
|
||||
@@ -115,8 +115,8 @@ result = Monday 1971-04-05 00:00:00 AST
|
||||
wanted = Monday 00:00:00
|
||||
|
||||
Asia/Baku
|
||||
ts = Friday 1971-01-01 17:17:17 BAKT
|
||||
result = Monday 1971-01-04 00:00:00 BAKT
|
||||
ts = Friday 1971-01-01 17:17:17 +04
|
||||
result = Monday 1971-01-04 00:00:00 +04
|
||||
wanted = Monday 00:00:00
|
||||
|
||||
Europe/Sarajevo
|
||||
@@ -165,6 +165,6 @@ result = Monday 1980-04-07 00:00:00 CEST
|
||||
wanted = Monday 00:00:00
|
||||
|
||||
Asia/Baku
|
||||
ts = Monday 1995-12-25 17:17:17 AZT
|
||||
result = Monday 1996-01-01 00:00:00 AZT
|
||||
ts = Monday 1995-12-25 17:17:17 +04
|
||||
result = Monday 1996-01-01 00:00:00 +04
|
||||
wanted = Monday 00:00:00
|
||||
@@ -49,9 +49,9 @@ print "TZ=Asia/Baku - wrong day.\n";
|
||||
date_default_timezone_set("Asia/Baku");
|
||||
$tStamp = mktime (17, 17, 17, 1, 8299, 1970);
|
||||
print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n";
|
||||
$strtotime_tstamp = strtotime("next Sunday", $tStamp);
|
||||
$strtotime_tstamp = strtotime("second Monday", $tStamp);
|
||||
print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n";
|
||||
print "wanted=Sunday 00:00:00\n\n";
|
||||
print "wanted=Monday 00:00:00\n\n";
|
||||
|
||||
print "TZ=America/Noronha - wrong day.\n";
|
||||
date_default_timezone_set("America/Noronha");
|
||||
@@ -226,9 +226,9 @@ result=Thursday 1980-04-10 00:00:00 CEST 1
|
||||
wanted=Thursday 00:00:00
|
||||
|
||||
TZ=Asia/Baku - wrong day.
|
||||
tStamp=Sunday 1992-09-20 17:17:17 AZST 1
|
||||
result=Sunday 1992-09-27 00:00:00 AZT 0
|
||||
wanted=Sunday 00:00:00
|
||||
tStamp=Sunday 1992-09-20 17:17:17 +04 1
|
||||
result=Monday 1992-09-28 00:00:00 +04 0
|
||||
wanted=Monday 00:00:00
|
||||
|
||||
TZ=America/Noronha - wrong day.
|
||||
tStamp=Friday 1999-10-01 17:17:17 FNT 0
|
||||
|
||||
@@ -28,6 +28,6 @@ result=Monday 1990-10-22 00:00:00 WART 0
|
||||
wanted=Monday 00:00:00
|
||||
|
||||
TZ=Asia/Tbilisi - Is it OK for this to be 2 AM?
|
||||
tStamp=Sunday 2005-03-20 17:17:17 GET 0
|
||||
result=Sunday 2005-03-27 00:00:00 GET 0
|
||||
tStamp=Sunday 2005-03-20 17:17:17 +03 0
|
||||
result=Sunday 2005-03-27 00:00:00 +03 0
|
||||
wanted=Sunday 00:00:00
|
||||
@@ -0,0 +1,41 @@
|
||||
--TEST--
|
||||
Bug #63740 (strtotime seems to use both sunday and monday as start of week)
|
||||
--FILE--
|
||||
<?php
|
||||
$dates = [
|
||||
'2015-07-04',
|
||||
'2015-07-05',
|
||||
'2015-07-06',
|
||||
'2015-07-07',
|
||||
'2015-07-08',
|
||||
'2015-07-09',
|
||||
'2015-07-10',
|
||||
'2015-07-11',
|
||||
'2015-07-12',
|
||||
'2015-07-13',
|
||||
'2015-07-14',
|
||||
];
|
||||
|
||||
foreach ( $dates as $date )
|
||||
{
|
||||
$dt = new DateTimeImmutable( "$date 00:00 UTC" );
|
||||
|
||||
echo $dt->format( "D Y-m-d H:i" ), " → ";
|
||||
|
||||
$dtn = $dt->modify( "this week" );
|
||||
|
||||
echo $dtn->format( "D Y-m-d H:i" ), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Sat 2015-07-04 00:00 → Mon 2015-06-29 00:00
|
||||
Sun 2015-07-05 00:00 → Mon 2015-06-29 00:00
|
||||
Mon 2015-07-06 00:00 → Mon 2015-07-06 00:00
|
||||
Tue 2015-07-07 00:00 → Mon 2015-07-06 00:00
|
||||
Wed 2015-07-08 00:00 → Mon 2015-07-06 00:00
|
||||
Thu 2015-07-09 00:00 → Mon 2015-07-06 00:00
|
||||
Fri 2015-07-10 00:00 → Mon 2015-07-06 00:00
|
||||
Sat 2015-07-11 00:00 → Mon 2015-07-06 00:00
|
||||
Sun 2015-07-12 00:00 → Mon 2015-07-06 00:00
|
||||
Mon 2015-07-13 00:00 → Mon 2015-07-13 00:00
|
||||
Tue 2015-07-14 00:00 → Mon 2015-07-13 00:00
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #66836 (DateTime::createFromFormat 'U' with pre 1970 dates fails parsing)
|
||||
--INI--
|
||||
date.timezone=Europe/Berlin
|
||||
--FILE--
|
||||
<?php
|
||||
foreach (['-1', '-86400', '-1000000'] as $timestamp) {
|
||||
$dt = DateTime::createFromFormat('U', $timestamp);
|
||||
var_dump($dt->format('U') === $timestamp);
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
@@ -250,6 +250,7 @@ val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC) {
|
||||
if (skip == -1 && dba->next.key.group && dba->next.key.name && !inifile_key_cmp(&dba->next.key, key TSRMLS_CC)) {
|
||||
/* we got position already from last fetch */
|
||||
php_stream_seek(dba->fp, dba->next.pos, SEEK_SET);
|
||||
ln.key.group = estrdup(dba->next.key.group);
|
||||
} else {
|
||||
/* specific instance or not same key -> restart search */
|
||||
/* the slow way: restart and seacrch */
|
||||
@@ -402,7 +403,7 @@ static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifi
|
||||
return FAILURE;
|
||||
}
|
||||
php_stream_seek(dba->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream_ex(dba->fp, fp, pos_end - pos_start, NULL)) {
|
||||
if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp, pos_end - pos_start, NULL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy group [%zu - %zu] to temporary stream", pos_start, pos_end);
|
||||
return FAILURE;
|
||||
}
|
||||
@@ -427,7 +428,7 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRML
|
||||
pos_curr = php_stream_tell(from->fp);
|
||||
if (pos_start != pos_next) {
|
||||
php_stream_seek(from->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
|
||||
if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start);
|
||||
ret = FAILURE;
|
||||
}
|
||||
@@ -446,7 +447,7 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRML
|
||||
}
|
||||
if (pos_start != pos_next) {
|
||||
php_stream_seek(from->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
|
||||
if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start);
|
||||
ret = FAILURE;
|
||||
}
|
||||
@@ -497,7 +498,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons
|
||||
php_stream_seek(dba->fp, 0, SEEK_END);
|
||||
if (pos_grp_next != (size_t)php_stream_tell(dba->fp)) {
|
||||
php_stream_seek(dba->fp, pos_grp_next, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream_ex(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL, NULL)) {
|
||||
if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL, NULL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy remainder to temporary stream");
|
||||
ret = FAILURE;
|
||||
}
|
||||
@@ -538,7 +539,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons
|
||||
if (fp_tmp && php_stream_tell(fp_tmp)) {
|
||||
php_stream_seek(fp_tmp, 0, SEEK_SET);
|
||||
php_stream_seek(dba->fp, 0, SEEK_END);
|
||||
if (!php_stream_copy_to_stream_ex(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL, NULL)) {
|
||||
if (SUCCESS != php_stream_copy_to_stream_ex(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL, NULL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Could not copy from temporary stream - ini file truncated");
|
||||
ret = FAILURE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
--TEST--
|
||||
Bug #70825 (Cannot fetch multiple values with group in ini file)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('dba')) die('skip dba extension not available');
|
||||
if (!in_array('inifile', dba_handlers())) die('skip inifile handler not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70825.ini';
|
||||
|
||||
$db = dba_open($filename, 'n', 'inifile');
|
||||
dba_insert('foo', 23, $db);
|
||||
dba_insert('foo', 42, $db);
|
||||
dba_insert('foo', 1337, $db);
|
||||
var_dump(dba_fetch('foo', -1, $db));
|
||||
var_dump(dba_fetch('foo', -1, $db));
|
||||
var_dump(dba_fetch('foo', -1, $db));
|
||||
dba_close($db);
|
||||
unlink($filename);
|
||||
|
||||
$db = dba_open($filename, 'n', 'inifile');
|
||||
dba_insert(['foo', 'bar'], 23, $db);
|
||||
dba_insert(['foo', 'bar'], 42, $db);
|
||||
dba_insert(['foo', 'bar'], 1337, $db);
|
||||
var_dump(dba_fetch(['foo', 'bar'], -1, $db));
|
||||
var_dump(dba_fetch(['foo', 'bar'], -1, $db));
|
||||
var_dump(dba_fetch(['foo', 'bar'], -1, $db));
|
||||
dba_close($db);
|
||||
unlink($filename);
|
||||
|
||||
$db = dba_open($filename, 'n', 'inifile');
|
||||
dba_insert('[foo]bar', 23, $db);
|
||||
dba_insert('[foo]bar', 42, $db);
|
||||
dba_insert('[foo]bar', 1337, $db);
|
||||
var_dump(dba_fetch('[foo]bar', -1, $db));
|
||||
var_dump(dba_fetch('[foo]bar', -1, $db));
|
||||
var_dump(dba_fetch('[foo]bar', -1, $db));
|
||||
dba_close($db);
|
||||
unlink($filename);
|
||||
|
||||
$db = dba_open($filename, 'n', 'inifile');
|
||||
dba_insert('[foo]bar', 23, $db);
|
||||
dba_insert('[foo]bar', 42, $db);
|
||||
dba_insert('[foo]bar', 1337, $db);
|
||||
var_dump(dba_fetch('[foo]bar', 0, $db));
|
||||
var_dump(dba_fetch('[foo]bar', 1, $db));
|
||||
var_dump(dba_fetch('[foo]bar', 2, $db));
|
||||
dba_close($db);
|
||||
unlink($filename);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(2) "23"
|
||||
string(2) "42"
|
||||
string(4) "1337"
|
||||
string(2) "23"
|
||||
string(2) "42"
|
||||
string(4) "1337"
|
||||
string(2) "23"
|
||||
string(2) "42"
|
||||
string(4) "1337"
|
||||
string(2) "23"
|
||||
string(2) "42"
|
||||
string(4) "1337"
|
||||
==DONE==
|
||||
--CLEAN--
|
||||
<?php
|
||||
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70825.ini';
|
||||
unlink($filename);
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Bug #71514 (Bad dba_replace condition because of wrong API usage)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('dba')) die('skip dba extension not available');
|
||||
if (!in_array('inifile', dba_handlers())) die('skip inifile handler not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug71514.ini';
|
||||
|
||||
$db = dba_open($filename, 'c', 'inifile');
|
||||
|
||||
dba_insert('foo', 'value1', $db);
|
||||
dba_replace('foo', 'value2', $db);
|
||||
var_dump(dba_fetch('foo', $db));
|
||||
|
||||
dba_close($db);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(6) "value2"
|
||||
==DONE==
|
||||
--CLEAN--
|
||||
<?php
|
||||
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug71514.ini';
|
||||
unlink($filename);
|
||||
?>
|
||||
@@ -40,7 +40,7 @@ do {
|
||||
}
|
||||
if ($handler != 'cdb') {
|
||||
$db_writer = dba_open($db_filename, 'c'.$lock_flag, $handler);
|
||||
if (($dba_reader = @dba_open($db_filename, 'r'.$lock_flag.($lock_flag ? 't' : ''), $handler))===false) {
|
||||
if (($dba_reader = @dba_open($db_filename, 'r'.$lock_flag.'t', $handler))===false) {
|
||||
echo "Read during write: not allowed\n";
|
||||
} else {
|
||||
echo "Read during write: allowed\n";
|
||||
|
||||
+2
-2
@@ -1792,7 +1792,7 @@ PHP_FUNCTION(dom_document_savexml)
|
||||
if (options & LIBXML_SAVE_NOEMPTYTAG) {
|
||||
xmlSaveNoEmptyTags = saveempty;
|
||||
}
|
||||
if (!size) {
|
||||
if (!size || !mem) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
RETVAL_STRINGL(mem, size, 1);
|
||||
@@ -2327,7 +2327,7 @@ PHP_FUNCTION(dom_document_save_html)
|
||||
#else
|
||||
htmlDocDumpMemory(docp, &mem, &size);
|
||||
#endif
|
||||
if (!size) {
|
||||
if (!size || !mem) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
RETVAL_STRINGL((const char*) mem, size, 1);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Bug #66502 (DOM document dangling reference)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('dom')) die('skip requires ext/dom');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$element = $dom->appendChild(new DOMElement('root'));
|
||||
$comment = new DOMComment("Comment 0");
|
||||
$comment = $element->appendChild($comment);
|
||||
|
||||
$comment->__construct("Comment 1");
|
||||
$comment->__construct("Comment 2");
|
||||
$comment->__construct("Comment 3");
|
||||
echo 'DONE', PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
DONE
|
||||
+27
-22
@@ -14,7 +14,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Rasmus Lerdorf <rasmus@php.net> |
|
||||
| Jim Winstead <jimw@php.net> |
|
||||
| Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
|
||||
| Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
/* $Id$ */
|
||||
@@ -29,7 +29,7 @@
|
||||
/* {{{ arginfo */
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_ereg, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(1, registers) /* ARRAY_INFO(1, registers, 1) */
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
@@ -41,8 +41,8 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_split, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(0, limit)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(0, limit)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_sql_regcase, 0)
|
||||
@@ -204,7 +204,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags TSRMLS_DC
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void _free_ereg_cache(reg_cache *rc)
|
||||
static void _free_ereg_cache(reg_cache *rc)
|
||||
{
|
||||
regfree(&rc->preg);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
if (icase) {
|
||||
copts |= REG_ICASE;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 2) {
|
||||
copts |= REG_NOSUB;
|
||||
}
|
||||
@@ -337,7 +337,7 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
|
||||
/* allocate storage for (sub-)expression-matches */
|
||||
subs = (regmatch_t *)ecalloc(sizeof(regmatch_t),re.re_nsub+1);
|
||||
|
||||
|
||||
/* actually execute the regular expression */
|
||||
err = regexec(&re, string, re.re_nsub+1, subs, 0);
|
||||
if (err && err != REG_NOMATCH) {
|
||||
@@ -409,8 +409,8 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
*nbuf, /* nbuf is used when we grow the buffer */
|
||||
*walkbuf; /* used to walk buf when replacing backrefs */
|
||||
const char *walk; /* used to walk replacement string for backrefs */
|
||||
int buf_len;
|
||||
int pos, tmp, string_len, new_l;
|
||||
size_t buf_len, new_l;
|
||||
int pos, tmp, string_len;
|
||||
int err, copts = 0;
|
||||
|
||||
string_len = strlen(string);
|
||||
@@ -434,8 +434,8 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
|
||||
/* start with a buffer that is twice the size of the stringo
|
||||
we're doing replacements in */
|
||||
buf = safe_emalloc(string_len, 2, 1);
|
||||
buf_len = 2 * string_len + 1;
|
||||
buf = safe_emalloc(buf_len, sizeof(char), 0);
|
||||
|
||||
err = pos = 0;
|
||||
buf[0] = '\0';
|
||||
@@ -472,8 +472,8 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
}
|
||||
}
|
||||
if (new_l + 1 > buf_len) {
|
||||
nbuf = safe_emalloc(new_l + 1, 2, buf_len);
|
||||
buf_len = 1 + buf_len + 2 * new_l;
|
||||
nbuf = emalloc(buf_len);
|
||||
strncpy(nbuf, buf, buf_len - 1);
|
||||
nbuf[buf_len - 1] = '\0';
|
||||
efree(buf);
|
||||
@@ -491,7 +491,7 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1
|
||||
/* this next case shouldn't happen. it does. */
|
||||
&& subs[walk[1] - '0'].rm_so <= subs[walk[1] - '0'].rm_eo) {
|
||||
|
||||
|
||||
tmp = subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so;
|
||||
memcpy (walkbuf, &string[pos + subs[walk[1] - '0'].rm_so], tmp);
|
||||
walkbuf += tmp;
|
||||
@@ -510,8 +510,8 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
}
|
||||
new_l = strlen (buf) + 1;
|
||||
if (new_l + 1 > buf_len) {
|
||||
nbuf = safe_emalloc(new_l + 1, 2, buf_len);
|
||||
buf_len = 1 + buf_len + 2 * new_l;
|
||||
nbuf = safe_emalloc(buf_len, sizeof(char), 0);
|
||||
strncpy(nbuf, buf, buf_len-1);
|
||||
efree(buf);
|
||||
buf = nbuf;
|
||||
@@ -526,7 +526,7 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
new_l = strlen(buf) + strlen(&string[pos]);
|
||||
if (new_l + 1 > buf_len) {
|
||||
buf_len = new_l + 1; /* now we know exactly how long it is */
|
||||
nbuf = safe_emalloc(buf_len, sizeof(char), 0);
|
||||
nbuf = safe_emalloc(new_l, 1, 1);
|
||||
strncpy(nbuf, buf, buf_len-1);
|
||||
efree(buf);
|
||||
buf = nbuf;
|
||||
@@ -556,7 +556,7 @@ static void php_do_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
char *replace;
|
||||
char *ret;
|
||||
int arg_string_len;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZs", &arg_pattern, &arg_replace, &arg_string, &arg_string_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
@@ -598,7 +598,7 @@ static void php_do_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
if (ret == (char *) -1) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
RETVAL_STRING(ret, 1);
|
||||
RETVAL_STRINGL_CHECK(ret, strlen(ret), 1);
|
||||
STR_FREE(ret);
|
||||
}
|
||||
|
||||
@@ -664,9 +664,9 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
} else if (subs[0].rm_so == 0 && subs[0].rm_eo == 0) {
|
||||
/* No more matches */
|
||||
regfree(&re);
|
||||
|
||||
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Regular Expression");
|
||||
|
||||
|
||||
zend_hash_destroy(Z_ARRVAL_P(return_value));
|
||||
efree(Z_ARRVAL_P(return_value));
|
||||
RETURN_FALSE;
|
||||
@@ -675,7 +675,7 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
|
||||
/* make a copy of the substring */
|
||||
size = subs[0].rm_so;
|
||||
|
||||
|
||||
/* add it to the array */
|
||||
add_next_index_stringl(return_value, strp, size, 1);
|
||||
|
||||
@@ -701,7 +701,7 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
|
||||
/* otherwise we just have one last element to add to the array */
|
||||
size = endp - strp;
|
||||
|
||||
|
||||
add_next_index_stringl(return_value, strp, size, 1);
|
||||
|
||||
regfree(&re);
|
||||
@@ -738,11 +738,16 @@ PHP_EREG_API PHP_FUNCTION(sql_regcase)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tmp = safe_emalloc(string_len, 4, 1);
|
||||
|
||||
|
||||
for (i = j = 0; i < string_len; i++) {
|
||||
c = (unsigned char) string[i];
|
||||
if ( j >= INT_MAX - 1 || (isalpha(c) && j >= INT_MAX - 4)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "String too long, max length is %d", INT_MAX);
|
||||
efree(tmp);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (isalpha(c)) {
|
||||
tmp[j++] = '[';
|
||||
tmp[j++] = toupper(c);
|
||||
|
||||
+69
-17
@@ -1709,6 +1709,10 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c
|
||||
break;
|
||||
case TAG_FMT_UNDEFINED:
|
||||
if (value) {
|
||||
if (tag == TAG_MAKER_NOTE) {
|
||||
length = MIN(length, strlen(value));
|
||||
}
|
||||
|
||||
/* do not recompute length here */
|
||||
info_value->s = estrndup(value, length);
|
||||
info_data->length = length;
|
||||
@@ -2613,6 +2617,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
|
||||
*pszEncoding = NULL;
|
||||
/* Copy the comment */
|
||||
if (ByteCount>=8) {
|
||||
const zend_encoding *from, *to;
|
||||
if (!memcmp(szValuePtr, "UNICODE\0", 8)) {
|
||||
*pszEncoding = estrdup((const char*)szValuePtr);
|
||||
szValuePtr = szValuePtr+8;
|
||||
@@ -2633,14 +2638,16 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
|
||||
} else {
|
||||
decode = ImageInfo->decode_unicode_le;
|
||||
}
|
||||
to = zend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC);
|
||||
from = zend_multibyte_fetch_encoding(decode TSRMLS_CC);
|
||||
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
|
||||
if (zend_multibyte_encoding_converter(
|
||||
if (!to || !from || zend_multibyte_encoding_converter(
|
||||
(unsigned char**)pszInfoPtr,
|
||||
&len,
|
||||
(unsigned char*)szValuePtr,
|
||||
ByteCount,
|
||||
zend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC),
|
||||
zend_multibyte_fetch_encoding(decode TSRMLS_CC)
|
||||
to,
|
||||
from
|
||||
TSRMLS_CC) == (size_t)-1) {
|
||||
len = exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount);
|
||||
}
|
||||
@@ -2655,13 +2662,15 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
|
||||
szValuePtr = szValuePtr+8;
|
||||
ByteCount -= 8;
|
||||
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
|
||||
if (zend_multibyte_encoding_converter(
|
||||
to = zend_multibyte_fetch_encoding(ImageInfo->encode_jis TSRMLS_CC);
|
||||
from = zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_jis_be : ImageInfo->decode_jis_le TSRMLS_CC);
|
||||
if (!to || !from || zend_multibyte_encoding_converter(
|
||||
(unsigned char**)pszInfoPtr,
|
||||
&len,
|
||||
(unsigned char*)szValuePtr,
|
||||
ByteCount,
|
||||
zend_multibyte_fetch_encoding(ImageInfo->encode_jis TSRMLS_CC),
|
||||
zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_jis_be : ImageInfo->decode_jis_le TSRMLS_CC)
|
||||
to,
|
||||
from
|
||||
TSRMLS_CC) == (size_t)-1) {
|
||||
len = exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount);
|
||||
}
|
||||
@@ -2718,8 +2727,14 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
|
||||
char *dir_start;
|
||||
|
||||
for (i=0; i<=sizeof(maker_note_array)/sizeof(maker_note_type); i++) {
|
||||
if (i==sizeof(maker_note_array)/sizeof(maker_note_type))
|
||||
return FALSE;
|
||||
if (i==sizeof(maker_note_array)/sizeof(maker_note_type)) {
|
||||
#ifdef EXIF_DEBUG
|
||||
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "No maker note data found. Detected maker: %s (length = %d)", ImageInfo->make, strlen(ImageInfo->make));
|
||||
#endif
|
||||
/* unknown manufacturer, not an error, use it as a string */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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:"");*/
|
||||
@@ -2732,6 +2747,12 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
|
||||
break;
|
||||
}
|
||||
|
||||
if (maker_note->offset >= value_len) {
|
||||
/* Do not go past the value end */
|
||||
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short: 0x%04X offset 0x%04X", value_len, maker_note->offset);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dir_start = value_ptr + maker_note->offset;
|
||||
|
||||
#ifdef EXIF_DEBUG
|
||||
@@ -2760,10 +2781,19 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
|
||||
offset_base = value_ptr;
|
||||
break;
|
||||
case MN_OFFSET_GUESS:
|
||||
if (maker_note->offset + 10 + 4 >= value_len) {
|
||||
/* Can not read dir_start+10 since it's beyond value end */
|
||||
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short: 0x%04X", value_len);
|
||||
return FALSE;
|
||||
}
|
||||
offset_diff = 2 + NumDirEntries*12 + 4 - php_ifd_get32u(dir_start+10, ImageInfo->motorola_intel);
|
||||
#ifdef EXIF_DEBUG
|
||||
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Using automatic offset correction: 0x%04X", ((int)dir_start-(int)offset_base+maker_note->offset+displacement) + offset_diff);
|
||||
#endif
|
||||
if (offset_diff < 0 || offset_diff >= value_len ) {
|
||||
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data bad offset: 0x%04X length 0x%04X", offset_diff, value_len);
|
||||
return FALSE;
|
||||
}
|
||||
offset_base = value_ptr + offset_diff;
|
||||
break;
|
||||
default:
|
||||
@@ -2772,7 +2802,7 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
|
||||
}
|
||||
|
||||
if ((2+NumDirEntries*12) > value_len) {
|
||||
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: 2 + x%04X*12 = x%04X > x%04X", NumDirEntries, 2+NumDirEntries*12, value_len);
|
||||
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: 2 + 0x%04X*12 = 0x%04X > 0x%04X", NumDirEntries, 2+NumDirEntries*12, value_len);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -2878,11 +2908,11 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
|
||||
}
|
||||
|
||||
fpos = php_stream_tell(ImageInfo->infile);
|
||||
php_stream_seek(ImageInfo->infile, offset_val, SEEK_SET);
|
||||
php_stream_seek(ImageInfo->infile, displacement+offset_val, SEEK_SET);
|
||||
fgot = php_stream_tell(ImageInfo->infile);
|
||||
if (fgot!=offset_val) {
|
||||
if (fgot!=displacement+offset_val) {
|
||||
EFREE_IF(outside);
|
||||
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Wrong file pointer: 0x%08X != 0x%08X", fgot, offset_val);
|
||||
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Wrong file pointer: 0x%08X != 0x%08X", fgot, displacement+offset_val);
|
||||
return FALSE;
|
||||
}
|
||||
fgot = php_stream_read(ImageInfo->infile, value_ptr, byte_count);
|
||||
@@ -2955,7 +2985,7 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
|
||||
/* When there are any characters after the first NUL */
|
||||
ImageInfo->CopyrightPhotographer = estrdup(value_ptr);
|
||||
ImageInfo->CopyrightEditor = estrndup(value_ptr+length+1, byte_count-length-1);
|
||||
spprintf(&ImageInfo->Copyright, 0, "%s, %s", value_ptr, value_ptr+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 */
|
||||
@@ -3058,7 +3088,10 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
|
||||
break;
|
||||
|
||||
case TAG_MAKER_NOTE:
|
||||
exif_process_IFD_in_MAKERNOTE(ImageInfo, value_ptr, byte_count, offset_base, IFDlength, displacement TSRMLS_CC);
|
||||
if (!exif_process_IFD_in_MAKERNOTE(ImageInfo, value_ptr, byte_count, offset_base, IFDlength, displacement TSRMLS_CC)) {
|
||||
EFREE_IF(outside);
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case TAG_EXIF_IFD_POINTER:
|
||||
@@ -3124,6 +3157,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)) {
|
||||
@@ -3147,6 +3185,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 */
|
||||
@@ -3196,9 +3238,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;
|
||||
}
|
||||
@@ -3688,8 +3734,11 @@ static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offse
|
||||
fgot = php_stream_read(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size);
|
||||
if (fgot < ImageInfo->Thumbnail.size) {
|
||||
EXIF_ERRLOG_THUMBEOF(ImageInfo)
|
||||
efree(ImageInfo->Thumbnail.data);
|
||||
ImageInfo->Thumbnail.data = NULL;
|
||||
} else {
|
||||
exif_thumbnail_build(ImageInfo TSRMLS_CC);
|
||||
}
|
||||
exif_thumbnail_build(ImageInfo TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3722,8 +3771,11 @@ static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offse
|
||||
fgot = php_stream_read(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size);
|
||||
if (fgot < ImageInfo->Thumbnail.size) {
|
||||
EXIF_ERRLOG_THUMBEOF(ImageInfo)
|
||||
efree(ImageInfo->Thumbnail.data);
|
||||
ImageInfo->Thumbnail.data = NULL;
|
||||
} else {
|
||||
exif_thumbnail_build(ImageInfo TSRMLS_CC);
|
||||
}
|
||||
exif_thumbnail_build(ImageInfo TSRMLS_CC);
|
||||
}
|
||||
#ifdef EXIF_DEBUG
|
||||
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read next IFD (THUMBNAIL) done");
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 785 KiB |
@@ -0,0 +1,140 @@
|
||||
--TEST--
|
||||
Bug #50845 (exif_read_data() returns corrupted exif headers)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||
--FILE--
|
||||
<?php
|
||||
$infile = dirname(__FILE__).'/bug50845.jpg';
|
||||
var_dump(exif_read_data($infile));
|
||||
--EXPECTF--
|
||||
array(44) {
|
||||
["FileName"]=>
|
||||
string(12) "bug50845.jpg"
|
||||
["FileDateTime"]=>
|
||||
int(%d)
|
||||
["FileSize"]=>
|
||||
int(803603)
|
||||
["FileType"]=>
|
||||
int(2)
|
||||
["MimeType"]=>
|
||||
string(10) "image/jpeg"
|
||||
["SectionsFound"]=>
|
||||
string(30) "ANY_TAG, IFD0, THUMBNAIL, EXIF"
|
||||
["COMPUTED"]=>
|
||||
array(9) {
|
||||
["html"]=>
|
||||
string(26) "width="5472" height="3648""
|
||||
["Height"]=>
|
||||
int(3648)
|
||||
["Width"]=>
|
||||
int(5472)
|
||||
["IsColor"]=>
|
||||
int(1)
|
||||
["ByteOrderMotorola"]=>
|
||||
int(0)
|
||||
["ApertureFNumber"]=>
|
||||
string(5) "f/7.1"
|
||||
["Copyright"]=>
|
||||
string(13) "Public Domain"
|
||||
["Thumbnail.FileType"]=>
|
||||
int(2)
|
||||
["Thumbnail.MimeType"]=>
|
||||
string(10) "image/jpeg"
|
||||
}
|
||||
["ImageDescription"]=>
|
||||
string(295) "A U.S. Marine Corps MV-22 Osprey lands on the USS Whidbey Island (LSD-41), May 5, 2016. The vehicles were loaded to support a theater security cooperation event as a part of a MEU readiness exercise. (U.S. Marine Corps photo by Lance Cpl. Koby I. Saunders/22 Marine Expeditionary Unit/ Released)"
|
||||
["Make"]=>
|
||||
string(5) "Canon"
|
||||
["Model"]=>
|
||||
string(22) "Canon EOS-1D X Mark II"
|
||||
["Orientation"]=>
|
||||
int(1)
|
||||
["XResolution"]=>
|
||||
string(5) "240/1"
|
||||
["YResolution"]=>
|
||||
string(5) "240/1"
|
||||
["ResolutionUnit"]=>
|
||||
int(2)
|
||||
["Artist"]=>
|
||||
string(24) "Lance Cpl. Koby Saunders"
|
||||
["Copyright"]=>
|
||||
string(13) "Public Domain"
|
||||
["Exif_IFD_Pointer"]=>
|
||||
int(12572)
|
||||
["THUMBNAIL"]=>
|
||||
array(6) {
|
||||
["Compression"]=>
|
||||
int(6)
|
||||
["XResolution"]=>
|
||||
string(5) "240/1"
|
||||
["YResolution"]=>
|
||||
string(5) "240/1"
|
||||
["ResolutionUnit"]=>
|
||||
int(2)
|
||||
["JPEGInterchangeFormat"]=>
|
||||
int(860)
|
||||
["JPEGInterchangeFormatLength"]=>
|
||||
int(11204)
|
||||
}
|
||||
["ExposureTime"]=>
|
||||
string(5) "1/200"
|
||||
["FNumber"]=>
|
||||
string(5) "71/10"
|
||||
["ExposureProgram"]=>
|
||||
int(1)
|
||||
["ISOSpeedRatings"]=>
|
||||
int(100)
|
||||
["UndefinedTag:0x8830"]=>
|
||||
int(2)
|
||||
["UndefinedTag:0x8832"]=>
|
||||
int(100)
|
||||
["ExifVersion"]=>
|
||||
string(4) "0230"
|
||||
["ShutterSpeedValue"]=>
|
||||
string(15) "7643856/1000000"
|
||||
["ApertureValue"]=>
|
||||
string(15) "5655638/1000000"
|
||||
["ExposureBiasValue"]=>
|
||||
string(3) "0/1"
|
||||
["MaxApertureValue"]=>
|
||||
string(3) "4/1"
|
||||
["MeteringMode"]=>
|
||||
int(5)
|
||||
["Flash"]=>
|
||||
int(16)
|
||||
["FocalLength"]=>
|
||||
string(4) "24/1"
|
||||
["ColorSpace"]=>
|
||||
int(65535)
|
||||
["FocalPlaneXResolution"]=>
|
||||
string(12) "5472000/1438"
|
||||
["FocalPlaneYResolution"]=>
|
||||
string(11) "3648000/958"
|
||||
["FocalPlaneResolutionUnit"]=>
|
||||
int(2)
|
||||
["CustomRendered"]=>
|
||||
int(0)
|
||||
["ExposureMode"]=>
|
||||
int(1)
|
||||
["WhiteBalance"]=>
|
||||
int(0)
|
||||
["SceneCaptureType"]=>
|
||||
int(0)
|
||||
["UndefinedTag:0xA431"]=>
|
||||
string(12) "002099000358"
|
||||
["UndefinedTag:0xA432"]=>
|
||||
array(4) {
|
||||
[0]=>
|
||||
string(4) "24/1"
|
||||
[1]=>
|
||||
string(5) "105/1"
|
||||
[2]=>
|
||||
string(3) "0/0"
|
||||
[3]=>
|
||||
string(3) "0/0"
|
||||
}
|
||||
["UndefinedTag:0xA434"]=>
|
||||
string(22) "EF24-105mm f/4L IS USM"
|
||||
["UndefinedTag:0xA435"]=>
|
||||
string(10) "000044bc4c"
|
||||
}
|
||||
@@ -13,8 +13,4 @@ exif_read_data(__DIR__ . '/bug54002_2.jpeg');
|
||||
--EXPECTF--
|
||||
Warning: exif_read_data(bug54002_1.jpeg): Process tag(x0205=UndefinedTa): Illegal byte_count in %sbug54002.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug54002_1.jpeg): Process tag(xA000=FlashPixVer): Illegal pointer offset(%s) in %sbug54002.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug54002_2.jpeg): Process tag(x0205=UndefinedTa): Illegal byte_count in %sbug54002.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug54002_2.jpeg): Process tag(xA000=FlashPixVer): Illegal pointer offset(%s) in %sbug54002.php on line %d
|
||||
Warning: exif_read_data(bug54002_2.jpeg): Process tag(x0205=UndefinedTa): Illegal byte_count in %sbug54002.php on line %d
|
||||
@@ -10,7 +10,9 @@ echo "Test\n";
|
||||
var_dump(count(exif_read_data(__DIR__."/bug62523_2.jpg")));
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
Test
|
||||
int(76)
|
||||
|
||||
Warning: exif_read_data(bug62523_2.jpg): IFD data bad offset: 0xADB23672 length 0x0D94 in %s%ebug62523_2.php on line %d
|
||||
int(30)
|
||||
Done
|
||||
@@ -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%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Process tag(x8298=Copyright ): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Illegal IFD offset in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): File structure corrupted in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_1.jpg): Invalid JPEG file in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_2.jpg): Illegal IFD size in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_2.jpg): File structure corrupted in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_2.jpg): Invalid JPEG file in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Illegal IFD size in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): File structure corrupted in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_3.jpg): Invalid JPEG file in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_4.jpg): Invalid TIFF start (1) in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_4.jpg): File structure corrupted in %s%ebug72094.php on line %d
|
||||
|
||||
Warning: exif_read_data(bug72094_4.jpg): Invalid JPEG file in %s%ebug72094.php on line %d
|
||||
DONE
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
@@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Bug #72603 (Out of bound read in exif_process_IFD_in_MAKERNOTE)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(count(exif_read_data(dirname(__FILE__) . "/bug72603.jpeg")));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: exif_read_data(bug72603.jpeg): %s in %s%ebug72603.php on line %d
|
||||
int(%d)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
@@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Bug 72618 (NULL Pointer Dereference in exif_process_user_comment)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(count(exif_read_data(dirname(__FILE__) . "/bug72618.jpg")));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: exif_read_data(bug72618.jpg): %s in %s%ebug72618.php on line %d
|
||||
int(%d)
|
||||
@@ -0,0 +1,71 @@
|
||||
--TEST--
|
||||
Bug #72627 (Memory Leakage In exif_process_IFD_in_TIFF)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||
--FILE--
|
||||
<?php
|
||||
$exif = exif_read_data(__DIR__ . '/bug72627.tiff',0,0,true);
|
||||
var_dump($exif);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: exif_read_data(%s): Thumbnail goes IFD boundary or end of file reached in %sbug72627.php on line %d
|
||||
|
||||
Warning: exif_read_data(%s): Error in TIFF: filesize(x04E2) less than start of IFD dir(x829A0004) in %sbug72627.php on line %d
|
||||
|
||||
Warning: exif_read_data(%s): Thumbnail goes IFD boundary or end of file reached in %sbug72627.php on line %d
|
||||
array(11) {
|
||||
["FileName"]=>
|
||||
string(13) "bug72627.tiff"
|
||||
["FileDateTime"]=>
|
||||
int(%d)
|
||||
["FileSize"]=>
|
||||
int(1250)
|
||||
["FileType"]=>
|
||||
int(7)
|
||||
["MimeType"]=>
|
||||
string(10) "image/tiff"
|
||||
["SectionsFound"]=>
|
||||
string(30) "ANY_TAG, IFD0, THUMBNAIL, EXIF"
|
||||
["COMPUTED"]=>
|
||||
array(10) {
|
||||
["html"]=>
|
||||
string(24) "width="128" height="132""
|
||||
["Height"]=>
|
||||
int(132)
|
||||
["Width"]=>
|
||||
int(128)
|
||||
["IsColor"]=>
|
||||
int(0)
|
||||
["ByteOrderMotorola"]=>
|
||||
int(0)
|
||||
["ApertureFNumber"]=>
|
||||
string(5) "f/1.0"
|
||||
["Thumbnail.FileType"]=>
|
||||
int(2)
|
||||
["Thumbnail.MimeType"]=>
|
||||
string(10) "image/jpeg"
|
||||
["Thumbnail.Height"]=>
|
||||
int(132)
|
||||
["Thumbnail.Width"]=>
|
||||
int(128)
|
||||
}
|
||||
["XResolution"]=>
|
||||
string(21) "1414812756/1414812756"
|
||||
["THUMBNAIL"]=>
|
||||
array(5) {
|
||||
["ImageWidth"]=>
|
||||
int(128)
|
||||
["ImageLength"]=>
|
||||
int(132)
|
||||
["JPEGInterchangeFormat"]=>
|
||||
int(1280)
|
||||
["JPEGInterchangeFormatLength"]=>
|
||||
int(100)
|
||||
["THUMBNAIL"]=>
|
||||
NULL
|
||||
}
|
||||
["ExposureTime"]=>
|
||||
string(21) "1414812756/1414812756"
|
||||
["FNumber"]=>
|
||||
string(21) "1414812756/1414812756"
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Bug #69107 (finfo no longer detects PHP files)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('fileinfo')) die('skip fileinfo extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
|
||||
var_dump($finfo->buffer("<?php\nclass A{}"));
|
||||
var_dump($finfo->buffer("<?php class A{}"));
|
||||
var_dump($finfo->buffer("<?php\tclass A{}"));
|
||||
var_dump($finfo->buffer("<?php\n\rclass A{}"));
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
string(10) "text/x-php"
|
||||
string(10) "text/x-php"
|
||||
string(10) "text/x-php"
|
||||
string(10) "text/x-php"
|
||||
===DONE===
|
||||
+9
-2
@@ -380,8 +380,14 @@ static void php_zval_filter(zval **value, long filter, long flags, zval *options
|
||||
|
||||
ce = Z_OBJCE_PP(value);
|
||||
if (!ce->__tostring) {
|
||||
ZVAL_FALSE(*value);
|
||||
return;
|
||||
zval_dtor(*value);
|
||||
/* #67167: doesn't return null on failure for objects */
|
||||
if (flags & FILTER_NULL_ON_FAILURE) {
|
||||
ZVAL_NULL(*value);
|
||||
} else {
|
||||
ZVAL_FALSE(*value);
|
||||
}
|
||||
goto handle_default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,6 +396,7 @@ static void php_zval_filter(zval **value, long filter, long flags, zval *options
|
||||
|
||||
filter_func.function(*value, flags, options, charset TSRMLS_CC);
|
||||
|
||||
handle_default:
|
||||
if (
|
||||
options && (Z_TYPE_P(options) == IS_ARRAY || Z_TYPE_P(options) == IS_OBJECT) &&
|
||||
((flags & FILTER_NULL_ON_FAILURE && Z_TYPE_PP(value) == IS_NULL) ||
|
||||
|
||||
@@ -704,7 +704,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
|
||||
if (flags & FILTER_FLAG_NO_PRIV_RANGE) {
|
||||
if (
|
||||
(ip[0] == 10) ||
|
||||
(ip[0] == 172 && (ip[1] >= 16 && ip[1] <= 31)) ||
|
||||
(ip[0] == 172 && ip[1] >= 16 && ip[1] <= 31) ||
|
||||
(ip[0] == 192 && ip[1] == 168)
|
||||
) {
|
||||
RETURN_VALIDATION_FAILED
|
||||
@@ -714,11 +714,9 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
|
||||
if (flags & FILTER_FLAG_NO_RES_RANGE) {
|
||||
if (
|
||||
(ip[0] == 0) ||
|
||||
(ip[0] == 100 && (ip[1] >= 64 && ip[1] <= 127)) ||
|
||||
(ip[0] == 169 && ip[1] == 254) ||
|
||||
(ip[0] == 192 && ip[1] == 0 && ip[2] == 2) ||
|
||||
(ip[0] == 127 && ip[1] == 0 && ip[2] == 0 && ip[3] == 1) ||
|
||||
(ip[0] >= 224 && ip[0] <= 255)
|
||||
(ip[0] >= 240) ||
|
||||
(ip[0] == 127) ||
|
||||
(ip[0] == 169 && ip[1] == 254)
|
||||
) {
|
||||
RETURN_VALIDATION_FAILED
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ bool(false)
|
||||
string(12) "192.0.34.166"
|
||||
bool(false)
|
||||
string(9) "192.0.0.1"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(10) "100.64.0.0"
|
||||
string(15) "100.127.255.255"
|
||||
string(12) "192.0.34.166"
|
||||
bool(false)
|
||||
string(15) "255.255.255.255"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Bug #67167: object with VALIDATE_BOOLEAN and NULL_ON_FAILURE
|
||||
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("filter")) die("skip"); ?>
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(filter_var(
|
||||
new \StdClass(),
|
||||
FILTER_VALIDATE_BOOLEAN,
|
||||
FILTER_NULL_ON_FAILURE
|
||||
));
|
||||
|
||||
--EXPECTF--
|
||||
NULL
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Bug #67167: filter_var(null,FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE) returns null
|
||||
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("filter")) die("skip"); ?>
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(filter_var(
|
||||
null,
|
||||
FILTER_VALIDATE_BOOLEAN,
|
||||
FILTER_NULL_ON_FAILURE
|
||||
));
|
||||
|
||||
--XFAIL--
|
||||
Requires php_zval_filter to not use convert_to_string for all filters.
|
||||
|
||||
--EXPECTF--
|
||||
NULL
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Bug #73054 (default option ignored when object passed to int filter)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('filter')) die('skip filter extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(
|
||||
filter_var(new stdClass, FILTER_VALIDATE_INT, [
|
||||
'options' => ['default' => 2],
|
||||
]),
|
||||
filter_var(new stdClass, FILTER_VALIDATE_INT, [
|
||||
'options' => ['default' => 2],
|
||||
'flags' => FILTER_NULL_ON_FAILURE
|
||||
])
|
||||
);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
int(2)
|
||||
int(2)
|
||||
===DONE===
|
||||
@@ -0,0 +1,137 @@
|
||||
--TEST--
|
||||
Bug #71745 FILTER_FLAG_NO_RES_RANGE does not cover whole 127.0.0.0/8 range
|
||||
--FILE--
|
||||
<?php
|
||||
//https://tools.ietf.org/html/rfc6890#section-2.1
|
||||
|
||||
$privateRanges = array();
|
||||
// 10.0.0.0/8
|
||||
$privateRanges['10.0.0.0/8'] = array('10.0.0.0', '10.255.255.255');
|
||||
|
||||
// 169.254.0.0/16
|
||||
$privateRanges['168.254.0.0/16'] = array('169.254.0.0', '169.254.255.255');
|
||||
|
||||
// 172.16.0.0/12
|
||||
$privateRanges['172.16.0.0/12'] = array('172.16.0.0', '172.31.0.0');
|
||||
|
||||
// 192.168.0.0/16
|
||||
$privateRanges['192.168.0.0/16'] = array('192.168.0.0', '192.168.255.255');
|
||||
|
||||
foreach ($privateRanges as $key => $range) {
|
||||
list($min, $max) = $range;
|
||||
var_dump($key);
|
||||
var_dump(filter_var($min, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE));
|
||||
var_dump(filter_var($max, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE));
|
||||
}
|
||||
|
||||
$reservedRanges = array();
|
||||
|
||||
// 0.0.0.0/8
|
||||
$reserverRanges['0.0.0.0/8'] = array('0.0.0.0', '0.255.255.255');
|
||||
|
||||
// 10.0.0.0/8
|
||||
$reserverdRanges['10.0.0.0/8'] = array('10.0.0.0', '10.255.255.255');
|
||||
|
||||
// 100.64.0.0/10
|
||||
$reserverdRanges['10.64.0.0/10'] = array('100.64.0.0', '100.127.255.255');
|
||||
|
||||
// 127.0.0.0/8
|
||||
$reserverdRanges['127.0.0.0/8'] = array('127.0.0.0', '127.255.255.255');
|
||||
|
||||
// 169.254.0.0/16
|
||||
$reserverdRanges['169.254.0.0/16'] = array('169.254.0.0', '169.254.255.255');
|
||||
|
||||
// 172.16.0.0/12
|
||||
$reserverdRanges['172.16.0.0/12'] = array('172.16.0.0', '172.31.0.0');
|
||||
|
||||
// 192.0.0.0/24
|
||||
$reserverdRanges['192.0.0.0/24'] = array('192.0.0.0', '192.0.0.255');
|
||||
|
||||
// 192.0.0.0/29
|
||||
$reserverdRanges['192.0.0.0/29'] = array('192.0.0.0', '192.0.0.7');
|
||||
|
||||
// 192.0.2.0/24
|
||||
$reserverdRanges['192.0.2.0/24'] = array('192.0.2.0', '192.0.2.255');
|
||||
|
||||
// 198.18.0.0/15
|
||||
$reserverdRanges['198.18.0.0/15'] = array('198.18.0.0', '198.19.255.255');
|
||||
|
||||
// 198.51.100.0/24
|
||||
$reserverdRanges['198.51.100.0/24'] = array('198.51.100.0', '198.51.100.255');
|
||||
|
||||
// 192.88.99.0/24
|
||||
$reserverdRanges['192.88.99.0/24'] = array('192.88.99.0', '192.88.99.255');
|
||||
|
||||
// 192.168.0.0/16
|
||||
$reserverdRanges['192.168.0.0/16'] = array('192.168.0.0', '192.168.255.255');
|
||||
|
||||
// 203.0.113.0/24
|
||||
$reserverdRanges['203.0.113.0/24'] = array('203.0.113.0', '203.0.113.255');
|
||||
|
||||
// 240.0.0.0/4 + 255.255.255.255/32
|
||||
$reserverdRanges['240.0.0.0/4'] = array('224.0.0.0', '255.255.255.255');
|
||||
|
||||
foreach ($reserverdRanges as $key => $range) {
|
||||
list($min, $max) = $range;
|
||||
var_dump($key);
|
||||
var_dump(filter_var($min, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE));
|
||||
var_dump(filter_var($max, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE));
|
||||
}
|
||||
|
||||
|
||||
|
||||
--EXPECT--
|
||||
string(10) "10.0.0.0/8"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(14) "168.254.0.0/16"
|
||||
string(11) "169.254.0.0"
|
||||
string(15) "169.254.255.255"
|
||||
string(13) "172.16.0.0/12"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(14) "192.168.0.0/16"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(10) "10.0.0.0/8"
|
||||
string(8) "10.0.0.0"
|
||||
string(14) "10.255.255.255"
|
||||
string(12) "10.64.0.0/10"
|
||||
string(10) "100.64.0.0"
|
||||
string(15) "100.127.255.255"
|
||||
string(11) "127.0.0.0/8"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(14) "169.254.0.0/16"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(13) "172.16.0.0/12"
|
||||
string(10) "172.16.0.0"
|
||||
string(10) "172.31.0.0"
|
||||
string(12) "192.0.0.0/24"
|
||||
string(9) "192.0.0.0"
|
||||
string(11) "192.0.0.255"
|
||||
string(12) "192.0.0.0/29"
|
||||
string(9) "192.0.0.0"
|
||||
string(9) "192.0.0.7"
|
||||
string(12) "192.0.2.0/24"
|
||||
string(9) "192.0.2.0"
|
||||
string(11) "192.0.2.255"
|
||||
string(13) "198.18.0.0/15"
|
||||
string(10) "198.18.0.0"
|
||||
string(14) "198.19.255.255"
|
||||
string(15) "198.51.100.0/24"
|
||||
string(12) "198.51.100.0"
|
||||
string(14) "198.51.100.255"
|
||||
string(14) "192.88.99.0/24"
|
||||
string(11) "192.88.99.0"
|
||||
string(13) "192.88.99.255"
|
||||
string(14) "192.168.0.0/16"
|
||||
string(11) "192.168.0.0"
|
||||
string(15) "192.168.255.255"
|
||||
string(14) "203.0.113.0/24"
|
||||
string(11) "203.0.113.0"
|
||||
string(13) "203.0.113.255"
|
||||
string(11) "240.0.0.0/4"
|
||||
string(9) "224.0.0.0"
|
||||
bool(false)
|
||||
+25
-17
@@ -290,6 +290,9 @@ ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC)
|
||||
#endif
|
||||
SSL_CTX_set_options(ctx, ssl_ctx_options);
|
||||
|
||||
/* allow SSL to re-use sessions */
|
||||
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_BOTH);
|
||||
|
||||
ftp->ssl_handle = SSL_new(ctx);
|
||||
if (ftp->ssl_handle == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to create the SSL handle");
|
||||
@@ -1495,7 +1498,8 @@ data_accept(databuf_t *data, ftpbuf_t *ftp TSRMLS_DC)
|
||||
|
||||
#if HAVE_OPENSSL_EXT
|
||||
SSL_CTX *ctx;
|
||||
long ssl_ctx_options = SSL_OP_ALL;
|
||||
SSL_SESSION *session;
|
||||
int result;
|
||||
#endif
|
||||
|
||||
if (data->fd != -1) {
|
||||
@@ -1516,31 +1520,40 @@ data_accepted:
|
||||
|
||||
/* now enable ssl if we need to */
|
||||
if (ftp->use_ssl && ftp->use_ssl_for_data) {
|
||||
ctx = SSL_CTX_new(SSLv23_client_method());
|
||||
ctx = SSL_get_SSL_CTX(ftp->ssl_handle);
|
||||
if (ctx == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: failed to create the SSL context");
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: failed to retreive the existing SSL context");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x0090605fL
|
||||
ssl_ctx_options &= ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
|
||||
#endif
|
||||
SSL_CTX_set_options(ctx, ssl_ctx_options);
|
||||
|
||||
data->ssl_handle = SSL_new(ctx);
|
||||
if (data->ssl_handle == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: failed to create the SSL handle");
|
||||
SSL_CTX_free(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
SSL_set_fd(data->ssl_handle, data->fd);
|
||||
|
||||
if (ftp->old_ssl) {
|
||||
SSL_copy_session_id(data->ssl_handle, ftp->ssl_handle);
|
||||
}
|
||||
|
||||
/* get the session from the control connection so we can re-use it */
|
||||
session = SSL_get_session(ftp->ssl_handle);
|
||||
if (session == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: failed to retreive the existing SSL session");
|
||||
SSL_free(data->ssl_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* and set it on the data connection */
|
||||
result = SSL_set_session(data->ssl_handle, session);
|
||||
if (result == 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: failed to set the existing SSL session");
|
||||
SSL_free(data->ssl_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (SSL_connect(data->ssl_handle) <= 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: SSL/TLS handshake failed");
|
||||
SSL_shutdown(data->ssl_handle);
|
||||
@@ -1571,10 +1584,7 @@ data_close(ftpbuf_t *ftp, databuf_t *data)
|
||||
if (data->listener != -1) {
|
||||
#if HAVE_OPENSSL_EXT
|
||||
if (data->ssl_active) {
|
||||
|
||||
ctx = SSL_get_SSL_CTX(data->ssl_handle);
|
||||
SSL_CTX_free(ctx);
|
||||
|
||||
/* don't free the data context, it's the same as the control */
|
||||
SSL_shutdown(data->ssl_handle);
|
||||
SSL_free(data->ssl_handle);
|
||||
data->ssl_active = 0;
|
||||
@@ -1585,9 +1595,7 @@ data_close(ftpbuf_t *ftp, databuf_t *data)
|
||||
if (data->fd != -1) {
|
||||
#if HAVE_OPENSSL_EXT
|
||||
if (data->ssl_active) {
|
||||
ctx = SSL_get_SSL_CTX(data->ssl_handle);
|
||||
SSL_CTX_free(ctx);
|
||||
|
||||
/* don't free the data context, it's the same as the control */
|
||||
SSL_shutdown(data->ssl_handle);
|
||||
SSL_free(data->ssl_handle);
|
||||
data->ssl_active = 0;
|
||||
|
||||
+47
-46
@@ -1,48 +1,49 @@
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIIBmzCCAQQCAQAwWzELMAkGA1UEBhMCUFQxCzAJBgNVBAgTAkx4MQswCQYDVQQH
|
||||
EwJMeDEcMBoGA1UEChMTQSBtaW5oYSBlbXByZXNhLCBTQTEUMBIGA1UECxMLUEhQ
|
||||
IFFBIFRlYW0wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM9mfEOSYwXf58ch
|
||||
4NyO1QOU1XMfquz8OVpvMUITABLAevZpeQn6vZPHNyXHFQC0QC8scydK1rAYd2U+
|
||||
9K2aPub6ioMjYyjPpAE07l9EAAPUEBlqqsziB/wT8QjWkByyJEkYu+o0Wyjokhfn
|
||||
BMPvm52wLWUx9nvUeNDCftnKg1wxAgMBAAGgADANBgkqhkiG9w0BAQQFAAOBgQDD
|
||||
s1FeqPxnF2bWj8/dG8MyPaRfOAMVz1UsCZUciXIVG5LSIvR2qnMC3iEYt3s13sEq
|
||||
z8VJlNHa8nniE+VFNv093yIu+PlWXMEvb5y5EFqP2AYq3RAT+SJsSxGqIdzPZiKY
|
||||
INaktLCZmQ/E1v7/4hFzVRq9ydJI82DVS1nv282Whw==
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC4zCCAkygAwIBAgIBADANBgkqhkiG9w0BAQQFADBbMQswCQYDVQQGEwJQVDEL
|
||||
MAkGA1UECBMCTHgxCzAJBgNVBAcTAkx4MRwwGgYDVQQKExNBIG1pbmhhIGVtcHJl
|
||||
c2EsIFNBMRQwEgYDVQQLEwtQSFAgUUEgVGVhbTAeFw0wNjExMTkxODIzNTNaFw0w
|
||||
NzExMTkxODIzNTNaMFsxCzAJBgNVBAYTAlBUMQswCQYDVQQIEwJMeDELMAkGA1UE
|
||||
BxMCTHgxHDAaBgNVBAoTE0EgbWluaGEgZW1wcmVzYSwgU0ExFDASBgNVBAsTC1BI
|
||||
UCBRQSBUZWFtMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDPZnxDkmMF3+fH
|
||||
IeDcjtUDlNVzH6rs/DlabzFCEwASwHr2aXkJ+r2TxzclxxUAtEAvLHMnStawGHdl
|
||||
PvStmj7m+oqDI2Moz6QBNO5fRAAD1BAZaqrM4gf8E/EI1pAcsiRJGLvqNFso6JIX
|
||||
5wTD75udsC1lMfZ71HjQwn7ZyoNcMQIDAQABo4G2MIGzMB0GA1UdDgQWBBTIga5L
|
||||
q+Ub1SWXgNZRYCpq3c8Z+jCBgwYDVR0jBHwweoAUyIGuS6vlG9Ull4DWUWAqat3P
|
||||
GfqhX6RdMFsxCzAJBgNVBAYTAlBUMQswCQYDVQQIEwJMeDELMAkGA1UEBxMCTHgx
|
||||
HDAaBgNVBAoTE0EgbWluaGEgZW1wcmVzYSwgU0ExFDASBgNVBAsTC1BIUCBRQSBU
|
||||
ZWFtggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAe6AA8aC3KDI8
|
||||
smd+7XWjaTSp1Q0uMkEZ2PEBzif2I1aPPqw1CQykJ1iDdC/8PJ1yEIezloP2XQoZ
|
||||
NjTaCO+uubay03ncoPTZvDUwExN9BYFAYgc2z3tLMHYbA7kM2sIbKys7ZQegLibr
|
||||
TSKYQOBeYA/FB9GHECJGU3zBRvYi+Og=
|
||||
MIIDhTCCAm2gAwIBAgIJAN75FFz+owOAMA0GCSqGSIb3DQEBCwUAMFkxCzAJBgNV
|
||||
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
|
||||
aWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMMCTEyNy4wLjAuMTAeFw0xNjA3MjUxMjM3
|
||||
MTJaFw0yNjA3MjMxMjM3MTJaMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21l
|
||||
LVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNV
|
||||
BAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALtG
|
||||
AIrNUDItISfpAqztL2TFEWEHLGTzCEh5Ag2sdMD7UYbqIPHLOE4EINv+dqEMM0Nz
|
||||
LYnw7ChtVegXT907xCaQcmeDFSdhqze4L8zawDfnn4syB8XAwGYJfpstYwe3nO6+
|
||||
0WvLSb1A5TYNeyoXjwlAUKElxkeWAo51uhR41GDhDQ9GgpqX1ccAhmSoUhgIRSzf
|
||||
6f4KE3WTdzl1p12ZtkYHB8Jo2jB/JXnwGOz6isLnpRvkex4B7sUX+7u1MqK/e1X7
|
||||
Hi1G/VkaAfC2SOfjTePtGBDBXrQ1arYXDPRA04sgFzSh55l7lC/4HasQ/jAb3h95
|
||||
dcEIqyc69iioaN1c1NcCAwEAAaNQME4wHQYDVR0OBBYEFNv3kefb1H+6/6CpjiBi
|
||||
+I2s9E90MB8GA1UdIwQYMBaAFNv3kefb1H+6/6CpjiBi+I2s9E90MAwGA1UdEwQF
|
||||
MAMBAf8wDQYJKoZIhvcNAQELBQADggEBAIzSEWpHSaBs7KduBRXX5+qFxBN6OCPl
|
||||
7ID0rxAOYfw7ruzbmwgOpBgMIHGn+KqA6CmQI0jh9bZbv5TV2aFpFsUihugPc2lW
|
||||
5EshCozxlEPmIJNsO8jDqPE4w3m4KiVTscRWjBa5cco+lwLDqboerm2l7vvrtr6B
|
||||
pgLaZct1c73MouvoJSCGK5EOGW7jsgaxjxJ3UZug+24Ko1wulO2cgBLhda9Ilrnx
|
||||
CIKI9h8Z2WVWuVQfyCyO1g7XkJgkBec77OhxD+m4onzPY6waqnnhmFOBcS+gKgBV
|
||||
jHeK9DCvZ9zet3EyEp6fyQOOtsC+gU0piYgfsQL7aCp5oLe+fjTiuUY=
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,928762DB6DE222AD
|
||||
|
||||
oOxNUBX0wrqmRqb3IEZMogc1bnVm6JoW6YFjGfHNcIz0jS7UPDhUFDR26y0dYujL
|
||||
LEgxOcYo8ItvGcXSRbs+3W7lISbosgkB0DOaKx5jVmOGwUVRergUUSY8rbf93FtP
|
||||
27CEvAfsU6do5HmlJ34mYZW1k+onCznlJXJkupQ5jmiily3GwEdr/5mMIVOmXQ6p
|
||||
xWkxHySDKyVbR0v4JY3SJLRBuhgofYNG5155PiqZ7KwYY4Aw60eVgINsvJCF9/8b
|
||||
kEj+lecHbBdAf7N82320Ga+F+VeFnUl0gWFjoIF9UFCO80+7ZvIGdGlyPkr4zMvt
|
||||
TsC1snJQdHg+IlT3sGayYrQANpTG6GPYhn3KEvK5aqq+bPEe5lija0gw34jbPCo+
|
||||
TjHR76lToxzubGZODyyF/rjl5KwUbqTCNuv1PX1jTx7n7sCbu+KHpqXMhTHLKtby
|
||||
+Wh7WAfsVrbIW+P85/mkfhPbPZ2621f9cyStdFGgWU4dHdD00HIGOgAJvUSbC2Au
|
||||
oVUoKf2818t1s9aA4ptog04sNi+Ixu+z+3yYNLZj51j4ZX3KuXxLIiQvlvFQ8LQi
|
||||
RHGQk3u2W3iNtDKKUQjMPaB2FlVtC7FmtHBCpRmos6ld240DDyucqMdIDTMaqV0+
|
||||
sL4X+LIeBM/hP/IquRTuQBHBmgjkN4845ihTUJOanyKx605ANq/roHzXrbIxhR5p
|
||||
pcJLCBMLMWgdOCJMZRavSq04iXeNfP6Mk/joVpHS62Ljdfc94BBLfsOKOErA20Nq
|
||||
lfvbZqy2tI5IIDoq05S8FU0DYNqq/hyrv9Udo8IAo+WkBOABm0x/WA==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC7RgCKzVAyLSEn
|
||||
6QKs7S9kxRFhByxk8whIeQINrHTA+1GG6iDxyzhOBCDb/nahDDNDcy2J8OwobVXo
|
||||
F0/dO8QmkHJngxUnYas3uC/M2sA355+LMgfFwMBmCX6bLWMHt5zuvtFry0m9QOU2
|
||||
DXsqF48JQFChJcZHlgKOdboUeNRg4Q0PRoKal9XHAIZkqFIYCEUs3+n+ChN1k3c5
|
||||
daddmbZGBwfCaNowfyV58Bjs+orC56Ub5HseAe7FF/u7tTKiv3tV+x4tRv1ZGgHw
|
||||
tkjn403j7RgQwV60NWq2Fwz0QNOLIBc0oeeZe5Qv+B2rEP4wG94feXXBCKsnOvYo
|
||||
qGjdXNTXAgMBAAECggEAD7yDISa9fWnjZlojGmrX16zjl/alWVo+sPBSJtn9+ZVk
|
||||
tWSJHihIc+3O4Q2R5FiFGj7cbcHr5j3BwT3sPRfflKoAowgVx/hiDc2RXrJnAouZ
|
||||
EXZDxu86e5iCpgF7V9OrATjRmjA74wZH/HHHjrLqFwnrfI8TCULmthfYag35Mqax
|
||||
qrIEzvSuYdaGxblNe+ZfnVEDW2F9DLBGcma0ffUlJp8AvV7bpo8Rj/JovPxit/VS
|
||||
UdwSRxwSAugctFpmcGlFkoQfxUx1WdEy8hjopLrayMjCCJvRUL4+C4zT9r9PBHOj
|
||||
fCSbJ+ajQIoRrgaL9bURk8BFMHY8+yMUsWEYVSmFAQKBgQDtOvPkhvZsNocUB5nJ
|
||||
ti3SXyDQ6OZQuKKHPSeDV/EvmZKeNlrQ1ZnwXLP3vkcedDOkt1nEVq/hUewpjt08
|
||||
2MvmMwJBQEnmbTzMf43DtlXsStdP1lhYaFbU4iMM5zRfyBHDu1GPZEPXvKKpJUk0
|
||||
M+jYIyTAP3mcZhqDKn0mPVP7VwKBgQDKFy9DtWFKxCvhFQvHx7YeZiVWJbIst/O4
|
||||
ZyuPVAErni0hzSeCkmm7+F9hgEdPSLRcSaeTWP4L0u1cixECKboIhoNs38aft7o3
|
||||
MdnI2RDSEKtKX2uVuhvpGDNuGpBAc8Qu8iCiv5INSC36ZhD1h++O/TiiUdgRJ3yX
|
||||
yeG7ej+CgQKBgCR5F95e0aw5hfMSaBaXJ9xcO9Niu2ZVvMdGI7kR4EcNOXmRqczJ
|
||||
ym0mE5VXb9/Cxd3hQq/pFAl0avbIvEMKoe62kPYvSC1hRiO6yLT6Z6N4rjncHqEZ
|
||||
CaCZVAI72dWQEQsi1ZtSMwwMOIYA8YxRHs98N75HBA+DszfPZIZoj2zpAoGBAJHp
|
||||
B3ElhmeLF/tdTLIj2bQ9H/wBH5H2Bvw/UU4c4vNxMzjSfRJjUAAtpgAptFLkNYTk
|
||||
kR9sA5DZ7BMDPXaIVg9Nv5peP3SWHNc5IPtI7kIdUu9R0cW7J+e2V3vJphlC/ITA
|
||||
wRuAoZ0BXmEKTHhae3aMEdXwrcZE8kpNsrO/4hcBAoGBAMISiPJPuxAX1UtqcxTa
|
||||
mDJfnQ2gxRu6AK9VmXqo0X4IBxDSnTjcL0huUlS849wgsE5oTXgdYb2hn+TXM5JJ
|
||||
NsEXLhV09X1mrk4M4LV1npd0mYxvFsO4+p+IX5YLiahInmQtq0gx3DWE8wouVFER
|
||||
4yzfp27z8MZT8Qvr/ZI9lzWd
|
||||
-----END PRIVATE KEY-----
|
||||
+36
-11
@@ -2,7 +2,7 @@
|
||||
|
||||
$socket = null;
|
||||
$errno = 0;
|
||||
$context = stream_context_create(array('ssl' => array('local_cert' => dirname(__FILE__).'/cert.pem', 'passphrase' => 'pass')));
|
||||
$context = stream_context_create(array('ssl' => array('local_cert' => dirname(__FILE__).'/cert.pem')));
|
||||
|
||||
for ($i=0; $i<10 && !$socket; ++$i) {
|
||||
$port = rand(50000, 65535);
|
||||
@@ -139,7 +139,10 @@ if ($pid) {
|
||||
$buf = fread($s, 2048);
|
||||
}
|
||||
|
||||
if (!preg_match('/^USER (\w+)\r\n$/', $buf, $m)) {
|
||||
if ($buf == "AUTH TLS\r\n") {
|
||||
fputs($s, "500 not supported.\r\n");
|
||||
return ;
|
||||
} else if (!preg_match('/^USER (\w+)\r\n$/', $buf, $m)) {
|
||||
fputs($s, "500 Syntax error, command unrecognized.\r\n");
|
||||
dump_and_exit($buf);
|
||||
}
|
||||
@@ -208,6 +211,10 @@ if ($pid) {
|
||||
$ascii = true;
|
||||
fputs($s, "200 OK\r\n");
|
||||
|
||||
} elseif ($buf === "AUTH SSL\r\n") {
|
||||
$ascii = true;
|
||||
fputs($s, "500 not supported\r\n");
|
||||
|
||||
} elseif ($buf === "TYPE I\r\n") {
|
||||
$ascii = false;
|
||||
fputs($s, "200 OK\r\n");
|
||||
@@ -265,7 +272,7 @@ if ($pid) {
|
||||
|
||||
} elseif (preg_match("~^NLST(?: ([A-Za-z./]+))?\r\n$~", $buf, $m)) {
|
||||
|
||||
if (isset($m[1]) && $m[1] === 'bogusdir') {
|
||||
if (isset($m[1]) && (($m[1] === 'bogusdir') || ($m[1] === '/bogusdir'))) {
|
||||
fputs($s, "250 $m[1]: No such file or directory\r\n");
|
||||
continue;
|
||||
}
|
||||
@@ -276,11 +283,20 @@ if ($pid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
fputs($s, "150 File status okay; about to open data connection\r\n");
|
||||
if (empty($pasv)) {
|
||||
fputs($s, "150 File status okay; about to open data connection\r\n");
|
||||
if (!$fs = stream_socket_client("tcp://$host:$port")) {
|
||||
fputs($s, "425 Can't open data connection\r\n");
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
fputs($s, "125 Data connection already open; transfer starting.\r\n");
|
||||
$fs=$pasvs;
|
||||
}
|
||||
|
||||
if (!$fs = stream_socket_client("tcp://$host:$port")) {
|
||||
fputs($s, "425 Can't open data connection\r\n");
|
||||
continue;
|
||||
|
||||
if ((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER))) {
|
||||
die("SSLv23 handshake failed.\n");
|
||||
}
|
||||
|
||||
if (empty($m[1]) || $m[1] !== 'emptydir') {
|
||||
@@ -368,7 +384,7 @@ if ($pid) {
|
||||
}
|
||||
fputs($s, "226 Closing data Connection.\r\n");
|
||||
break;
|
||||
case "mediumfile":
|
||||
case "mediumfile":
|
||||
fputs($s, "150 File status okay; about to open data connection.\r\n");
|
||||
for($i = 0; $i < 150; $i++){
|
||||
fputs($fs, "This is line $i of the test data.\n");
|
||||
@@ -384,13 +400,22 @@ if ($pid) {
|
||||
|
||||
|
||||
}elseif (preg_match('/^PASV/', $buf, $matches)) {
|
||||
$port = $pasv_port;
|
||||
$p2 = $port % ((int) 1 << 8);
|
||||
$p1 = ($port-$p2)/((int) 1 << 8);
|
||||
$pasv=true;
|
||||
$p2 = $pasv_port % ((int) 1 << 8);
|
||||
$p1 = ($pasv_port-$p2)/((int) 1 << 8);
|
||||
$host = "127.0.0.1";
|
||||
if (!empty($ssl)) {
|
||||
$soc = stream_socket_server("tcp://127.0.0.1:$pasv_port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
|
||||
} else {
|
||||
$soc = stream_socket_server("tcp://127.0.0.1:$pasv_port");
|
||||
}
|
||||
|
||||
fputs($s, "227 Entering Passive Mode. (127,0,0,1,{$p1},{$p2})\r\n");
|
||||
|
||||
$pasvs = stream_socket_accept($soc,10);
|
||||
|
||||
}elseif (preg_match('/^EPSV/', $buf, $matches)) {
|
||||
fputs($s, "550 Extended passsive mode not supported.\r\n");
|
||||
} elseif (preg_match('/^SITE EXEC/', $buf, $matches)) {
|
||||
fputs($s, "200 OK\r\n");
|
||||
|
||||
|
||||
+87
-23
@@ -69,6 +69,9 @@ static void php_free_ps_enc(zend_rsrc_list_entry *rsrc TSRMLS_DC);
|
||||
#endif
|
||||
|
||||
#include <gd.h>
|
||||
#ifndef HAVE_GD_BUNDLED
|
||||
# include <gd_errors.h>
|
||||
#endif
|
||||
#include <gdfontt.h> /* 1 Tiny font */
|
||||
#include <gdfonts.h> /* 2 Small font */
|
||||
#include <gdfontmb.h> /* 3 Medium bold font */
|
||||
@@ -96,7 +99,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int, int);
|
||||
|
||||
#include "gd_ctx.c"
|
||||
|
||||
/* as it is not really public, duplicate declaration here to avoid
|
||||
/* as it is not really public, duplicate declaration here to avoid
|
||||
pointless warnings */
|
||||
int overflow2(int a, int b);
|
||||
|
||||
@@ -1099,6 +1102,18 @@ void php_gd_error_method(int type, const char *format, va_list args)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
switch (type) {
|
||||
case GD_DEBUG:
|
||||
case GD_INFO:
|
||||
case GD_NOTICE:
|
||||
type = E_NOTICE;
|
||||
break;
|
||||
case GD_WARNING:
|
||||
type = E_WARNING;
|
||||
break;
|
||||
default:
|
||||
type = E_ERROR;
|
||||
}
|
||||
php_verror(NULL, "", type, format, args TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
@@ -1148,6 +1163,7 @@ PHP_MINIT_FUNCTION(gd)
|
||||
REGISTER_LONG_CONSTANT("IMG_PNG", 4, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("IMG_WBMP", 8, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("IMG_XPM", 16, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("IMG_WEBP", 32, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
/* special colours for gd */
|
||||
REGISTER_LONG_CONSTANT("IMG_COLOR_TILED", gdTiled, CONST_CS | CONST_PERSISTENT);
|
||||
@@ -1181,7 +1197,7 @@ PHP_MINIT_FUNCTION(gd)
|
||||
REGISTER_LONG_CONSTANT("IMG_CROP_SIDES", GD_CROP_SIDES, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("IMG_CROP_THRESHOLD", GD_CROP_THRESHOLD, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
|
||||
|
||||
REGISTER_LONG_CONSTANT("IMG_BELL", GD_BELL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("IMG_BESSEL", GD_BESSEL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("IMG_BILINEAR_FIXED", GD_BILINEAR_FIXED, CONST_CS | CONST_PERSISTENT);
|
||||
@@ -1539,6 +1555,7 @@ PHP_FUNCTION(imagesetstyle)
|
||||
int * stylearr;
|
||||
int index;
|
||||
HashPosition pos;
|
||||
int num_styles;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra", &IM, &styles) == FAILURE) {
|
||||
return;
|
||||
@@ -1546,8 +1563,14 @@ PHP_FUNCTION(imagesetstyle)
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
|
||||
|
||||
num_styles = zend_hash_num_elements(HASH_OF(styles));
|
||||
if (num_styles == 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "styles array must not be empty");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* copy the style values in the stylearr */
|
||||
stylearr = safe_emalloc(sizeof(int), zend_hash_num_elements(HASH_OF(styles)), 0);
|
||||
stylearr = safe_emalloc(sizeof(int), num_styles, 0);
|
||||
|
||||
zend_hash_internal_pointer_reset_ex(HASH_OF(styles), &pos);
|
||||
|
||||
@@ -1621,7 +1644,7 @@ PHP_FUNCTION(imageistruecolor)
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto void imagetruecolortopalette(resource im, bool ditherFlag, int colorsWanted)
|
||||
Convert a true colour image to a palette based image with a number of colours, optionally using dithering. */
|
||||
Convert a true color image to a palette based image with a number of colors, optionally using dithering. */
|
||||
PHP_FUNCTION(imagetruecolortopalette)
|
||||
{
|
||||
zval *IM;
|
||||
@@ -1635,11 +1658,11 @@ PHP_FUNCTION(imagetruecolortopalette)
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
|
||||
|
||||
if (ncolors <= 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of colors has to be greater than zero");
|
||||
if (ncolors <= 0 || ncolors > INT_MAX) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of colors has to be greater than zero and no more than %d", INT_MAX);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
gdImageTrueColorToPalette(im, dither, ncolors);
|
||||
gdImageTrueColorToPalette(im, dither, (int)ncolors);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@@ -1647,8 +1670,8 @@ PHP_FUNCTION(imagetruecolortopalette)
|
||||
|
||||
|
||||
|
||||
/* {{{ proto void imagetruecolortopalette(resource im, bool ditherFlag, int colorsWanted)
|
||||
Convert a true colour image to a palette based image with a number of colours, optionally using dithering. */
|
||||
/* {{{ proto void imagepalettetotruecolor(resource im)
|
||||
Convert a palette based image to a true color image. */
|
||||
PHP_FUNCTION(imagepalettetotruecolor)
|
||||
{
|
||||
zval *IM;
|
||||
@@ -2200,6 +2223,9 @@ PHP_FUNCTION(imagetypes)
|
||||
#if defined(HAVE_GD_XPM)
|
||||
ret |= 16;
|
||||
#endif
|
||||
#ifdef HAVE_GD_WEBP
|
||||
ret |= 32;
|
||||
#endif
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
@@ -2588,11 +2614,11 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
|
||||
|
||||
if (argc > 1) {
|
||||
fn = file;
|
||||
if (argc == 3) {
|
||||
if (argc >= 3) {
|
||||
q = quality;
|
||||
}
|
||||
if (argc == 4) {
|
||||
t = type;
|
||||
if (argc == 4) {
|
||||
t = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3056,6 +3082,11 @@ PHP_FUNCTION(imagegammacorrect)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( input <= 0.0 || output <= 0.0 ) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Gamma values should be positive");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
|
||||
|
||||
if (gdImageTrueColor(im)) {
|
||||
@@ -3823,7 +3854,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
|
||||
{
|
||||
zval *IM, *EXT = NULL;
|
||||
gdImagePtr im=NULL;
|
||||
long col = -1, x = -1, y = -1;
|
||||
long col = -1, x = 0, y = 0;
|
||||
int str_len, fontname_len, i, brect[8];
|
||||
double ptsize, angle;
|
||||
char *str = NULL, *fontname = NULL;
|
||||
@@ -3887,7 +3918,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
|
||||
#endif /* VIRTUAL_DIR */
|
||||
|
||||
PHP_GD_CHECK_OPEN_BASEDIR(fontname, "Invalid font filename");
|
||||
|
||||
|
||||
#ifdef HAVE_GD_FREETYPE
|
||||
if (extended) {
|
||||
error = gdImageStringFTEx(im, brect, col, fontname, ptsize, angle, x, y, str, &strex);
|
||||
@@ -4465,7 +4496,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
int x, y;
|
||||
float x_ratio, y_ratio;
|
||||
long ignore_warning;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pplll", &f_org, &f_org_len, &f_dest, &f_dest_len, &height, &width, &threshold) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
@@ -4499,6 +4530,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
dest = VCWD_FOPEN(fn_dest, "wb");
|
||||
if (!dest) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' for writing", fn_dest);
|
||||
fclose(org);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -4507,6 +4539,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
im_org = gdImageCreateFromGif(org);
|
||||
if (im_org == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' Not a valid GIF file", fn_dest);
|
||||
fclose(org);
|
||||
fclose(dest);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
break;
|
||||
@@ -4517,6 +4551,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
im_org = gdImageCreateFromJpegEx(org, ignore_warning);
|
||||
if (im_org == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' Not a valid JPEG file", fn_dest);
|
||||
fclose(org);
|
||||
fclose(dest);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
break;
|
||||
@@ -4527,6 +4563,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
im_org = gdImageCreateFromPng(org);
|
||||
if (im_org == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' Not a valid PNG file", fn_dest);
|
||||
fclose(org);
|
||||
fclose(dest);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
break;
|
||||
@@ -4534,10 +4572,14 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
|
||||
default:
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Format not supported");
|
||||
fclose(org);
|
||||
fclose(dest);
|
||||
RETURN_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
fclose(org);
|
||||
|
||||
org_width = gdImageSX (im_org);
|
||||
org_height = gdImageSY (im_org);
|
||||
|
||||
@@ -4568,6 +4610,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
im_tmp = gdImageCreate (dest_width, dest_height);
|
||||
if (im_tmp == NULL ) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate temporary buffer");
|
||||
fclose(dest);
|
||||
gdImageDestroy(im_org);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -4575,23 +4619,29 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
|
||||
gdImageDestroy(im_org);
|
||||
|
||||
fclose(org);
|
||||
|
||||
im_dest = gdImageCreate(dest_width, dest_height);
|
||||
if (im_dest == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate destination buffer");
|
||||
fclose(dest);
|
||||
gdImageDestroy(im_tmp);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
white = gdImageColorAllocate(im_dest, 255, 255, 255);
|
||||
if (white == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate the colors for the destination buffer");
|
||||
fclose(dest);
|
||||
gdImageDestroy(im_tmp);
|
||||
gdImageDestroy(im_dest);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
black = gdImageColorAllocate(im_dest, 0, 0, 0);
|
||||
if (black == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate the colors for the destination buffer");
|
||||
fclose(dest);
|
||||
gdImageDestroy(im_tmp);
|
||||
gdImageDestroy(im_dest);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -5097,7 +5147,7 @@ PHP_FUNCTION(imagecropauto)
|
||||
break;
|
||||
|
||||
case GD_CROP_THRESHOLD:
|
||||
if (color < 0) {
|
||||
if (color < 0 || (!gdImageTrueColor(im) && color >= gdImageColorsTotal(im))) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Color argument missing with threshold mode");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -5125,7 +5175,7 @@ PHP_FUNCTION(imagescale)
|
||||
gdImagePtr im_scaled = NULL;
|
||||
int new_width, new_height;
|
||||
long tmp_w, tmp_h=-1, tmp_m = GD_BILINEAR_FIXED;
|
||||
gdInterpolationMethod method;
|
||||
gdInterpolationMethod method, old_method;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|ll", &IM, &tmp_w, &tmp_h, &tmp_m) == FAILURE) {
|
||||
return;
|
||||
@@ -5145,12 +5195,19 @@ PHP_FUNCTION(imagescale)
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp_h <= 0 || tmp_w <= 0) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
new_width = tmp_w;
|
||||
new_height = tmp_h;
|
||||
|
||||
/* gdImageGetInterpolationMethod() is only available as of GD 2.1.1 */
|
||||
old_method = im->interpolation_id;
|
||||
if (gdImageSetInterpolationMethod(im, method)) {
|
||||
im_scaled = gdImageScale(im, new_width, new_height);
|
||||
}
|
||||
gdImageSetInterpolationMethod(im, old_method);
|
||||
|
||||
if (im_scaled == NULL) {
|
||||
RETURN_FALSE;
|
||||
@@ -5344,7 +5401,7 @@ PHP_FUNCTION(imageaffinematrixget)
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing y position");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (type == GD_AFFINE_TRANSLATE) {
|
||||
res = gdAffineTranslate(affine, x, y);
|
||||
} else {
|
||||
@@ -5362,8 +5419,15 @@ PHP_FUNCTION(imageaffinematrixget)
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number is expected as option");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
convert_to_double_ex(&options);
|
||||
angle = Z_DVAL_P(options);
|
||||
if(Z_TYPE_P(options) != IS_DOUBLE) {
|
||||
zval dval;
|
||||
dval = *options;
|
||||
zval_copy_ctor(&dval);
|
||||
convert_to_double(&dval);
|
||||
angle = Z_DVAL(dval);
|
||||
} else {
|
||||
angle = Z_DVAL_P(options);
|
||||
}
|
||||
|
||||
if (type == GD_AFFINE_SHEAR_HORIZONTAL) {
|
||||
res = gdAffineShearHorizontal(affine, angle);
|
||||
|
||||
+156
-124
@@ -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 */
|
||||
@@ -186,7 +190,7 @@ gdImagePtr gdImageCreateTrueColor (int sx, int sy)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (overflow2(sizeof(int), sx)) {
|
||||
if (overflow2(sizeof(int *), sx)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -595,15 +599,18 @@ void gdImageColorDeallocate (gdImagePtr im, int color)
|
||||
|
||||
void gdImageColorTransparent (gdImagePtr im, int color)
|
||||
{
|
||||
if (color < 0) {
|
||||
return;
|
||||
}
|
||||
if (!im->trueColor) {
|
||||
if((color >= im->colorsTotal)) {
|
||||
return;
|
||||
}
|
||||
/* Make the old transparent color opaque again */
|
||||
if (im->transparent != -1) {
|
||||
im->alpha[im->transparent] = gdAlphaOpaque;
|
||||
}
|
||||
if (color > -1 && color < im->colorsTotal && color < gdMaxColors) {
|
||||
im->alpha[color] = gdAlphaTransparent;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
im->alpha[color] = gdAlphaTransparent;
|
||||
}
|
||||
im->transparent = color;
|
||||
}
|
||||
@@ -1051,11 +1058,13 @@ void gdImageAABlend (gdImagePtr im)
|
||||
}
|
||||
}
|
||||
|
||||
static void _gdImageFilledHRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color);
|
||||
|
||||
static void gdImageHLine(gdImagePtr im, int y, int x1, int x2, int col)
|
||||
{
|
||||
if (im->thick > 1) {
|
||||
int thickhalf = im->thick >> 1;
|
||||
gdImageFilledRectangle(im, x1, y - thickhalf, x2, y + im->thick - thickhalf - 1, col);
|
||||
_gdImageFilledHRectangle(im, x1, y - thickhalf, x2, y + im->thick - thickhalf - 1, col);
|
||||
} else {
|
||||
if (x2 < x1) {
|
||||
int t = x2;
|
||||
@@ -1098,17 +1107,17 @@ 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;
|
||||
}
|
||||
|
||||
/* 2.0.10: Nick Atty: clip to edges of drawing rectangle, return if no points need to be drawn */
|
||||
if (!clip_1d(&x1,&y1,&x2,&y2,gdImageSX(im)) || !clip_1d(&y1,&x1,&y2,&x2,gdImageSY(im))) {
|
||||
if (!clip_1d(&x1,&y1,&x2,&y2,gdImageSX(im)-1) || !clip_1d(&y1,&x1,&y2,&x2,gdImageSY(im)-1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1289,58 +1298,13 @@ inline static void gdImageSetAAPixelColor(gdImagePtr im, int x, int y, int color
|
||||
void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col)
|
||||
{
|
||||
/* keep them as 32bits */
|
||||
long x, y, inc;
|
||||
long x, y, inc, frac;
|
||||
long dx, dy,tmp;
|
||||
|
||||
if (y1 < 0 && y2 < 0) {
|
||||
/* 2.0.10: Nick Atty: clip to edges of drawing rectangle, return if no points need to be drawn */
|
||||
if (!clip_1d(&x1,&y1,&x2,&y2,gdImageSX(im)-1) || !clip_1d(&y1,&x1,&y2,&x2,gdImageSY(im)-1)) {
|
||||
return;
|
||||
}
|
||||
if (y1 < 0) {
|
||||
x1 += (y1 * (x1 - x2)) / (y2 - y1);
|
||||
y1 = 0;
|
||||
}
|
||||
if (y2 < 0) {
|
||||
x2 += (y2 * (x1 - x2)) / (y2 - y1);
|
||||
y2 = 0;
|
||||
}
|
||||
|
||||
/* bottom edge */
|
||||
if (y1 >= im->sy && y2 >= im->sy) {
|
||||
return;
|
||||
}
|
||||
if (y1 >= im->sy) {
|
||||
x1 -= ((im->sy - y1) * (x1 - x2)) / (y2 - y1);
|
||||
y1 = im->sy - 1;
|
||||
}
|
||||
if (y2 >= im->sy) {
|
||||
x2 -= ((im->sy - y2) * (x1 - x2)) / (y2 - y1);
|
||||
y2 = im->sy - 1;
|
||||
}
|
||||
|
||||
/* left edge */
|
||||
if (x1 < 0 && x2 < 0) {
|
||||
return;
|
||||
}
|
||||
if (x1 < 0) {
|
||||
y1 += (x1 * (y1 - y2)) / (x2 - x1);
|
||||
x1 = 0;
|
||||
}
|
||||
if (x2 < 0) {
|
||||
y2 += (x2 * (y1 - y2)) / (x2 - x1);
|
||||
x2 = 0;
|
||||
}
|
||||
/* right edge */
|
||||
if (x1 >= im->sx && x2 >= im->sx) {
|
||||
return;
|
||||
}
|
||||
if (x1 >= im->sx) {
|
||||
y1 -= ((im->sx - x1) * (y1 - y2)) / (x2 - x1);
|
||||
x1 = im->sx - 1;
|
||||
}
|
||||
if (x2 >= im->sx) {
|
||||
y2 -= ((im->sx - x2) * (y1 - y2)) / (x2 - x1);
|
||||
x2 = im->sx - 1;
|
||||
}
|
||||
|
||||
dx = x2 - x1;
|
||||
dy = y2 - y1;
|
||||
@@ -1359,16 +1323,22 @@ void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col)
|
||||
dx = x2 - x1;
|
||||
dy = y2 - y1;
|
||||
}
|
||||
x = x1 << 16;
|
||||
y = y1 << 16;
|
||||
y = y1;
|
||||
inc = (dy * 65536) / dx;
|
||||
while ((x >> 16) <= x2) {
|
||||
gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (y >> 8) & 0xFF);
|
||||
if ((y >> 16) + 1 < im->sy) {
|
||||
gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1,col, (~y >> 8) & 0xFF);
|
||||
frac = 0;
|
||||
for (x = x1; x <= x2; x++) {
|
||||
gdImageSetAAPixelColor(im, x, y, col, (frac >> 8) & 0xFF);
|
||||
if (y + 1 < im->sy) {
|
||||
gdImageSetAAPixelColor(im, x, y + 1, col, (~frac >> 8) & 0xFF);
|
||||
}
|
||||
frac += inc;
|
||||
if (frac >= 65536) {
|
||||
frac -= 65536;
|
||||
y++;
|
||||
} else if (frac < 0) {
|
||||
frac += 65536;
|
||||
y--;
|
||||
}
|
||||
x += (1 << 16);
|
||||
y += inc;
|
||||
}
|
||||
} else {
|
||||
if (dy < 0) {
|
||||
@@ -1381,16 +1351,22 @@ void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col)
|
||||
dx = x2 - x1;
|
||||
dy = y2 - y1;
|
||||
}
|
||||
x = x1 << 16;
|
||||
y = y1 << 16;
|
||||
x = x1;
|
||||
inc = (dx * 65536) / dy;
|
||||
while ((y>>16) <= y2) {
|
||||
gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (x >> 8) & 0xFF);
|
||||
if ((x >> 16) + 1 < im->sx) {
|
||||
gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16),col, (~x >> 8) & 0xFF);
|
||||
frac = 0;
|
||||
for (y = y1; y <= y2; y++) {
|
||||
gdImageSetAAPixelColor(im, x, y, col, (frac >> 8) & 0xFF);
|
||||
if (x + 1 < im->sx) {
|
||||
gdImageSetAAPixelColor(im, x + 1, y, col, (~frac >> 8) & 0xFF);
|
||||
}
|
||||
frac += inc;
|
||||
if (frac >= 65536) {
|
||||
frac -= 65536;
|
||||
x++;
|
||||
} else if (frac < 0) {
|
||||
frac += 65536;
|
||||
x--;
|
||||
}
|
||||
x += inc;
|
||||
y += (1<<16);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1661,23 +1637,17 @@ long lsqrt (long n)
|
||||
/* s and e are integers modulo 360 (degrees), with 0 degrees
|
||||
being the rightmost extreme and degrees changing clockwise.
|
||||
cx and cy are the center in pixels; w and h are the horizontal
|
||||
and vertical diameter in pixels. Nice interface, but slow.
|
||||
See gd_arc_f_buggy.c for a better version that doesn't
|
||||
seem to be bug-free yet. */
|
||||
and vertical diameter in pixels. */
|
||||
|
||||
void gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)
|
||||
{
|
||||
if ((s % 360) == (e % 360)) {
|
||||
gdImageEllipse(im, cx, cy, w, h, color);
|
||||
} else {
|
||||
gdImageFilledArc(im, cx, cy, w, h, s, e, color, gdNoFill);
|
||||
}
|
||||
gdImageFilledArc(im, cx, cy, w, h, s, e, color, gdNoFill);
|
||||
}
|
||||
|
||||
void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style)
|
||||
{
|
||||
gdPoint pts[3];
|
||||
int i;
|
||||
gdPoint pts[363];
|
||||
int i, pti;
|
||||
int lx = 0, ly = 0;
|
||||
int fx = 0, fy = 0;
|
||||
|
||||
@@ -1705,7 +1675,7 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e
|
||||
}
|
||||
}
|
||||
|
||||
for (i = s; i <= e; i++) {
|
||||
for (i = s, pti = 1; i <= e; i++, pti++) {
|
||||
int x, y;
|
||||
x = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx;
|
||||
y = ((long) gdSinT[i % 360] * (long) h / (2 * 1024)) + cy;
|
||||
@@ -1714,19 +1684,28 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e
|
||||
if (style & gdNoFill) {
|
||||
gdImageLine(im, lx, ly, x, y, color);
|
||||
} else {
|
||||
/* This is expensive! */
|
||||
pts[0].x = lx;
|
||||
pts[0].y = ly;
|
||||
pts[1].x = x;
|
||||
pts[1].y = y;
|
||||
pts[2].x = cx;
|
||||
pts[2].y = cy;
|
||||
gdImageFilledPolygon(im, pts, 3, color);
|
||||
}
|
||||
if (y == ly) {
|
||||
pti--; /* don't add this point */
|
||||
if (((i > 270 || i < 90) && x > lx) || ((i > 90 && i < 270) && x < lx)) {
|
||||
/* replace the old x coord, if increasing on the
|
||||
right side or decreasing on the left side */
|
||||
pts[pti].x = x;
|
||||
}
|
||||
} else {
|
||||
pts[pti].x = x;
|
||||
pts[pti].y = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fx = x;
|
||||
fy = y;
|
||||
if (!(style & (gdChord | gdNoFill))) {
|
||||
pts[0].x = cx;
|
||||
pts[0].y = cy;
|
||||
pts[pti].x = x;
|
||||
pts[pti].y = y;
|
||||
}
|
||||
}
|
||||
lx = x;
|
||||
ly = y;
|
||||
@@ -1753,6 +1732,10 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e
|
||||
gdImageLine(im, cx, cy, lx, ly, color);
|
||||
gdImageLine(im, cx, cy, fx, fy, color);
|
||||
}
|
||||
} else {
|
||||
pts[pti].x = cx;
|
||||
pts[pti].y = cy;
|
||||
gdImageFilledPolygon(im, pts, pti+1, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1764,11 +1747,17 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
|
||||
int leftLimit = -1, rightLimit;
|
||||
int i, restoreAlphaBlending = 0;
|
||||
|
||||
if (border < 0) {
|
||||
if (border < 0 || color < 0) {
|
||||
/* Refuse to fill to a non-solid border */
|
||||
return;
|
||||
}
|
||||
|
||||
if (!im->trueColor) {
|
||||
if ((color > (im->colorsTotal - 1)) || (border > (im->colorsTotal - 1)) || (color < 0)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
restoreAlphaBlending = im->alphaBlendingFlag;
|
||||
im->alphaBlendingFlag = 0;
|
||||
|
||||
@@ -1880,7 +1869,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){
|
||||
@@ -1892,7 +1881,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;
|
||||
}
|
||||
|
||||
@@ -1955,7 +1944,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)
|
||||
@@ -2063,7 +2052,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;
|
||||
|
||||
@@ -2114,10 +2103,53 @@ void gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
|
||||
}
|
||||
}
|
||||
|
||||
void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
|
||||
static void _gdImageFilledHRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (x1 == x2 && y1 == y2) {
|
||||
gdImageSetPixel(im, x1, y1, color);
|
||||
return;
|
||||
}
|
||||
|
||||
if (x1 > x2) {
|
||||
x = x1;
|
||||
x1 = x2;
|
||||
x2 = x;
|
||||
}
|
||||
|
||||
if (y1 > y2) {
|
||||
y = y1;
|
||||
y1 = y2;
|
||||
y2 = y;
|
||||
}
|
||||
|
||||
if (x1 < 0) {
|
||||
x1 = 0;
|
||||
}
|
||||
|
||||
if (x2 >= gdImageSX(im)) {
|
||||
x2 = gdImageSX(im) - 1;
|
||||
}
|
||||
|
||||
if (y1 < 0) {
|
||||
y1 = 0;
|
||||
}
|
||||
|
||||
if (y2 >= gdImageSY(im)) {
|
||||
y2 = gdImageSY(im) - 1;
|
||||
}
|
||||
|
||||
for (x = x1; (x <= x2); x++) {
|
||||
for (y = y1; (y <= y2); y++) {
|
||||
gdImageSetPixel (im, x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void _gdImageFilledVRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (x1 == x2 && y1 == y2) {
|
||||
gdImageSetPixel(im, x1, y1, color);
|
||||
@@ -2159,6 +2191,11 @@ void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int
|
||||
}
|
||||
}
|
||||
|
||||
void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
|
||||
{
|
||||
_gdImageFilledVRectangle(im, x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h)
|
||||
{
|
||||
int c;
|
||||
@@ -2177,7 +2214,9 @@ void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
|
||||
for (y = 0; (y < h); y++) {
|
||||
for (x = 0; (x < w); x++) {
|
||||
int c = gdImageGetTrueColorPixel (src, srcX + x, srcY + y);
|
||||
gdImageSetPixel (dst, dstX + x, dstY + y, c);
|
||||
if (c != src->transparent) {
|
||||
gdImageSetPixel (dst, dstX + x, dstY + y, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -2194,26 +2233,6 @@ void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
|
||||
return;
|
||||
}
|
||||
|
||||
/* Destination is palette based */
|
||||
if (src->trueColor) { /* But source is truecolor (Ouch!) */
|
||||
toy = dstY;
|
||||
for (y = srcY; (y < (srcY + h)); y++) {
|
||||
tox = dstX;
|
||||
for (x = srcX; x < (srcX + w); x++) {
|
||||
int nc;
|
||||
c = gdImageGetPixel (src, x, y);
|
||||
|
||||
/* Get best match possible. */
|
||||
nc = gdImageColorResolveAlpha(dst, gdTrueColorGetRed(c), gdTrueColorGetGreen(c), gdTrueColorGetBlue(c), gdTrueColorGetAlpha(c));
|
||||
|
||||
gdImageSetPixel(dst, tox, toy, nc);
|
||||
tox++;
|
||||
}
|
||||
toy++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Palette based to palette based */
|
||||
for (i = 0; i < gdMaxColors; i++) {
|
||||
colorMap[i] = (-1);
|
||||
@@ -2265,7 +2284,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++) {
|
||||
@@ -2362,7 +2381,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;
|
||||
}
|
||||
@@ -2661,6 +2680,19 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
|
||||
maxy = p[i].y;
|
||||
}
|
||||
}
|
||||
/* necessary special case: horizontal line */
|
||||
if (n > 1 && miny == maxy) {
|
||||
x1 = x2 = p[0].x;
|
||||
for (i = 1; (i < n); i++) {
|
||||
if (p[i].x < x1) {
|
||||
x1 = p[i].x;
|
||||
} else if (p[i].x > x2) {
|
||||
x2 = p[i].x;
|
||||
}
|
||||
}
|
||||
gdImageLine(im, x1, miny, x2, miny, c);
|
||||
return;
|
||||
}
|
||||
pmaxy = maxy;
|
||||
/* 2.0.16: Optimization by Ilia Chipitsine -- don't waste time offscreen */
|
||||
if (miny < 0) {
|
||||
@@ -2907,7 +2939,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? */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -243,6 +243,10 @@ gdImagePtr gdImageCropThreshold(gdImagePtr im, const unsigned int color, const f
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!gdImageTrueColor(im) && color >= gdImageColorsTotal(im)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* TODO: Add gdImageGetRowPtr and works with ptr at the row level
|
||||
* for the true color and palette images
|
||||
* new formats will simply work with ptr
|
||||
|
||||
+21
-8
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -178,21 +191,21 @@ static gdImagePtr _gd2CreateFromFile (gdIOCtxPtr in, int *sx, int *sy, int *cs,
|
||||
}
|
||||
if (im == NULL) {
|
||||
GD2_DBG(php_gd_error("Could not create gdImage"));
|
||||
goto fail1;
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
if (!_gdGetColors(in, im, (*vers) == 2)) {
|
||||
GD2_DBG(php_gd_error("Could not read color palette"));
|
||||
goto fail2;
|
||||
goto fail3;
|
||||
}
|
||||
GD2_DBG(php_gd_error("Image palette completed: %d colours", im->colorsTotal));
|
||||
|
||||
return im;
|
||||
|
||||
fail2:
|
||||
fail3:
|
||||
gdImageDestroy(im);
|
||||
return 0;
|
||||
|
||||
fail2:
|
||||
gdFree(*cidx);
|
||||
fail1:
|
||||
return 0;
|
||||
}
|
||||
@@ -657,7 +670,7 @@ static void _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt)
|
||||
|
||||
/* Force fmt to a valid value since we don't return anything. */
|
||||
if ((fmt != GD2_FMT_RAW) && (fmt != GD2_FMT_COMPRESSED)) {
|
||||
fmt = im->trueColor ? GD2_FMT_TRUECOLOR_COMPRESSED : GD2_FMT_COMPRESSED;
|
||||
fmt = GD2_FMT_COMPRESSED;
|
||||
}
|
||||
if (im->trueColor) {
|
||||
fmt += 2;
|
||||
@@ -676,8 +689,8 @@ static void _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt)
|
||||
}
|
||||
|
||||
/* Work out number of chunks. */
|
||||
ncx = im->sx / cs + 1;
|
||||
ncy = im->sy / cs + 1;
|
||||
ncx = (im->sx + cs - 1) / cs;
|
||||
ncy = (im->sy + cs - 1) / cs;
|
||||
|
||||
/* Write the standard header. */
|
||||
_gd2PutHeader (im, out, cs, fmt, ncx, ncy);
|
||||
|
||||
@@ -601,14 +601,26 @@ nomatch:
|
||||
* code in turn. When the buffer fills up empty it and start over.
|
||||
*/
|
||||
|
||||
static unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F,
|
||||
static const unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F,
|
||||
0x001F, 0x003F, 0x007F, 0x00FF,
|
||||
0x01FF, 0x03FF, 0x07FF, 0x0FFF,
|
||||
0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
|
||||
|
||||
|
||||
/* Arbitrary value to mark output is done. When we see EOFCode, then we don't
|
||||
* expect to see any more data. If we do (e.g. corrupt image inputs), cur_bits
|
||||
* might be negative, so flag it to return early.
|
||||
*/
|
||||
#define CUR_BITS_FINISHED -1000
|
||||
|
||||
|
||||
static void
|
||||
output(code_int code, GifCtx *ctx)
|
||||
{
|
||||
if (ctx->cur_bits == CUR_BITS_FINISHED) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->cur_accum &= masks[ ctx->cur_bits ];
|
||||
|
||||
if( ctx->cur_bits > 0 )
|
||||
@@ -655,8 +667,10 @@ output(code_int code, GifCtx *ctx)
|
||||
ctx->cur_bits -= 8;
|
||||
}
|
||||
|
||||
flush_char(ctx);
|
||||
/* Flag that it's done to prevent re-entry. */
|
||||
ctx->cur_bits = CUR_BITS_FINISHED;
|
||||
|
||||
flush_char(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+135
-89
@@ -41,8 +41,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.
|
||||
*/
|
||||
@@ -635,7 +635,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];
|
||||
@@ -879,20 +879,42 @@ int getPixelInterpolated(gdImagePtr im, const double x, const double y, const in
|
||||
static inline LineContribType * _gdContributionsAlloc(unsigned int line_length, unsigned int windows_size)
|
||||
{
|
||||
unsigned int u = 0;
|
||||
LineContribType *res;
|
||||
LineContribType *res;
|
||||
int overflow_error = 0;
|
||||
|
||||
res = (LineContribType *) gdMalloc(sizeof(LineContribType));
|
||||
if (!res) {
|
||||
return NULL;
|
||||
}
|
||||
res->WindowSize = windows_size;
|
||||
res->LineLength = line_length;
|
||||
res->ContribRow = (ContributionType *) gdMalloc(line_length * sizeof(ContributionType));
|
||||
|
||||
for (u = 0 ; u < line_length ; u++) {
|
||||
res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double));
|
||||
}
|
||||
return res;
|
||||
res->WindowSize = windows_size;
|
||||
res->LineLength = line_length;
|
||||
if (overflow2(line_length, sizeof(ContributionType))) {
|
||||
gdFree(res);
|
||||
return NULL;
|
||||
}
|
||||
res->ContribRow = (ContributionType *) gdMalloc(line_length * sizeof(ContributionType));
|
||||
if (res->ContribRow == NULL) {
|
||||
gdFree(res);
|
||||
return NULL;
|
||||
}
|
||||
for (u = 0 ; u < line_length ; u++) {
|
||||
if (overflow2(windows_size, sizeof(double))) {
|
||||
overflow_error = 1;
|
||||
} else {
|
||||
res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double));
|
||||
}
|
||||
if (overflow_error == 1 || res->ContribRow[u].Weights == NULL) {
|
||||
unsigned int i;
|
||||
u--;
|
||||
for (i=0;i<=u;i++) {
|
||||
gdFree(res->ContribRow[i].Weights);
|
||||
}
|
||||
gdFree(res->ContribRow);
|
||||
gdFree(res);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline void _gdContributionsFree(LineContribType * p)
|
||||
@@ -907,59 +929,62 @@ static inline void _gdContributionsFree(LineContribType * p)
|
||||
|
||||
static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsigned int src_size, double scale_d, const interpolation_method pFilter)
|
||||
{
|
||||
double width_d;
|
||||
double scale_f_d = 1.0;
|
||||
const double filter_width_d = DEFAULT_BOX_RADIUS;
|
||||
double width_d;
|
||||
double scale_f_d = 1.0;
|
||||
const double filter_width_d = DEFAULT_BOX_RADIUS;
|
||||
int windows_size;
|
||||
unsigned int u;
|
||||
LineContribType *res;
|
||||
int overflow_error = 0;
|
||||
|
||||
if (scale_d < 1.0) {
|
||||
width_d = filter_width_d / scale_d;
|
||||
scale_f_d = scale_d;
|
||||
} else {
|
||||
width_d= filter_width_d;
|
||||
}
|
||||
if (scale_d < 1.0) {
|
||||
width_d = filter_width_d / scale_d;
|
||||
scale_f_d = scale_d;
|
||||
} else {
|
||||
width_d= filter_width_d;
|
||||
}
|
||||
|
||||
windows_size = 2 * (int)ceil(width_d) + 1;
|
||||
res = _gdContributionsAlloc(line_size, windows_size);
|
||||
|
||||
for (u = 0; u < line_size; u++) {
|
||||
const double dCenter = (double)u / scale_d;
|
||||
/* get the significant edge points affecting the pixel */
|
||||
register int iLeft = MAX(0, (int)floor (dCenter - width_d));
|
||||
int iRight = MIN((int)ceil(dCenter + width_d), (int)src_size - 1);
|
||||
double dTotalWeight = 0.0;
|
||||
windows_size = 2 * (int)ceil(width_d) + 1;
|
||||
res = _gdContributionsAlloc(line_size, windows_size);
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (u = 0; u < line_size; u++) {
|
||||
const double dCenter = (double)u / scale_d;
|
||||
/* get the significant edge points affecting the pixel */
|
||||
register int iLeft = MAX(0, (int)floor (dCenter - width_d));
|
||||
int iRight = MIN((int)ceil(dCenter + width_d), (int)src_size - 1);
|
||||
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)) {
|
||||
iLeft++;
|
||||
} else {
|
||||
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)) {
|
||||
iLeft++;
|
||||
} else {
|
||||
iRight--;
|
||||
}
|
||||
}
|
||||
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)));
|
||||
}
|
||||
for (iSrc = iLeft; iSrc <= iRight; iSrc++) {
|
||||
dTotalWeight += (res->ContribRow[u].Weights[iSrc-iLeft] = scale_f_d * (*pFilter)(scale_f_d * (dCenter - (double)iSrc)));
|
||||
}
|
||||
|
||||
if (dTotalWeight < 0.0) {
|
||||
_gdContributionsFree(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dTotalWeight > 0.0) {
|
||||
for (iSrc = iLeft; iSrc <= iRight; iSrc++) {
|
||||
res->ContribRow[u].Weights[iSrc-iLeft] /= dTotalWeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
if (dTotalWeight > 0.0) {
|
||||
for (iSrc = iLeft; iSrc <= iRight; iSrc++) {
|
||||
res->ContribRow[u].Weights[iSrc-iLeft] /= dTotalWeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline void _gdScaleRow(gdImagePtr pSrc, unsigned int src_width, gdImagePtr dst, unsigned int dst_width, unsigned int row, LineContribType *contrib)
|
||||
@@ -1047,6 +1072,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);
|
||||
@@ -1059,6 +1087,10 @@ gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_widt
|
||||
gdImagePtr tmp_im;
|
||||
gdImagePtr dst;
|
||||
|
||||
if (new_width == 0 || new_height == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Convert to truecolor if it isn't; this code requires it. */
|
||||
if (!src->trueColor) {
|
||||
gdImagePaletteToTrueColor(src);
|
||||
@@ -1087,6 +1119,10 @@ gdImagePtr Scale(const gdImagePtr src, const unsigned int src_width, const unsig
|
||||
{
|
||||
gdImagePtr tmp_im;
|
||||
|
||||
if (new_width == 0 || new_height == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmp_im = gdImageCreateTrueColor(new_width, src_height);
|
||||
if (tmp_im == NULL) {
|
||||
return NULL;
|
||||
@@ -1096,7 +1132,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;
|
||||
}
|
||||
|
||||
@@ -1120,6 +1156,10 @@ gdImagePtr gdImageScaleNearestNeighbour(gdImagePtr im, const unsigned int width,
|
||||
unsigned long dst_offset_y = 0;
|
||||
unsigned int i;
|
||||
|
||||
if (new_width == 0 || new_height == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dst_img = gdImageCreateTrueColor(new_width, new_height);
|
||||
|
||||
if (dst_img == NULL) {
|
||||
@@ -1221,11 +1261,21 @@ static gdImagePtr gdImageScaleBilinearPalette(gdImagePtr im, const unsigned int
|
||||
gdImagePtr new_img;
|
||||
const int transparent = im->transparent;
|
||||
|
||||
if (new_width == 0 || new_height == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_img = gdImageCreateTrueColor(new_width, new_height);
|
||||
if (new_img == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
new_img->transparent = gdTrueColorAlpha(im->red[transparent], im->green[transparent], im->blue[transparent], im->alpha[transparent]);
|
||||
|
||||
if (transparent < 0) {
|
||||
/* uninitialized */
|
||||
new_img->transparent = -1;
|
||||
} else {
|
||||
new_img->transparent = gdTrueColorAlpha(im->red[transparent], im->green[transparent], im->blue[transparent], im->alpha[transparent]);
|
||||
}
|
||||
|
||||
for (i=0; i < _height; i++) {
|
||||
long j;
|
||||
@@ -1281,10 +1331,10 @@ static gdImagePtr gdImageScaleBilinearPalette(gdImagePtr im, const unsigned int
|
||||
f_a4 = gd_itofx(gdTrueColorGetAlpha(pixel4));
|
||||
|
||||
{
|
||||
const char red = (char) gd_fxtoi(gd_mulfx(f_w1, f_r1) + gd_mulfx(f_w2, f_r2) + gd_mulfx(f_w3, f_r3) + gd_mulfx(f_w4, f_r4));
|
||||
const char green = (char) gd_fxtoi(gd_mulfx(f_w1, f_g1) + gd_mulfx(f_w2, f_g2) + gd_mulfx(f_w3, f_g3) + gd_mulfx(f_w4, f_g4));
|
||||
const char blue = (char) gd_fxtoi(gd_mulfx(f_w1, f_b1) + gd_mulfx(f_w2, f_b2) + gd_mulfx(f_w3, f_b3) + gd_mulfx(f_w4, f_b4));
|
||||
const char alpha = (char) gd_fxtoi(gd_mulfx(f_w1, f_a1) + gd_mulfx(f_w2, f_a2) + gd_mulfx(f_w3, f_a3) + gd_mulfx(f_w4, f_a4));
|
||||
const unsigned char red = (unsigned char) gd_fxtoi(gd_mulfx(f_w1, f_r1) + gd_mulfx(f_w2, f_r2) + gd_mulfx(f_w3, f_r3) + gd_mulfx(f_w4, f_r4));
|
||||
const unsigned char green = (unsigned char) gd_fxtoi(gd_mulfx(f_w1, f_g1) + gd_mulfx(f_w2, f_g2) + gd_mulfx(f_w3, f_g3) + gd_mulfx(f_w4, f_g4));
|
||||
const unsigned char blue = (unsigned char) gd_fxtoi(gd_mulfx(f_w1, f_b1) + gd_mulfx(f_w2, f_b2) + gd_mulfx(f_w3, f_b3) + gd_mulfx(f_w4, f_b4));
|
||||
const unsigned char alpha = (unsigned char) gd_fxtoi(gd_mulfx(f_w1, f_a1) + gd_mulfx(f_w2, f_a2) + gd_mulfx(f_w3, f_a3) + gd_mulfx(f_w4, f_a4));
|
||||
|
||||
new_img->tpixels[dst_offset_v][dst_offset_h] = gdTrueColorAlpha(red, green, blue, alpha);
|
||||
}
|
||||
@@ -1313,6 +1363,10 @@ static gdImagePtr gdImageScaleBilinearTC(gdImagePtr im, const unsigned int new_w
|
||||
long i;
|
||||
gdImagePtr new_img;
|
||||
|
||||
if (new_width == 0 || new_height == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_img = gdImageCreateTrueColor(new_width, new_height);
|
||||
if (!new_img){
|
||||
return NULL;
|
||||
@@ -1412,6 +1466,10 @@ gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src, const unsigned int width, co
|
||||
unsigned int dst_offset_y = 0;
|
||||
long i;
|
||||
|
||||
if (new_width == 0 || new_height == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* impact perf a bit, but not that much. Implementation for palette
|
||||
images can be done at a later point.
|
||||
*/
|
||||
@@ -1451,13 +1509,8 @@ gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src, const unsigned int width, co
|
||||
src_offset_y[0] = m;
|
||||
}
|
||||
|
||||
if (m < 1) {
|
||||
src_offset_x[1] = n;
|
||||
src_offset_y[1] = m;
|
||||
} else {
|
||||
src_offset_x[1] = n;
|
||||
src_offset_y[1] = m;
|
||||
}
|
||||
src_offset_x[1] = n;
|
||||
src_offset_y[1] = m;
|
||||
|
||||
if ((m < 1) || (n >= src_w - 1)) {
|
||||
src_offset_x[2] = n;
|
||||
@@ -1509,13 +1562,8 @@ gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src, const unsigned int width, co
|
||||
src_offset_y[8] = m;
|
||||
}
|
||||
|
||||
if (m >= src_h - 1) {
|
||||
src_offset_x[8] = n;
|
||||
src_offset_y[8] = m;
|
||||
} else {
|
||||
src_offset_x[9] = n;
|
||||
src_offset_y[9] = m;
|
||||
}
|
||||
src_offset_x[9] = n;
|
||||
src_offset_y[9] = m;
|
||||
|
||||
if ((m >= src_h-1) || (n >= src_w-1)) {
|
||||
src_offset_x[10] = n;
|
||||
@@ -1541,13 +1589,8 @@ gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src, const unsigned int width, co
|
||||
src_offset_y[12] = m;
|
||||
}
|
||||
|
||||
if (m >= src_h - 2) {
|
||||
src_offset_x[13] = n;
|
||||
src_offset_y[13] = m;
|
||||
} else {
|
||||
src_offset_x[13] = n;
|
||||
src_offset_y[13] = m;
|
||||
}
|
||||
src_offset_x[13] = n;
|
||||
src_offset_y[13] = m;
|
||||
|
||||
if ((m >= src_h - 2) || (n >= src_w - 1)) {
|
||||
src_offset_x[14] = n;
|
||||
@@ -1634,7 +1677,11 @@ gdImagePtr gdImageScale(const gdImagePtr src, const unsigned int new_width, cons
|
||||
gdImagePtr im_scaled = NULL;
|
||||
|
||||
if (src == NULL || src->interpolation_id < 0 || src->interpolation_id > GD_METHOD_COUNT) {
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (new_width == 0 || new_height == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (src->interpolation_id) {
|
||||
@@ -1680,6 +1727,10 @@ gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees, co
|
||||
unsigned int i;
|
||||
gdImagePtr dst;
|
||||
|
||||
if (new_width == 0 || new_height == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dst = gdImageCreateTrueColor(new_width, new_height);
|
||||
if (!dst) {
|
||||
return NULL;
|
||||
@@ -1948,13 +1999,8 @@ gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees, const
|
||||
src_offset_y[0] = m;
|
||||
}
|
||||
|
||||
if (m < 1) {
|
||||
src_offset_x[1] = n;
|
||||
src_offset_y[1] = m;
|
||||
} else {
|
||||
src_offset_x[1] = n;
|
||||
src_offset_y[1] = m ;
|
||||
}
|
||||
src_offset_x[1] = n;
|
||||
src_offset_y[1] = m;
|
||||
|
||||
if ((m < 1) || (n >= src_w-1)) {
|
||||
src_offset_x[2] = - 1;
|
||||
@@ -2007,8 +2053,8 @@ gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees, const
|
||||
}
|
||||
|
||||
if (m >= src_h-1) {
|
||||
src_offset_x[8] = - 1;
|
||||
src_offset_y[8] = - 1;
|
||||
src_offset_x[9] = - 1;
|
||||
src_offset_y[9] = - 1;
|
||||
} else {
|
||||
src_offset_x[9] = n;
|
||||
src_offset_y[9] = m;
|
||||
@@ -2284,7 +2330,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);
|
||||
@@ -2343,7 +2389,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);
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 512 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user