summaryrefslogtreecommitdiffstats
path: root/env-pr10.patch
blob: 055937c9b382c3504495cd46fdd9e68f25b106d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
From cf3d85f354489a39c96823332c797af45a4e781f Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 22 Sep 2020 15:01:31 +0200
Subject: [PATCH 1/4] trivial fix for PHP 8

---
 env.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/env.h b/env.h
index 85059ef..b0a67be 100644
--- a/env.h
+++ b/env.h
@@ -1,5 +1,11 @@
 #ifndef ENV_H
 #define ENV_H
+
+#ifndef TSRMLS_CC
+#define TSRMLS_CC
+#define TSRMLS_DC
+#endif
+
 void php_env_module_init(HashTable *vars TSRMLS_DC);
 void php_env_request_init(HashTable *vars TSRMLS_DC);
 #endif

From cc660bfe4d0f5bb315e776892ceee500637e5262 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Thu, 1 Dec 2016 17:40:42 +0100
Subject: [PATCH 2/4] fix segfault with 7.1.0, fix #7

---
 php7/php_env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/php7/php_env.c b/php7/php_env.c
index 22c19b4..b891ba7 100644
--- a/php7/php_env.c
+++ b/php7/php_env.c
@@ -37,7 +37,7 @@ void php_env_module_init(HashTable *vars TSRMLS_DC) {
 				fh.filename = ENV_G(file);
 				fh.type = ZEND_HANDLE_FP;
 
-				if (zend_parse_ini_file(&fh, 0, 0 /* ZEND_INI_SCANNER_NORMAL */,
+				if (zend_parse_ini_file(&fh, 1, 0 /* ZEND_INI_SCANNER_NORMAL */,
 							php_env_ini_parser_cb, vars) == FAILURE || ENV_G(parse_err)) {
 					if (ENV_G(parse_err)) {
 						php_error(E_WARNING, "env: parsing '%s' failed", ENV_G(file));

From b03a18682a939e241e756a5bb86c41bde8ec99f1 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 19 Feb 2020 09:38:24 +0100
Subject: [PATCH 3/4] fix multiple definition of 'env_globals'

---
 php5/php_env.c | 2 --
 php7/php_env.c | 2 --
 php_env.h      | 2 ++
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/php5/php_env.c b/php5/php_env.c
index 62a231a..a1381df 100644
--- a/php5/php_env.c
+++ b/php5/php_env.c
@@ -2,8 +2,6 @@
 #include "../php_env.h"
 #include "../env.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(env)
-
 static void php_env_ini_parser_cb(zval *key, zval *value, zval *index, int callback_type, HashTable *ht) /* {{{ */ {
 	zval *rv;
 	char *str;
diff --git a/php7/php_env.c b/php7/php_env.c
index b891ba7..b1fa628 100644
--- a/php7/php_env.c
+++ b/php7/php_env.c
@@ -2,8 +2,6 @@
 #include "../php_env.h"
 #include "../env.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(env)
-
 static void php_env_ini_parser_cb(zval *key, zval *value, zval *index, int callback_type, void *arg) /* {{{ */ {
 	HashTable *ht = (HashTable*)arg;
 	char *str;
diff --git a/php_env.h b/php_env.h
index de91d42..8455854 100644
--- a/php_env.h
+++ b/php_env.h
@@ -44,6 +44,8 @@ ZEND_BEGIN_MODULE_GLOBALS(env)
 	int parse_err;
 ZEND_END_MODULE_GLOBALS(env)
 
+ZEND_EXTERN_MODULE_GLOBALS(env)
+
 #ifdef ZTS
 #define ENV_G(v) TSRMG(env_globals_id, zend_env_globals *, v)
 #else

From f66fbcf635f7f258c32ab9d103ac44906093989d Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 1 Oct 2024 08:05:46 +0200
Subject: [PATCH 4/4] fix for 8.1

---
 env.c          |  3 ---
 php7/php_env.c | 12 ++++++++----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/env.c b/env.c
index 9263445..6ef73d7 100644
--- a/env.c
+++ b/env.c
@@ -30,9 +30,6 @@
 
 ZEND_DECLARE_MODULE_GLOBALS(env)
 
-/* True global resources - no need for thread safety here */
-static int le_env;
-
 /* {{{ PHP_INI
  */
 PHP_INI_BEGIN()
diff --git a/php7/php_env.c b/php7/php_env.c
index b1fa628..c9956f7 100644
--- a/php7/php_env.c
+++ b/php7/php_env.c
@@ -23,16 +23,17 @@ static void php_env_ini_parser_cb(zval *key, zval *value, zval *index, int callb
 }
 
 void php_env_module_init(HashTable *vars TSRMLS_DC) {
-	int ndir = 255;
-	uint32_t i;
-	unsigned char c;
 	struct zend_stat sb;
 	zend_file_handle fh = {0};
 
 	if (ENV_G(file) != NULL && strlen(ENV_G(file)) > 0 && VCWD_STAT(ENV_G(file), &sb) == 0) {
 		if (S_ISREG(sb.st_mode)) {
 			if ((fh.handle.fp = VCWD_FOPEN(ENV_G(file), "r"))) {
+#if PHP_VERSION_ID >= 80100
+				fh.filename = zend_string_init(ENV_G(file), strlen(ENV_G(file)), 0);
+#else
 				fh.filename = ENV_G(file);
+#endif
 				fh.type = ZEND_HANDLE_FP;
 
 				if (zend_parse_ini_file(&fh, 1, 0 /* ZEND_INI_SCANNER_NORMAL */,
@@ -43,6 +44,9 @@ void php_env_module_init(HashTable *vars TSRMLS_DC) {
 
 					ENV_G(parse_err) = 0;
 				}
+#if PHP_VERSION_ID >= 80100
+				zend_string_release(fh.filename);
+#endif
 			}
 		}
 	}
@@ -51,11 +55,11 @@ void php_env_module_init(HashTable *vars TSRMLS_DC) {
 void php_env_request_init(HashTable *vars TSRMLS_DC)
 {
 	zend_string *str;
-	uint   len;
 	ulong  idx;
 	zval *val;
 
 	ZEND_HASH_FOREACH_KEY_VAL(vars, idx, str, val) {
+		(void)idx;
 		if (str) {
 			setenv(ZSTR_VAL(str), Z_PTR_P(val), 1);
 		}