diff options
author | Michihiro NAKAJIMA <ggcueroad@gmail.com> | 2011-05-16 07:52:47 -0400 |
---|---|---|
committer | Michihiro NAKAJIMA <ggcueroad@gmail.com> | 2011-05-16 07:52:47 -0400 |
commit | 63a1a334c6f70852062558c086034fb70234c076 (patch) | |
tree | d6f7d6e99d14e0ecc372fb40b94e2364ddd51a81 /libarchive/archive_write_set_format_cpio_newc.c | |
parent | f96f655c4bfb526c784a27fd068d5b6987bde5a2 (diff) | |
download | libarchive-63a1a334c6f70852062558c086034fb70234c076.tar.gz |
Rework a handling of memory allocation failure in string conversion;
report the failure to the caller as much as we can instead of calling __archive_errx().
SVN-Revision: 3345
Diffstat (limited to 'libarchive/archive_write_set_format_cpio_newc.c')
-rw-r--r-- | libarchive/archive_write_set_format_cpio_newc.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libarchive/archive_write_set_format_cpio_newc.c b/libarchive/archive_write_set_format_cpio_newc.c index 2a4aa01e..cc6d2246 100644 --- a/libarchive/archive_write_set_format_cpio_newc.c +++ b/libarchive/archive_write_set_format_cpio_newc.c @@ -179,7 +179,12 @@ archive_write_newc_header(struct archive_write *a, struct archive_entry *entry) return (ARCHIVE_FAILED); } - (void)archive_entry_pathname_l(entry, &path, &len, get_sconv(a)); + if (archive_entry_pathname_l(entry, &path, &len, get_sconv(a)) != 0 + && errno == ENOMEM) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate memory for Pathname"); + return (ARCHIVE_FATAL); + } if (len == 0 || path == NULL || path[0] == '\0') { archive_set_error(&a->archive, -1, "Pathname required"); return (ARCHIVE_FAILED); @@ -211,6 +216,11 @@ write_header(struct archive_write *a, struct archive_entry *entry) ret = archive_entry_pathname_l(entry, &path, &len, sconv); if (ret != 0) { + if (errno == ENOMEM) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate memory for Pathname"); + return (ARCHIVE_FATAL); + } archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Can't translate pathname '%s' to %s", archive_entry_pathname(entry), @@ -258,6 +268,11 @@ write_header(struct archive_write *a, struct archive_entry *entry) /* Symlinks get the link written as the body of the entry. */ ret = archive_entry_symlink_l(entry, &p, &len, sconv); if (ret != 0) { + if (errno == ENOMEM) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate memory for Likname"); + return (ARCHIVE_FATAL); + } archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Can't translate linkname '%s' to %s", archive_entry_symlink(entry), |