summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Fuhrmannek2021-08-08 12:44:13 +0200
committerBen Fuhrmannek2021-08-08 12:44:13 +0200
commitecbc2bba7ba2d1c0c766dd16195ee88edbe550a8 (patch)
tree88a1caa56a709066cdb38759a265a5b4bc593bb8
parentf41303ebed6f5de3a264ba5c70851d4da215061c (diff)
more PHP 7 compatibility and license clarification
-rw-r--r--PHP_LICENSE68
-rw-r--r--doc/source/faq.rst6
-rw-r--r--src/sp_php_compat.c3
-rw-r--r--src/sp_php_compat.h93
4 files changed, 162 insertions, 8 deletions
diff --git a/PHP_LICENSE b/PHP_LICENSE
new file mode 100644
index 0000000..4076fe9
--- /dev/null
+++ b/PHP_LICENSE
@@ -0,0 +1,68 @@
1--------------------------------------------------------------------
2 The PHP License, version 3.01
3Copyright (c) 1999 - 2019 The PHP Group. All rights reserved.
4--------------------------------------------------------------------
5
6Redistribution and use in source and binary forms, with or without
7modification, is permitted provided that the following conditions
8are met:
9
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in
15 the documentation and/or other materials provided with the
16 distribution.
17
18 3. The name "PHP" must not be used to endorse or promote products
19 derived from this software without prior written permission. For
20 written permission, please contact group@php.net.
21
22 4. Products derived from this software may not be called "PHP", nor
23 may "PHP" appear in their name, without prior written permission
24 from group@php.net. You may indicate that your software works in
25 conjunction with PHP by saying "Foo for PHP" instead of calling
26 it "PHP Foo" or "phpfoo"
27
28 5. The PHP Group may publish revised and/or new versions of the
29 license from time to time. Each version will be given a
30 distinguishing version number.
31 Once covered code has been published under a particular version
32 of the license, you may always continue to use it under the terms
33 of that version. You may also choose to use such covered code
34 under the terms of any subsequent version of the license
35 published by the PHP Group. No one other than the PHP Group has
36 the right to modify the terms applicable to covered code created
37 under this License.
38
39 6. Redistributions of any form whatsoever must retain the following
40 acknowledgment:
41 "This product includes PHP software, freely available from
42 <http://www.php.net/software/>".
43
44THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
45ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
46THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
47PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
48DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
49INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55OF THE POSSIBILITY OF SUCH DAMAGE.
56
57--------------------------------------------------------------------
58
59This software consists of voluntary contributions made by many
60individuals on behalf of the PHP Group.
61
62The PHP Group can be contacted via Email at group@php.net.
63
64For more information on the PHP Group and the PHP project,
65please see <http://www.php.net>.
66
67PHP includes the Zend Engine, freely available at
68<http://www.zend.com>.
diff --git a/doc/source/faq.rst b/doc/source/faq.rst
index bdfc7c1..57b910d 100644
--- a/doc/source/faq.rst
+++ b/doc/source/faq.rst
@@ -79,6 +79,12 @@ We chose the LGPL because we don't care that much how you're using Snuffleupagus
79but we'd like to force people to make their improvements/contributions 79but we'd like to force people to make their improvements/contributions
80available to everyone. 80available to everyone.
81 81
82The complete license text is shipped with the sources and can be found under ``LICENSE``.
83
84For compatibility with older PHP versions, some original PHP source code was copied or ported back to older versions.
85This source code resides in ``src/sp_php_compat.c`` and ``src/sp_php_compat.h`` and retains its original license
86`The PHP License, version 3.01 <https://www.php.net/license/3_01.txt>`, also included with the sources as ``PHP_LICENSE``.
87
82 88
83What is the different between SNuffleupaugs and a (WAF) like ModSecurity? 89What is the different between SNuffleupaugs and a (WAF) like ModSecurity?
84""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 90"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
diff --git a/src/sp_php_compat.c b/src/sp_php_compat.c
index 933acd8..cd7c3e7 100644
--- a/src/sp_php_compat.c
+++ b/src/sp_php_compat.c
@@ -2,8 +2,7 @@
2 2
3#if PHP_VERSION_ID < 80000 3#if PHP_VERSION_ID < 80000
4 4
5// zend_string_concat2 taken from PHP 8.0.9 zend_string.c 5// copied from PHP 8.0.9 sources
6// TODO: license clarification
7 6
8ZEND_API zend_string *zend_string_concat2( 7ZEND_API zend_string *zend_string_concat2(
9 const char *str1, size_t str1_len, 8 const char *str1, size_t str1_len,
diff --git a/src/sp_php_compat.h b/src/sp_php_compat.h
index 380abe4..992c3e2 100644
--- a/src/sp_php_compat.h
+++ b/src/sp_php_compat.h
@@ -1,12 +1,93 @@
1#if PHP_VERSION_ID < 80000 1#if PHP_VERSION_ID < 80000
2
3// copied from PHP 8.0.9 sources
2ZEND_API zend_string *zend_string_concat2( 4ZEND_API zend_string *zend_string_concat2(
3 const char *str1, size_t str1_len, 5 const char *str1, size_t str1_len,
4 const char *str2, size_t str2_len); 6 const char *str2, size_t str2_len);
5 7
6#define ZEND_HASH_REVERSE_FOREACH_KEY_PTR(ht, _h, _key, _ptr) \ 8#define ZEND_HASH_REVERSE_FOREACH_KEY_PTR(ht, _h, _key, _ptr) \
7 ZEND_HASH_REVERSE_FOREACH(ht, 0); \ 9 ZEND_HASH_REVERSE_FOREACH(ht, 0); \
8 _h = _p->h; \ 10 _h = _p->h; \
9 _key = _p->key; \ 11 _key = _p->key; \
10 _ptr = Z_PTR_P(_z); 12 _ptr = Z_PTR_P(_z);
13
14#endif
15
16#if PHP_VERSION_ID < 70300
17
18// copied from PHP 7.4.22 sources
19
20static zend_always_inline uint32_t zend_gc_delref(zend_refcounted_h *p) {
21 ZEND_ASSERT(p->refcount > 0);
22 // ZEND_RC_MOD_CHECK(p);
23 return --(p->refcount);
24}
25#define GC_DELREF(p) zend_gc_delref(&(p)->gc)
26
27static zend_always_inline void zend_string_release_ex(zend_string *s, int persistent)
28{
29 if (!ZSTR_IS_INTERNED(s)) {
30 if (GC_DELREF(s) == 0) {
31 if (persistent) {
32 ZEND_ASSERT(GC_FLAGS(s) & IS_STR_PERSISTENT);
33 free(s);
34 } else {
35 ZEND_ASSERT(!(GC_FLAGS(s) & IS_STR_PERSISTENT));
36 efree(s);
37 }
38 }
39 }
40}
41
42static zend_always_inline void zend_string_efree(zend_string *s)
43{
44 ZEND_ASSERT(!ZSTR_IS_INTERNED(s));
45 ZEND_ASSERT(GC_REFCOUNT(s) <= 1);
46 ZEND_ASSERT(!(GC_FLAGS(s) & IS_STR_PERSISTENT));
47 efree(s);
48}
49
50#endif
51
52#if PHP_VERSION_ID < 70200
53
54#undef ZEND_HASH_REVERSE_FOREACH
55
56// copied from PHP 7.4.22 sources
57
58#define ZEND_HASH_REVERSE_FOREACH(_ht, indirect) do { \
59 HashTable *__ht = (_ht); \
60 uint32_t _idx = __ht->nNumUsed; \
61 Bucket *_p = __ht->arData + _idx; \
62 zval *_z; \
63 for (_idx = __ht->nNumUsed; _idx > 0; _idx--) { \
64 _p--; \
65 _z = &_p->val; \
66 if (indirect && Z_TYPE_P(_z) == IS_INDIRECT) { \
67 _z = Z_INDIRECT_P(_z); \
68 } \
69 if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
70
71
72#define ZEND_HASH_FOREACH_END_DEL() \
73 __ht->nNumOfElements--; \
74 do { \
75 uint32_t j = HT_IDX_TO_HASH(_idx - 1); \
76 uint32_t nIndex = _p->h | __ht->nTableMask; \
77 uint32_t i = HT_HASH(__ht, nIndex); \
78 if (UNEXPECTED(j != i)) { \
79 Bucket *prev = HT_HASH_TO_BUCKET(__ht, i); \
80 while (Z_NEXT(prev->val) != j) { \
81 i = Z_NEXT(prev->val); \
82 prev = HT_HASH_TO_BUCKET(__ht, i); \
83 } \
84 Z_NEXT(prev->val) = Z_NEXT(_p->val); \
85 } else { \
86 HT_HASH(__ht, nIndex) = Z_NEXT(_p->val); \
87 } \
88 } while (0); \
89 } \
90 __ht->nNumUsed = _idx; \
91 } while (0)
11 92
12#endif \ No newline at end of file 93#endif \ No newline at end of file