tar: don't crash if getcwd fails
* src/extract.c: Don't include xgetcwd.h. (extract_dir): stat "." rather than statting getcwd's output. * src/misc.c (normalize_filename_x): Rewrite so as not to resolve /../, which can't be done reliably in the presence of symlinks. Don't reject valid names such as ".". (normalize_filename): Don't make it absolute; that way, we don't have to invoke xgetcwd which might fail. Don't bother to realloc at the end, since that uses time and now saves little space. (chdir_do): Don't crash if xgetcwd fails. * tests/Makefile.am (TESTSUITE_AT): Add listed03.at. * tests/listed03.at: New file. * tests/testsuite.at: Include listed03.at.
This commit is contained in:
committed by
Paul Eggert
parent
ab6dd4948d
commit
cc40c57a37
@@ -23,7 +23,6 @@
|
||||
#include <quotearg.h>
|
||||
#include <utimens.h>
|
||||
#include <errno.h>
|
||||
#include <xgetcwd.h>
|
||||
#include <priv-set.h>
|
||||
|
||||
#include "common.h"
|
||||
@@ -648,13 +647,11 @@ extract_dir (char *file_name, int typeflag)
|
||||
if (one_file_system_option && root_device == 0)
|
||||
{
|
||||
struct stat st;
|
||||
char *dir = xgetcwd ();
|
||||
|
||||
if (deref_stat (true, dir, &st))
|
||||
stat_diag (dir);
|
||||
if (stat (".", &st) != 0)
|
||||
stat_diag (".");
|
||||
else
|
||||
root_device = st.st_dev;
|
||||
free (dir);
|
||||
}
|
||||
|
||||
if (incremental_option)
|
||||
|
||||
Reference in New Issue
Block a user