[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] segfault getting cwd with --listed-incremental
From: |
Paul Eggert |
Subject: |
Re: [Bug-tar] segfault getting cwd with --listed-incremental |
Date: |
Fri, 16 Jul 2010 11:01:52 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100527 Thunderbird/3.0.5 |
How about the following patch until we get this absolute filename
business resolved? It goes back to the algorithm used in tar-1.23.90,
except that it falls back on relative names if getcwd fails,
and it does not attempt to optimize ".." away. For J Chapman Flack's
example, this will cause tar to issue a warning but proceed and generate
tar and list files.
I have not pushed this.
>From fb24e8abcef554c9bf4b91c452590abfe4e7bc57 Mon Sep 17 00:00:00 2001
From: Paul R. Eggert <address@hidden>
Date: Fri, 16 Jul 2010 10:25:02 -0700
Subject: [PATCH] tar: go back to absolutifying filenames in normalize_filename
for now
* src/misc.c (normalize_filename): For now, go back to making
filenames absolute, even though this causes 'tar' to fail when
getcwd fails. However, do not attempt to resolve ".." as this
does not work with symlinks. Also, do the right thing with
leading file system prefixes and on hosts where // != /.
---
src/misc.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/src/misc.c b/src/misc.c
index 12b40ac..40635be 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -278,7 +278,32 @@ normalize_filename_x (char *file_name)
char *
normalize_filename (const char *name)
{
- char *copy = xstrdup (name);
+ char *copy = NULL;
+
+ if (IS_RELATIVE_FILE_NAME (name))
+ {
+ /* Set COPY to the absolute file name if possible.
+
+ FIXME: There should be no need to get the absolute file name.
+ getcwd is slow, it might fail, and it does not necessarily
+ return a canonical name even when it succeeds. Perhaps we
+ can use dev+ino pairs instead of names? */
+ copy = xgetcwd ();
+ if (copy)
+ {
+ size_t copylen = strlen (copy);
+ bool need_separator = ! (DOUBLE_SLASH_IS_DISTINCT_ROOT
+ && copylen == 2 && ISSLASH (copy[1]));
+ copy = xrealloc (copy, copylen + need_separator + strlen (name) + 1);
+ copy[copylen] = DIRECTORY_SEPARATOR;
+ strcpy (copy + copylen + need_separator, name);
+ }
+ else
+ WARN ((0, errno, _("Cannot get working directory")));
+ }
+
+ if (! copy)
+ copy = xstrdup (name);
normalize_filename_x (copy);
return copy;
}
--
1.7.1
- Re: [Bug-tar] segfault getting cwd with --listed-incremental, Paul Eggert, 2010/07/15
- Re: [Bug-tar] segfault getting cwd with --listed-incremental, Sergey Poznyakoff, 2010/07/15
- Re: [Bug-tar] segfault getting cwd with --listed-incremental, Paul Eggert, 2010/07/15
- Re: [Bug-tar] segfault getting cwd with --listed-incremental, Sergey Poznyakoff, 2010/07/16
- Re: [Bug-tar] segfault getting cwd with --listed-incremental, Paul Eggert, 2010/07/16
- Re: [Bug-tar] segfault getting cwd with --listed-incremental, Sergey Poznyakoff, 2010/07/17
- Re: [Bug-tar] segfault getting cwd with --listed-incremental, Joerg Schilling, 2010/07/19
- Re: [Bug-tar] segfault getting cwd with --listed-incremental, Paul Eggert, 2010/07/19
- Re: [Bug-tar] segfault getting cwd with --listed-incremental, Joerg Schilling, 2010/07/19
- Re: [Bug-tar] segfault getting cwd with --listed-incremental,
Paul Eggert <=
- Re: [Bug-tar] segfault getting cwd with --listed-incremental, Sergey Poznyakoff, 2010/07/17