|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-10-14 10:30 UTC] mberchtold at gmail dot com
[2014-11-28 09:23 UTC] ab@php.net
[2014-11-28 09:23 UTC] ab@php.net
-Status: Open
+Status: Closed
[2014-12-05 07:00 UTC] ab@php.net
[2016-07-20 11:40 UTC] davey@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 10:00:01 2026 UTC |
Description: ------------ unpack with the X format code is broken. There are 2 related issues: 1. Unexpected warning PHP Warning: unpack(): Type X: outside of string The bug is here: File: php-src / ext / standard / pack.c In the following snipped size is -1 for the X format code, therefore the first condition if (inputpos < size) is always true. case 'X': if (inputpos < size) { inputpos = -size; i = arg - 1; /* Break out of for loop */ if (arg >= 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type %c: outside of string", type); } } break; 2. unpack returns false and additional warning: HP Warning: unpack(): Type X: not enough input, need -1, have 0 Test script: --------------- <?php $data = pack('VV', 1, 2); $result = unpack('Va/X' ,$data); // PHP Warning: unpack(): Type X: outside of string $result = unpack('Va/X4' ,$data); // PHP Warning: unpack(): Type X: outside of string $result = unpack('V1a/X4/V1b/V1c/X4/V1d', $data); // PHP Warning: unpack(): Type X: outside of string // PHP Warning: unpack(): Type X: not enough input, need -1, have 0 // unpack returns false var_dump($result); ?> Expected result: ---------------- No warnings. No failures Actual result: -------------- Warnings: PHP Warning: unpack(): Type X: outside of string PHP Warning: unpack(): Type X: not enough input, need -1, have 0 And wrong result.