random: Fix return type of php_random_(bytes|int) (#10687)

These return a `zend_result`, not `int`.
This commit is contained in:
Tim Düsterhus 2023-02-24 15:10:44 +01:00 committed by GitHub
parent e9c8621632
commit f079aa2e24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -25,6 +25,7 @@
#include "php.h" #include "php.h"
#include "zend_result.h"
#include "Zend/zend_exceptions.h" #include "Zend/zend_exceptions.h"
#include "php_random.h" #include "php_random.h"
@ -60,7 +61,7 @@
# include <sanitizer/msan_interface.h> # include <sanitizer/msan_interface.h>
#endif #endif
PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw) PHPAPI zend_result php_random_bytes(void *bytes, size_t size, bool should_throw)
{ {
#ifdef PHP_WIN32 #ifdef PHP_WIN32
/* Defer to CryptGenRandom on Windows */ /* Defer to CryptGenRandom on Windows */
@ -209,7 +210,7 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
return SUCCESS; return SUCCESS;
} }
PHPAPI int php_random_int(zend_long min, zend_long max, zend_long *result, bool should_throw) PHPAPI zend_result php_random_int(zend_long min, zend_long max, zend_long *result, bool should_throw)
{ {
zend_ulong umax; zend_ulong umax;
zend_ulong trial; zend_ulong trial;

View file

@ -31,6 +31,8 @@
#ifndef PHP_RANDOM_H #ifndef PHP_RANDOM_H
# define PHP_RANDOM_H # define PHP_RANDOM_H
# include "zend_result.h"
PHPAPI double php_combined_lcg(void); PHPAPI double php_combined_lcg(void);
/* /*
@ -198,8 +200,8 @@ static inline uint64_t php_random_pcgoneseq128xslrr64_rotr64(php_random_uint128_
# define php_random_int_throw(min, max, result) php_random_int((min), (max), (result), 1) # define php_random_int_throw(min, max, result) php_random_int((min), (max), (result), 1)
# define php_random_int_silent(min, max, result) php_random_int((min), (max), (result), 0) # define php_random_int_silent(min, max, result) php_random_int((min), (max), (result), 0)
PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw); PHPAPI zend_result php_random_bytes(void *bytes, size_t size, bool should_throw);
PHPAPI int php_random_int(zend_long min, zend_long max, zend_long *result, bool should_throw); PHPAPI zend_result php_random_int(zend_long min, zend_long max, zend_long *result, bool should_throw);
typedef struct _php_random_status_ { typedef struct _php_random_status_ {
size_t last_generated_size; size_t last_generated_size;