From 5695db8f27535e50a8159a226902687fe32ffe9a Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 29 Dec 2013 11:39:54 -0600 Subject: [PATCH] Return new error code when trying to open encrypted WIM --- include/wimlib.h | 1 + src/util.c | 2 ++ src/wim.c | 8 +++++--- src/xml.c | 10 ++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/wimlib.h b/include/wimlib.h index c1290e1f..fcc88b02 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -1886,6 +1886,7 @@ enum wimlib_error_code { WIMLIB_ERR_WIM_IS_READONLY, WIMLIB_ERR_WRITE, WIMLIB_ERR_XML, + WIMLIB_ERR_WIM_IS_ENCRYPTED, }; diff --git a/src/util.c b/src/util.c index 27f01c41..b2e59e40 100644 --- a/src/util.c +++ b/src/util.c @@ -424,6 +424,8 @@ static const tchar *error_strings[] = { = T("Failed to write data to a file"), [WIMLIB_ERR_XML] = T("The XML data of the WIM is invalid"), + [WIMLIB_ERR_WIM_IS_ENCRYPTED] + = T("The WIM file (or parts of it) is encrypted"), }; /* API function documented in wimlib.h */ diff --git a/src/wim.c b/src/wim.c index 6c69de35..498821bc 100644 --- a/src/wim.c +++ b/src/wim.c @@ -709,9 +709,6 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd, if (wim->lookup_table == NULL) return WIMLIB_ERR_NOMEM; } else { - ret = read_wim_lookup_table(wim); - if (ret) - return ret; ret = read_wim_xml_data(wim); if (ret) @@ -725,6 +722,11 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd, " element per image.", wim->hdr.image_count); return WIMLIB_ERR_IMAGE_COUNT; } + + ret = read_wim_lookup_table(wim); + if (ret) + return ret; + DEBUG("Done beginning read of WIM file `%"TS"'.", wimfile); } return 0; diff --git a/src/xml.c b/src/xml.c index 5103d75d..cafc14f4 100644 --- a/src/xml.c +++ b/src/xml.c @@ -566,6 +566,16 @@ xml_read_wim_info(const xmlNode *wim_node, struct wim_info **wim_info_ret) i++; } else if (node_name_is(child, "TOTALBYTES")) { wim_info->total_bytes = node_get_u64(child); + } else if (node_name_is(child, "ESD")) { + xmlNode *esdchild; + for_node_child(child, esdchild) { + if (node_is_element(esdchild) && + node_name_is(esdchild, "ENCRYPTED")) + { + ret = WIMLIB_ERR_WIM_IS_ENCRYPTED; + goto err; + } + } } } -- 2.43.0