Bug 91042 - PCRE functions in php incorrectly process binary data containing binary zeros
PCRE functions in php incorrectly process binary data containing binary zeros
Status: CLOSED WONTFIX
Product: Red Hat Linux
Classification: Retired
Component: php (Show other bugs)
7.3
All Linux
medium Severity medium
: ---
: ---
Assigned To: Joe Orton
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-05-16 14:58 EDT by Need Real Name
Modified: 2007-04-18 12:53 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-01-25 11:47:43 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2003-05-16 14:58:57 EDT
Description of problem:
PCRE-functions do not correctly process binary data containing binary zeros.
Results are being truncated at the first binary zero in the resulting string.

For example, pattern "/.*/s" should match all incoming strings, but it matches
only part of the string from the beginning to the first binary zero. This
problem seems to be common in preg_match and preg_match_all functions.

Version-Release number of selected component (if applicable):
php-4.1.2-7.3.6

How reproducible:
Consistently

Steps to Reproduce:
The following short script illustrates the problem. It reads a .jpg and .pdf
file, and outputs the real length of each file and the length as parsed by the
"preg_match" function.  On a default RH7.3 system the parsed lengths will be
much smaller, but using php compiled from source this works as expected and the
parsed length will match the real length.

<?
$f=fopen('test.pdf', 'rb');
$data=fread($f, filesize('test.pdf'));
fclose($f);
preg_match('/.*/s', $data, $matches);

echo 'PDF<br>
';
echo 'Source data length: ' . strlen($data) . '<br>
';
#print_r($matches);
echo 'Parsed data length: ' . strlen($matches[0]) . '<br>
';

$f=fopen('test.jpg', 'rb');
$data=fread($f, filesize('test.jpg'));
fclose($f);
preg_match('/.*/s', $data, $matches);

echo 'JPEG<br>
';
echo 'Source data length: ' . strlen($data) . '<br>
';
#print_r($matches);
echo 'Parsed data length: ' . strlen($matches[0]) . '<br>
';
?>

    
Actual results:
pcre function incorrectly processes binary data.

Expected results:
Correctly processs that binary data. :)

Additional info:
The behavior appears identical to the bug described in the link below. The php
site says it was fixed in January of 2002.

http://bugs.php.net/bug.php?id=14173
Comment 1 Joe Orton 2005-01-25 11:47:43 EST
Thanks for the report.  This is a mass bug update; since this release
of Red Hat Linux is no longer supported, please either:

a) try and reproduce the bug with a supported version of Red Hat
Enterprise Linux or Fedora Core, and re-open this bug as appropriate
after changing the Product field, or,

b) if relevant, try and reproduce this bug using the current version
of the upstream package, and report the bug upstream.

c) report the bug to the Fedora Legacy project who may wish to
continue maintenance of this package.

Note You need to log in before you can comment on or make changes to this bug.