Menu

#621 (ok 3.4) rare ZIP archive dates generate error

closed-accepted
1
2011-05-11
2011-04-04
No

Minor fix for rare occurrence: zipping files with dates <1981 generates the following errors:

PHP Notice: Uninitialized string offset: 6 in /home/carcich/phpmyadmin/libraries/zip.lib.php on line 100
PHP Notice: Uninitialized string offset: 7 in /home/carcich/phpmyadmin/libraries/zip.lib.php on line 100

This does occasionally happen.

Test with this code (send stdout to x.zip):

<?php
$fn='zip.lib.php';
require_once $fn';
$zf = new zipfile;
$zf -> addFile( file_get_contents( $fn), $fn, 315640920); // 315640920 is 1980-01-02 01:02
echo $zf -> file();
?>

N.B. Also submitted with patch 3271853; separated out here to isolate bug and feature request

Discussion

  • Brian Carcich

    Brian Carcich - 2011-04-04
     
  • Michal Čihař

    Michal Čihař - 2011-04-05
    • priority: 5 --> 1
    • summary: Patch for Bug 3271816; rare ZIP archive dates generate error --> (ok 3.4) rare ZIP archive dates generate error
    • status: open --> open-accepted
     
  • Michal Čihař

    Michal Čihař - 2011-04-05

    Merged, though I don't think this does affect our case (the dates should not be that in our past).

     
  • Michal Čihař

    Michal Čihař - 2011-04-05
    • assigned_to: nobody --> nijel
     
  • Brian Carcich

    Brian Carcich - 2011-04-05

    Michal, Thanks!

    FYI:

    I agree that this bug is unlikely to affect phpMyAdmin. I can't even find where zip.lib.php is used.

    However, this routine has been picked up and used by others.

    The only reason I noticed this bug was that I have used zip.lib.php for a project of my own, and I had a problem wrt the memory_limit in php.ini (see Feature request 3271770), and I used a fixed old timestamp for testing i.e. so that I could confirm identical results of ZIP archive files produced by different methods.

     
  • Michal Čihař

    Michal Čihař - 2011-04-05

    I can see three uses of zip.lib.php quite easily:

    $ git grep /zip.lib.php
    export.php:require_once './libraries/zip.lib.php';
    libraries/opendocument.lib.php:require_once './libraries/zip.lib.php';
    webapp.php:require './libraries/zip.lib.php';

     
  • Brian Carcich

    Brian Carcich - 2011-04-05

    Ah yes, there they are; I don't know how I missed them. Thanks.

    Also: I could have used str_pad( dechex(...), 8, '0', STR_PAD_LEFT) instead of substr( '00000000' . dechex(...), -8)

     
  • Michal Čihař

    Michal Čihař - 2011-05-11
    • status: open-accepted --> closed-accepted
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.