]> Dogcows Code - chaz/tar/blobdiff - src/unlink.c
tar: do not dereference NULL pointer with '--remove-files .'
[chaz/tar] / src / unlink.c
index 225d49b1bf2654ae8b08e769e41cc85d9ee09256..7f86cc5844a16f3aeecd1f96a69a34a2cf80de5d 100644 (file)
@@ -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)
This page took 0.016892 seconds and 4 git commands to generate.