rfc:range_checks_for_64_bit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:range_checks_for_64_bit [2015/08/24 15:51] abrfc:range_checks_for_64_bit [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== PHP RFC: Range checks for external libary APIs in 64-bit builds ======+====== PHP RFC: Range checks for external and internal APIs in 64-bit builds ======
   * Version: 0.9   * Version: 0.9
   * Date: 2015-08-24   * Date: 2015-08-24
   * Author: Anatol Belski, ab@php.net   * Author: Anatol Belski, ab@php.net
-  * Status: Draft+  * Status: withdrawn
  
 ===== Introduction ===== ===== Introduction =====
Line 36: Line 36:
  
 #if SIZEOF_INT == SIZEOF_ZEND_LONG #if SIZEOF_INT == SIZEOF_ZEND_LONG
-# define ZEND_LONG_INT_OVFL(zl) (0)+# define ZEND_LONG_UINT_OVFL(zl) (0)
 #else #else
 # define ZEND_LONG_UINT_OVFL(zlong) ((zlong) < 0 || (zlong) > (zend_long)UINT_MAX) # define ZEND_LONG_UINT_OVFL(zlong) ((zlong) < 0 || (zlong) > (zend_long)UINT_MAX)
Line 42: Line 42:
  
 #define ZEND_SIZE_T_INT_OVFL(size) ((size) > (size_t)INT_MAX) #define ZEND_SIZE_T_INT_OVFL(size) ((size) > (size_t)INT_MAX)
 +
 +#if SIZEOF_INT == SIZEOF_SIZE_T
 +# define ZEND_SIZE_T_UINT_OVFL(size) (0)
 +#else
 +# define ZEND_SIZE_T_UINT_OVFL(size) ((size) > (size_t)UINT_MAX)
 +#endif
  
 </code> </code>
Line 54: Line 60:
 </code> </code>
  
-All the macros should be put into a dedicated header, so any extensions can be put there.+All the macros should be put into a dedicated header, so any extensions and improvements can follow up in the scope
  
 ==== Proposed ZPP changes ==== ==== Proposed ZPP changes ====
Line 149: Line 155:
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
-Several new warnings or harder error handling might be introduced with the new range checks. However this should only affect the edge cases where the erorrs are actually catched. The general behaviour has to comply with the behavior in the core.+Several new warnings or harder error handling might be introduced with the new range checks. However this should only affect the edge cases where the errors are actually happen and are catched. The general behaviour has to comply with the behavior in the core.
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
Line 177: Line 183:
  
 ===== Future Scope ===== ===== Future Scope =====
 +
 Having this minimalistic start as a base, the topic of overflows in the mathematical operations can be entered. This topic is not handled by this RFC. Having this minimalistic start as a base, the topic of overflows in the mathematical operations can be entered. This topic is not handled by this RFC.
 +
 +Also, some good patterns for other cases can be added later by need. Like compare int vs size_t, or compare variables with different sizes.
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
Line 184: Line 193:
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
-The implementation of the base functionality is trivial and can be done if the proposed strategy is accepted. Many places in the core extensions related to libxml2, openssl, tidy, etc. are obvious and can be addressed step by step already before hand+The implementation of the base functionality is trivial and can be done if the proposed strategy is accepted. Many places in the core extensions related to libxml2, openssl, tidy, etc. are obvious and will be addressed already before merging.
  
 ===== Implementation ===== ===== Implementation =====
rfc/range_checks_for_64_bit.1440431513.txt.gz · Last modified: 2017/09/22 13:28 (external edit)