Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PharData limitation of file name length

Tags:

php

tar

phar

I'm experiencing issues with a PharData and longer FileNames. I get the following exception:

tar-based phar \"2014-07-17-09-22-32.tar\" cannot be created, filename \"XXX.99999.YYYYYYYYYYYYYYYY.YYYYYYY.YYYYYYYYYYYYYYYYYYYYYYYYY.5f4a75e7-ee73-49f1-8a27-9440cfb35196.1405588952.xml\" is too long for tar file format

(sorry, had to encrypt a little ^^)

Now the weird thing is, if I use this command from the CommandLine, it works like a charm:

tar cvf foo.tar XXX.99999.YYYYYYYYYYYYYYYY.YYYYYYY.YYYYYYYYYYYYYYYYYYYYYYYYY.5f4a75e7-ee73-49f1-8a27-9440cfb35196.1405588952.xml

I am unable to find any information about PharData having different limitations than what TAR offers. Are there any options I can use for PharData? Many thanks in advance!

like image 335
Sam Avatar asked Jan 11 '23 05:01

Sam


1 Answers

Allowing file names longer than 100 chars is an GNU extension to the tar standard. (ustar). PHP handles file names correctly.

You can verify this by passing the -o (--old-archive) option to GNU tar, it will trow an error:

$ tar ocvf foo.tar XXX.99999.YYYYYYYYYYYYYYYY.YYYYYYY.YYYYYYYYYYYYYYYYYYYYYYYYY.5f4a75e7-ee73-49f1-8a27-9440cfb35196.1405588952.xml
tar: XXX.99999.YYYY...588952.xml: file name is too long (max 99); not dumped
tar: Exiting with failure status due to previous errors

I've found the following documentation:

GNU tar was based on an early draft of the POSIX 1003.1 ustar standard. GNU extensions to tar, such as the support for file names longer than 100 characters, use portions of the tar header record which were specified in that POSIX draft as unused. Subsequent changes in POSIX have allocated the same parts of the header record for other purposes. As a result, GNU tar is incompatible with the current POSIX spec, and with tar programs that follow it.


Btw, this restriction was added to PHP by this commit: https://github.com/php/php-src/commit/667c59abd697d5d80cb0cadf6a5cb7d94dee3a22

The commit was made because of the following bug report: https://bugs.php.net/bug.php?id=49020

like image 144
hek2mgl Avatar answered Jan 22 '23 05:01

hek2mgl