diff options
author | kientzle <kientzle@FreeBSD.org> | 2005-09-21 04:25:06 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2005-09-21 04:25:06 +0000 |
commit | dcb8de96ab47d1932ce313adbac5a673210b1c91 (patch) | |
tree | 6f61f48765d8080ef9566d9cbfc0f3e97cefd834 /lib/libarchive/archive_read_support_format_cpio.c | |
parent | b035b8b7b3780581ed55ea9ca0660c0af57f5a5b (diff) | |
download | FreeBSD-src-dcb8de96ab47d1932ce313adbac5a673210b1c91.zip FreeBSD-src-dcb8de96ab47d1932ce313adbac5a673210b1c91.tar.gz |
Add a lot of error checks, based on the patches provided by Dan Lukes.
Also fixes a memory leak reported by Andrew Turner.
PR: bin/83476
Thanks to: Dan Lukes, Andrew Turner
Diffstat (limited to 'lib/libarchive/archive_read_support_format_cpio.c')
-rw-r--r-- | lib/libarchive/archive_read_support_format_cpio.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libarchive/archive_read_support_format_cpio.c b/lib/libarchive/archive_read_support_format_cpio.c index 5a0ac70..e74ca3a 100644 --- a/lib/libarchive/archive_read_support_format_cpio.c +++ b/lib/libarchive/archive_read_support_format_cpio.c @@ -134,6 +134,10 @@ archive_read_support_format_cpio(struct archive *a) int r; cpio = malloc(sizeof(*cpio)); + if (cpio == NULL) { + archive_set_error(a, ENOMEM, "Can't allocate cpio data"); + return (ARCHIVE_FATAL); + } memset(cpio, 0, sizeof(*cpio)); cpio->magic = CPIO_MAGIC; @@ -576,6 +580,8 @@ record_hardlink(struct cpio *cpio, struct archive_entry *entry, } le = malloc(sizeof(struct links_entry)); + if (le == NULL) + __archive_errx(1, "Out of memory adding file to list"); if (cpio->links_head != NULL) cpio->links_head->previous = le; le->next = cpio->links_head; @@ -585,4 +591,6 @@ record_hardlink(struct cpio *cpio, struct archive_entry *entry, le->ino = st->st_ino; le->links = st->st_nlink - 1; le->name = strdup(archive_entry_pathname(entry)); + if (le->name == NULL) + __archive_errx(1, "Out of memory adding file to list"); } |