php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69271 ext/phar/tests/zip/phar_setsignaturealgo2.phpt fails
Submitted: 2015-03-20 15:05 UTC Modified: 2018-08-05 04:12 UTC
From: ondrej@php.net Assigned: carusogabriel (profile)
Status: Closed Package: PHAR related
PHP Version: 5.4.39 OS: Debian wheezy
Private report: No CVE-ID: None
 [2015-03-20 15:05 UTC] ondrej@php.net
Description:
------------
It looks like there's something fishy going on in phar/zip, as the test fails with the SHA-512 output listed twice instead of one SHA-512 and one OpenSSL.

Rerunning the test manually (copying out the script part from .phpt) works fine:

php -n -d phar.require_hash=0 -d phar.readonly=0 phar_setsignaturealgo2.php

[...see Expected results...]

so this might happen only in a very rare cases, but I don't recall this happening before, so it might have been introduced in 5.4.39.

Looks like this might happen if signing with openssl fails (the SHA-512 signature is retained), related bug: https://bugs.php.net/bug.php?id=61906

Unfortunately no warnings were provided this time and I cannot reproduce the issue except this one build.

Test script:
---------------
Standard test as found in ext/phar/tests/zip/phar_setsignaturealgo2.phpt


Expected result:
----------------
array(2) {
  ["hash"]=>
  string(32) "41F52A687D44E275EDD28190A95BA9A7"
  ["hash_type"]=>
  string(3) "MD5"
}
array(2) {
  ["hash"]=>
  string(32) "41F52A687D44E275EDD28190A95BA9A7"
  ["hash_type"]=>
  string(3) "MD5"
}
array(2) {
  ["hash"]=>
  string(40) "BB20CA7A9336A23FABA77DF462D249AA17EF8BA1"
  ["hash_type"]=>
  string(5) "SHA-1"
}
array(2) {
  ["hash"]=>
  string(64) "2B70E40D73E36B241804714D2F66DE10A00763AE17911EB0385181F98841CB3A"
  ["hash_type"]=>
  string(7) "SHA-256"
}
array(2) {
  ["hash"]=>
  string(128) "624BECAE7FE58642594E0A2ECDE2729D86E35955E6461CE287C1A1A5D040CF902CE2EA2DB1EB5D76B2B64F5F7DDA9613FE63C15A46435120408FE92ED67F104A"
  ["hash_type"]=>
  string(7) "SHA-512"
}
array(2) {
  ["hash"]=>
  string(256) "CD8B9E756A7096EE51420C130814AA8585E05E8004DA05EE6B1E035087CB05574BF5C40D8353E432EE2C904E99D1E77F71F6942E2F2CB747695CE6C7C46EC3F3E41DE636C7077DAC54E7049A4F361C1C9B39EA8E535B816AB3D8794DAD5915A09D1A505FD4C165ACAF46D78D9A6CDDBE7AFE6FC65C67AB7684A0EC593B8361AF"
  ["hash_type"]=>
  string(7) "OpenSSL"
}


Actual result:
--------------
array(2) {
  ["hash"]=>
  string(40) "3D26CC3B912BBB02C55F649706E8B39883C60E88"
  ["hash_type"]=>
  string(5) "SHA-1"
}
array(2) {
  ["hash"]=>
  string(32) "B8B09BC157C79208E9E8FF6D65C22591"
  ["hash_type"]=>
  string(3) "MD5"
}
array(2) {
  ["hash"]=>
  string(40) "3D26CC3B912BBB02C55F649706E8B39883C60E88"
  ["hash_type"]=>
  string(5) "SHA-1"
}
array(2) {
  ["hash"]=>
  string(64) "ED774B2ACAC8AE2C806CC0C205B26EF3E757C5F5893AC59B7F0B432D8F777939"
  ["hash_type"]=>
  string(7) "SHA-256"
}
array(2) {
  ["hash"]=>
  string(128) "F6A3978098FA4ED528FB354C5AC026F82C7A33561C1D7A89753830B33666BB304EAB062C4C9A808547F5C220F0B13CBD7F548D401489F8645BB12302F689D09E"
  ["hash_type"]=>
  string(7) "SHA-512"
}
array(2) {
  ["hash"]=>
  string(128) "F6A3978098FA4ED528FB354C5AC026F82C7A33561C1D7A89753830B33666BB304EAB062C4C9A808547F5C220F0B13CBD7F548D401489F8645BB12302F689D09E"
  ["hash_type"]=>
  string(7) "SHA-512"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-20 15:38 UTC] ondrej@php.net
I can reproduce the bug when running tests as a part of Debian package building process, however I cannot reproduce this when running this separately.

I will try to get some more useful information during next week (unless somebody has an idea what might be happening...)
 [2015-03-20 15:52 UTC] ondrej@php.net
Ok, I have just reproduced a failure in this test, it's completely random and it looks like it can fail at different algoritms:

# php run-tests.php -q --keep-all --no-clean --show-diff -s failed.out -a failed.log -n ext/phar/tests/zip/phar_setsignaturealgo2.phpt

=====================================================================
PHP         : /usr/bin/php 
PHP_SAPI    : cli
PHP_VERSION : 5.4.39-0+deb7u1
ZEND_VERSION: 2.4.0
PHP_OS      : Linux - Linux lettie.nic.cz 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u2 x86_64
INI actual  : /tmp/php-src
More .INIs  :  
CWD         : /tmp/php-src
Extra dirs  : 
VALGRIND    : Not used
=====================================================================
Running selected tests.
TEST 1/1 [ext/phar/tests/zip/phar_setsignaturealgo2.phpt]
========DIFF========
005+   string(3) "MD5"
005-   string(5) "SHA-1"
========DONE========
FAIL Phar::setSupportedSignatures() with hash, zip-based [ext/phar/tests/zip/phar_setsignaturealgo2.phpt] 
=====================================================================
Number of tests :    1                 1
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    1 (100.0%) (100.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      :    0 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Phar::setSupportedSignatures() with hash, zip-based [ext/phar/tests/zip/phar_setsignaturealgo2.phpt]
=====================================================================
 [2015-03-20 15:57 UTC] ondrej@php.net
Disregard the last comment, this happens when --no-clean is used.

I am going to try again since I can reproduce this only in the build.
 [2015-03-20 16:04 UTC] ab@php.net
Ondrej,

I guess it's unlikely fails due to the test change. The patch in bug #61906 is purely to force the usage of the openssl.cnf supplied with the test suite. I'd rather guess it could be because of phar/openssl itself or some issue in the build process.

Cheers.
 [2015-03-20 18:28 UTC] ondrej@php.net
I wasn't implying that the test change caused that, just you might have an idea what might be happening :).

I'll give it some more debugging next week since running this in a loop:

while [ "$(wc -l failed.log | cut -f 1 -d \ )" -eq 0 ]; do php run-tests.php -q --keep-all --show-diff -s failed.out -a failed.log -n ext/phar/tests/zip/phar_setsignaturealgo2.phpt >/dev/null 2>/dev/null; done 

still hasn't failed (I ran it for ~2 hours).

It fails only as a part of the build.  I run a full test suite during the build, so that's the only difference - Perhaps there's some leftovers from some other test that is causing this to fail.
 [2015-03-24 20:00 UTC] ab@php.net
Another idea that maybe could help. During your builds, do the test run in parallel (or maybe you run multiple builds simultaneously)? Namely if yes, it could collide with the same test or with something in the other tests which could overwrite each others files.

Otherwise, hm ... might be some weird bug in the output buffering. Whereby it would be showing itself at a lot of other places, if so.

Thanks.
 [2015-08-24 17:03 UTC] cmb@php.net
Looks like you're not the only one for whom this test is failing,
Ondřej:
<https://qa.php.net/reports/viewreports.php?version=5.6.10&test=%2Fext%2Fphar%2Ftests%2Fzip%2Fphar_setsignaturealgo2.phpt>.

The other test result looks like PHP crashes during the test.
 [2018-08-05 04:12 UTC] carusogabriel@php.net
Closing as this test was already fixed, as described in Bug #61906, as isn't shown in http://gcov.php.net/viewer.php?version=PHP_HEAD&func=tests
 [2018-08-05 04:12 UTC] carusogabriel@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: carusogabriel
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 19:01:30 2024 UTC