Skip to content

Commit 3f0bb67

Browse files
devnexencmb69
authored andcommitted
Avoid void* arithmetic in sockets/multicast.c on NetBSD
On NetBSD, ifconf.ifc_buf member, unlike most of platforms, is a void pointer. We also fix the cpuinfo declarations with empty parameter lists. Closes GH-7819.
1 parent 096a01c commit 3f0bb67

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ PHP NEWS
2424
- PDO_PGSQL:
2525
. Fixed error message allocation of PDO PgSQL. (SATO Kentaro)
2626

27+
- Sockets:
28+
. Avoid void* arithmetic in sockets/multicast.c on NetBSD. (David Carlier)
29+
2730
- Spl:
2831
. Fixed bug #75917 (SplFileObject::seek broken with CSV flags). (Aliaksandr
2932
Bystry)

Zend/zend_cpuinfo.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo
7575

7676
#if defined(__i386__) || defined(__x86_64__)
7777
/* Function based on compiler-rt implementation. */
78-
static unsigned get_xcr0_eax() {
78+
static unsigned get_xcr0_eax(void) {
7979
# if defined(__GNUC__) || defined(__clang__)
8080
// Check xgetbv; this uses a .byte sequence instead of the instruction
8181
// directly because older assemblers do not include support for xgetbv and
@@ -90,7 +90,7 @@ static unsigned get_xcr0_eax() {
9090
# endif
9191
}
9292

93-
static zend_bool is_avx_supported() {
93+
static zend_bool is_avx_supported(void) {
9494
if (!(cpuinfo.ecx & ZEND_CPU_FEATURE_AVX)) {
9595
/* No support for AVX */
9696
return 0;
@@ -106,7 +106,7 @@ static zend_bool is_avx_supported() {
106106
return 1;
107107
}
108108
#else
109-
static zend_bool is_avx_supported() {
109+
static zend_bool is_avx_supported(void) {
110110
return 0;
111111
}
112112
#endif

ext/sockets/multicast.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *i
784784
}
785785

786786
for (p = if_conf.ifc_buf;
787-
p < if_conf.ifc_buf + if_conf.ifc_len;
787+
p < ((char *)if_conf.ifc_buf) + if_conf.ifc_len;
788788
p += entry_len) {
789789
/* p may be misaligned on macos. */
790790
struct ifreq cur_req;

0 commit comments

Comments
 (0)