mirror of
https://github.com/php/php-src.git
synced 2026-10-28 17:56:50 +08:00
Negate after casting to unsigned instead of before, avoiding signed integer overflow when offset is ZEND_LONG_MIN. The same pattern existed in the pdo_sqlite and sqlite3 stream seek handlers. Closes GH-20964 Closes GH-20927
23 lines
425 B
PHP
23 lines
425 B
PHP
--TEST--
|
|
GH-20964 (fseek() on php://memory with PHP_INT_MIN causes undefined behavior)
|
|
--FILE--
|
|
<?php
|
|
$stream = fopen('php://memory', 'r+');
|
|
fwrite($stream, 'hello');
|
|
rewind($stream);
|
|
|
|
var_dump(fseek($stream, PHP_INT_MIN, SEEK_END));
|
|
var_dump(ftell($stream));
|
|
|
|
rewind($stream);
|
|
var_dump(fseek($stream, PHP_INT_MIN, SEEK_CUR));
|
|
var_dump(ftell($stream));
|
|
|
|
fclose($stream);
|
|
?>
|
|
--EXPECT--
|
|
int(-1)
|
|
bool(false)
|
|
int(-1)
|
|
bool(false)
|