summaryrefslogtreecommitdiff
path: root/libarchive/archive_write_set_format_iso9660.c
diff options
context:
space:
mode:
authorMartin Matuska <martin@matuska.org>2020-02-01 00:58:03 +0100
committerMartin Matuska <martin@matuska.org>2020-02-01 01:01:41 +0100
commit8705a85c7e74ee50227ed57fd88a390aa063f619 (patch)
treee993fd8528793469f9ed1f89b2a2922d5a19fe13 /libarchive/archive_write_set_format_iso9660.c
parentd4be6c17cb106a0e72e6ad9efd10d4f653d5b124 (diff)
downloadlibarchive-8705a85c7e74ee50227ed57fd88a390aa063f619.tar.gz
Fix use after free in ISO9660 and XAR writer
Remove rbtree nodes before freeing them. For better code readability import new rbtree macros from NetBSD. Fixes #1325
Diffstat (limited to 'libarchive/archive_write_set_format_iso9660.c')
-rw-r--r--libarchive/archive_write_set_format_iso9660.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c
index e3020cc9..7cde44c3 100644
--- a/libarchive/archive_write_set_format_iso9660.c
+++ b/libarchive/archive_write_set_format_iso9660.c
@@ -5094,13 +5094,11 @@ isofile_init_hardlinks(struct iso9660 *iso9660)
static void
isofile_free_hardlinks(struct iso9660 *iso9660)
{
- struct archive_rb_node *n, *next;
+ struct archive_rb_node *n, *tmp;
- for (n = ARCHIVE_RB_TREE_MIN(&(iso9660->hardlink_rbtree)); n;) {
- next = __archive_rb_tree_iterate(&(iso9660->hardlink_rbtree),
- n, ARCHIVE_RB_DIR_RIGHT);
+ ARCHIVE_RB_TREE_FOREACH_SAFE(n, &(iso9660->hardlink_rbtree), tmp) {
+ __archive_rb_tree_remove_node(&(iso9660->hardlink_rbtree), n);
free(n);
- n = next;
}
}