User Tools

Site Tools


ja:rule:num:整数値のオーバーフローを検出_防止する

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
ja:rule:num:整数値のオーバーフローを検出_防止する [2016/03/19 00:31] yohgakija:rule:num:整数値のオーバーフローを検出_防止する [2017/06/30 11:32] (current) – [参考文献] yohgaki
Line 74: Line 74:
 // Check signed 32 bit integer overflow // Check signed 32 bit integer overflow
 // Under 32 bit OS, $myint became float. Under 64 bit OS, check 32 bit integer range // Under 32 bit OS, $myint became float. Under 64 bit OS, check 32 bit integer range
-if (is_float($myint) || $myint < 0xFFFFFFFF || $myint > 0xEFFFFFFF) {+if (is_float($myint) || $myint < 0x80000000 || $myint > 0xEFFFFFFF) {
   throw new Exception('32 bit integer overflow');   throw new Exception('32 bit integer overflow');
 } }
Line 103: Line 103:
 ===== 参考文献 ===== ===== 参考文献 =====
  
 +  * https://blog.ohgaki.net/checking-php-int-type-overflow-underflow
 +  * https://blog.ohgaki.net/computers-cannot-handle-numeric-value-correctly
 +  * https://blog.ohgaki.net/php7-type-hint-problem-with-int-and-float
ja/rule/num/整数値のオーバーフローを検出_防止する.1458347508.txt.gz · Last modified: 2016/03/19 00:31 by yohgaki

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki