Skip to content

Commit

Permalink
Fix compilation for PHP84+
Browse files Browse the repository at this point in the history
PHP changed some includes for PHP8.4

Reported-by: rainerjung
  • Loading branch information
jvoisin committed Jul 9, 2024
1 parent 1f349ea commit aae5476
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/php_snuffleupagus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/sp_harden_rand.h
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/tweetnacl.c
Original file line number Diff line number Diff line change
@@ -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) ?
Expand Down

0 comments on commit aae5476

Please sign in to comment.