summaryrefslogtreecommitdiffstats
path: root/vld-git.patch
blob: 1ab9a5e6f9d882ee7a7adf980e57ec116f15f202 (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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
From 28c5d156fe21dd9e3ddcd318b0bf7dd3b387a28a Mon Sep 17 00:00:00 2001
From: Derick Rethans <github@derickrethans.nl>
Date: Sat, 8 Mar 2014 20:43:18 +0000
Subject: [PATCH] Adding missing PHP 5.6 opcodes.

---
 srm_oparray.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/srm_oparray.c b/srm_oparray.c
index 81a872c..28b868b 100644
--- a/srm_oparray.c
+++ b/srm_oparray.c
@@ -232,6 +232,9 @@
 	/*  161 */	{ "GENERATOR_RETURN", NONE_USED },
 	/*  162 */	{ "FAST_CALL", OP1_USED },
 	/*  163 */	{ "FAST_RET", NONE_USED },
+	/*  164 */	{ "ZEND_RECV_VARIADIC", ALL_USED },
+	/*  165 */	{ "POW", ALL_USED },
+	/*  166 */	{ "POW_ASSIGN", ALL_USED | EXT_VAL },
 #endif
 };
 
-- 
1.8.5.5

From b116904efc9399a1fcf3933efeba12b556dde593 Mon Sep 17 00:00:00 2001
From: Derick Rethans <github@derickrethans.nl>
Date: Tue, 22 Oct 2013 09:58:31 +0100
Subject: [PATCH] Fixed license headers in files.

---
 CREDITS       |  4 ++--
 LICENSE       | 23 +++++++++++++++++++++++
 branchinfo.c  | 14 ++++----------
 branchinfo.h  | 14 ++++----------
 php_vld.h     | 14 ++++----------
 set.c         | 14 ++++----------
 set.h         | 14 ++++----------
 srm_oparray.c | 14 ++++----------
 srm_oparray.h | 14 ++++----------
 vld.c         | 14 ++++----------
 10 files changed, 57 insertions(+), 82 deletions(-)
 create mode 100644 LICENSE

diff --git a/CREDITS b/CREDITS
index 86e26f2..70c997b 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1,2 +1,2 @@
-vle
-Marcus Börger, Derick Rethans, Andrei Zmievski
+vld
+Marcus Börger, Derick Rethans, Andrei Zmievski and others
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..14dbb68
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,23 @@
+Copyright (c) 2002-2013, Derick Rethans
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/branchinfo.c b/branchinfo.c
index d8379af..1702899 100644
--- a/branchinfo.c
+++ b/branchinfo.c
@@ -1,16 +1,10 @@
 /*
    +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
+   | Copyright (c) 1997-2013 Derick Rethans                               |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
+   | This source file is subject to the 2-Clause BSD license which is     |
+   | available through the LICENSE file, or online at                     |
+   | http://opensource.org/licenses/bsd-license.php                       |
    +----------------------------------------------------------------------+
    | Authors:  Derick Rethans <derick@derickrethans.nl>                   |
    +----------------------------------------------------------------------+
diff --git a/branchinfo.h b/branchinfo.h
index 0d1e020..27b4f42 100644
--- a/branchinfo.h
+++ b/branchinfo.h
@@ -1,16 +1,10 @@
 /*
    +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
+   | Copyright (c) 1997-2013 Derick Rethans                               |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
+   | This source file is subject to the 2-Clause BSD license which is     |
+   | available through the LICENSE file, or online at                     |
+   | http://opensource.org/licenses/bsd-license.php                       |
    +----------------------------------------------------------------------+
    | Authors:  Derick Rethans <derick@derickrethans.nl>                   |
    +----------------------------------------------------------------------+
diff --git a/php_vld.h b/php_vld.h
index b9d4a34..85ae8f1 100644
--- a/php_vld.h
+++ b/php_vld.h
@@ -1,16 +1,10 @@
 /*
    +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
+   | Copyright (c) 1997-2013 Derick Rethans                               |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
+   | This source file is subject to the 2-Clause BSD license which is     |
+   | available through the LICENSE file, or online at                     |
+   | http://opensource.org/licenses/bsd-license.php                       |
    +----------------------------------------------------------------------+
    | Authors:  Derick Rethans <derick@derickrethans.nl>                   |
    +----------------------------------------------------------------------+
diff --git a/set.c b/set.c
index 595900b..80917ce 100644
--- a/set.c
+++ b/set.c
@@ -1,16 +1,10 @@
 /*
    +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
+   | Copyright (c) 1997-2013 Derick Rethans                               |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
+   | This source file is subject to the 2-Clause BSD license which is     |
+   | available through the LICENSE file, or online at                     |
+   | http://opensource.org/licenses/bsd-license.php                       |
    +----------------------------------------------------------------------+
    | Authors:  Derick Rethans <derick@derickrethans.nl>                   |
    +----------------------------------------------------------------------+
diff --git a/set.h b/set.h
index 01c94c4..6bfaf7c 100644
--- a/set.h
+++ b/set.h
@@ -1,16 +1,10 @@
 /*
    +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
+   | Copyright (c) 1997-2013 Derick Rethans                               |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
+   | This source file is subject to the 2-Clause BSD license which is     |
+   | available through the LICENSE file, or online at                     |
+   | http://opensource.org/licenses/bsd-license.php                       |
    +----------------------------------------------------------------------+
    | Authors:  Derick Rethans <derick@derickrethans.nl>                   |
    +----------------------------------------------------------------------+
diff --git a/srm_oparray.c b/srm_oparray.c
index c1f2ee2..bce534b 100644
--- a/srm_oparray.c
+++ b/srm_oparray.c
@@ -1,16 +1,10 @@
 /*
    +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
+   | Copyright (c) 1997-2013 Derick Rethans                               |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
+   | This source file is subject to the 2-Clause BSD license which is     |
+   | available through the LICENSE file, or online at                     |
+   | http://opensource.org/licenses/bsd-license.php                       |
    +----------------------------------------------------------------------+
    | Authors:  Derick Rethans <derick@derickrethans.nl>                   |
    |           Andrei Zmievski <andrei@gravitonic.com>                    |
diff --git a/srm_oparray.h b/srm_oparray.h
index 9656c2f..355a1ad 100644
--- a/srm_oparray.h
+++ b/srm_oparray.h
@@ -1,16 +1,10 @@
 /*
    +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
+   | Copyright (c) 1997-2013 Derick Rethans                               |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
+   | This source file is subject to the 2-Clause BSD license which is     |
+   | available through the LICENSE file, or online at                     |
+   | http://opensource.org/licenses/bsd-license.php                       |
    +----------------------------------------------------------------------+
    | Authors:  Derick Rethans <derick@derickrethans.nl>                   |
    |           Andrei Zmievski <andrei@gravitonic.com>                    |
diff --git a/vld.c b/vld.c
index e7eae4f..831959a 100644
--- a/vld.c
+++ b/vld.c
@@ -1,16 +1,10 @@
 /*
    +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
+   | Copyright (c) 1997-2013 Derick Rethans                               |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
+   | This source file is subject to the 2-Clause BSD license which is     |
+   | available through the LICENSE file, or online at                     |
+   | http://opensource.org/licenses/bsd-license.php                       |
    +----------------------------------------------------------------------+
    | Authors:  Derick Rethans <derick@derickrethans.nl>                   |
    +----------------------------------------------------------------------+
-- 
1.9.3

From 6c3b76529e29d986a82735c12763b8bf839ff5bc Mon Sep 17 00:00:00 2001
From: Derick Rethans <github@derickrethans.nl>
Date: Thu, 13 Mar 2014 13:58:10 -0500
Subject: [PATCH] Fixed memory leaks and wrongly typed ints.

---
 branchinfo.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/branchinfo.c b/branchinfo.c
index cf2545b..8c223c8 100644
--- a/branchinfo.c
+++ b/branchinfo.c
@@ -36,9 +36,16 @@ vld_branch_info *vld_branch_info_create(unsigned int size)
 
 void vld_branch_info_free(vld_branch_info *branch_info)
 {
+	unsigned int i;
+
+	for (i = 0; i < branch_info->paths_count; i++) {
+		free(branch_info->paths[i]->elements);
+		free(branch_info->paths[i]);
+	}
+	free(branch_info->paths);
 	free(branch_info->branches);
-	free(branch_info->starts);
-	free(branch_info->ends);
+	vld_set_free(branch_info->starts);
+	vld_set_free(branch_info->ends);
 	free(branch_info);
 }
 
@@ -51,7 +58,8 @@ void vld_branch_info_update(vld_branch_info *branch_info, unsigned int pos, unsi
 
 void vld_branch_post_process(vld_branch_info *branch_info)
 {
-	int i, in_branch = 0, last_start = -1;
+	unsigned int i;
+	int in_branch = 0, last_start = -1;
 
 	for (i = 0; i < branch_info->starts->size; i++) {
 		if (vld_set_in(branch_info->starts, i)) {
@@ -123,7 +131,7 @@ static unsigned int vld_branch_find_last_element(vld_path *path)
 
 static int vld_path_exists(vld_path *path, unsigned int elem1, unsigned int elem2)
 {
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < path->elements_count - 1; i++) {
 		if (path->elements[i] == elem1 && path->elements[i + 1] == elem2) {
@@ -172,7 +180,7 @@ void vld_branch_find_paths(vld_branch_info *branch_info)
 
 void vld_branch_info_dump(zend_op_array *opa, vld_branch_info *branch_info TSRMLS_DC)
 {
-	int i, j;
+	unsigned int i, j;
 	char *fname = opa->function_name ? opa->function_name : "__main";
 
 	if (VLD_G(path_dump_file)) {
-- 
1.9.3

From efbcfa7f34b397e58a43a0b5d34cf0bf95472907 Mon Sep 17 00:00:00 2001
From: Derick Rethans <github@derickrethans.nl>
Date: Sun, 16 Mar 2014 10:15:04 -0500
Subject: [PATCH] Fixed cont/brk jump point analysis.

This could never ever have worked before.
---
 srm_oparray.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srm_oparray.c b/srm_oparray.c
index 503fcb0..b023cae 100644
--- a/srm_oparray.c
+++ b/srm_oparray.c
@@ -782,7 +782,7 @@ int vld_find_jump(zend_op_array *opa, unsigned int position, long *jmp1, long *j
 #endif
 		) {
 #if PHP_VERSION_ID >= 50399
-			el = vld_find_brk_cont(opcode.op2.constant, VLD_ZNODE_ELEM(opcode.op1, opline_num), opa);
+			el = vld_find_brk_cont(Z_LVAL_P(opcode.op2.zv), VLD_ZNODE_ELEM(opcode.op1, opline_num), opa);
 #else
 			el = vld_find_brk_cont(opcode.op2.u.constant.value.lval, VLD_ZNODE_ELEM(opcode.op1, opline_num), opa);
 #endif
-- 
1.9.3

From ab0a701555da63da026bc27450d42c748b6ec170 Mon Sep 17 00:00:00 2001
From: Derick Rethans <github@derickrethans.nl>
Date: Fri, 2 May 2014 12:02:24 +0100
Subject: [PATCH] Rename to use the same order as the other ASSIGN opcodes.

---
 srm_oparray.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srm_oparray.c b/srm_oparray.c
index b023cae..0e1a6fb 100644
--- a/srm_oparray.c
+++ b/srm_oparray.c
@@ -234,7 +234,7 @@ static const op_usage opcodes[] = {
 	/*  163 */	{ "FAST_RET", NONE_USED },
 	/*  164 */	{ "ZEND_RECV_VARIADIC", ALL_USED },
 	/*  165 */	{ "POW", ALL_USED },
-	/*  166 */	{ "POW_ASSIGN", ALL_USED | EXT_VAL },
+	/*  166 */	{ "ASSIGN_POW", ALL_USED | EXT_VAL },
 #endif
 };
 
-- 
1.9.3

From d5880af0a6a1532857933d920774de4b1715ea8a Mon Sep 17 00:00:00 2001
From: Derick Rethans <github@derickrethans.nl>
Date: Fri, 2 May 2014 12:02:42 +0100
Subject: [PATCH] Replace IS_CONSTANT_ARRAY with IS_CONSTANT_AST for PHP 5.6
 and later.

---
 srm_oparray.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/srm_oparray.c b/srm_oparray.c
index 0e1a6fb..553d8bd 100644
--- a/srm_oparray.c
+++ b/srm_oparray.c
@@ -319,10 +319,17 @@ static inline int vld_dump_zval_constant(zvalue_value value)
 	return vld_printf (stderr, "<const:'%s'>", value.str.val);
 }
 
+#if PHP_VERSION_ID >= 50600
+static inline int vld_dump_zval_constant_ast(zvalue_value value)
+{
+	return vld_printf (stderr, "<const ast>");
+}
+#else
 static inline int vld_dump_zval_constant_array(zvalue_value value)
 {
 	return vld_printf (stderr, "<const array>");
 }
+#endif
 
 
 int vld_dump_zval (zval val)
@@ -337,7 +344,11 @@ int vld_dump_zval (zval val)
 		case IS_BOOL:           return vld_dump_zval_bool (val.value);
 		case IS_RESOURCE:       return vld_dump_zval_resource (val.value);
 		case IS_CONSTANT:       return vld_dump_zval_constant (val.value);
+#if PHP_VERSION_ID >= 50600
+		case IS_CONSTANT_AST:   return vld_dump_zval_constant_ast (val.value);
+#else
 		case IS_CONSTANT_ARRAY: return vld_dump_zval_constant_array (val.value);
+#endif
 #if PHP_VERSION_ID >= 60000
 		case IS_UNICODE:        return vld_dump_zval_unicode (val.value);
 #endif
-- 
1.9.3