mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fix undefined behaviour in GENERATE_SEED() Fix undefined behaviour when writing 32-bit values in phar/tar.c
This commit is contained in:
commit
0b212ab5ab
2 changed files with 10 additions and 8 deletions
|
@ -1240,13 +1240,15 @@ nostub:
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
# define PHAR_SET_32(var, buffer) \
|
# define PHAR_SET_32(destination, source) do { \
|
||||||
*(uint32_t *)(var) = (((((unsigned char*)&(buffer))[3]) << 24) \
|
uint32_t swapped = (((((unsigned char*)&(source))[3]) << 24) \
|
||||||
| ((((unsigned char*)&(buffer))[2]) << 16) \
|
| ((((unsigned char*)&(source))[2]) << 16) \
|
||||||
| ((((unsigned char*)&(buffer))[1]) << 8) \
|
| ((((unsigned char*)&(source))[1]) << 8) \
|
||||||
| (((unsigned char*)&(buffer))[0]))
|
| (((unsigned char*)&(source))[0])); \
|
||||||
|
memcpy(destination, &swapped, 4); \
|
||||||
|
} while (0);
|
||||||
#else
|
#else
|
||||||
# define PHAR_SET_32(var, buffer) *(uint32_t *)(var) = (uint32_t) (buffer)
|
# define PHAR_SET_32(destination, source) memcpy(destination, &source, 4)
|
||||||
#endif
|
#endif
|
||||||
PHAR_SET_32(sigbuf, phar->sig_flags);
|
PHAR_SET_32(sigbuf, phar->sig_flags);
|
||||||
PHAR_SET_32(sigbuf + 4, signature_length);
|
PHAR_SET_32(sigbuf + 4, signature_length);
|
||||||
|
|
|
@ -65,9 +65,9 @@ PHPAPI double php_combined_lcg(void);
|
||||||
(__n) = (__min) + (zend_long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0)))
|
(__n) = (__min) + (zend_long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0)))
|
||||||
|
|
||||||
# ifdef PHP_WIN32
|
# ifdef PHP_WIN32
|
||||||
# define GENERATE_SEED() (((zend_long) (time(0) * GetCurrentProcessId())) ^ ((zend_long) (1000000.0 * php_combined_lcg())))
|
# define GENERATE_SEED() (((zend_long) ((zend_ulong) time(NULL) * (zend_ulong) GetCurrentProcessId())) ^ ((zend_long) (1000000.0 * php_combined_lcg())))
|
||||||
# else
|
# else
|
||||||
# define GENERATE_SEED() (((zend_long) (time(0) * getpid())) ^ ((zend_long) (1000000.0 * php_combined_lcg())))
|
# define GENERATE_SEED() (((zend_long) ((zend_ulong) time(NULL) * (zend_ulong) getpid())) ^ ((zend_long) (1000000.0 * php_combined_lcg())))
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define PHP_MT_RAND_MAX ((zend_long) (0x7FFFFFFF)) /* (1<<31) - 1 */
|
# define PHP_MT_RAND_MAX ((zend_long) (0x7FFFFFFF)) /* (1<<31) - 1 */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue