From 668c363a59c521f48eecbc4dd549c07a3e36179e Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 16 Jan 2014 21:05:10 -0600 Subject: [PATCH] wimlib: strict checks for unassigned flags This prevents programs that specify unassigned flags from working, since these flags could be assigned in the future. --- include/wimlib.h | 12 ++++++----- include/wimlib/write.h | 17 ++++++++++++++- programs/imagex.c | 2 +- src/add_image.c | 6 +++++- src/export_image.c | 5 +++++ src/extract.c | 49 +++++++++++++++++++++++++++++++++--------- src/iterate_dir.c | 5 +++++ src/lookup_table.c | 3 +++ src/mount_image.c | 16 ++++++++++++++ src/reference.c | 9 ++++++++ src/split.c | 5 ++++- src/template.c | 3 +++ src/update_image.c | 38 +++++++++++++++++++++++++++++++- src/wim.c | 21 +++++++++++++++++- src/write.c | 13 +++++------ 15 files changed, 177 insertions(+), 27 deletions(-) diff --git a/include/wimlib.h b/include/wimlib.h index f7286a39..5b164b6d 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -1309,7 +1309,8 @@ typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resour * scanned. */ #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004 -/** Mark the image being added as the bootable image of the WIM. */ +/** Mark the image being added as the bootable image of the WIM. Not valid for + * wimlib_update_image(). */ #define WIMLIB_ADD_FLAG_BOOT 0x00000008 /** Store the UNIX owner, group, and mode. This is done by adding a special @@ -1770,16 +1771,17 @@ typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resour /** @ingroup G_nonstandalone_wims * @{ */ -/** wimlib_reference_resource_files() only: Enable shell-style filename - * globbing. */ +/** For wimlib_reference_resource_files(), enable shell-style filename globbing. + * Ignored by wimlib_reference_resources(). */ #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001 -/** wimlib_reference_resource_files() only: Issue an error +/** For wimlib_reference_resource_files(), issue an error * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The * default behavior without this flag is to issue no error at that point, but * then attempt to open the glob as a literal path, which of course will fail * anyway if no file exists at that path. No effect if - * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. */ + * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by + * wimlib_reference_resources(). */ #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002 /** @} */ diff --git a/include/wimlib/write.h b/include/wimlib/write.h index 3665eea4..190bf941 100644 --- a/include/wimlib/write.h +++ b/include/wimlib/write.h @@ -13,7 +13,22 @@ #define WIMLIB_WRITE_FLAG_USE_EXISTING_TOTALBYTES 0x04000000 #define WIMLIB_WRITE_FLAG_NO_METADATA 0x02000000 #define WIMLIB_WRITE_FLAG_OVERWRITE 0x01000000 -#define WIMLIB_WRITE_MASK_PUBLIC 0x00ffffff + +/* Keep in sync with wimlib.h */ +#define WIMLIB_WRITE_MASK_PUBLIC ( \ + WIMLIB_WRITE_FLAG_CHECK_INTEGRITY | \ + WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY | \ + WIMLIB_WRITE_FLAG_PIPABLE | \ + WIMLIB_WRITE_FLAG_NOT_PIPABLE | \ + WIMLIB_WRITE_FLAG_RECOMPRESS | \ + WIMLIB_WRITE_FLAG_FSYNC | \ + WIMLIB_WRITE_FLAG_REBUILD | \ + WIMLIB_WRITE_FLAG_SOFT_DELETE | \ + WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG | \ + WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS | \ + WIMLIB_WRITE_FLAG_STREAMS_OK | \ + WIMLIB_WRITE_FLAG_RESERVED | \ + WIMLIB_WRITE_FLAG_PACK_STREAMS) #if defined(HAVE_SYS_FILE_H) && defined(HAVE_FLOCK) extern int diff --git a/programs/imagex.c b/programs/imagex.c index 19a78b66..0e3c6e8b 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -4071,7 +4071,7 @@ T( " [--check] [--ref=\"GLOB\"] [--dest-dir=CMD_DIR]\n" " [--to-stdout] [--no-acls] [--strict-acls]\n" " [--no-attributes] [--include-invalid-names]\n" -" [--no-wildcards] [--nullglob]\n" +" [--no-wildcards] [--nullglob] [--preserve-dir-structure]\n" ), [CMD_INFO] = T( diff --git a/src/add_image.c b/src/add_image.c index a06ee939..9b8cffb9 100644 --- a/src/add_image.c +++ b/src/add_image.c @@ -139,7 +139,7 @@ capture_sources_to_add_cmds(const struct wimlib_capture_source *sources, sources[i].fs_source_path, sources[i].wim_target_path); add_cmds[i].op = WIMLIB_UPDATE_OP_ADD; - add_cmds[i].add.add_flags = add_flags; + add_cmds[i].add.add_flags = add_flags & ~WIMLIB_ADD_FLAG_BOOT; add_cmds[i].add.config = (struct wimlib_capture_config*)config; add_cmds[i].add.fs_source_path = sources[i].fs_source_path; add_cmds[i].add.wim_target_path = sources[i].wim_target_path; @@ -164,6 +164,10 @@ wimlib_add_image_multisource(WIMStruct *wim, DEBUG("Adding image \"%"TS"\" from %zu sources (add_flags=%#x)", name, num_sources, add_flags); + for (size_t i = 0; i < num_sources; i++) + if (sources[i].reserved != 0) + return WIMLIB_ERR_INVALID_PARAM; + /* Add the new image (initially empty) */ ret = wimlib_add_empty_image(wim, name, NULL); if (ret) diff --git a/src/export_image.c b/src/export_image.c index 56725e66..f901ff19 100644 --- a/src/export_image.c +++ b/src/export_image.c @@ -113,6 +113,11 @@ wimlib_export_image(WIMStruct *src_wim, u32 orig_dest_image_count; /* Check for sane parameters. */ + if (export_flags & ~(WIMLIB_EXPORT_FLAG_BOOT | + WIMLIB_EXPORT_FLAG_NO_NAMES | + WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS)) + return WIMLIB_ERR_INVALID_PARAM; + if (src_wim == NULL || dest_wim == NULL) return WIMLIB_ERR_INVALID_PARAM; diff --git a/src/extract.c b/src/extract.c index 8e695f66..995f9cbb 100644 --- a/src/extract.c +++ b/src/extract.c @@ -71,7 +71,31 @@ #define WIMLIB_EXTRACT_FLAG_FROM_PIPE 0x40000000 #define WIMLIB_EXTRACT_FLAG_FILEMODE 0x20000000 #define WIMLIB_EXTRACT_FLAG_IMAGEMODE 0x10000000 -#define WIMLIB_EXTRACT_MASK_PUBLIC 0x0fffffff + +/* Keep in sync with wimlib.h */ +#define WIMLIB_EXTRACT_MASK_PUBLIC \ + (WIMLIB_EXTRACT_FLAG_NTFS | \ + WIMLIB_EXTRACT_FLAG_HARDLINK | \ + WIMLIB_EXTRACT_FLAG_SYMLINK | \ + WIMLIB_EXTRACT_FLAG_VERBOSE | \ + WIMLIB_EXTRACT_FLAG_SEQUENTIAL | \ + WIMLIB_EXTRACT_FLAG_UNIX_DATA | \ + WIMLIB_EXTRACT_FLAG_NO_ACLS | \ + WIMLIB_EXTRACT_FLAG_STRICT_ACLS | \ + WIMLIB_EXTRACT_FLAG_RPFIX | \ + WIMLIB_EXTRACT_FLAG_NORPFIX | \ + WIMLIB_EXTRACT_FLAG_TO_STDOUT | \ + WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES | \ + WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS | \ + WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS | \ + WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES | \ + WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS | \ + WIMLIB_EXTRACT_FLAG_RESUME | \ + WIMLIB_EXTRACT_FLAG_FILE_ORDER | \ + WIMLIB_EXTRACT_FLAG_GLOB_PATHS | \ + WIMLIB_EXTRACT_FLAG_STRICT_GLOB | \ + WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES | \ + WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE) /* Given a WIM dentry in the tree to be extracted, resolve all streams in the * corresponding inode and set 'out_refcnt' in each to 0. */ @@ -2881,9 +2905,12 @@ wimlib_extract_files(WIMStruct *wim, default_extract_flags |= WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE; for (size_t i = 0; i < num_cmds; i++) { - int cmd_flags = ((cmds[i].extract_flags | - default_extract_flags) & - WIMLIB_EXTRACT_MASK_PUBLIC); + int cmd_flags = (cmds[i].extract_flags | + default_extract_flags); + + if (cmd_flags & ~WIMLIB_EXTRACT_MASK_PUBLIC) + return WIMLIB_ERR_INVALID_PARAM; + int cmd_link_flags = (cmd_flags & (WIMLIB_EXTRACT_FLAG_SYMLINK | WIMLIB_EXTRACT_FLAG_HARDLINK)); if (i == 0) { @@ -2904,9 +2931,8 @@ wimlib_extract_files(WIMStruct *wim, } for (size_t i = 0; i < num_cmds; i++) { - int extract_flags = ((cmds[i].extract_flags | - default_extract_flags) & - WIMLIB_EXTRACT_MASK_PUBLIC); + int extract_flags = (cmds[i].extract_flags | + default_extract_flags); const tchar *target = cmds[i].fs_dest_path; const tchar *wim_source_path = cmds[i].wim_source_path; @@ -2933,7 +2959,8 @@ wimlib_extract_paths(WIMStruct *wim, { int ret; - extract_flags &= WIMLIB_EXTRACT_MASK_PUBLIC; + if (extract_flags & ~WIMLIB_EXTRACT_MASK_PUBLIC) + return WIMLIB_ERR_INVALID_PARAM; ret = do_wimlib_extract_paths(wim, image, target, paths, num_paths, extract_flags, progress_func); @@ -2979,7 +3006,8 @@ wimlib_extract_image_from_pipe(int pipe_fd, const tchar *image_num_or_name, int image; unsigned i; - extract_flags &= WIMLIB_EXTRACT_MASK_PUBLIC; + if (extract_flags & ~WIMLIB_EXTRACT_MASK_PUBLIC) + return WIMLIB_ERR_INVALID_PARAM; if (extract_flags & WIMLIB_EXTRACT_FLAG_FILE_ORDER) return WIMLIB_ERR_INVALID_PARAM; @@ -3136,7 +3164,8 @@ wimlib_extract_image(WIMStruct *wim, int extract_flags, wimlib_progress_func_t progress_func) { - extract_flags &= WIMLIB_EXTRACT_MASK_PUBLIC; + if (extract_flags & ~WIMLIB_EXTRACT_MASK_PUBLIC) + return WIMLIB_ERR_INVALID_PARAM; return do_wimlib_extract_image(wim, image, target, extract_flags, progress_func); } diff --git a/src/iterate_dir.c b/src/iterate_dir.c index 042c76ac..cc5c63b8 100644 --- a/src/iterate_dir.c +++ b/src/iterate_dir.c @@ -242,6 +242,11 @@ wimlib_iterate_dir_tree(WIMStruct *wim, int image, const tchar *_path, tchar *path; int ret; + if (flags & ~(WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE | + WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN | + WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED)) + return WIMLIB_ERR_INVALID_PARAM; + path = canonicalize_wim_path(_path); if (path == NULL) return WIMLIB_ERR_NOMEM; diff --git a/src/lookup_table.c b/src/lookup_table.c index c76823d1..4a3bc1e2 100644 --- a/src/lookup_table.c +++ b/src/lookup_table.c @@ -1181,6 +1181,9 @@ wimlib_iterate_lookup_table(WIMStruct *wim, int flags, wimlib_iterate_lookup_table_callback_t cb, void *user_ctx) { + if (flags != 0) + return WIMLIB_ERR_INVALID_PARAM; + struct iterate_lte_context ctx = { .cb = cb, .user_ctx = user_ctx, diff --git a/src/mount_image.c b/src/mount_image.c index 7c480ebc..7b3a9147 100644 --- a/src/mount_image.c +++ b/src/mount_image.c @@ -2410,6 +2410,15 @@ wimlib_mount_image(WIMStruct *wim, int image, const char *dir, if (!wim || !dir) return WIMLIB_ERR_INVALID_PARAM; + if (mount_flags & ~(WIMLIB_MOUNT_FLAG_READWRITE | + WIMLIB_MOUNT_FLAG_DEBUG | + WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE | + WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR | + WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS | + WIMLIB_MOUNT_FLAG_UNIX_DATA | + WIMLIB_MOUNT_FLAG_ALLOW_OTHER)) + return WIMLIB_ERR_INVALID_PARAM; + if (mount_flags & WIMLIB_MOUNT_FLAG_READWRITE) { ret = can_delete_from_wim(wim); if (ret) @@ -2570,6 +2579,13 @@ wimlib_unmount_image(const char *dir, int unmount_flags, int ret; struct wimfs_context wimfs_ctx; + if (unmount_flags & ~(WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY | + WIMLIB_UNMOUNT_FLAG_COMMIT | + WIMLIB_UNMOUNT_FLAG_REBUILD | + WIMLIB_UNMOUNT_FLAG_RECOMPRESS | + WIMLIB_UNMOUNT_FLAG_LAZY)) + return WIMLIB_ERR_INVALID_PARAM; + init_wimfs_context(&wimfs_ctx); ret = set_message_queue_names(&wimfs_ctx, dir); diff --git a/src/reference.c b/src/reference.c index 1a83a4a6..3238abe4 100644 --- a/src/reference.c +++ b/src/reference.c @@ -33,6 +33,9 @@ #include "wimlib/lookup_table.h" #include "wimlib/wim.h" +#define WIMLIB_REF_MASK_PUBLIC (WIMLIB_REF_FLAG_GLOB_ENABLE | \ + WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH) + static int lte_clone_if_new(struct wim_lookup_table_entry *lte, void *_lookup_table) { @@ -76,6 +79,9 @@ wimlib_reference_resources(WIMStruct *wim, if (num_resource_wims != 0 && resource_wims == NULL) return WIMLIB_ERR_INVALID_PARAM; + if (ref_flags & ~WIMLIB_REF_MASK_PUBLIC) + return WIMLIB_ERR_INVALID_PARAM; + for (i = 0; i < num_resource_wims; i++) if (resource_wims[i] == NULL) return WIMLIB_ERR_INVALID_PARAM; @@ -195,6 +201,9 @@ wimlib_reference_resource_files(WIMStruct *wim, unsigned i; int ret; + if (ref_flags & ~WIMLIB_REF_MASK_PUBLIC) + return WIMLIB_ERR_INVALID_PARAM; + if (ref_flags & WIMLIB_REF_FLAG_GLOB_ENABLE) { for (i = 0; i < count; i++) { ret = reference_resource_glob(wim, diff --git a/src/split.c b/src/split.c index 2688e7f6..d1317cf9 100644 --- a/src/split.c +++ b/src/split.c @@ -115,7 +115,7 @@ write_split_wim(WIMStruct *orig_wim, const tchar *swm_name, &progress); } - part_write_flags = write_flags & WIMLIB_WRITE_MASK_PUBLIC; + part_write_flags = write_flags; part_write_flags |= WIMLIB_WRITE_FLAG_USE_EXISTING_TOTALBYTES; if (part_number != 1) part_write_flags |= WIMLIB_WRITE_FLAG_NO_METADATA; @@ -211,6 +211,9 @@ wimlib_split(WIMStruct *wim, const tchar *swm_name, if (swm_name == NULL || swm_name[0] == T('\0') || part_size == 0) return WIMLIB_ERR_INVALID_PARAM; + if (write_flags & ~WIMLIB_WRITE_MASK_PUBLIC) + return WIMLIB_ERR_INVALID_PARAM; + if (!wim_has_metadata(wim)) return WIMLIB_ERR_METADATA_NOT_FOUND; diff --git a/src/template.c b/src/template.c index 7348258e..6b21015a 100644 --- a/src/template.c +++ b/src/template.c @@ -212,6 +212,9 @@ wimlib_reference_template_image(WIMStruct *wim, int new_image, int ret; struct wim_image_metadata *new_imd; + if (flags != 0) + return WIMLIB_ERR_INVALID_PARAM; + if (wim == NULL || template_wim == NULL) return WIMLIB_ERR_INVALID_PARAM; diff --git a/src/update_image.c b/src/update_image.c index b7a3abdf..5a5ae690 100644 --- a/src/update_image.c +++ b/src/update_image.c @@ -465,6 +465,21 @@ check_add_command(struct wimlib_update_command *cmd, { int add_flags = cmd->add.add_flags; + if (add_flags & ~(WIMLIB_ADD_FLAG_NTFS | + WIMLIB_ADD_FLAG_DEREFERENCE | + WIMLIB_ADD_FLAG_VERBOSE | + /* BOOT doesn't make sense for wimlib_update_image() */ + /*WIMLIB_ADD_FLAG_BOOT |*/ + WIMLIB_ADD_FLAG_UNIX_DATA | + WIMLIB_ADD_FLAG_NO_ACLS | + WIMLIB_ADD_FLAG_STRICT_ACLS | + WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE | + WIMLIB_ADD_FLAG_RPFIX | + WIMLIB_ADD_FLAG_NORPFIX | + WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE | + WIMLIB_ADD_FLAG_WINCONFIG)) + return WIMLIB_ERR_INVALID_PARAM; + /* Are we adding the entire image or not? An empty wim_target_path * indicates that the tree we're adding is to be placed in the root of * the image. We consider this to be capturing the entire image, @@ -534,6 +549,23 @@ check_add_command(struct wimlib_update_command *cmd, return 0; } +static int +check_delete_command(const struct wimlib_update_command *cmd) +{ + if (cmd->delete_.delete_flags & ~(WIMLIB_DELETE_FLAG_FORCE | + WIMLIB_DELETE_FLAG_RECURSIVE)) + return WIMLIB_ERR_INVALID_PARAM; + return 0; +} + +static int +check_rename_command(const struct wimlib_update_command *cmd) +{ + if (cmd->rename.rename_flags != 0) + return WIMLIB_ERR_INVALID_PARAM; + return 0; +} + static int check_update_command(struct wimlib_update_command *cmd, const struct wim_header *hdr) @@ -542,8 +574,9 @@ check_update_command(struct wimlib_update_command *cmd, case WIMLIB_UPDATE_OP_ADD: return check_add_command(cmd, hdr); case WIMLIB_UPDATE_OP_DELETE: + return check_delete_command(cmd); case WIMLIB_UPDATE_OP_RENAME: - break; + return check_rename_command(cmd); } return 0; } @@ -667,6 +700,9 @@ wimlib_update_image(WIMStruct *wim, struct wimlib_update_command *cmds_copy; bool deletion_requested = false; + if (update_flags & ~WIMLIB_UPDATE_FLAG_SEND_PROGRESS) + return WIMLIB_ERR_INVALID_PARAM; + DEBUG("Updating image %d with %zu commands", image, num_cmds); for (size_t i = 0; i < num_cmds; i++) diff --git a/src/wim.c b/src/wim.c index d885b797..febc68aa 100644 --- a/src/wim.c +++ b/src/wim.c @@ -392,6 +392,12 @@ wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info, int whic { int ret; + if (which & ~(WIMLIB_CHANGE_READONLY_FLAG | + WIMLIB_CHANGE_GUID | + WIMLIB_CHANGE_BOOT_INDEX | + WIMLIB_CHANGE_RPFIX_FLAG)) + return WIMLIB_ERR_INVALID_PARAM; + if (which & WIMLIB_CHANGE_READONLY_FLAG) { if (info->is_marked_readonly) wim->hdr.flags |= WIM_HDR_FLAG_READONLY; @@ -721,7 +727,11 @@ WIMLIBAPI int wimlib_open_wim(const tchar *wimfile, int open_flags, WIMStruct **wim_ret, wimlib_progress_func_t progress_func) { - open_flags &= WIMLIB_OPEN_MASK_PUBLIC; + if (open_flags & ~(WIMLIB_OPEN_FLAG_CHECK_INTEGRITY | + WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT | + WIMLIB_OPEN_FLAG_WRITE_ACCESS)) + return WIMLIB_ERR_INVALID_PARAM; + return open_wim_as_WIMStruct(wimfile, open_flags, wim_ret, progress_func); } @@ -975,6 +985,15 @@ wimlib_global_init(int init_flags) if (already_inited) return 0; + + if (init_flags & ~(WIMLIB_INIT_FLAG_ASSUME_UTF8 | + WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES | + WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES | + WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES | + WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE | + WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE)) + return WIMLIB_ERR_INVALID_PARAM; + libxml_global_init(); if (!(init_flags & WIMLIB_INIT_FLAG_ASSUME_UTF8)) { wimlib_mbs_is_utf8 = test_locale_ctype_utf8(); diff --git a/src/write.c b/src/write.c index 1df05c95..07b55750 100644 --- a/src/write.c +++ b/src/write.c @@ -2819,10 +2819,11 @@ wimlib_write(WIMStruct *wim, const tchar *path, int image, int write_flags, unsigned num_threads, wimlib_progress_func_t progress_func) { - if (!path) + if (write_flags & ~WIMLIB_WRITE_MASK_PUBLIC) return WIMLIB_ERR_INVALID_PARAM; - write_flags &= WIMLIB_WRITE_MASK_PUBLIC; + if (path == NULL || path[0] == T('\0')) + return WIMLIB_ERR_INVALID_PARAM; return write_standalone_wim(wim, path, image, write_flags, num_threads, progress_func); @@ -2834,10 +2835,12 @@ wimlib_write_to_fd(WIMStruct *wim, int fd, int image, int write_flags, unsigned num_threads, wimlib_progress_func_t progress_func) { + if (write_flags & ~WIMLIB_WRITE_MASK_PUBLIC) + return WIMLIB_ERR_INVALID_PARAM; + if (fd < 0) return WIMLIB_ERR_INVALID_PARAM; - write_flags &= WIMLIB_WRITE_MASK_PUBLIC; write_flags |= WIMLIB_WRITE_FLAG_FILE_DESCRIPTOR; return write_standalone_wim(wim, &fd, image, write_flags, @@ -3200,9 +3203,7 @@ wimlib_overwrite(WIMStruct *wim, int write_flags, int ret; u32 orig_hdr_flags; - write_flags &= WIMLIB_WRITE_MASK_PUBLIC; - - if (write_flags & WIMLIB_WRITE_FLAG_FILE_DESCRIPTOR) + if (write_flags & ~WIMLIB_WRITE_MASK_PUBLIC) return WIMLIB_ERR_INVALID_PARAM; if (!wim->filename) -- 2.43.0