[php-src] PR #22572: ext/intl: Fix NumberFormatter parse offset overflow
| From: | LamentXU123 | Date: | Fri, 03 Jul 2026 10:24:45 +0000 |
| Subject: | [php-src] PR #22572: ext/intl: Fix NumberFormatter parse offset overflow | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36798@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22572
Author: LamentXU123
Same as #22423, NumberFormatter::parse() and NumberFormatter::parseCurrency() accepted the
by-reference offset as a zend_long, but then cast it directly to int32_t. So it will cause a silent
truncation.
```
<?php
$fmt = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
$offset = PHP_INT_MAX;
var_dump($fmt->parse('123', NumberFormatter::TYPE_DOUBLE, $offset));
var_dump($offset);
```
[returns](https://onlinephp.io?s=s7EvyCjg5VJJyy1RsFXISy1X8CvNTUotcssvyk0sKUkt0lBPzYsPDVbXQZewsnJxdfb0dfTRtOblApqQn5ZWnAoyJMAjIN7TLyTe1zECKFOWWBSfUppboAGyQteuILGoOFVD3dDIGJuJIZEBrvEu_qFOPq46ClATNTVRTIEKWgMA&v=8.5.6)
```
float(0)
int(-1)
```
In order to align with other previous fixes, we throw an error when the number is out of range