aboutsummaryrefslogtreecommitdiff
path: root/src/copyin.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2005-05-21 23:21:42 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2005-05-21 23:21:42 +0000
commitc429d55207a323014c16265ae05f03ea3adfa30e (patch)
treea1eab1f40e26266718f58f8defcce1eeafa6bbb8 /src/copyin.c
parent27fa4e52979ead56b58ed484ba0eeab852e3508c (diff)
downloadcpio-c429d55207a323014c16265ae05f03ea3adfa30e.tar.gz
cpio-c429d55207a323014c16265ae05f03ea3adfa30e.tar.bz2
[!HAVE_LCHOWN] (lchown): Define to 0 to avoid changing ownership of the target file.
(process_copy_in): Use safer_name_suffix()
Diffstat (limited to 'src/copyin.c')
-rw-r--r--src/copyin.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/copyin.c b/src/copyin.c
index 4efb9d2..64b2c96 100644
--- a/src/copyin.c
+++ b/src/copyin.c
@@ -29,11 +29,11 @@
#include "defer.h"
#include <rmt.h>
#ifndef FNM_PATHNAME
-#include <fnmatch.h>
+# include <fnmatch.h>
#endif
#ifndef HAVE_LCHOWN
-#define lchown chown
+# define lchown(f,u,g) 0
#endif
static void copyin_regular_file(struct new_cpio_header* file_hdr,
@@ -1403,26 +1403,18 @@ process_copy_in ()
/* Do we have to ignore absolute paths, and if so, does the filename
have an absolute path? */
- if (no_abs_paths_flag && file_hdr.c_name && file_hdr.c_name [0] == '/')
+ if (no_abs_paths_flag && file_hdr.c_name && file_hdr.c_name[0])
{
- char *p;
-
- p = file_hdr.c_name;
- while (*p == '/')
- ++p;
- if (*p == '\0')
- {
- strcpy (file_hdr.c_name, ".");
- }
- else
+ char *p = safer_name_suffix (file_hdr.c_name, false, false);
+ if (p != file_hdr.c_name)
{
- /* Debian hack: file_hrd.c_name is sometimes set to
+ /* Debian hack: file_hdr.c_name is sometimes set to
point to static memory by code in tar.c. This
causes a segfault. Therefore, memmove is used
instead of freeing and reallocating. (Reported by
Horst Knobloch.) This bug has been reported to
"bug-gnu-utils@prep.ai.mit.edu". (99/1/6) -BEM */
- (void)memmove (file_hdr.c_name, p, (size_t)(strlen (p) + 1));
+ memmove (file_hdr.c_name, p, (size_t)(strlen (p) + 1));
}
}

Return to:

Send suggestions and report system problems to the System administrator.