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
|
From 5b2b573d2bc7d894fe247978b7b42644218aad0b Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
Date: Tue, 9 Jul 2024 15:09:40 +0200
Subject: [PATCH] fix for PHP 8.4
---
oauth.c | 2 +-
php_oauth.h | 6 +++++-
provider.c | 4 +++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/oauth.c b/oauth.c
index 46fe08b..9bd8d2a 100644
--- a/oauth.c
+++ b/oauth.c
@@ -1330,7 +1330,7 @@ static void make_standard_query(HashTable *ht, php_so_object *soo) /* {{{ */
gettimeofday((struct timeval *) &tv, (struct timezone *) NULL);
sec = (int) tv.tv_sec;
usec = (int) (tv.tv_usec % 0x100000);
- spprintf(&nonce, 0, "%ld%08x%05x%.8f", php_rand(), sec, usec, php_combined_lcg() * 10);
+ spprintf(&nonce, 0, "%d%08x%05x%.8f", php_mt_rand(), sec, usec, php_combined_lcg() * 10);
}
add_arg_for_req(ht, OAUTH_PARAM_CONSUMER_KEY, Z_STRVAL_P(soo_get_property(soo, OAUTH_ATTR_CONSUMER_KEY)));
diff --git a/php_oauth.h b/php_oauth.h
index e5a1225..63a29ec 100644
--- a/php_oauth.h
+++ b/php_oauth.h
@@ -29,7 +29,12 @@
#include "php_main.h"
#include "php_ini.h"
#include "ext/standard/php_string.h"
+#if PHP_VERSION_ID < 80400
#include "ext/standard/php_rand.h"
+#include "ext/standard/php_lcg.h"
+#else
+#include "ext/random/php_random.h"
+#endif
#include "ext/standard/php_smart_string.h"
#include "ext/standard/info.h"
#include "ext/standard/php_string.h"
@@ -41,7 +46,6 @@
#include "php_globals.h"
#include "ext/standard/file.h"
#include "ext/standard/base64.h"
-#include "ext/standard/php_lcg.h"
#include "ext/pcre/php_pcre.h"
#include "php_network.h"
diff --git a/provider.c b/provider.c
index cd853f0..5247441 100644
--- a/provider.c
+++ b/provider.c
@@ -236,7 +236,9 @@ static int oauth_provider_parse_auth_header(php_oauth_provider *sop, char *auth_
&return_value,
&subpats,
1, /* global */
+#if PHP_VERSION_ID < 80400
1, /* use flags */
+#endif
2, /* PREG_SET_ORDER */
0
);
@@ -956,7 +958,7 @@ SOP_METHOD(generateToken)
php_error_docref(NULL, E_WARNING, "Could not gather enough random data, falling back on rand()");
}
while (reaped < size) {
- iv[reaped++] = (char) (255.0 * php_rand() / RAND_MAX);
+ iv[reaped++] = (char)php_mt_rand_range(0, 255);
}
}
|