diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 1edc0083449..60e248c78df 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -1240,13 +1240,15 @@ nostub: return EOF; } #ifdef WORDS_BIGENDIAN -# define PHAR_SET_32(var, buffer) \ - *(uint32_t *)(var) = (((((unsigned char*)&(buffer))[3]) << 24) \ - | ((((unsigned char*)&(buffer))[2]) << 16) \ - | ((((unsigned char*)&(buffer))[1]) << 8) \ - | (((unsigned char*)&(buffer))[0])) +# define PHAR_SET_32(destination, source) do { \ + uint32_t swapped = (((((unsigned char*)&(source))[3]) << 24) \ + | ((((unsigned char*)&(source))[2]) << 16) \ + | ((((unsigned char*)&(source))[1]) << 8) \ + | (((unsigned char*)&(source))[0])); \ + memcpy(destination, &swapped, 4); \ + } while (0); #else -# define PHAR_SET_32(var, buffer) *(uint32_t *)(var) = (uint32_t) (buffer) +# define PHAR_SET_32(destination, source) memcpy(destination, &source, 4) #endif PHAR_SET_32(sigbuf, phar->sig_flags); PHAR_SET_32(sigbuf + 4, signature_length); diff --git a/ext/random/php_random.h b/ext/random/php_random.h index a29095fd2e3..f991cc2d79d 100644 --- a/ext/random/php_random.h +++ b/ext/random/php_random.h @@ -65,9 +65,9 @@ PHPAPI double php_combined_lcg(void); (__n) = (__min) + (zend_long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0))) # 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 -# 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 # define PHP_MT_RAND_MAX ((zend_long) (0x7FFFFFFF)) /* (1<<31) - 1 */