]> granicus.if.org Git - php/commitdiff
Fix shift UB in constants
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 19 Jun 2019 10:47:56 +0000 (12:47 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 19 Jun 2019 13:09:00 +0000 (15:09 +0200)
We were shifting out the top bit of a signed integer.

Zend/zend_alloc.c
Zend/zend_compile.h
Zend/zend_gc.c

index 9c081477d031254fcb662acf197345ced941b6d8..93660e1cdc42540b4338670ac8c0f32774bff8c0 100644 (file)
@@ -591,7 +591,7 @@ static zend_always_inline void zend_mm_bitset_reset_range(zend_mm_bitset *bitset
 
                if (pos != end) {
                        /* reset bits from "bit" to ZEND_MM_BITSET_LEN-1 */
-                       tmp = ~((Z_L(1) << bit) - 1);
+                       tmp = ~((Z_UL(1) << bit) - 1);
                        bitset[pos++] &= ~tmp;
                        while (pos != end) {
                                /* set all bits */
index b47d762a7487853f659adb123ac0c8951be7db21..0ca688c5ff34a0ab245e43a58c0741a1d36a7abf 100644 (file)
@@ -516,7 +516,7 @@ struct _zend_execute_data {
 #define ZEND_CALL_FAKE_CLOSURE       (1 << 23)
 #define ZEND_CALL_GENERATOR          (1 << 24)
 #define ZEND_CALL_DYNAMIC            (1 << 25)
-#define ZEND_CALL_SEND_ARG_BY_REF    (1 << 31)
+#define ZEND_CALL_SEND_ARG_BY_REF    (1u << 31)
 
 #define ZEND_CALL_NESTED_FUNCTION    (ZEND_CALL_FUNCTION | ZEND_CALL_NESTED)
 #define ZEND_CALL_NESTED_CODE        (ZEND_CALL_CODE | ZEND_CALL_NESTED)
index 7ed3078ed1e797da8fa036404391b68c97985a39..a5eb711f318b4039a4b2f14e37f9622e4c99364d 100644 (file)
 #endif
 
 /* GC_INFO layout */
-#define GC_ADDRESS  0x0fffff
-#define GC_COLOR    0x300000
+#define GC_ADDRESS  0x0fffffu
+#define GC_COLOR    0x300000u
 
-#define GC_BLACK    0x000000 /* must be zero */
-#define GC_WHITE    0x100000
-#define GC_GREY     0x200000
-#define GC_PURPLE   0x300000
+#define GC_BLACK    0x000000u /* must be zero */
+#define GC_WHITE    0x100000u
+#define GC_GREY     0x200000u
+#define GC_PURPLE   0x300000u
 
 /* GC_INFO access */
 #define GC_REF_ADDRESS(ref) \