diff options
author | kientzle <kientzle@FreeBSD.org> | 2004-04-23 17:15:48 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2004-04-23 17:15:48 +0000 |
commit | fd3f8b3142cd4f1ab39c008864b8f886537b7388 (patch) | |
tree | d945b760df53021b23a1bbaa2ec3e5558fe102ae /lib/libarchive/archive_entry.c | |
parent | 1291cc3eae682ac8efaeda1225dfbc26c6ce58ea (diff) | |
download | FreeBSD-src-fd3f8b3142cd4f1ab39c008864b8f886537b7388.zip FreeBSD-src-fd3f8b3142cd4f1ab39c008864b8f886537b7388.tar.gz |
Make clone more aggressive about copying strings to the new entry.
The original might have pointers to user-specified strings;
copying the string (instead of just the pointer) protects against
the client re-using their own buffers.
I'm trying hard to avoid dumping all of the 'set' string functions
in favor of slower, but more predictable 'copy' semantics.
Diffstat (limited to 'lib/libarchive/archive_entry.c')
-rw-r--r-- | lib/libarchive/archive_entry.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/libarchive/archive_entry.c b/lib/libarchive/archive_entry.c index d0fc238..1f85e59 100644 --- a/lib/libarchive/archive_entry.c +++ b/lib/libarchive/archive_entry.c @@ -150,13 +150,13 @@ void aes_copy(struct aes *dest, struct aes *src) { *dest = *src; - if (src->aes_mbs_alloc != NULL) { - dest->aes_mbs_alloc = strdup(src->aes_mbs_alloc); + if (src->aes_mbs != NULL) { + dest->aes_mbs_alloc = strdup(src->aes_mbs); dest->aes_mbs = dest->aes_mbs_alloc; } - if (src->aes_wcs_alloc != NULL) { - dest->aes_wcs_alloc = malloc((wcslen(src->aes_wcs_alloc) + 1) + if (src->aes_wcs != NULL) { + dest->aes_wcs_alloc = malloc((wcslen(src->aes_wcs) + 1) * sizeof(wchar_t)); dest->aes_wcs = dest->aes_wcs_alloc; wcscpy(dest->aes_wcs_alloc, src->aes_wcs); @@ -292,12 +292,12 @@ archive_entry_clone(struct archive_entry *entry) memset(entry2, 0, sizeof(*entry2)); entry2->ae_stat = entry->ae_stat; - aes_copy(&entry2->ae_fflags ,&entry->ae_fflags); - aes_copy(&entry2->ae_gname ,&entry->ae_gname); - aes_copy(&entry2->ae_hardlink ,&entry->ae_hardlink); + aes_copy(&entry2->ae_fflags, &entry->ae_fflags); + aes_copy(&entry2->ae_gname, &entry->ae_gname); + aes_copy(&entry2->ae_hardlink, &entry->ae_hardlink); aes_copy(&entry2->ae_pathname, &entry->ae_pathname); - aes_copy(&entry2->ae_symlink ,&entry->ae_symlink); - aes_copy(&entry2->ae_uname ,&entry->ae_uname); + aes_copy(&entry2->ae_symlink, &entry->ae_symlink); + aes_copy(&entry2->ae_uname, &entry->ae_uname); return (entry2); } |