]> wimlib.net Git - wimlib/commitdiff
Check for case where too many identical files are being extracted
authorEric Biggers <ebiggers3@gmail.com>
Mon, 26 May 2014 22:52:58 +0000 (17:52 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 26 May 2014 22:54:17 +0000 (17:54 -0500)
Hoping to add a real fix for this, but for now at least avoid the buffer
overflow in UNIX and NTFS-3g extraction modes.

src/ntfs-3g_apply.c
src/unix_apply.c
src/win32_apply.c

index ff145a61871a2cc98184bd9599672b8a0085ee7b..e7557cf663a9712609c264a40449f390a6aad237 100644 (file)
@@ -726,6 +726,11 @@ ntfs_3g_begin_extract_stream_to_attr(struct wim_lookup_table_entry *stream,
                return WIMLIB_ERR_NTFS_3G;
        }
 
                return WIMLIB_ERR_NTFS_3G;
        }
 
+       if (ctx->num_open_attrs == MAX_OPEN_ATTRS) {
+               ERROR("Can't extract data: too many open files!");
+               return WIMLIB_ERR_UNSUPPORTED;
+       }
+
        attr = ntfs_attr_open(ni, AT_DATA, stream_name, stream_name_nchars);
        if (!attr) {
                ERROR_WITH_ERRNO("Failed to open data stream of \"%s\"",
        attr = ntfs_attr_open(ni, AT_DATA, stream_name, stream_name_nchars);
        if (!attr) {
                ERROR_WITH_ERRNO("Failed to open data stream of \"%s\"",
index 25b28f9d368d3b792eda7832e69fbe9af0e99ad7..4eeee2ca4153511ad8359366a88ce68d8aa5e99d 100644 (file)
@@ -64,7 +64,7 @@ unix_get_supported_features(const char *target,
 }
 
 #define NUM_PATHBUFS 2  /* We need 2 when creating hard links  */
 }
 
 #define NUM_PATHBUFS 2  /* We need 2 when creating hard links  */
-#define MAX_OPEN_FDS 1024 /* TODO: Add special case for when the number of
+#define MAX_OPEN_FDS 1000 /* TODO: Add special case for when the number of
                             identical streams exceeds this number.  */
 
 struct unix_apply_ctx {
                             identical streams exceeds this number.  */
 
 struct unix_apply_ctx {
@@ -543,6 +543,11 @@ unix_begin_extract_stream_instance(const struct wim_lookup_table_entry *stream,
                return 0;
        }
 
                return 0;
        }
 
+       if (ctx->num_open_fds == MAX_OPEN_FDS) {
+               ERROR("Can't extract data: too many open files!");
+               return WIMLIB_ERR_UNSUPPORTED;
+       }
+
        first_dentry = inode_first_extraction_dentry(inode);
        first_path = unix_build_extraction_path(first_dentry, ctx);
 retry_create:
        first_dentry = inode_first_extraction_dentry(inode);
        first_path = unix_build_extraction_path(first_dentry, ctx);
 retry_create:
index 0cd67afabffa0a5932501567e632762cb4ffdbf5..4f4cf6eb3350658bc01f14150fc7eeb2bfb0a2f1 100644 (file)
@@ -1359,7 +1359,7 @@ begin_extract_stream_instance(const struct wim_lookup_table_entry *stream,
 
        /* Too many open handles?  */
        if (ctx->num_open_handles == MAX_OPEN_HANDLES) {
 
        /* Too many open handles?  */
        if (ctx->num_open_handles == MAX_OPEN_HANDLES) {
-               ERROR("Too many open handles!");
+               ERROR("Can't extract data: too many open files!");
                return WIMLIB_ERR_UNSUPPORTED;
        }
 
                return WIMLIB_ERR_UNSUPPORTED;
        }