From aae5476d9d5d3cbf20bbfa8a18a566979c783472 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 9 Jul 2024 15:17:19 +0200 Subject: [PATCH] Fix compilation for PHP84+ PHP changed some includes for PHP8.4 Reported-by: rainerjung --- src/php_snuffleupagus.h | 6 ++++++ src/sp_harden_rand.h | 5 ++++- src/tweetnacl.c | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/php_snuffleupagus.h b/src/php_snuffleupagus.h index 6e035d40..f287e03c 100644 --- a/src/php_snuffleupagus.h +++ b/src/php_snuffleupagus.h @@ -42,6 +42,7 @@ #include "ext/standard/php_string.h" #include "ext/standard/php_var.h" #include "ext/session/php_session.h" +#include "ext/hash/php_hash.h" #include "php.h" #include "php_ini.h" #include "rfc1867.h" @@ -69,6 +70,11 @@ typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS); #error Snuffleupagus requires PHP7+ with PCRE support #endif #endif +#if PHP_VERSION_ID >= 80300 +#include "ext/random/php_random.h" +#else +#include "ext/standard/php_random.h" +#endif #define SP_CONFIG_VALID 1 #define SP_CONFIG_INVALID 0 diff --git a/src/sp_harden_rand.h b/src/sp_harden_rand.h index bbe9be49..ae342fa2 100644 --- a/src/sp_harden_rand.h +++ b/src/sp_harden_rand.h @@ -1,8 +1,11 @@ #ifndef __SP_HARDEN_RAND_H #define __SP_HARDEN_RAND_H -#include "ext/standard/php_rand.h" +#if PHP_VERSION_ID >= 80200 +#include "ext/random/php_random.h" +#else #include "ext/standard/php_random.h" +#endif #include "zend_exceptions.h" int hook_rand(void); diff --git a/src/tweetnacl.c b/src/tweetnacl.c index 746cabc2..2d35ca80 100644 --- a/src/tweetnacl.c +++ b/src/tweetnacl.c @@ -1,7 +1,11 @@ /* Since TweetNacl doesn't come with a `randombytes` implementation, we're using the one from PHP.*/ #include "php_snuffleupagus.h" +#if PHP_VERSION_ID >= 80200 +#include "ext/random/php_random.h" +#else #include "ext/standard/php_random.h" +#endif static void randombytes(unsigned char *x, unsigned long long xlen) { assert(SIZE_MAX >= ULLONG_MAX); // max(size_t) > max(ull) ?