php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77668 ZipArchive::close crashes
Submitted: 2019-02-25 21:25 UTC Modified: 2019-02-26 10:26 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: mario at snowpaws dot de Assigned: cmb (profile)
Status: Not a bug Package: Zip Related
PHP Version: 7.3.2 OS: Windows 10/Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 - 18 = ?
Subscribe to this entry?

 
 [2019-02-25 21:25 UTC] mario at snowpaws dot de
Description:
------------
If the file date/time is set to  -1, the method ZipArchive::close() crashes on windows.

We used https://windows.php.net/downloads/releases/php-7.3.2-nts-Win32-VC15-x64.zip

Test script:
---------------
<?php
  echo "1";
  $f=fopen('test.jpg', 'w'); fputs($f, 'foobar'); fclose($f);
  touch('test.jpg', -1);
  $zip=new ZipArchive();
  $zip->open('test.zip', ZipArchive::CREATE);
  $zip->addFile('test.jpg','file');
  $zip->close();

  echo "2";
?>

Expected result:
----------------
Output: 12

Actual result:
--------------
Output: 1

and only 1 temporally zip name is created, for example test.zip.1636f7f3

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-26 10:26 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2019-02-26 10:26 UTC] cmb@php.net
I can confirm the segfault.  It is, however, not a PHP but rather
a libzip issue, since libzip calls localtime()[1] without checking
whether it returns NULL (which it does on Windows, if a negative
sourceTime is passed[2]).

Please report this issue at <https://github.com/nih-at/libzip/>.

[1] <https://github.com/nih-at/libzip/blob/rel-1-4-0/lib/zip_dirent.c#L1094>
[2] <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/localtime-localtime32-localtime64?view=vs-2017>
 [2019-02-26 13:01 UTC] mario at snowpaws dot de
This issue seems to be fixed, see https://github.com/nih-at/libzip/issues/83
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 05:01:27 2024 UTC