svn: p ecl/phar/trunk/tar.c ecl/phar/trunk/tests/tar/bignames.phpt hp/php-src/branches/PHP_5_3/NEWS hp/php-src/branches/PHP_5_3/ext/phar/tar.c
hp/php-src/branches/PHP_5_3/ext/phar/tests/tar/bignames.phpt hp/php-src/trunk/ext/phar/tar.c hp/php-src/trunk/ext/phar/tests/tar/bignames.phpt
| From: | Greg Beaver | Date: | Wed, 22 Jul 2009 18:13:38 +0000 |
| Subject: | svn: p ecl/phar/trunk/tar.c ecl/phar/trunk/tests/tar/bignames.phpt hp/php-src/branches/PHP_5_3/NEWS hp/php-src/branches/PHP_5_3/ext/phar/tar.c hp/php-src/branches/PHP_5_3/ext/phar/tests/tar/bignames.phpt hp/php-src/trunk/ext/phar/tar.c hp/php-src/trunk/ext/phar/tests/tar/bignames.phpt |
||
| Groups: | php.cvs php.pecl.cvs | ||
| Request: | Send a blank email to php-cvs+get-59730@lists.php.net to get a copy of this message | ||
cellog Wed, 22 Jul 2009 18:13:38 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=284618
Log:
fix php bug #49018 (phar tar stores long filenames with prefix/name reversed)
Bug: http://bugs.php.net/49018 (Closed) phar tar stores long
filenames with prefix/name reversed
Changed paths:
U pecl/phar/trunk/tar.c
U pecl/phar/trunk/tests/tar/bignames.phpt
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/phar/tar.c
U php/php-src/branches/PHP_5_3/ext/phar/tests/tar/bignames.phpt
U php/php-src/trunk/ext/phar/tar.c
U php/php-src/trunk/ext/phar/tests/tar/bignames.phpt
Modified: pecl/phar/trunk/tar.c
===================================================================
--- pecl/phar/trunk/tar.c 2009-07-22 16:10:00 UTC (rev 284617)
+++ pecl/phar/trunk/tar.c 2009-07-22 18:13:38 UTC (rev 284618)
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| TAR archive support for Phar |
+----------------------------------------------------------------------+
- | Copyright (c) 2005-2008 The PHP Group |
+ | Copyright (c) 2005-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -39,7 +39,7 @@
/* adapted from format_octal() in libarchive
*
- * Copyright (c) 2003-2008 Tim Kientzle
+ * Copyright (c) 2003-2009 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -343,6 +343,9 @@
}
for (j = 0; j < 100; j++) {
name[i+j] = hdr->name[j];
+ if (name[i+j] == '\0') {
+ break;
+ }
}
entry.filename_len = i+j;
@@ -644,8 +647,8 @@
}
return ZEND_HASH_APPLY_STOP;
}
- memcpy(header.prefix, entry->filename+100, entry->filename_len - 100);
- memcpy(header.name, entry->filename, 100);
+ memcpy(header.prefix, entry->filename, entry->filename_len - 100);
+ memcpy(header.name, entry->filename + (entry->filename_len - 100), 100);
} else {
memcpy(header.name, entry->filename, entry->filename_len);
}
Modified: pecl/phar/trunk/tests/tar/bignames.phpt
===================================================================
--- pecl/phar/trunk/tests/tar/bignames.phpt 2009-07-22 16:10:00 UTC (rev 284617)
+++ pecl/phar/trunk/tests/tar/bignames.phpt 2009-07-22 18:13:38 UTC (rev 284618)
@@ -11,11 +11,11 @@
$pname = 'phar://' . $fname;
$p1 = new PharData($fname);
-$p1[str_repeat('a', 101)] = 'hi';
+$p1[str_repeat('a', 100) . 'b'] = 'hi';
$p1[str_repeat('a', 255)] = 'hi2';
copy($fname, $fname2);
$p2 = new PharData($fname2);
-echo $p2[str_repeat('a', 101)]->getContent() . "\n";
+echo $p2[str_repeat('a', 100) . 'b']->getContent() . "\n";
echo $p2[str_repeat('a', 255)]->getContent() . "\n";
try {
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2009-07-22 16:10:00 UTC (rev 284617)
+++ php/php-src/branches/PHP_5_3/NEWS 2009-07-22 18:13:38 UTC (rev 284618)
@@ -6,6 +6,8 @@
- Fixed open_basedir circumvention for mail.log. (Maksymilian Arciemowicz,
Stas)
+- Fixed bug #49018 (phar tar stores long filenames wit prefix/name reversed).
+ (Greg)
- Fixed bug #48962 (cURL does not upload files with specified filename).
(Ilia)
- Fixed bug #48929 (Double \r\n after HTTP headers when "header" context
Modified: php/php-src/branches/PHP_5_3/ext/phar/tar.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/phar/tar.c 2009-07-22 16:10:00 UTC (rev 284617)
+++ php/php-src/branches/PHP_5_3/ext/phar/tar.c 2009-07-22 18:13:38 UTC (rev 284618)
@@ -343,6 +343,9 @@
}
for (j = 0; j < 100; j++) {
name[i+j] = hdr->name[j];
+ if (name[i+j] == '\0') {
+ break;
+ }
}
entry.filename_len = i+j;
@@ -644,8 +647,8 @@
}
return ZEND_HASH_APPLY_STOP;
}
- memcpy(header.prefix, entry->filename+100, entry->filename_len - 100);
- memcpy(header.name, entry->filename, 100);
+ memcpy(header.prefix, entry->filename, entry->filename_len - 100);
+ memcpy(header.name, entry->filename + (entry->filename_len - 100), 100);
} else {
memcpy(header.name, entry->filename, entry->filename_len);
}
Modified: php/php-src/branches/PHP_5_3/ext/phar/tests/tar/bignames.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/phar/tests/tar/bignames.phpt 2009-07-22 16:10:00 UTC (rev
284617)
+++ php/php-src/branches/PHP_5_3/ext/phar/tests/tar/bignames.phpt 2009-07-22 18:13:38 UTC (rev
284618)
@@ -11,11 +11,11 @@
$pname = 'phar://' . $fname;
$p1 = new PharData($fname);
-$p1[str_repeat('a', 101)] = 'hi';
+$p1[str_repeat('a', 100) . 'b'] = 'hi';
$p1[str_repeat('a', 255)] = 'hi2';
copy($fname, $fname2);
$p2 = new PharData($fname2);
-echo $p2[str_repeat('a', 101)]->getContent() . "\n";
+echo $p2[str_repeat('a', 100) . 'b']->getContent() . "\n";
echo $p2[str_repeat('a', 255)]->getContent() . "\n";
try {
Modified: php/php-src/trunk/ext/phar/tar.c
===================================================================
--- php/php-src/trunk/ext/phar/tar.c 2009-07-22 16:10:00 UTC (rev 284617)
+++ php/php-src/trunk/ext/phar/tar.c 2009-07-22 18:13:38 UTC (rev 284618)
@@ -343,6 +343,9 @@
}
for (j = 0; j < 100; j++) {
name[i+j] = hdr->name[j];
+ if (name[i+j] == '\0') {
+ break;
+ }
}
entry.filename_len = i+j;
@@ -644,8 +647,8 @@
}
return ZEND_HASH_APPLY_STOP;
}
- memcpy(header.prefix, entry->filename+100, entry->filename_len - 100);
- memcpy(header.name, entry->filename, 100);
+ memcpy(header.prefix, entry->filename, entry->filename_len - 100);
+ memcpy(header.name, entry->filename + (entry->filename_len - 100), 100);
} else {
memcpy(header.name, entry->filename, entry->filename_len);
}
Modified: php/php-src/trunk/ext/phar/tests/tar/bignames.phpt
===================================================================
--- php/php-src/trunk/ext/phar/tests/tar/bignames.phpt 2009-07-22 16:10:00 UTC (rev 284617)
+++ php/php-src/trunk/ext/phar/tests/tar/bignames.phpt 2009-07-22 18:13:38 UTC (rev 284618)
@@ -11,11 +11,11 @@
$pname = 'phar://' . $fname;
$p1 = new PharData($fname);
-$p1[str_repeat('a', 101)] = 'hi';
+$p1[str_repeat('a', 100) . 'b'] = 'hi';
$p1[str_repeat('a', 255)] = 'hi2';
copy($fname, $fname2);
$p2 = new PharData($fname2);
-echo $p2[str_repeat('a', 101)]->getContent() . "\n";
+echo $p2[str_repeat('a', 100) . 'b']->getContent() . "\n";
echo $p2[str_repeat('a', 255)]->getContent() . "\n";
try {