aboutsummaryrefslogtreecommitdiff
path: root/cpio/cpio.c
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2020-03-02 02:12:53 +0000
committerMartin Matuska <mm@FreeBSD.org>2020-03-02 02:12:53 +0000
commit65da968c5ce7595908a244f509658357bf4bc49d (patch)
treec979bd80e10d9a6fc4ca0ce88f137ee6370d6a76 /cpio/cpio.c
parent8185c4ae244f9a52ad987b36e7d6300500054d00 (diff)
downloadsrc-65da968c5ce7595908a244f509658357bf4bc49d.tar.gz
src-65da968c5ce7595908a244f509658357bf4bc49d.zip
Notes
Diffstat (limited to 'cpio/cpio.c')
-rw-r--r--cpio/cpio.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/cpio/cpio.c b/cpio/cpio.c
index da5c39860018..c15ee525f068 100644
--- a/cpio/cpio.c
+++ b/cpio/cpio.c
@@ -737,7 +737,7 @@ file_to_archive(struct cpio *cpio, const char *srcpath)
*/
destpath = srcpath;
if (cpio->destdir) {
- len = strlen(cpio->destdir) + strlen(srcpath) + 8;
+ len = cpio->destdir_len + strlen(srcpath) + 8;
if (len >= cpio->pass_destpath_alloc) {
while (len >= cpio->pass_destpath_alloc) {
cpio->pass_destpath_alloc += 512;
@@ -1228,15 +1228,14 @@ 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. */
- 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->destdir_len = strlen(destdir);
+ cpio->destdir = malloc(cpio->destdir_len + 8);
+ memcpy(cpio->destdir, destdir, cpio->destdir_len);
+ if (cpio->destdir_len == 0 || destdir[cpio->destdir_len - 1] != '/')
+ cpio->destdir[cpio->destdir_len++] = '/';
+ cpio->destdir[cpio->destdir_len] = '\0';
cpio->archive = archive_write_disk_new();
if (cpio->archive == NULL)