From 065b2b3513da8692efab0cd5344c054f246fa635 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 3 Oct 2015 14:56:32 -0500 Subject: [PATCH] Add WIMLIB_ERR_WIM_IS_INCOMPLETE Usually WIMLIB_ERR_XML was returned in this situation, but a separate error code is more appropriate. --- include/wimlib.h | 4 ++++ src/error.c | 2 ++ src/wim.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/include/wimlib.h b/include/wimlib.h index a2d6299e..e9fb0b76 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -2479,6 +2479,7 @@ enum wimlib_error_code { WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81, WIMLIB_ERR_FVE_LOCKED_VOLUME = 82, WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG = 83, + WIMLIB_ERR_WIM_IS_INCOMPLETE = 84, }; @@ -3553,6 +3554,9 @@ wimlib_mount_image(WIMStruct *wim, * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED * The WIM cannot be opened because it contains encrypted segments. (It * may be a Windows 8 "ESD" file.) + * @retval ::WIMLIB_ERR_WIM_IS_INCOMPLETE + * The WIM file is not complete (e.g. the program which wrote it was + * terminated before it finished) * @retval ::WIMLIB_ERR_WIM_IS_READONLY * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was * considered read-only because of any of the reasons mentioned in the diff --git a/src/error.c b/src/error.c index a4672a56..ac12cec4 100644 --- a/src/error.c +++ b/src/error.c @@ -332,6 +332,8 @@ static const tchar * const error_strings[] = { = T("The volume must be unlocked before it can be used"), [WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG] = T("The capture configuration file could not be read"), + [WIMLIB_ERR_WIM_IS_INCOMPLETE] + = T("The WIM file is incomplete"), }; WIMLIBAPI const tchar * diff --git a/src/wim.c b/src/wim.c index 9b5e4b24..1b66aaf7 100644 --- a/src/wim.c +++ b/src/wim.c @@ -733,6 +733,9 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd, int open_flags) if (!wim->blob_table) return WIMLIB_ERR_NOMEM; } else { + if (wim->hdr.blob_table_reshdr.uncompressed_size == 0 && + wim->hdr.xml_data_reshdr.uncompressed_size == 0) + return WIMLIB_ERR_WIM_IS_INCOMPLETE; ret = read_wim_xml_data(wim); if (ret) -- 2.43.0