Skip to content

Commit f553344

Browse files
Merge branch 'php:master' into master
2 parents 8707dec + a408781 commit f553344

31 files changed

+150
-94
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ PHP NEWS
9999
- Standard:
100100
. E_NOTICEs emitted by unserialize() have been promoted to E_WARNING. (timwolla)
101101
. Make array_pad's $length warning less confusing. (nielsdos)
102+
. E_WARNING emitted by strtok in the caase both arguments are not provided when
103+
starting tokenisation. (David Carlier)
102104

103105
- Streams:
104106
. Fixed bug #51056: blocking fread() will block even if data is available.

UPGRADING

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ PHP 8.3 UPGRADE NOTES
6868
. array_pad() is now only limited by the maximum number of elements an array
6969
can have. Before, it was only possible to add at most 1048576 elements at a
7070
time.
71+
. strtok() raises a warning in the case token is not provided when starting tokenization.
7172

7273
========================================
7374
6. New Functions

UPGRADING.INTERNALS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ PHP 8.3 INTERNALS UPGRADE NOTES
3535
2. Build system changes
3636
========================
3737

38+
* Removed the HAVE_DEV_URANDOM compile time check. HAVE_DEV_URANDOM will
39+
now never be defined. Any checks relying on HAVE_DEV_URANDOM should be
40+
removed. Even with HAVE_DEV_URANDOM it was not guaranteed that
41+
/dev/urandom is actually available at run time and thus a runtime
42+
check needs to happen in all cases.
43+
3844
========================
3945
3. Module changes
4046
========================

Zend/Zend.m4

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,6 @@ AC_MSG_RESULT($ZEND_SIGNALS)
304304
305305
])
306306

307-
AC_MSG_CHECKING(whether /dev/urandom exists)
308-
if test -r "/dev/urandom" && test -c "/dev/urandom"; then
309-
AC_DEFINE([HAVE_DEV_URANDOM], 1, [Define if the target system has /dev/urandom device])
310-
AC_MSG_RESULT(yes)
311-
else
312-
AC_MSG_RESULT(no)
313-
fi
314-
315307
AC_ARG_ENABLE([gcc-global-regs],
316308
[AS_HELP_STRING([--disable-gcc-global-regs],
317309
[whether to enable GCC global register variables])],

Zend/zend_signal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void
7171
#define TIMEOUT_SIG SIGPROF
7272
#endif
7373

74-
static int zend_sigs[] = { TIMEOUT_SIG, SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2 };
74+
static const int zend_sigs[] = { TIMEOUT_SIG, SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2 };
7575

7676
#define SA_FLAGS_MASK ~(SA_NODEFER | SA_RESETHAND)
7777

configure.ac

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ PKG_PROG_PKG_CONFIG
128128
AC_PROG_CC([cc gcc])
129129
PHP_DETECT_ICC
130130
PHP_DETECT_SUNCC
131-
AC_PROG_CC_C99
131+
132+
dnl AC_PROG_CC_C99 is obsolete with autoconf >= 2.70 yet necessary for <= 2.69.
133+
m4_version_prereq([2.70],,[AC_PROG_CC_C99])
132134
AC_PROG_CPP
133135
AC_USE_SYSTEM_EXTENSIONS
134136
AC_PROG_LN_S

ext/dba/dba.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ PHP_MSHUTDOWN_FUNCTION(dba);
5555
PHP_MINFO_FUNCTION(dba);
5656

5757
ZEND_BEGIN_MODULE_GLOBALS(dba)
58-
char *default_handler;
59-
dba_handler *default_hptr;
58+
const char *default_handler;
59+
const dba_handler *default_hptr;
6060
ZEND_END_MODULE_GLOBALS(dba)
6161

6262
ZEND_DECLARE_MODULE_GLOBALS(dba)
@@ -159,7 +159,7 @@ static zend_string* php_dba_make_key(HashTable *key)
159159

160160
/* {{{ globals */
161161

162-
static dba_handler handler[] = {
162+
static const dba_handler handler[] = {
163163
#ifdef DBA_GDBM
164164
DBA_HND(gdbm, DBA_LOCK_EXT) /* Locking done in library if set */
165165
#endif
@@ -249,7 +249,7 @@ PHPAPI void dba_fetch_resource(dba_info **pinfo, zval **id)
249249
/* {{{ dba_get_handler
250250
PHPAPI dba_handler *dba_get_handler(const char* handler_name)
251251
{
252-
dba_handler *hptr;
252+
const dba_handler *hptr;
253253
for (hptr = handler; hptr->name && strcasecmp(hptr->name, handler_name); hptr++);
254254
return hptr;
255255
}
@@ -320,7 +320,7 @@ static void dba_close_pe_rsrc(zend_resource *rsrc)
320320
/* {{{ PHP_INI */
321321
ZEND_INI_MH(OnUpdateDefaultHandler)
322322
{
323-
dba_handler *hptr;
323+
const dba_handler *hptr;
324324

325325
if (!ZSTR_LEN(new_value)) {
326326
DBA_G(default_hptr) = NULL;
@@ -377,7 +377,7 @@ PHP_MSHUTDOWN_FUNCTION(dba)
377377
/* {{{ PHP_MINFO_FUNCTION */
378378
PHP_MINFO_FUNCTION(dba)
379379
{
380-
dba_handler *hptr;
380+
const dba_handler *hptr;
381381
smart_str handlers = {0};
382382

383383
for(hptr = handler; hptr->name; hptr++) {
@@ -461,7 +461,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
461461
{
462462
dba_mode_t modenr;
463463
dba_info *info, *other;
464-
dba_handler *hptr;
464+
const dba_handler *hptr;
465465
char *error = NULL;
466466
int lock_mode, lock_flag = 0;
467467
char *file_mode;
@@ -1165,7 +1165,7 @@ PHP_FUNCTION(dba_sync)
11651165
/* {{{ List configured database handlers */
11661166
PHP_FUNCTION(dba_handlers)
11671167
{
1168-
dba_handler *hptr;
1168+
const dba_handler *hptr;
11691169
bool full_info = 0;
11701170

11711171
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &full_info) == FAILURE) {

ext/dba/php_dba.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef struct dba_info {
4848
zend_long driver_flags;
4949
/* private */
5050
int flags; /* whether and how dba did locking and other flags*/
51-
struct dba_handler *hnd;
51+
const struct dba_handler *hnd;
5252
dba_lock lock;
5353
} dba_info;
5454

@@ -85,7 +85,7 @@ typedef struct dba_handler {
8585
zend_string* (*nextkey)(dba_info *);
8686
zend_result (*optimize)(dba_info *);
8787
zend_result (*sync)(dba_info *);
88-
char* (*info)(struct dba_handler *hnd, dba_info *);
88+
char* (*info)(const struct dba_handler *hnd, dba_info *);
8989
/* dba_info==NULL: Handler info, dba_info!=NULL: Database info */
9090
} dba_handler;
9191

@@ -112,7 +112,7 @@ typedef struct dba_handler {
112112
#define DBA_SYNC_FUNC(x) \
113113
zend_result dba_sync_##x(dba_info *info)
114114
#define DBA_INFO_FUNC(x) \
115-
char *dba_info_##x(dba_handler *hnd, dba_info *info)
115+
char *dba_info_##x(const dba_handler *hnd, dba_info *info)
116116

117117
#define DBA_FUNCS(x) \
118118
DBA_OPEN_FUNC(x); \

ext/exif/exif.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ static size_t php_strnlen(char* str, size_t maxlen) {
230230
/* }}} */
231231

232232
/* {{{ error messages */
233-
static const char * EXIF_ERROR_FILEEOF = "Unexpected end of file reached";
234-
static const char * EXIF_ERROR_CORRUPT = "File structure corrupted";
235-
static const char * EXIF_ERROR_THUMBEOF = "Thumbnail goes IFD boundary or end of file reached";
236-
static const char * EXIF_ERROR_FSREALLOC = "Illegal reallocating of undefined file section";
233+
static const char *const EXIF_ERROR_FILEEOF = "Unexpected end of file reached";
234+
static const char *const EXIF_ERROR_CORRUPT = "File structure corrupted";
235+
static const char *const EXIF_ERROR_THUMBEOF = "Thumbnail goes IFD boundary or end of file reached";
236+
static const char *const EXIF_ERROR_FSREALLOC = "Illegal reallocating of undefined file section";
237237

238238
#define EXIF_ERRLOG_FILEEOF(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "%s", EXIF_ERROR_FILEEOF);
239239
#define EXIF_ERRLOG_CORRUPT(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "%s", EXIF_ERROR_CORRUPT);
@@ -244,7 +244,7 @@ static const char * EXIF_ERROR_FSREALLOC = "Illegal reallocating of undefined fi
244244
/* {{{ format description defines
245245
Describes format descriptor
246246
*/
247-
static int php_tiff_bytes_per_format[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
247+
static const int php_tiff_bytes_per_format[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
248248
#define NUM_FORMATS 13
249249

250250
#define TAG_FMT_BYTE 1
@@ -3805,6 +3805,9 @@ static bool exif_scan_JPEG_header(image_info_type *ImageInfo)
38053805

38063806
fpos = php_stream_tell(ImageInfo->infile);
38073807

3808+
/* safety net in case the above algorithm change dramatically, should not trigger */
3809+
ZEND_ASSERT(marker != 0xff);
3810+
38083811
/* Read the length of the section. */
38093812
if ((lh = php_stream_getc(ImageInfo->infile)) == (unsigned int)EOF) {
38103813
EXIF_ERRLOG_CORRUPT(ImageInfo)

ext/intl/grapheme/grapheme_string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ grapheme_extract_count_iter(UBreakIterator *bi, int32_t size, unsigned char *pst
679679
/* {{{ grapheme extract iter function pointer array */
680680
typedef int32_t (*grapheme_extract_iter)(UBreakIterator * /*bi*/, int32_t /*size*/, unsigned char * /*pstr*/, int32_t /*str_len*/);
681681

682-
static grapheme_extract_iter grapheme_extract_iters[] = {
682+
static const grapheme_extract_iter grapheme_extract_iters[] = {
683683
&grapheme_extract_count_iter,
684684
&grapheme_extract_bytecount_iter,
685685
&grapheme_extract_charcount_iter,

ext/mbstring/gen_rare_cp_bitvec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* as less likely to be the correct one.
4141
*/
4242
43-
static uint32_t rare_codepoint_bitvec[] = {
43+
static const uint32_t rare_codepoint_bitvec[] = {
4444
HEADER;
4545

4646
for ($i = 0; $i < 0xFFFF / 32; $i++) {

ext/mbstring/rare_cp_bitvec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* as less likely to be the correct one.
1010
*/
1111

12-
static uint32_t rare_codepoint_bitvec[] = {
12+
static const uint32_t rare_codepoint_bitvec[] = {
1313
0xffffd9ff, 0x00000000, 0x00000000, 0x80000000, 0xffffffff, 0x00002001, 0x00000000, 0x00000000,
1414
0x70ff0f0f, 0xfffcffff, 0x70fcfe61, 0x81fc3fcc, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
1515
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,

ext/opcache/shared_alloc_mmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static size_t segment_type_size(void)
276276
return sizeof(zend_shared_segment);
277277
}
278278

279-
zend_shared_memory_handlers zend_alloc_mmap_handlers = {
279+
const zend_shared_memory_handlers zend_alloc_mmap_handlers = {
280280
create_segments,
281281
detach_segment,
282282
segment_type_size

ext/opcache/shared_alloc_posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static size_t segment_type_size(void)
8989
return sizeof(zend_shared_segment_posix);
9090
}
9191

92-
zend_shared_memory_handlers zend_alloc_posix_handlers = {
92+
const zend_shared_memory_handlers zend_alloc_posix_handlers = {
9393
(create_segments_t)create_segments,
9494
(detach_segment_t)detach_segment,
9595
segment_type_size

ext/opcache/shared_alloc_shm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static size_t segment_type_size(void)
135135
return sizeof(zend_shared_segment_shm);
136136
}
137137

138-
zend_shared_memory_handlers zend_alloc_shm_handlers = {
138+
const zend_shared_memory_handlers zend_alloc_shm_handlers = {
139139
(create_segments_t)create_segments,
140140
(detach_segment_t)detach_segment,
141141
segment_type_size

ext/opcache/shared_alloc_win32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static size_t segment_type_size(void)
352352
return sizeof(zend_shared_segment);
353353
}
354354

355-
zend_shared_memory_handlers zend_alloc_win32_handlers = {
355+
const zend_shared_memory_handlers zend_alloc_win32_handlers = {
356356
create_segments,
357357
detach_segment,
358358
segment_type_size

ext/opcache/zend_accelerator_hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#include "zend_shared_alloc.h"
2626

2727
/* Generated on an Octa-ALPHA 300MHz CPU & 2.5GB RAM monster */
28-
static uint32_t prime_numbers[] =
28+
static const uint32_t prime_numbers[] =
2929
{5, 11, 19, 53, 107, 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793 };
30-
static uint32_t num_prime_numbers = sizeof(prime_numbers) / sizeof(uint32_t);
30+
static const uint32_t num_prime_numbers = sizeof(prime_numbers) / sizeof(uint32_t);
3131

3232
void zend_accel_hash_clean(zend_accel_hash *accel_hash)
3333
{

ext/opcache/zend_shared_alloc.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ typedef struct {
9191

9292
typedef struct _handler_entry {
9393
const char *name;
94-
zend_shared_memory_handlers *handler;
94+
const zend_shared_memory_handlers *handler;
9595
} zend_shared_memory_handler_entry;
9696

9797
typedef struct _zend_shared_memory_state {
@@ -197,19 +197,19 @@ const char *zend_accel_get_shared_model(void);
197197
void zend_accel_shared_protect(int mode);
198198

199199
#ifdef USE_MMAP
200-
extern zend_shared_memory_handlers zend_alloc_mmap_handlers;
200+
extern const zend_shared_memory_handlers zend_alloc_mmap_handlers;
201201
#endif
202202

203203
#ifdef USE_SHM
204-
extern zend_shared_memory_handlers zend_alloc_shm_handlers;
204+
extern const zend_shared_memory_handlers zend_alloc_shm_handlers;
205205
#endif
206206

207207
#ifdef USE_SHM_OPEN
208-
extern zend_shared_memory_handlers zend_alloc_posix_handlers;
208+
extern const zend_shared_memory_handlers zend_alloc_posix_handlers;
209209
#endif
210210

211211
#ifdef ZEND_WIN32
212-
extern zend_shared_memory_handlers zend_alloc_win32_handlers;
212+
extern const zend_shared_memory_handlers zend_alloc_win32_handlers;
213213
void zend_shared_alloc_create_lock(void);
214214
void zend_shared_alloc_lock_win32(void);
215215
void zend_shared_alloc_unlock_win32(void);

ext/openssl/tests/bug80747.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--TEST--
22
Bug #80747: Providing RSA key size < 512 generates key that crash PHP
3-
--FILE--
43
--EXTENSIONS--
54
openssl
65
--SKIPIF--

ext/random/random.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,7 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
557557

558558
if (fd < 0) {
559559
errno = 0;
560-
# if HAVE_DEV_URANDOM
561560
fd = open("/dev/urandom", O_RDONLY);
562-
# endif
563561
if (fd < 0) {
564562
if (should_throw) {
565563
if (errno != 0) {

ext/session/session.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,14 @@ static void bin_to_readable(unsigned char *in, size_t inlen, char *out, size_t o
306306
}
307307
/* }}} */
308308

309-
#define PS_EXTRA_RAND_BYTES 60
310-
311309
PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
312310
{
313-
unsigned char rbuf[PS_MAX_SID_LENGTH + PS_EXTRA_RAND_BYTES];
311+
unsigned char rbuf[PS_MAX_SID_LENGTH];
314312
zend_string *outid;
315313

316314
/* It would be enough to read ceil(sid_length * sid_bits_per_character / 8) bytes here.
317315
* We read sid_length bytes instead for simplicity. */
318-
/* Read additional PS_EXTRA_RAND_BYTES just in case CSPRNG is not safe enough */
319-
if (php_random_bytes_throw(rbuf, PS(sid_length) + PS_EXTRA_RAND_BYTES) == FAILURE) {
316+
if (php_random_bytes_throw(rbuf, PS(sid_length)) == FAILURE) {
320317
return NULL;
321318
}
322319

ext/snmp/snmp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ ZEND_DECLARE_MODULE_GLOBALS(snmp)
9191
static PHP_GINIT_FUNCTION(snmp);
9292

9393
/* constant - can be shared among threads */
94-
static oid objid_mib[] = {1, 3, 6, 1, 2, 1};
94+
static const oid objid_mib[] = {1, 3, 6, 1, 2, 1};
9595

9696
/* Handlers */
9797
static zend_object_handlers php_snmp_object_handlers;
@@ -765,7 +765,7 @@ static bool php_snmp_parse_oid(
765765
return false;
766766
}
767767
} else {
768-
memmove((char *)objid_query->vars[0].name, (char *)objid_mib, sizeof(objid_mib));
768+
memmove((char *)objid_query->vars[0].name, (const char *)objid_mib, sizeof(objid_mib));
769769
objid_query->vars[0].name_length = sizeof(objid_mib) / sizeof(oid);
770770
}
771771
} else {

ext/standard/link.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ PHP_FUNCTION(readlink)
7575

7676
if (ret == -1) {
7777
#ifdef PHP_WIN32
78-
php_error_docref(NULL, E_WARNING, "readlink failed to read the symbolic link (%s), error %d)", link, GetLastError());
78+
php_error_docref(NULL, E_WARNING, "readlink failed to read the symbolic link (%s), error %d", link, GetLastError());
7979
#else
8080
php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
8181
#endif

0 commit comments

Comments
 (0)