X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fdentry.c;h=b948859c644774f308be9e3f486dcb5b2f1251d0;hp=86a82eb6ffe771581ef358d77137a9856df61cb4;hb=9c7e852e60e96935beef11a28b0f010f7e24e863;hpb=0bfcb6ff6c9b07acb5ea16a22b5e24eb36b3609b;ds=sidebyside diff --git a/src/dentry.c b/src/dentry.c index 86a82eb6..b948859c 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -1960,6 +1960,14 @@ read_dentry_tree(const u8 metadata_resource[], u64 metadata_resource_len, * entries. */ cur_offset += dentry_total_length(child); + if (unlikely(!dentry_has_long_name(child))) { + WARNING("Ignoring unnamed dentry in " + "directory \"%"TS"\"", + dentry_full_path(dentry)); + free_dentry(child); + continue; + } + duplicate = dentry_add_child(dentry, child); if (unlikely(duplicate)) { const tchar *child_type, *duplicate_type; @@ -1971,23 +1979,23 @@ read_dentry_tree(const u8 metadata_resource[], u64 metadata_resource_len, child_type, dentry_full_path(duplicate), duplicate_type); free_dentry(child); - } else { - inode_add_dentry(child, child->d_inode); - /* If there are children of this child, call this - * procedure recursively. */ - if (child->subdir_offset != 0) { - if (likely(dentry_is_directory(child))) { - ret = read_dentry_tree(metadata_resource, - metadata_resource_len, - child); - if (ret) - break; - } else { - WARNING("Ignoring children of non-directory \"%"TS"\"", - dentry_full_path(child)); - } - } + continue; + } + inode_add_dentry(child, child->d_inode); + /* If there are children of this child, call this + * procedure recursively. */ + if (child->subdir_offset != 0) { + if (likely(dentry_is_directory(child))) { + ret = read_dentry_tree(metadata_resource, + metadata_resource_len, + child); + if (ret) + break; + } else { + WARNING("Ignoring children of non-directory \"%"TS"\"", + dentry_full_path(child)); + } } } return ret; @@ -2041,6 +2049,8 @@ write_dentry(const struct wim_dentry * restrict dentry, u8 * restrict p) disk_dentry->file_name_nbytes = cpu_to_le16(dentry->file_name_nbytes); p += sizeof(struct wim_dentry_on_disk); + wimlib_assert(dentry_is_root(dentry) != dentry_has_long_name(dentry)); + if (dentry_has_long_name(dentry)) p = mempcpy(p, dentry->file_name, dentry->file_name_nbytes + 2);