X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fextract.c;h=a5be7d1b333486bc21cdf4e24626b4e61b6ca124;hb=8895e346ab7a4df65c980ba435d1e5d1c2654d3f;hp=b0df25d0719245c3dbab0d3580ea524019a607cb;hpb=29ac4319aa9c75811cd5629cd3471a681fbeb552;p=wimlib diff --git a/src/extract.c b/src/extract.c index b0df25d0..a5be7d1b 100644 --- a/src/extract.c +++ b/src/extract.c @@ -39,7 +39,13 @@ # include "config.h" #endif +#include +#include +#include +#include + #include "wimlib/apply.h" +#include "wimlib/assert.h" #include "wimlib/dentry.h" #include "wimlib/encoding.h" #include "wimlib/endianness.h" @@ -59,12 +65,6 @@ #include "wimlib/wildcard.h" #include "wimlib/wim.h" -#include -#include -#include -#include -#include - #define WIMLIB_EXTRACT_FLAG_FROM_PIPE 0x80000000 #define WIMLIB_EXTRACT_FLAG_IMAGEMODE 0x40000000 @@ -144,16 +144,22 @@ dentry_is_supported(struct wim_dentry *dentry, struct wim_inode *inode = dentry->d_inode; if (inode->i_attributes & FILE_ATTRIBUTE_REPARSE_POINT) { - return supported_features->reparse_points || - (inode_is_symlink(inode) && - supported_features->symlink_reparse_points); + if (!(supported_features->reparse_points || + (inode_is_symlink(inode) && + supported_features->symlink_reparse_points))) + return false; } + if (inode->i_attributes & FILE_ATTRIBUTE_ENCRYPTED) { - if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) - return supported_features->encrypted_directories != 0; - else - return supported_features->encrypted_files != 0; + if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) { + if (!supported_features->encrypted_directories) + return false; + } else { + if (!supported_features->encrypted_files) + return false; + } } + return true; } @@ -808,7 +814,7 @@ dentry_calculate_extraction_name(struct wim_dentry *dentry, { int ret; - if (!dentry_is_supported(dentry, &ctx->supported_features)) + if (unlikely(!dentry_is_supported(dentry, &ctx->supported_features))) goto skip_dentry; if (dentry_is_root(dentry)) @@ -1008,7 +1014,7 @@ dentry_list_resolve_streams(struct list_head *dentry_list, } static int -ref_stream(struct wim_lookup_table_entry *lte, u32 stream_idx, +ref_stream(struct wim_lookup_table_entry *lte, unsigned stream_idx, struct wim_dentry *dentry, struct apply_ctx *ctx) { struct wim_inode *inode = dentry->d_inode; @@ -1083,12 +1089,9 @@ ref_unnamed_stream(struct wim_dentry *dentry, struct apply_ctx *ctx) { struct wim_inode *inode = dentry->d_inode; int ret; - u16 stream_idx; + unsigned stream_idx; struct wim_lookup_table_entry *stream; - if (unlikely(inode_is_encrypted_directory(inode))) - return 0; - if (unlikely(ctx->apply_ops->will_externally_back)) { ret = (*ctx->apply_ops->will_externally_back)(dentry, ctx); if (ret >= 0) { @@ -1120,8 +1123,8 @@ dentry_ref_streams(struct wim_dentry *dentry, struct apply_ctx *ctx) * extraction mode and volume, and to avoid complications, if not doing * a linked extraction. */ if (ctx->supported_features.named_data_streams) { - for (u16 i = 0; i < inode->i_num_ads; i++) { - if (!ads_entry_is_named_stream(&inode->i_ads_entries[i])) + for (unsigned i = 0; i < inode->i_num_ads; i++) { + if (!inode->i_ads_entries[i].stream_name_nbytes) continue; ret = ref_stream(inode->i_ads_entries[i].lte, i + 1, dentry, ctx); @@ -1473,6 +1476,11 @@ extract_trees(WIMStruct *wim, struct wim_dentry **trees, size_t num_trees, if (ret) goto out_cleanup; + if (unlikely(list_empty(&dentry_list))) { + WARNING("There is nothing to extract!"); + goto out_cleanup; + } + ret = dentry_list_resolve_streams(&dentry_list, ctx); if (ret) goto out_cleanup; @@ -2017,7 +2025,7 @@ wimlib_extract_image_from_pipe_with_progress(int pipe_fd, if (i == image) { /* Metadata resource is for the image being extracted. * Parse it and save the metadata in memory. */ - ret = read_metadata_resource(pwm, imd); + ret = read_metadata_resource(imd); if (ret) goto out_wimlib_free; imd->modified = 1;