[php-src] Issue #15980: Signed integer overflow in main/streams/streams.c

From: Date: Sun, 22 Sep 2024 09:09:55 +0000
Subject: [php-src] Issue #15980: Signed integer overflow in main/streams/streams.c
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-247850@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/15980 Author: YuanchengJiang ### Description The following code: ```php <?php $file_modes = array( "w","wb","wt","w+","w+b","w+t", "x","xb","xt","x+","x+b","x+t"); $file_content_types = array( "text_with_new_line","alphanumeric"); $offset = array(-1,0,1,PHP_INT_MAX,600); // different offsets $filename = __DIR__."/fseek_ftell_rewind_variation6.tmp"; // this is name of the file created by create_files() foreach($file_content_types as $file_content_type){ foreach($file_modes as $file_mode) { $file_handle = fopen($filename, $file_mode); foreach($offset as $count){ var_dump( fseek($file_handle,$count,SEEK_CUR) ); } //end of offset loop } //end of file_mode loop } //end of file_content_types loop ``` Resulted in this output: ``` /php-src/main/streams/streams.c:1385:31: runtime error: signed integer overflow: 1 + 9223372036854775807 cannot be represented in type 'long' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/main/streams/streams.c:1385:31 in ``` ### PHP Version PHP 8.4.0-dev ### Operating System ubuntu 22.04

« previous php.bugs (#247850) next »