Skip to content

Signed integer overflow in main/streams/streams.c #15980

Description

@YuanchengJiang

Description

The following code:

<?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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions