|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-09-27 10:23 UTC] cmb@php.net
-Status: Open
+Status: Verified
[2021-09-27 10:23 UTC] cmb@php.net
[2024-07-06 16:34 UTC] git@php.net
[2024-07-06 16:34 UTC] git@php.net
-Status: Verified
+Status: Closed
[2024-09-09 12:49 UTC] git@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 03:00:02 2025 UTC |
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