]> wimlib.net Git - wimlib/blobdiff - src/security.c
wimlib_set_output_{,pack_}_compression_type(): Fix chunk size check
[wimlib] / src / security.c
index aab9808e0447a72ccef3fabf750b024cf863ed13..797345ba686f11c0b39b03954b2764701c162b7d 100644 (file)
@@ -51,20 +51,19 @@ new_wim_security_data(void)
  * Reads the security data from the metadata resource of a WIM image.
  *
  * @metadata_resource: An array that contains the uncompressed metadata
- *                             resource for the WIM image.
- * @metadata_resource_len:     The length of @metadata_resource.  It must be at
- *                             least 8 bytes.
+ *                             resource for the WIM image.
+ * @metadata_resource_len:     The length of @metadata_resource.
  * @sd_ret:    A pointer to a pointer to a wim_security_data structure that
- *             will be filled in with a pointer to a new wim_security_data
- *             structure containing the security data on success.
+ *             will be filled in with a pointer to a new wim_security_data
+ *             structure containing the security data on success.
  *
  * Note: There is no `offset' argument because the security data is located at
  * the beginning of the metadata resource.
  *
  * Return values:
  *     WIMLIB_ERR_SUCCESS (0)
- *     WIMLIB_ERR_INVALID_METADATA_RESOURCE
- *     WIMLIB_ERR_NOMEM
+ *     WIMLIB_ERR_INVALID_METADATA_RESOURCE
+ *     WIMLIB_ERR_NOMEM
  */
 int
 read_wim_security_data(const u8 metadata_resource[], size_t metadata_resource_len,
@@ -78,7 +77,8 @@ read_wim_security_data(const u8 metadata_resource[], size_t metadata_resource_le
        const struct wim_security_data_disk *sd_disk;
        const u8 *p;
 
-       wimlib_assert(metadata_resource_len >= 8);
+       if (metadata_resource_len < 8)
+               return WIMLIB_ERR_INVALID_METADATA_RESOURCE;
 
        sd = new_wim_security_data();
        if (!sd)