[php-src] Issue #20962: UndefinedBehaviorSanitizer crash in SQLite3 BLOB fseek(PHP_INT_MIN, SEEK_END)
| From: | arshidkv12 | Date: | Sun, 18 Jan 2026 03:35:52 +0000 |
| Subject: | [php-src] Issue #20962: UndefinedBehaviorSanitizer crash in SQLite3 BLOB fseek(PHP_INT_MIN, SEEK_END) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251559@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20962
Author: arshidkv12
### Description
The following code:
```php
<?php
$db = new SQLite3(':memory:');
$db->exec('CREATE TABLE test (id TEXT, data BLOB)');
$stmt = $db->prepare('INSERT INTO test (id, data) VALUES (:id, :data)');
$stmt->bindValue(':id', 'a', SQLITE3_TEXT);
$stmt->bindValue(':data', 'TEST TEST', SQLITE3_BLOB);
$stmt->execute();
$row = $db->querySingle("SELECT data FROM test WHERE id='a'", true);
$stream = $db->openBlob('test', 'data', 1);
var_dump(fseek($stream, PHP_INT_MIN, SEEK_END));
```
Resulted in this output:
```
php-src/ext/sqlite3/sqlite3.c:1193:47: runtime error: negation of -9223372036854775808 cannot be
represented in type 'zend_off_t' (aka 'long long'); cast to an unsigned type to
negate this value to itself
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/Users/arshid/Downloads/php-src/ext/sqlite3/sqlite3.c:1193:47
[2] 88129 abort sapi/cli/php z.php
```
But I expected this output instead:
```
int(-1)
```
### PHP Version
```plain
PHP 8.4.11 (cli) (built: Jul 29 2025 15:30:21) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.11, Copyright (c) Zend Technologies
with Xdebug v3.5.0, Copyright (c) 2002-2025, by Derick Rethans
with Zend OPcache v8.4.11, Copyright (c), by Zend Technologies
```
### Operating System
_No response_