Bug #81481 [NEW]: xml_get_current_byte_index limited to 32-bit numbers on 64-bit builds
| From: | dev at b65sol dot com | Date: | Sun, 26 Sep 2021 15:41:47 +0000 |
| Subject: | Bug #81481 [NEW]: xml_get_current_byte_index limited to 32-bit numbers on 64-bit builds | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-236851@lists.php.net to get a copy of this message | ||
From: dev at b65sol dot com
Operating system: 64-bit Linux
PHP version: 8.0.11
Package: XML Reader
Bug Type: Bug
Bug description:xml_get_current_byte_index limited to 32-bit numbers on 64-bit builds
Description:
------------
xml_get_current_byte_index is limited to 32-bit integers even on 64-bit
builds, resulting in negative or incorrectly small results after parsing
2GiB or more XML text, which is well below PHP_INT_MAX.
To get the "Expected" results listed, I changed the definition on
XML_GetCurrentByteIndex to be long instead of int, but I'm unsure if
that's a truly portable fix.
Test script:
---------------
<?php
$parser = xml_parser_create('UTF-8');
xml_set_element_handler( $parser, 'startelement', null );
$emptylong = str_repeat(' ', 1024*1024);
xml_parse($parser,
'<root><i></i><b/><ext>Hello</ext>', false);
for($i = 0; $i < 2896; $i++) {
xml_parse($parser, $emptylong, false);
}
xml_parse($parser, '<ext></ext><ext></ext></root>', false);
function startelement($parser, $name, $attribute) {
if ( $name == 'EXT' ) { echo "Byte
Index:".xml_get_current_byte_index($parser)."\n"; }
}
Expected result:
----------------
Byte Index:21
Byte Index:3036676133
Byte Index:3036676144
Actual result:
--------------
Byte Index:21
Byte Index:-1258291163
Byte Index:-1258291152
--
Edit bug report at https://bugs.php.net/bug.php?id=81481&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81481&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81481&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81481&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81481&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81481&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81481&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81481&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81481&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81481&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81481&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81481&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81481&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81481&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81481&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81481&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81481&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81481&r=mysqlcfg