- dentry_offset = (imd->security_data->total_length + 7) & ~7;
-
- if (dentry_offset == 0) {
- ERROR("Integer overflow while reading metadata resource");
- ret = WIMLIB_ERR_INVALID_SECURITY_DATA;
- goto out_free_security_data;
- }
-
- DEBUG("Reading root dentry");
-
- /* Allocate memory for the root dentry and read it into memory */
- dentry = MALLOC(sizeof(struct wim_dentry));
- if (!dentry) {
- ERROR("Failed to allocate %zu bytes for root dentry",
- sizeof(struct wim_dentry));
- ret = WIMLIB_ERR_NOMEM;
- goto out_free_security_data;
- }
-
- ret = read_dentry(buf, metadata_len, dentry_offset, dentry);
-
- /* This is the root dentry, so set its parent to itself. */
- dentry->parent = dentry;
-
- if (ret == 0 && dentry->length == 0) {
- ERROR("Metadata resource cannot begin with end-of-directory entry!");
- ret = WIMLIB_ERR_INVALID_DENTRY;
- }
-
- if (ret != 0) {
- FREE(dentry);