mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-07-30 20:22:37 +00:00
tar: do not dereference NULL pointer with '--remove-files .'
Problem reported by Thorsten Hirsch in: http://lists.gnu.org/archive/html/bug-tar/2014-04/msg00011.html * src/unlink.c (flush_deferred_unlinks): Do not attempt to find the parent of "." when "." is at the top level. * tests/remfiles10.at: New file. * tests/Makefile.am (TESTSUITE_AT): * tests/testsuite.at: Add it.
This commit is contained in:
+5
-4
@@ -73,7 +73,7 @@ flush_deferred_unlinks (bool force)
|
||||
{
|
||||
struct deferred_unlink *p, *prev = NULL;
|
||||
int saved_chdir = chdir_current;
|
||||
|
||||
|
||||
for (p = dunlink_head; p; )
|
||||
{
|
||||
struct deferred_unlink *next = p->next;
|
||||
@@ -86,15 +86,16 @@ flush_deferred_unlinks (bool force)
|
||||
{
|
||||
const char *fname;
|
||||
|
||||
if (p->file_name[0] == 0 ||
|
||||
strcmp (p->file_name, ".") == 0)
|
||||
if (p->dir_idx
|
||||
&& (p->file_name[0] == 0
|
||||
|| strcmp (p->file_name, ".") == 0))
|
||||
{
|
||||
fname = tar_dirname ();
|
||||
chdir_do (p->dir_idx - 1);
|
||||
}
|
||||
else
|
||||
fname = p->file_name;
|
||||
|
||||
|
||||
if (unlinkat (chdir_fd, fname, AT_REMOVEDIR) != 0)
|
||||
{
|
||||
switch (errno)
|
||||
|
||||
Reference in New Issue
Block a user