Skip to content

Commit 8c8ab06

Browse files
committed
2 parents d3a6757 + 9f4d0e4 commit 8c8ab06

14 files changed

+272
-69
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
24+
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
2525

2626
name:
2727
- mac-x64

CHANGELOG.md

+21-10
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,39 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## [v0.4.16](https://github.com/NoiseByNorthwest/php-spx/compare/0.4.15...0.4.16)
7+
## [v0.4.17](https://github.com/NoiseByNorthwest/php-spx/compare/v0.4.16...v0.4.17)
8+
9+
### Added
10+
- PHP 8.4 support [#270](https://github.com/NoiseByNorthwest/php-spx/pull/270)
11+
- Subnet mask support for IP matching [#261](https://github.com/NoiseByNorthwest/php-spx/pull/261)
12+
- ZTS PHP beta support [#260](https://github.com/NoiseByNorthwest/php-spx/pull/260)
13+
14+
### Fixed
15+
- Keep scroll position in flatprofile view on repaint [#267](https://github.com/NoiseByNorthwest/php-spx/pull/267)
16+
- Improved confinement check for file access from WEB UI [#255](https://github.com/NoiseByNorthwest/php-spx/pull/255)
17+
18+
## [v0.4.16](https://github.com/NoiseByNorthwest/php-spx/compare/v0.4.15...v0.4.16)
819

920
### Added
1021
- Local snapshots of jQuery & jscolor in order to remove the internet access dependency of the Web UI [#217](https://github.com/NoiseByNorthwest/php-spx/issues/217)
1122

1223
### Fixed
1324
- Fixed unconfined server file access from WEB UI [#251](https://github.com/NoiseByNorthwest/php-spx/issues/251)
1425

15-
## [v0.4.15](https://github.com/NoiseByNorthwest/php-spx/compare/0.4.14...0.4.15)
26+
## [v0.4.15](https://github.com/NoiseByNorthwest/php-spx/compare/v0.4.14...v0.4.15)
1627

1728
### Added
1829
- Added Debian builds to github workflow [#222](https://github.com/NoiseByNorthwest/php-spx/pull/222)
19-
- Added PHP8.3 support [#230](https://github.com/NoiseByNorthwest/php-spx/pull/230)
20-
- Added PHP5.4 support [#227](https://github.com/NoiseByNorthwest/php-spx/pull/227)
30+
- Added PHP 8.3 support [#230](https://github.com/NoiseByNorthwest/php-spx/pull/230)
31+
- Added PHP 5.4 support [#227](https://github.com/NoiseByNorthwest/php-spx/pull/227)
2132

2233
### Fixed
2334
- Fixed ESM module imports in Web UI [#233](https://github.com/NoiseByNorthwest/php-spx/issues/233)
2435
- Fixed zlib.h path resolution for macOS/Macport [#238](https://github.com/NoiseByNorthwest/php-spx/issues/238)
2536
- Fixed non-portable path expectation in tests [#221](https://github.com/NoiseByNorthwest/php-spx/pull/221)
2637

2738

28-
## [v0.4.14](https://github.com/NoiseByNorthwest/php-spx/compare/0.4.13...0.4.14)
39+
## [v0.4.14](https://github.com/NoiseByNorthwest/php-spx/compare/v0.4.13...v0.4.14)
2940

3041
### Added
3142
- Added simple search feature
@@ -36,7 +47,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3647
- Fixed buffer overflow in str_builder
3748

3849

39-
## [v0.4.13](https://github.com/NoiseByNorthwest/php-spx/compare/0.4.12...0.4.13)
50+
## [v0.4.13](https://github.com/NoiseByNorthwest/php-spx/compare/v0.4.12...v0.4.13)
4051

4152
### Added
4253
- Github Actions workflow ([#180](https://github.com/NoiseByNorthwest/php-spx/issues/180))
@@ -50,7 +61,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
5061
- Travis CI [#195](https://github.com/NoiseByNorthwest/php-spx/issues/195)
5162

5263

53-
## [v0.4.0](https://github.com/NoiseByNorthwest/php-spx/compare/0.3.0...0.4.0)
64+
## [v0.4.0](https://github.com/NoiseByNorthwest/php-spx/compare/v0.3.0...v0.4.0)
5465

5566
### Added
5667
- Analysis screen: fix the NaNs in time grid when time goes above 1000s (fixes [#65](https://github.com/NoiseByNorthwest/php-spx/issues/65))
@@ -66,7 +77,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6677
- Fix build on macOS 10.11- (fixes [#78](https://github.com/NoiseByNorthwest/php-spx/pull/78))
6778

6879

69-
## [v0.3.0](https://github.com/NoiseByNorthwest/php-spx/compare/0.2.0...0.3.0)
80+
## [v0.3.0](https://github.com/NoiseByNorthwest/php-spx/compare/v0.2.0...v0.3.0)
7081

7182
### Added
7283
- Improve documentation around web UI requirements (fixes [#54](https://github.com/NoiseByNorthwest/php-spx/issues/54))
@@ -93,7 +104,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
93104
- Web UI / analysis screen: improved layout
94105

95106

96-
## [v0.2.0](https://github.com/NoiseByNorthwest/php-spx/compare/0.1.2...0.2.0)
107+
## [v0.2.0](https://github.com/NoiseByNorthwest/php-spx/compare/v0.1.2...v0.2.0)
97108

98109
### Added
99110
- Add web UI ([#14](https://github.com/NoiseByNorthwest/php-spx/pull/14))
@@ -106,7 +117,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
106117
- Remove Callgrind report type ([#11](https://github.com/NoiseByNorthwest/php-spx/issues/11))
107118

108119

109-
## [v0.1.2](https://github.com/NoiseByNorthwest/php-spx/compare/0.1.2...0.1.2)
120+
## [v0.1.2](https://github.com/NoiseByNorthwest/php-spx/compare/v0.1.2...v0.1.2)
110121

111122
### Added
112123
- Add macOS support ([orls](https://github.com/orls) in [#13](https://github.com/NoiseByNorthwest/php-spx/pull/13))

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ See the [LICENSE][:link-license:] file for more information.
2828
[:badge-ci:]: https://github.com/NoiseByNorthwest/php-spx/actions/workflows/main.yml/badge.svg
2929
[:link-ci:]: https://github.com/NoiseByNorthwest/php-spx/actions/workflows/main.yml
3030

31-
[:badge-php-versions:]: https://img.shields.io/badge/php-5.4--8.3-blue.svg
31+
[:badge-php-versions:]: https://img.shields.io/badge/php-5.4--8.4-blue.svg
3232
[:badge-supported-platforms:]: https://img.shields.io/badge/platform-GNU/Linux%20|%20macOS%20|%20FreeBSD%20-yellow
3333
[:badge-supported-arch:]: https://img.shields.io/badge/architecture-x86--64%20|%20ARM64%20-silver
3434

assets/web-ui/js/widget.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -573,21 +573,17 @@ class Widget {
573573

574574
this.repaintTimeout = setTimeout(
575575
() => {
576+
let initialScrollPos = 0;
576577
this.repaintTimeout = null;
577578

578579
const id = this.container.attr('id');
579-
// Remember the scroll position
580-
let scroll = 0;
581580
if (id === 'flatprofile') {
582-
scroll = $(`#flatprofile div`).scrollTop();
581+
initialScrollPos = document.querySelector('#flatprofile > div').scrollTop;
583582
}
584583
this.clear();
585584
this.render();
586-
// Restore the scroll position
587585
if (id === 'flatprofile') {
588-
$(`#flatprofile div`).scrollTop(scroll);
589-
} else {
590-
$(`#${id}`).scrollTop(scroll);
586+
document.querySelector('#flatprofile > div').scrollTop = initialScrollPos;
591587
}
592588
},
593589
0

config.m4

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ if test "$PHP_SPX" = "yes"; then
2323
CFLAGS="$CFLAGS -DCONTINUOUS_INTEGRATION"
2424
fi
2525

26+
if test "$(uname -s 2>/dev/null)" = "Darwin"
27+
then
28+
# see discussion here https://github.com/NoiseByNorthwest/php-spx/pull/270
29+
CFLAGS="$CFLAGS -Wno-typedef-redefinition"
30+
fi
31+
2632
if test "$PHP_SPX_DEV" = "yes"
2733
then
2834
CFLAGS="$CFLAGS -g"

src/php_spx.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ static int check_access(void)
552552
int found = 0;
553553

554554
SPX_UTILS_TOKENIZE_STRING(SPX_G(http_trusted_proxies), ',', trusted_proxy_ip_str, 64, {
555-
if (0 == strcmp(proxy_ip_str, trusted_proxy_ip_str)) {
555+
if (spx_utils_ip_match(proxy_ip_str, trusted_proxy_ip_str)) {
556556
found = 1;
557557
}
558558
});
@@ -586,18 +586,13 @@ static int check_access(void)
586586
}
587587

588588
SPX_UTILS_TOKENIZE_STRING(authorized_ips_str, ',', authorized_ip_str, 64, {
589-
if (0 == strcmp(ip_str, authorized_ip_str)) {
589+
if (spx_utils_ip_match(ip_str, authorized_ip_str)) {
590590
/* ip authorized (OK, as well as all previous checks) -> granted */
591591

592592
return 1;
593593
}
594594
});
595595

596-
if (0 == strcmp(authorized_ips_str, "*")) {
597-
/* all ips authorized */
598-
return 1;
599-
}
600-
601596
spx_php_log_notice(
602597
"access not granted: \"%s\" IP is not in white list (\"%s\")",
603598
ip_str,

src/php_spx.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
# error "Only x86-64 and ARM64 architectures are supported"
3232
#endif
3333

34-
#if ZEND_MODULE_API_NO < 20100525 || ZEND_MODULE_API_NO > 20230831 // 8.3-RC5
35-
# error "Only the following PHP versions are supported: 5.4 to 8.3"
34+
#if ZEND_MODULE_API_NO < 20100525 || ZEND_MODULE_API_NO > 20240924
35+
# error "Only the following PHP versions are supported: 5.4 to 8.4"
3636
#endif
3737

3838
#if defined(ZTS) && !defined(CONTINUOUS_INTEGRATION)
3939
# error "ZTS is not yet supported"
4040
#endif
4141

4242
#define PHP_SPX_EXTNAME "SPX"
43-
#define PHP_SPX_VERSION "0.4.15"
43+
#define PHP_SPX_VERSION "0.4.17"
4444

4545
extern zend_module_entry spx_module_entry;

src/spx_php.c

+46-40
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ typedef void (*execute_internal_func_t) (
7474
);
7575

7676
static struct {
77-
#if ZEND_MODULE_API_NO >= 20151012
78-
void * (*malloc) (size_t size);
79-
void (*free) (void * ptr);
80-
void * (*realloc) (void * ptr, size_t size);
81-
size_t (*block_size) (void * ptr);
82-
#endif
83-
8477
#if ZEND_MODULE_API_NO < 20121212
8578
void (*execute) (zend_op_array * op_array TSRMLS_DC);
8679
#else
@@ -124,9 +117,6 @@ static struct {
124117
#endif
125118
);
126119
} ze_hooked_func = {
127-
#if ZEND_MODULE_API_NO >= 20151012
128-
NULL, NULL, NULL, NULL,
129-
#endif
130120
NULL, NULL, NULL,
131121
NULL, NULL,
132122
#if ZEND_MODULE_API_NO >= 20151012
@@ -135,6 +125,17 @@ static struct {
135125
NULL
136126
};
137127

128+
#if ZEND_MODULE_API_NO >= 20151012
129+
static SPX_THREAD_TLS struct {
130+
void * (*malloc) (size_t size);
131+
void (*free) (void * ptr);
132+
void * (*realloc) (void * ptr, size_t size);
133+
size_t (*block_size) (void * ptr);
134+
} ze_tls_hooked_func = {
135+
NULL, NULL, NULL, NULL
136+
};
137+
#endif
138+
138139
static SPX_THREAD_TLS struct {
139140
struct {
140141
struct {
@@ -664,24 +665,28 @@ void spx_php_execution_init(void)
664665
#if ZEND_MODULE_API_NO >= 20151012
665666
zend_mm_heap * ze_mm_heap = zend_mm_get_heap();
666667

668+
/*
669+
* FIXME document why we need ze_mm_custom_block_size instead of ze_mm_block_size
670+
* when there is no previous MM custom handler.
671+
*/
672+
ze_tls_hooked_func.block_size = ze_mm_custom_block_size;
673+
667674
zend_mm_get_custom_handlers(
668675
ze_mm_heap,
669-
&ze_hooked_func.malloc,
670-
&ze_hooked_func.free,
671-
&ze_hooked_func.realloc
676+
&ze_tls_hooked_func.malloc,
677+
&ze_tls_hooked_func.free,
678+
&ze_tls_hooked_func.realloc
672679
);
673680

674-
ze_hooked_func.block_size = ze_mm_custom_block_size;
675-
676681
if (
677-
!ze_hooked_func.malloc
678-
|| !ze_hooked_func.free
679-
|| !ze_hooked_func.realloc
682+
!ze_tls_hooked_func.malloc
683+
|| !ze_tls_hooked_func.free
684+
|| !ze_tls_hooked_func.realloc
680685
) {
681-
ze_hooked_func.malloc = ze_mm_malloc;
682-
ze_hooked_func.free = ze_mm_free;
683-
ze_hooked_func.realloc = ze_mm_realloc;
684-
ze_hooked_func.block_size = ze_mm_block_size;
686+
ze_tls_hooked_func.malloc = ze_mm_malloc;
687+
ze_tls_hooked_func.free = ze_mm_free;
688+
ze_tls_hooked_func.realloc = ze_mm_realloc;
689+
ze_tls_hooked_func.block_size = ze_mm_block_size;
685690
}
686691

687692
zend_mm_set_custom_handlers(
@@ -697,24 +702,24 @@ void spx_php_execution_shutdown(void)
697702
{
698703
#if ZEND_MODULE_API_NO >= 20151012
699704
if (
700-
ze_hooked_func.malloc
701-
&& ze_hooked_func.free
702-
&& ze_hooked_func.realloc
705+
ze_tls_hooked_func.malloc
706+
&& ze_tls_hooked_func.free
707+
&& ze_tls_hooked_func.realloc
703708
) {
704709
zend_mm_heap * ze_mm_heap = zend_mm_get_heap();
705710

706711
if (
707712
/*
708-
* ze_hooked_func.malloc was defaulted to ze_mm_malloc only if there were no
713+
* ze_tls_hooked_func.malloc was defaulted to ze_mm_malloc only if there were no
709714
* previous custom handlers.
710715
*/
711-
ze_hooked_func.malloc != ze_mm_malloc
716+
ze_tls_hooked_func.malloc != ze_mm_malloc
712717
) {
713718
zend_mm_set_custom_handlers(
714719
ze_mm_heap,
715-
ze_hooked_func.malloc,
716-
ze_hooked_func.free,
717-
ze_hooked_func.realloc
720+
ze_tls_hooked_func.malloc,
721+
ze_tls_hooked_func.free,
722+
ze_tls_hooked_func.realloc
718723
);
719724
} else {
720725
/*
@@ -733,9 +738,10 @@ void spx_php_execution_shutdown(void)
733738
}
734739
}
735740

736-
ze_hooked_func.malloc = NULL;
737-
ze_hooked_func.free = NULL;
738-
ze_hooked_func.realloc = NULL;
741+
ze_tls_hooked_func.malloc = NULL;
742+
ze_tls_hooked_func.free = NULL;
743+
ze_tls_hooked_func.realloc = NULL;
744+
ze_tls_hooked_func.block_size = NULL;
739745
}
740746
#endif
741747

@@ -1013,11 +1019,11 @@ static void * ze_mm_realloc(void * ptr, size_t size)
10131019

10141020
static void * tls_hook_malloc(size_t size)
10151021
{
1016-
void * ptr = ze_hooked_func.malloc(size);
1022+
void * ptr = ze_tls_hooked_func.malloc(size);
10171023

10181024
if (ptr) {
10191025
context.alloc_count++;
1020-
context.alloc_bytes += ze_hooked_func.block_size(ptr);
1026+
context.alloc_bytes += ze_tls_hooked_func.block_size(ptr);
10211027
}
10221028

10231029
return ptr;
@@ -1027,17 +1033,17 @@ static void tls_hook_free(void * ptr)
10271033
{
10281034
if (ptr) {
10291035
context.free_count++;
1030-
context.free_bytes += ze_hooked_func.block_size(ptr);
1036+
context.free_bytes += ze_tls_hooked_func.block_size(ptr);
10311037
}
10321038

1033-
ze_hooked_func.free(ptr);
1039+
ze_tls_hooked_func.free(ptr);
10341040
}
10351041

10361042
static void * tls_hook_realloc(void * ptr, size_t size)
10371043
{
1038-
const size_t old_size = ptr ? ze_hooked_func.block_size(ptr) : 0;
1039-
void * new = ze_hooked_func.realloc(ptr, size);
1040-
const size_t new_size = new ? ze_hooked_func.block_size(new) : 0;
1044+
const size_t old_size = ptr ? ze_tls_hooked_func.block_size(ptr) : 0;
1045+
void * new = ze_tls_hooked_func.realloc(ptr, size);
1046+
const size_t new_size = new ? ze_tls_hooked_func.block_size(new) : 0;
10411047

10421048
if (ptr && new) {
10431049
if (ptr != new) {

0 commit comments

Comments
 (0)