]> wimlib.net Git - wimlib/commitdiff
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 c1290e1f8fd75b3258893a70ef743713dca6b639..fcc88b028cf4c44b3a6a94d4a4effead6fae0e22 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_READONLY,
        WIMLIB_ERR_WRITE,
        WIMLIB_ERR_XML,
+       WIMLIB_ERR_WIM_IS_ENCRYPTED,
 };
 
 
 };
 
 
index 27f01c415ff240594d22ed6d7fe5be18fb566f3d..b2e59e40417c3a4a555770a0d6d462f632466e6a 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"),
                = 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  */
 };
 
 /* API function documented in wimlib.h  */
index 6c69de35049a1f8c6c03d8c0e8ae626c4d5a0a11..498821bc2bffab8e38081d778d95df730486e137 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 {
                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)
 
                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;
                }
                              "<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;
                DEBUG("Done beginning read of WIM file `%"TS"'.", wimfile);
        }
        return 0;
index 5103d75d8d34d01901cf6505fc05950b98b4ad14..cafc14f4788cda5722cba8e837d2ce33ce097db5 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);
                                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;
+                                       }
+                               }
                        }
                }
 
                        }
                }