From: Eric Biggers Date: Mon, 26 May 2014 22:52:58 +0000 (-0500) Subject: Check for case where too many identical files are being extracted X-Git-Tag: v1.7.0~85 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=a3c63defc94455a84fa681024a461691c1ad5661 Check for case where too many identical files are being extracted Hoping to add a real fix for this, but for now at least avoid the buffer overflow in UNIX and NTFS-3g extraction modes. --- diff --git a/src/ntfs-3g_apply.c b/src/ntfs-3g_apply.c index ff145a61..e7557cf6 100644 --- a/src/ntfs-3g_apply.c +++ b/src/ntfs-3g_apply.c @@ -726,6 +726,11 @@ ntfs_3g_begin_extract_stream_to_attr(struct wim_lookup_table_entry *stream, 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\"", diff --git a/src/unix_apply.c b/src/unix_apply.c index 25b28f9d..4eeee2ca 100644 --- a/src/unix_apply.c +++ b/src/unix_apply.c @@ -64,7 +64,7 @@ unix_get_supported_features(const char *target, } #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 { @@ -543,6 +543,11 @@ unix_begin_extract_stream_instance(const struct wim_lookup_table_entry *stream, 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: diff --git a/src/win32_apply.c b/src/win32_apply.c index 0cd67afa..4f4cf6eb 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -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) { - ERROR("Too many open handles!"); + ERROR("Can't extract data: too many open files!"); return WIMLIB_ERR_UNSUPPORTED; }