Return new error code when trying to open encrypted WIM
authorEric Biggers <ebiggers3@gmail.com>
Sun, 29 Dec 2013 17:39:54 +0000 (11:39 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 29 Dec 2013 17:39:54 +0000 (11:39 -0600)
include/wimlib.h
src/util.c
src/wim.c
src/xml.c

index c1290e1..fcc88b0 100644 (file)
@@ -1886,6 +1886,7 @@ enum wimlib_error_code {
        WIMLIB_ERR_WIM_IS_READONLY,
        WIMLIB_ERR_WRITE,
        WIMLIB_ERR_XML,
+       WIMLIB_ERR_WIM_IS_ENCRYPTED,
 };
 
 
index 27f01c4..b2e59e4 100644 (file)
@@ -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  */
index 6c69de3..498821b 100644 (file)
--- 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,
                              "<IMAGE> 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;
index 5103d75..cafc14f 100644 (file)
--- 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;
+                                       }
+                               }
                        }
                }