X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fmetadata_resource.c;h=54ea91532e6bcc5336f1ccac404d63f5435ca2bc;hb=958cc5438f3ade80baafcfbf15da370e819a6b90;hp=b80ee710bca6f81db4ac6b0c7bece9ef5f0bf344;hpb=e074c6d474920b8bc1436f105e0dff89e6a4bccb;p=wimlib diff --git a/src/metadata_resource.c b/src/metadata_resource.c index b80ee710..54ea9153 100644 --- a/src/metadata_resource.c +++ b/src/metadata_resource.c @@ -5,25 +5,25 @@ /* * Copyright (C) 2012, 2013 Eric Biggers * - * This file is part of wimlib, a library for working with WIM files. + * This file is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at your option) any + * later version. * - * wimlib is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 3 of the License, or (at your option) any later - * version. + * This file is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. * - * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * wimlib; if not, see http://www.gnu.org/licenses/. + * You should have received a copy of the GNU Lesser General Public License + * along with this file; if not, see http://www.gnu.org/licenses/. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include "wimlib/assert.h" #include "wimlib/dentry.h" #include "wimlib/error.h" #include "wimlib/lookup_table.h" @@ -35,9 +35,6 @@ /* * Reads and parses a metadata resource for an image in the WIM file. * - * @wim: - * Pointer to the WIMStruct for the WIM file. - * * @imd: * Pointer to the image metadata structure for the image whose metadata * resource we are reading. Its `metadata_lte' member specifies the lookup @@ -53,7 +50,7 @@ * WIMLIB_ERR_DECOMPRESSION */ int -read_metadata_resource(WIMStruct *wim, struct wim_image_metadata *imd) +read_metadata_resource(struct wim_image_metadata *imd) { const struct wim_lookup_table_entry *metadata_lte; void *buf; @@ -112,11 +109,8 @@ read_metadata_resource(WIMStruct *wim, struct wim_image_metadata *imd) if (ret) goto out_free_dentry_tree; - image_for_each_inode(inode, imd) { - ret = verify_inode(inode, sd); - if (ret) - goto out_free_dentry_tree; - } + image_for_each_inode(inode, imd) + check_inode(inode, sd); /* Success; fill in the image_metadata structure. */ imd->root_dentry = root; @@ -152,7 +146,7 @@ prepare_metadata_resource(WIMStruct *wim, int image, int ret; u64 subdir_offset; struct wim_dentry *root; - u64 len; + size_t len; struct wim_security_data *sd; struct wim_image_metadata *imd; @@ -169,7 +163,7 @@ prepare_metadata_resource(WIMStruct *wim, int image, if (!root) { /* Empty image; create a dummy root. */ - ret = new_filler_directory(T(""), &root); + ret = new_filler_directory(&root); if (ret) return ret; imd->root_dentry = root; @@ -193,10 +187,12 @@ prepare_metadata_resource(WIMStruct *wim, int image, len = subdir_offset; /* Allocate a buffer to contain the uncompressed metadata resource. */ - buf = MALLOC(len); + buf = NULL; + if (likely(len == subdir_offset)) + buf = MALLOC(len); if (!buf) { ERROR("Failed to allocate %"PRIu64" bytes for " - "metadata resource", len); + "metadata resource", subdir_offset); return WIMLIB_ERR_NOMEM; }