[php-src] PR #17854: Fix GH-17746: Signed integer overflow when setting ATTR_TIMEOUT
| From: | cmb69 | Date: | Tue, 18 Feb 2025 16:02:51 +0000 |
| Subject: | [php-src] PR #17854: Fix GH-17746: Signed integer overflow when setting ATTR_TIMEOUT | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-30839@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/17854
Author: cmb69
::setAttribute(PDO::ATTR_TIMEOUT, …) accepts a timeout in seconds, but
sqlite3_busy_timeout()[1] expects the timeout in milliseconds, which is an
int. To avoid signed overflow, we reject values larger than the allowed range.
We also cater to negative values by simply clamping those to zero, since
sqlite3_busy_timeout() handles negative values the same as zero.
[1] <https://www.sqlite.org/c3ref/busy_timeout.html>
---
@nielsdos said:
> I wonder if we should warn in that case to notify the user that no timeout actually was
> applied.
I'm not sure about this, since that may raise an exception with ERRMODE_EXCEPTION
(and possibly even with ERRMODE_WARNING due to a global error handler), and *might*
break working code (not working as intended, but somehow working). Perhaps it's better to
postpone that to the master branch.