]> wimlib.net Git - wimlib/blobdiff - src/extract.c
extract.c: check for empty extraction list
[wimlib] / src / extract.c
index 39899c4094e2c5eb80b296bc93d6e09161123de0..c61dac764dfc612e36872c099100ca0c643af58f 100644 (file)
 #  include "config.h"
 #endif
 
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
 #include "wimlib/apply.h"
+#include "wimlib/assert.h"
 #include "wimlib/dentry.h"
 #include "wimlib/encoding.h"
 #include "wimlib/endianness.h"
 #include "wimlib/wildcard.h"
 #include "wimlib/wim.h"
 
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
 #define WIMLIB_EXTRACT_FLAG_FROM_PIPE   0x80000000
 #define WIMLIB_EXTRACT_FLAG_IMAGEMODE   0x40000000
 
@@ -1008,7 +1008,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,7 +1083,7 @@ 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)))
@@ -1120,8 +1120,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 +1473,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;