X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fextract.c;h=995f9cbb1c36b197b844120157f050ce3649292b;hp=beb5a54277ac3e9e09ca51f5dd7e6d649c5a2a75;hb=668c363a59c521f48eecbc4dd549c07a3e36179e;hpb=5961a91bf69aa12da60b8f97ec07fc048202f785 diff --git a/src/extract.c b/src/extract.c index beb5a542..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. */ @@ -2565,7 +2589,7 @@ check_extract_flags(const WIMStruct *wim, int *extract_flags_p) WIMLIB_EXTRACT_FLAG_NORPFIX)) == 0) { /* Do reparse point fixups by default if the WIM header says - * they are enabled and we are extracting a full image. */ + * they are enabled. */ if (wim->hdr.flags & WIM_HDR_FLAG_RP_FIX) extract_flags |= WIMLIB_EXTRACT_FLAG_RPFIX; } @@ -2841,6 +2865,10 @@ do_wimlib_extract_image(WIMStruct *wim, { int ret; + if (extract_flags & (WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE | + WIMLIB_EXTRACT_FLAG_TO_STDOUT)) + return WIMLIB_ERR_INVALID_PARAM; + if (image == WIMLIB_ALL_IMAGES) ret = extract_all_images(wim, target, extract_flags, progress_func); @@ -2877,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) { @@ -2900,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; @@ -2929,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); @@ -2975,9 +3006,10 @@ 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_TO_STDOUT) + if (extract_flags & WIMLIB_EXTRACT_FLAG_FILE_ORDER) return WIMLIB_ERR_INVALID_PARAM; /* Read the WIM header from the pipe and get a WIMStruct to represent @@ -3132,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); }