|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49130 sha1_file() returns incorrect/unpredictable values
Submitted: 2009-08-01 10:47 UTC Modified: 2009-08-25 01:00 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: adam at elishome dot org Assigned:
Status: No Feedback Package: hash related
PHP Version: 5.2.10 OS: freebsd
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-08-01 10:47 UTC] adam at elishome dot org
The value returned for the sha1_file() function is not reliable.

The sha1_file function's result in PHP 5.2.10 is not the same as the sha1 value returned by the freebsd system, or by ruby's sha1 function.

PHP 5.2.9 always returns the correct sha1 values, but 5.2.10 does not.  It occasionally gets it right, but the large majority of the time it is incorrect.

Reproduce code:
Lookup a file's sha1 value using PHP 5.2.9 using the sha1_file function (or using freebsd's system function, or using Ruby's sha1 function), and then compare it to the value returned by PHP 5.2.10's sha1_file function.

Expected result:
I expect the sha1_file function to return correct values.

Actual result:
The values returned by sha1_file were not correct.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-13 09:56 UTC] sjoerd-php at linuxonly dot nl
Thank you for your bug report.

Since I could not reproduce it, I have some questions for you. Can you reproduce the problem on a system with another OS? Is the output of php-5.2.10 sha1_file consistent for a given file, or does it give a different output each time? Can you supply an example file which gives a wrong hash, with both the good and the wrong hash?
 [2009-08-17 02:08 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

I can't reproduce this.

Nothing in the sha code has changed in 2+ years.
 [2009-08-25 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Feb 04 23:03:39 2023 UTC