Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checksum calculation for opcache #4804

Closed
wants to merge 1 commit into from

Conversation

mhagstrand
Copy link
Contributor

@mhagstrand mhagstrand commented Oct 9, 2019

https://bugs.php.net/bug.php?id=78654

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.

https://github.com/php/php-src/blob/PHP-7.2.24/ext/opcache/zend_file_cache.c#L870

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

https://github.com/php/php-src/blob/PHP-7.2.24/ext/opcache/zend_file_cache.c#L1461

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

https://github.com/php/php-src/blob/PHP-7.2.24/ext/opcache/zend_accelerator_util_funcs.c#L738

Added two pieces of additional logging. The first is to show when the opcache is load from a file into to memory. The second is to show the expect and actual checksums when when a file does not fails the check.

ext/opcache/zend_file_cache.c Outdated Show resolved Hide resolved
@krakjoe
Copy link
Member

krakjoe commented Oct 14, 2019

Merged as e2a6bf4

Thanks.

@krakjoe krakjoe closed this Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants