summaryrefslogtreecommitdiff
path: root/archivers/libarchive/files/cpio/cpio.c
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2017-08-01 22:21:09 +0000
committerjoerg <joerg@pkgsrc.org>2017-08-01 22:21:09 +0000
commit8ebf4e7079542370a0dd5eba7eed1790d20c7f96 (patch)
tree3c71484d8e555935fd266acfd45eff3b04d0f139 /archivers/libarchive/files/cpio/cpio.c
parentc8fcd52665c6781876ed54832bd7f6ea46348688 (diff)
downloadpkgsrc-8ebf4e7079542370a0dd5eba7eed1790d20c7f96.tar.gz
Import libarchive-3.3.2 + 9de5f3 + f9dacbf:
- Support NFS4 ACLs on Linux - Bugfixes
Diffstat (limited to 'archivers/libarchive/files/cpio/cpio.c')
-rw-r--r--archivers/libarchive/files/cpio/cpio.c69
1 files changed, 36 insertions, 33 deletions
diff --git a/archivers/libarchive/files/cpio/cpio.c b/archivers/libarchive/files/cpio/cpio.c
index 6c20ee68322..5beedd0d16b 100644
--- a/archivers/libarchive/files/cpio/cpio.c
+++ b/archivers/libarchive/files/cpio/cpio.c
@@ -108,22 +108,22 @@ static int entry_to_archive(struct cpio *, struct archive_entry *);
static int file_to_archive(struct cpio *, const char *);
static void free_cache(struct name_cache *cache);
static void list_item_verbose(struct cpio *, struct archive_entry *);
-static void long_help(void);
+static void long_help(void) __LA_DEAD;
static const char *lookup_gname(struct cpio *, gid_t gid);
static int lookup_gname_helper(struct cpio *,
const char **name, id_t gid);
static const char *lookup_uname(struct cpio *, uid_t uid);
static int lookup_uname_helper(struct cpio *,
const char **name, id_t uid);
-static void mode_in(struct cpio *);
-static void mode_list(struct cpio *);
+static void mode_in(struct cpio *) __LA_DEAD;
+static void mode_list(struct cpio *) __LA_DEAD;
static void mode_out(struct cpio *);
static void mode_pass(struct cpio *, const char *);
static const char *remove_leading_slash(const char *);
static int restore_time(struct cpio *, struct archive_entry *,
const char *, int fd);
-static void usage(void);
-static void version(void);
+static void usage(void) __LA_DEAD;
+static void version(void) __LA_DEAD;
static const char * passphrase_callback(struct archive *, void *);
static void passphrase_free(char *);
@@ -628,6 +628,7 @@ mode_out(struct cpio *cpio)
blocks == 1 ? "block" : "blocks");
}
archive_write_free(cpio->archive);
+ archive_entry_linkresolver_free(cpio->linkresolver);
}
static const char *
@@ -1194,12 +1195,15 @@ mode_pass(struct cpio *cpio, const char *destdir)
struct lafe_line_reader *lr;
const char *p;
int r;
+ size_t destdir_len;
/* Ensure target dir has a trailing '/' to simplify path surgery. */
- cpio->destdir = malloc(strlen(destdir) + 8);
- strcpy(cpio->destdir, destdir);
- if (destdir[strlen(destdir) - 1] != '/')
- strcat(cpio->destdir, "/");
+ destdir_len = strlen(destdir);
+ cpio->destdir = malloc(destdir_len + 8);
+ memcpy(cpio->destdir, destdir, destdir_len);
+ if (destdir_len == 0 || destdir[destdir_len - 1] != '/')
+ cpio->destdir[destdir_len++] = '/';
+ cpio->destdir[destdir_len++] = '\0';
cpio->archive = archive_write_disk_new();
if (cpio->archive == NULL)
@@ -1240,6 +1244,7 @@ mode_pass(struct cpio *cpio, const char *destdir)
}
archive_write_free(cpio->archive);
+ free(cpio->pass_destpath);
}
/*
@@ -1344,23 +1349,23 @@ lookup_name(struct cpio *cpio, struct name_cache **name_cache_variable,
cache->cache[slot].name = NULL;
}
- if (lookup_fn(cpio, &name, id) == 0) {
- if (name == NULL || name[0] == '\0') {
- /* If lookup failed, format it as a number. */
- snprintf(asnum, sizeof(asnum), "%u", (unsigned)id);
- name = asnum;
- }
- cache->cache[slot].name = strdup(name);
- if (cache->cache[slot].name != NULL) {
- cache->cache[slot].id = id;
- return (cache->cache[slot].name);
- }
- /*
- * Conveniently, NULL marks an empty slot, so
- * if the strdup() fails, we've just failed to
- * cache it. No recovery necessary.
- */
+ if (lookup_fn(cpio, &name, id)) {
+ /* If lookup failed, format it as a number. */
+ snprintf(asnum, sizeof(asnum), "%u", (unsigned)id);
+ name = asnum;
}
+
+ cache->cache[slot].name = strdup(name);
+ if (cache->cache[slot].name != NULL) {
+ cache->cache[slot].id = id;
+ return (cache->cache[slot].name);
+ }
+
+ /*
+ * Conveniently, NULL marks an empty slot, so
+ * if the strdup() fails, we've just failed to
+ * cache it. No recovery necessary.
+ */
return (NULL);
}
@@ -1381,15 +1386,14 @@ lookup_uname_helper(struct cpio *cpio, const char **name, id_t id)
errno = 0;
pwent = getpwuid((uid_t)id);
if (pwent == NULL) {
- *name = NULL;
- if (errno != 0 && errno != ENOENT)
+ if (errno && errno != ENOENT)
lafe_warnc(errno, "getpwuid(%s) failed",
cpio_i64toa((int64_t)id));
- return (errno);
+ return 1;
}
*name = pwent->pw_name;
- return (0);
+ return 0;
}
static const char *
@@ -1409,15 +1413,14 @@ lookup_gname_helper(struct cpio *cpio, const char **name, id_t id)
errno = 0;
grent = getgrgid((gid_t)id);
if (grent == NULL) {
- *name = NULL;
- if (errno != 0)
+ if (errno && errno != ENOENT)
lafe_warnc(errno, "getgrgid(%s) failed",
cpio_i64toa((int64_t)id));
- return (errno);
+ return 1;
}
*name = grent->gr_name;
- return (0);
+ return 0;
}
/*