|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78654 Incorrectly computed opcache checksum on files with non-ascii characters
Submitted: 2019-10-09 07:52 UTC Modified: 2019-10-17 07:37 UTC
From: mhagstrand at gmail dot com Assigned: nikic (profile)
Status: Closed Package: opcache
PHP Version: 7.2.23 OS:
Private report: No CVE-ID: None
 [2019-10-09 07:52 UTC] mhagstrand at gmail dot com
The checksum can be incorrectly computed when a file to be cached contains non-ascii characters.  When the opcache computes the checksum before it writes the file it chains together two calls to zend_adler32.

When the bin file containing the opcache is loaded it computes the checksum with a single call to zend_adler32.

The zend_adler32 function uses signed chars instead of unsigned chars. As a result non-ascii characters can have negative values. This means checksum is incorrectly computed and chained calls can result in different values than a single call to zend_adler32.

Test script:
Ini settings

$mbChars = ['°','₀','۰','0','¹','₁','۱','1','²','₂','۲','2','³','₃','۳','3','⁴','₄','۴','٤',
                'Ж',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ᅠ'];

echo "Hello World\n";

Expected result:
When the opcache is loaded from a file the checksum in the file matches the computed checksum. No warning about a corrupted file in the logs.

Actual result:
In the opcache log the following warning shows up if the opcache bin file exists.

Warning corrupted file '/tmp/285d13c8bcb81a2cb747f9609f2e9b08/opt/php-src/ext/opcache/tests/adler32_checksum.php.bin'


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-09 08:24 UTC] mhagstrand at gmail dot com
The following pull request has been associated:

Patch Name: Fix checksum calculation for opcache
On GitHub:
 [2019-10-17 07:37 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 04:01:31 2024 UTC