]> wimlib.net Git - wimlib/commitdiff
Fix various issues
authorEric Biggers <ebiggers3@gmail.com>
Wed, 29 Aug 2012 02:41:47 +0000 (21:41 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Wed, 29 Aug 2012 02:41:47 +0000 (21:41 -0500)
16 files changed:
src/dentry.c
src/extract.c
src/hardlink.c
src/integrity.c
src/lookup_table.c
src/lookup_table.h
src/modify.c
src/mount.c
src/ntfs-apply.c
src/ntfs-capture.c
src/resource.c
src/security.c
src/sha1.h
src/symlink.c
src/xml.c
tests/test-imagex

index 9854f85f7239ef1371c1a9d6f86b9fc7cdee87b5..fbc62b869295af7fcccb61eeb4864d5e1a01968f 100644 (file)
@@ -502,10 +502,6 @@ int print_dentry(struct dentry *dentry, void *lookup_table)
 #endif
 
        /* Translate the timestamps into something readable */
 #endif
 
        /* Translate the timestamps into something readable */
-       time_t creat_time = wim_timestamp_to_unix(dentry->creation_time);
-       time_t access_time = wim_timestamp_to_unix(dentry->last_access_time);
-       time_t mod_time = wim_timestamp_to_unix(dentry->last_write_time);
-
        time = wim_timestamp_to_unix(dentry->creation_time);
        p = asctime(gmtime(&time));
        *(strrchr(p, '\n')) = '\0';
        time = wim_timestamp_to_unix(dentry->creation_time);
        p = asctime(gmtime(&time));
        *(strrchr(p, '\n')) = '\0';
@@ -651,7 +647,6 @@ void put_dentry(struct dentry *dentry)
                }
                dentry->ads_entries_status = ADS_ENTRIES_USER;
        }
                }
                dentry->ads_entries_status = ADS_ENTRIES_USER;
        }
-       struct list_head *next;
        list_del(&dentry->link_group_list);
        free_dentry(dentry);
 }
        list_del(&dentry->link_group_list);
        free_dentry(dentry);
 }
@@ -812,6 +807,8 @@ int change_dentry_name(struct dentry *dentry, const char *new_name)
        ret = get_names(&dentry->file_name, &dentry->file_name_utf8,
                        &dentry->file_name_len, &dentry->file_name_utf8_len,
                         new_name);
        ret = get_names(&dentry->file_name, &dentry->file_name_utf8,
                        &dentry->file_name_len, &dentry->file_name_utf8_len,
                         new_name);
+       FREE(dentry->short_name);
+       dentry->short_name_len = 0;
        if (ret == 0)
                dentry->length = dentry_correct_length(dentry);
        return ret;
        if (ret == 0)
                dentry->length = dentry_correct_length(dentry);
        return ret;
@@ -941,7 +938,7 @@ static int read_ads_entries(const u8 *p, struct dentry *dentry,
                u64 length_no_padding;
                u64 total_length;
                size_t utf8_len;
                u64 length_no_padding;
                u64 total_length;
                size_t utf8_len;
-               const char *p_save = p;
+               const u8 *p_save = p;
 
                /* Read the base stream entry, excluding the stream name. */
                if (remaining_size < WIM_ADS_ENTRY_DISK_SIZE) {
 
                /* Read the base stream entry, excluding the stream name. */
                if (remaining_size < WIM_ADS_ENTRY_DISK_SIZE) {
@@ -972,7 +969,7 @@ static int read_ads_entries(const u8 *p, struct dentry *dentry,
                if (remaining_size < length_no_padding) {
                        ERROR("Stream entries go past end of metadata resource");
                        ERROR("(remaining_size = %"PRIu64" bytes, "
                if (remaining_size < length_no_padding) {
                        ERROR("Stream entries go past end of metadata resource");
                        ERROR("(remaining_size = %"PRIu64" bytes, "
-                             "length_no_padding = %"PRIu16" bytes)",
+                             "length_no_padding = %"PRIu64" bytes)",
                              remaining_size, length_no_padding);
                        ret = WIMLIB_ERR_INVALID_DENTRY;
                        goto out_free_ads_entries;
                              remaining_size, length_no_padding);
                        ret = WIMLIB_ERR_INVALID_DENTRY;
                        goto out_free_ads_entries;
@@ -1062,7 +1059,7 @@ int read_dentry(const u8 metadata_resource[], u64 metadata_resource_len,
        char *short_name = NULL;
        u16 short_name_len;
        u16 file_name_len;
        char *short_name = NULL;
        u16 short_name_len;
        u16 file_name_len;
-       size_t file_name_utf8_len;
+       size_t file_name_utf8_len = 0;
        int ret;
 
        dentry_common_init(dentry);
        int ret;
 
        dentry_common_init(dentry);
@@ -1324,14 +1321,11 @@ int verify_dentry(struct dentry *dentry, void *wim)
 
        /* Make sure there is only one un-named stream. */
        unsigned num_unnamed_streams = 0;
 
        /* Make sure there is only one un-named stream. */
        unsigned num_unnamed_streams = 0;
-       unsigned unnamed_stream_idx;
        for (unsigned i = 0; i <= dentry->num_ads; i++) {
                const u8 *hash;
                hash = dentry_stream_hash_unresolved(dentry, i);
        for (unsigned i = 0; i <= dentry->num_ads; i++) {
                const u8 *hash;
                hash = dentry_stream_hash_unresolved(dentry, i);
-               if (!dentry_stream_name_len(dentry, i) && !is_zero_hash(hash)) {
+               if (!dentry_stream_name_len(dentry, i) && !is_zero_hash(hash))
                        num_unnamed_streams++;
                        num_unnamed_streams++;
-                       unnamed_stream_idx = i;
-               }
        }
        if (num_unnamed_streams > 1) {
                ERROR("Dentry `%s' has multiple (%u) un-named streams", 
        }
        if (num_unnamed_streams > 1) {
                ERROR("Dentry `%s' has multiple (%u) un-named streams", 
@@ -1339,6 +1333,22 @@ int verify_dentry(struct dentry *dentry, void *wim)
                goto out;
        }
 
                goto out;
        }
 
+       /* Cannot have a short name but no long name */
+       if (dentry->short_name_len && !dentry->file_name_len) {
+               ERROR("Dentry `%s' has a short name but no long name",
+                     dentry->full_path_utf8);
+               goto out;
+       }
+
+       /* Make sure root dentry is unnamed */
+       if (dentry_is_root(dentry)) {
+               if (dentry->file_name_len) {
+                       ERROR("The root dentry is named `%s', but it must "
+                             "be unnamed", dentry->file_name_utf8);
+                       goto out;
+               }
+       }
+
 #if 0
        /* Check timestamps */
        if (dentry->last_access_time < dentry->creation_time ||
 #if 0
        /* Check timestamps */
        if (dentry->last_access_time < dentry->creation_time ||
@@ -1364,7 +1374,6 @@ out:
 static u8 *write_dentry(const struct dentry *dentry, u8 *p)
 {
        u8 *orig_p = p;
 static u8 *write_dentry(const struct dentry *dentry, u8 *p)
 {
        u8 *orig_p = p;
-       unsigned padding;
        const u8 *hash;
 
        /* We calculate the correct length of the dentry ourselves because the
        const u8 *hash;
 
        /* We calculate the correct length of the dentry ourselves because the
index b27c44325fabd8d7078b79d4ababa447b73b8e54..80cacf7906bcd58fd67835639ec7c7a3e5c46260 100644 (file)
@@ -123,7 +123,6 @@ static int extract_regular_file_unlinked(WIMStruct *w,
         * extracted in the way that they appear in the WIM. */
 
        int out_fd;
         * extracted in the way that they appear in the WIM. */
 
        int out_fd;
-       const struct resource_entry *res_entry;
        int ret;
        const struct list_head *head = &dentry->link_group_list;
 
        int ret;
        const struct list_head *head = &dentry->link_group_list;
 
index 23344ad989a98aa2aa2948fd040a8fc31537643a..3d01083124232991cb0c8db3eea4ef101a5b23c6 100644 (file)
@@ -194,8 +194,6 @@ static void free_link_group_list(struct link_group *group)
 /* Frees a link group table. */
 void free_link_group_table(struct link_group_table *table)
 {
 /* Frees a link group table. */
 void free_link_group_table(struct link_group_table *table)
 {
-       struct link_group *single, *next;
-
        if (table) {
                 if (table->array)
                         for (size_t i = 0; i < table->capacity; i++)
        if (table) {
                 if (table->array)
                         for (size_t i = 0; i < table->capacity; i++)
@@ -205,8 +203,9 @@ void free_link_group_table(struct link_group_table *table)
         }
 }
 
         }
 }
 
-u64 assign_link_group_ids_to_list(struct link_group *group, u64 id,
-                                  struct link_group **extra_groups)
+static u64
+assign_link_group_ids_to_list(struct link_group *group, u64 id,
+                              struct link_group **extra_groups)
 {
        struct dentry *dentry;
        struct list_head *cur_head;
 {
        struct dentry *dentry;
        struct list_head *cur_head;
@@ -439,7 +438,6 @@ fix_nominal_link_group(struct link_group *group,
        int ret;
        size_t num_true_link_groups;
        struct list_head *head;
        int ret;
        size_t num_true_link_groups;
        struct list_head *head;
-       u64 link_group_id;
 
        LIST_HEAD(dentries_with_data_streams);
        LIST_HEAD(dentries_with_no_data_streams);
 
        LIST_HEAD(dentries_with_data_streams);
        LIST_HEAD(dentries_with_no_data_streams);
@@ -472,11 +470,17 @@ fix_nominal_link_group(struct link_group *group,
         * link group to be a true link group */
        if (list_empty(&dentries_with_data_streams)) {
        #ifdef ENABLE_DEBUG
         * link group to be a true link group */
        if (list_empty(&dentries_with_data_streams)) {
        #ifdef ENABLE_DEBUG
-               DEBUG("Found link group of size %zu without any data streams:",
-                     dentry_link_group_size(dentry));
-               print_dentry_list(dentry);
-               DEBUG("We are going to interpret it as true link group, provided "
-                     "that the dentries are consistent.");
+               {
+                       size_t size = dentry_link_group_size(dentry);
+                       if (size > 1) {
+                               DEBUG("Found link group of size %zu without "
+                                     "any data streams:", size);
+                               print_dentry_list(dentry);
+                               DEBUG("We are going to interpret it as true "
+                                     "link group, provided that the dentries "
+                                     "are consistent.");
+                       }
+               }
        #endif
                return fix_true_link_group(container_of(group->dentry_list,
                                                        struct dentry,
        #endif
                return fix_true_link_group(container_of(group->dentry_list,
                                                        struct dentry,
@@ -568,7 +572,7 @@ next_dentry_2:
                        ERROR("Out of memory");
                        return WIMLIB_ERR_NOMEM;
                }
                        ERROR("Out of memory");
                        return WIMLIB_ERR_NOMEM;
                }
-               group->link_group_id = link_group_id;
+               group->link_group_id = dentry->link_group_id;
                group->dentry_list = &dentry->link_group_list;
                group->next = *new_groups;
                *new_groups = group;
                group->dentry_list = &dentry->link_group_list;
                group->next = *new_groups;
                *new_groups = group;
index 12968bf91004a0b2e54d6b59c677c5e8c5f261c2..f50d03abb539a4abaee7ba24d019c1592be9e4c3 100644 (file)
@@ -49,7 +49,7 @@ static int verify_integrity(FILE *fp, u64 num_bytes, u32 chunk_size,
                            const u8 *sha1sums, int show_progress,
                            int *status)
 {
                            const u8 *sha1sums, int show_progress,
                            int *status)
 {
-       char  *chunk_buf;
+       u8    *chunk_buf;
        u8     resblock[SHA1_HASH_SIZE];
        u64    bytes_remaining;
        size_t bytes_to_read;
        u8     resblock[SHA1_HASH_SIZE];
        u64    bytes_remaining;
        size_t bytes_to_read;
@@ -117,7 +117,6 @@ int check_wim_integrity(WIMStruct *w, int show_progress, int *status)
 {
 
        struct resource_entry *res_entry;
 {
 
        struct resource_entry *res_entry;
-       int ctype;
        u8 *buf = NULL;
        int ret;
        u32 integrity_table_size;
        u8 *buf = NULL;
        int ret;
        u32 integrity_table_size;
@@ -251,7 +250,7 @@ int write_integrity_table(FILE *out, u64 end_header_offset,
        u64   bytes_remaining;
        u8   *buf;
        u8   *p;
        u64   bytes_remaining;
        u8   *buf;
        u8   *p;
-       char *chunk_buf;
+       u8   *chunk_buf;
        u32   num_entries;
        u32   integrity_table_size;
        int   ret;
        u32   num_entries;
        u32   integrity_table_size;
        int   ret;
index 92fb8a9f178b0713bea0b6000e2fbc18b781edd6..007cd9eae689d655ec4580b7d2a00bfcf9fb84f2 100644 (file)
@@ -344,6 +344,8 @@ void print_lookup_table_entry(const struct lookup_table_entry *lte)
        case RESOURCE_IN_STAGING_FILE:
                printf("Staging File      = `%s'\n", lte->staging_file_name);
                break;
        case RESOURCE_IN_STAGING_FILE:
                printf("Staging File      = `%s'\n", lte->staging_file_name);
                break;
+       default:
+               break;
        }
        putchar('\n');
 }
        }
        putchar('\n');
 }
@@ -397,7 +399,7 @@ int lookup_resource(WIMStruct *w, const char *path,
        struct dentry *dentry;
        struct lookup_table_entry *lte;
        unsigned stream_idx;
        struct dentry *dentry;
        struct lookup_table_entry *lte;
        unsigned stream_idx;
-       const char *stream_name;
+       const char *stream_name = NULL;
        char *p = NULL;
 
        if (lookup_flags & LOOKUP_FLAG_ADS_OK) {
        char *p = NULL;
 
        if (lookup_flags & LOOKUP_FLAG_ADS_OK) {
index 3a653bfb531b15c13a437ac2a647c378c0e71a75..56e030589fd2a83c10d609fab9198fa4e6642c8c 100644 (file)
@@ -334,9 +334,7 @@ static inline const u8 *dentry_stream_hash(const struct dentry *dentry,
 static inline struct lookup_table_entry *
 dentry_unnamed_lte_resolved(const struct dentry *dentry)
 {
 static inline struct lookup_table_entry *
 dentry_unnamed_lte_resolved(const struct dentry *dentry)
 {
-       struct lookup_table_entry *lte;
        wimlib_assert(dentry->resolved);
        wimlib_assert(dentry->resolved);
-
        for (unsigned i = 0; i <= dentry->num_ads; i++)
                if (dentry_stream_name_len(dentry, i) == 0 &&
                     !is_zero_hash(dentry_stream_hash_resolved(dentry, i)))
        for (unsigned i = 0; i <= dentry->num_ads; i++)
                if (dentry_stream_name_len(dentry, i) == 0 &&
                     !is_zero_hash(dentry_stream_hash_resolved(dentry, i)))
@@ -348,9 +346,7 @@ static inline struct lookup_table_entry *
 dentry_unnamed_lte_unresolved(const struct dentry *dentry,
                              const struct lookup_table *table)
 {
 dentry_unnamed_lte_unresolved(const struct dentry *dentry,
                              const struct lookup_table *table)
 {
-       struct lookup_table_entry *lte;
        wimlib_assert(!dentry->resolved);
        wimlib_assert(!dentry->resolved);
-
        for (unsigned i = 0; i <= dentry->num_ads; i++)
                if (dentry_stream_name_len(dentry, i) == 0 &&
                     !is_zero_hash(dentry_stream_hash_unresolved(dentry, i)))
        for (unsigned i = 0; i <= dentry->num_ads; i++)
                if (dentry_stream_name_len(dentry, i) == 0 &&
                     !is_zero_hash(dentry_stream_hash_unresolved(dentry, i)))
index c979162a8ed11aadd2fd95ef012b7ef454a57cba..3a40c90e9f1f6ac598610535c7427ba00209548d 100644 (file)
@@ -85,6 +85,7 @@ static int build_dentry_tree(struct dentry **root_ret, const char *root_disk_pat
        int ret = 0;
        int (*stat_fn)(const char *restrict, struct stat *restrict);
        struct dentry *root;
        int ret = 0;
        int (*stat_fn)(const char *restrict, struct stat *restrict);
        struct dentry *root;
+       const char *filename;
 
        if (exclude_path(root_disk_path, config, true)) {
                if (add_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
 
        if (exclude_path(root_disk_path, config, true)) {
                if (add_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
@@ -117,11 +118,17 @@ static int build_dentry_tree(struct dentry **root_ret, const char *root_disk_pat
        }
        if (!S_ISREG(root_stbuf.st_mode) && !S_ISDIR(root_stbuf.st_mode)
            && !S_ISLNK(root_stbuf.st_mode)) {
        }
        if (!S_ISREG(root_stbuf.st_mode) && !S_ISDIR(root_stbuf.st_mode)
            && !S_ISLNK(root_stbuf.st_mode)) {
-               ERROR("`%s' is not a regular file, directory, or symbolic link.");
+               ERROR("`%s' is not a regular file, directory, or symbolic link.",
+                     root_disk_path);
                return WIMLIB_ERR_SPECIAL_FILE;
        }
 
                return WIMLIB_ERR_SPECIAL_FILE;
        }
 
-       root = new_dentry(path_basename(root_disk_path));
+       if (add_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT)
+               filename = "";
+       else
+               filename = path_basename(root_disk_path);
+
+       root = new_dentry(filename);
        if (!root)
                return WIMLIB_ERR_NOMEM;
 
        if (!root)
                return WIMLIB_ERR_NOMEM;
 
@@ -166,7 +173,6 @@ static int build_dentry_tree(struct dentry **root_ret, const char *root_disk_pat
                closedir(dir);
        } else if (dentry_is_symlink(root)) {
                /* Archiving a symbolic link */
                closedir(dir);
        } else if (dentry_is_symlink(root)) {
                /* Archiving a symbolic link */
-               size_t symlink_buf_len;
                char deref_name_buf[4096];
                ssize_t deref_name_len;
                
                char deref_name_buf[4096];
                ssize_t deref_name_len;
                
@@ -286,6 +292,7 @@ static int add_lte_to_dest_wim(struct dentry *dentry, void *arg)
  *
  * @w:           The WIMStruct for the WIM file.
  * @root_dentry:  The root of the directory tree for the image.
  *
  * @w:           The WIMStruct for the WIM file.
  * @root_dentry:  The root of the directory tree for the image.
+ * @sd:                  The security data for the image.
  */
 static int add_new_dentry_tree(WIMStruct *w, struct dentry *root_dentry,
                               struct wim_security_data *sd)
  */
 static int add_new_dentry_tree(WIMStruct *w, struct dentry *root_dentry,
                               struct wim_security_data *sd)
@@ -313,7 +320,7 @@ static int add_new_dentry_tree(WIMStruct *w, struct dentry *root_dentry,
 
        lgt = new_link_group_table(9001);
        if (!lgt)
 
        lgt = new_link_group_table(9001);
        if (!lgt)
-               goto out_free_security_data;
+               goto out_free_metadata_lte;
 
        metadata_lte->resource_entry.flags = WIM_RESHDR_FLAG_METADATA;
        random_hash(metadata_lte->hash);
 
        metadata_lte->resource_entry.flags = WIM_RESHDR_FLAG_METADATA;
        random_hash(metadata_lte->hash);
@@ -333,8 +340,6 @@ static int add_new_dentry_tree(WIMStruct *w, struct dentry *root_dentry,
 
        /* Change the current image to the new one. */
        return wimlib_select_image(w, w->hdr.image_count);
 
        /* Change the current image to the new one. */
        return wimlib_select_image(w, w->hdr.image_count);
-out_free_security_data:
-       FREE(sd);
 out_free_metadata_lte:
        FREE(metadata_lte);
 out_free_imd:
 out_free_metadata_lte:
        FREE(metadata_lte);
 out_free_imd:
@@ -573,7 +578,6 @@ static int init_capture_config(const char *_config_str, size_t config_len,
        char *p;
        char *eol;
        char *next_p;
        char *p;
        char *eol;
        char *next_p;
-       size_t next_bytes_remaining;
        size_t bytes_remaining;
        enum pattern_type type = NONE;
        int ret;
        size_t bytes_remaining;
        enum pattern_type type = NONE;
        int ret;
@@ -627,6 +631,7 @@ static int init_capture_config(const char *_config_str, size_t config_len,
                if (eol - p > 2 && isalpha(*p) && *(p + 1) == ':')
                        p += 2;
 
                if (eol - p > 2 && isalpha(*p) && *(p + 1) == ':')
                        p += 2;
 
+               ret = 0;
                if (strcmp(p, "[ExclusionList]") == 0)
                        type = EXCLUSION_LIST;
                else if (strcmp(p, "[ExclusionException]") == 0)
                if (strcmp(p, "[ExclusionList]") == 0)
                        type = EXCLUSION_LIST;
                else if (strcmp(p, "[ExclusionException]") == 0)
@@ -635,7 +640,11 @@ static int init_capture_config(const char *_config_str, size_t config_len,
                        type = COMPRESSION_EXCLUSION_LIST;
                else if (strcmp(p, "[AlignmentList]") == 0)
                        type = ALIGNMENT_LIST;
                        type = COMPRESSION_EXCLUSION_LIST;
                else if (strcmp(p, "[AlignmentList]") == 0)
                        type = ALIGNMENT_LIST;
-               else switch (type) {
+               else if (p[0] == '[' && strrchr(p, ']')) {
+                       ERROR("Unknown capture configuration section `%s'", p);
+                       ret = WIMLIB_ERR_INVALID_CAPTURE_CONFIG;
+                       goto out_destroy;
+               } else switch (type) {
                case EXCLUSION_LIST:
                        DEBUG("Adding pattern \"%s\" to exclusion list", p);
                        ret = pattern_list_add_pattern(&config->exclusion_list, p);
                case EXCLUSION_LIST:
                        DEBUG("Adding pattern \"%s\" to exclusion list", p);
                        ret = pattern_list_add_pattern(&config->exclusion_list, p);
@@ -742,7 +751,6 @@ int do_add_image(WIMStruct *w, const char *dir, const char *name,
                 void *extra_arg)
 {
        struct dentry *root_dentry = NULL;
                 void *extra_arg)
 {
        struct dentry *root_dentry = NULL;
-       struct image_metadata *imd;
        struct wim_security_data *sd;
        struct capture_config config;
        struct link_group_table *lgt;
        struct wim_security_data *sd;
        struct capture_config config;
        struct link_group_table *lgt;
@@ -834,7 +842,6 @@ out_destroy_imd:
        return ret;
 out_free_dentry_tree:
        free_dentry_tree(root_dentry, w->lookup_table);
        return ret;
 out_free_dentry_tree:
        free_dentry_tree(root_dentry, w->lookup_table);
-out_free_sd:
        free_security_data(sd);
 out_destroy_config:
        destroy_capture_config(&config);
        free_security_data(sd);
 out_destroy_config:
        destroy_capture_config(&config);
index 8a9640c3dbfa339f167ed52324673888c7c3906d..82abe7d90b4640e29742facfcd6aac0539bb9ba2 100644 (file)
@@ -196,7 +196,7 @@ static void remove_ads(struct dentry *dentry,
 
        wimlib_assert(dentry->resolved);
 
 
        wimlib_assert(dentry->resolved);
 
-       lte = lte_decrement_refcnt(lte, lookup_table);
+       lte = lte_decrement_refcnt(ads_entry->lte, lookup_table);
        if (lte)
                list_del(&ads_entry->lte_group_list.list);
        dentry_remove_ads(dentry, ads_entry);
        if (lte)
                list_del(&ads_entry->lte_group_list.list);
        dentry_remove_ads(dentry, ads_entry);
@@ -224,6 +224,7 @@ int dentry_to_stbuf(const struct dentry *dentry, struct stat *stbuf)
        lte = dentry_unnamed_lte_resolved(dentry);
        if (lte) {
                if (lte->resource_location == RESOURCE_IN_STAGING_FILE) {
        lte = dentry_unnamed_lte_resolved(dentry);
        if (lte) {
                if (lte->resource_location == RESOURCE_IN_STAGING_FILE) {
+                       wimlib_assert(mount_flags & WIMLIB_MOUNT_FLAG_READWRITE);
                        wimlib_assert(lte->staging_file_name);
                        struct stat native_stat;
                        if (stat(lte->staging_file_name, &native_stat) != 0) {
                        wimlib_assert(lte->staging_file_name);
                        struct stat native_stat;
                        if (stat(lte->staging_file_name, &native_stat) != 0) {
@@ -310,7 +311,6 @@ static int create_staging_file(char **name_ret, int open_flags)
 static struct lookup_table_entry *
 lte_extract_fds(struct lookup_table_entry *old_lte, u64 link_group)
 {
 static struct lookup_table_entry *
 lte_extract_fds(struct lookup_table_entry *old_lte, u64 link_group)
 {
-       int ret;
        u16 num_transferred_fds;
        struct lookup_table_entry *new_lte;
 
        u16 num_transferred_fds;
        struct lookup_table_entry *new_lte;
 
@@ -466,7 +466,7 @@ static int extract_resource_to_staging_dir(struct dentry *dentry,
                        new_lte = old_lte;
                } else {
                        DEBUG("Splitting lookup table entry "
                        new_lte = old_lte;
                } else {
                        DEBUG("Splitting lookup table entry "
-                             "(link_group_size = %u, lte refcnt = %u)",
+                             "(link_group_size = %zu, lte refcnt = %u)",
                              link_group_size, old_lte->refcnt);
                        /* Split a hard link group away from the "lookup table
                         * entry" hard link group (i.e. we had two hard link
                              link_group_size, old_lte->refcnt);
                        /* Split a hard link group away from the "lookup table
                         * entry" hard link group (i.e. we had two hard link
@@ -861,8 +861,6 @@ static int rebuild_wim(WIMStruct *w, bool check_integrity)
                if (ret != 0)
                        return ret;
        }
                if (ret != 0)
                        return ret;
        }
-       if (ret != 0)
-               return ret;
 
        xml_update_image_info(w, w->current_image);
 
 
        xml_update_image_info(w, w->current_image);
 
@@ -983,8 +981,6 @@ static int wimfs_ftruncate(const char *path, off_t size,
  */
 static int wimfs_getattr(const char *path, struct stat *stbuf)
 {
  */
 static int wimfs_getattr(const char *path, struct stat *stbuf)
 {
-       const char *stream_name;
-       char *p = NULL;
        struct dentry *dentry;
        int ret;
 
        struct dentry *dentry;
        int ret;
 
@@ -1027,7 +1023,7 @@ static int wimfs_getxattr(const char *path, const char *name, char *value,
                return res_size;
        if (res_size > size)
                return -ERANGE;
                return res_size;
        if (res_size > size)
                return -ERANGE;
-       ret = read_full_wim_resource(lte, value);
+       ret = read_full_wim_resource(lte, (u8*)value);
        if (ret != 0)
                return -EIO;
        return res_size;
        if (ret != 0)
                return -EIO;
        return res_size;
@@ -1152,7 +1148,6 @@ static int wimfs_mkdir(const char *path, mode_t mode)
 static int wimfs_mknod(const char *path, mode_t mode, dev_t rdev)
 {
        const char *stream_name;
 static int wimfs_mknod(const char *path, mode_t mode, dev_t rdev)
 {
        const char *stream_name;
-       const char *file_name;
        if ((mount_flags & WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS)
             && (stream_name = path_stream_name(path))) {
                /* Make an alternate data stream */
        if ((mount_flags & WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS)
             && (stream_name = path_stream_name(path))) {
                /* Make an alternate data stream */
@@ -1207,7 +1202,6 @@ static int wimfs_open(const char *path, struct fuse_file_info *fi)
 {
        struct dentry *dentry;
        struct lookup_table_entry *lte;
 {
        struct dentry *dentry;
        struct lookup_table_entry *lte;
-       u8 *dentry_hash;
        int ret;
        struct wimlib_fd *fd;
        unsigned stream_idx;
        int ret;
        struct wimlib_fd *fd;
        unsigned stream_idx;
@@ -1325,7 +1319,8 @@ static int wimfs_read(const char *path, char *buf, size_t size,
 
                size = min(size, res_entry->original_size - offset);
 
 
                size = min(size, res_entry->original_size - offset);
 
-               if (read_wim_resource(fd->lte, buf, size, offset, false) != 0)
+               if (read_wim_resource(fd->lte, (u8*)buf,
+                                     size, offset, false) != 0)
                        return -EIO;
                return size;
        }
                        return -EIO;
                return size;
        }
@@ -1375,7 +1370,6 @@ static int wimfs_readlink(const char *path, char *buf, size_t buf_len)
 /* Close a file. */
 static int wimfs_release(const char *path, struct fuse_file_info *fi)
 {
 /* Close a file. */
 static int wimfs_release(const char *path, struct fuse_file_info *fi)
 {
-       int ret;
        struct wimlib_fd *fd = (struct wimlib_fd*)fi->fh;
 
        if (!fd) {
        struct wimlib_fd *fd = (struct wimlib_fd*)fi->fh;
 
        if (!fd) {
@@ -1410,7 +1404,6 @@ static int wimfs_removexattr(const char *path, const char *name)
 {
        struct dentry *dentry;
        struct ads_entry *ads_entry;
 {
        struct dentry *dentry;
        struct ads_entry *ads_entry;
-       int ret;
        if (!(mount_flags & WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR))
                return -ENOTSUP;
 
        if (!(mount_flags & WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR))
                return -ENOTSUP;
 
@@ -1525,8 +1518,6 @@ static int wimfs_setxattr(const char *path, const char *name,
        struct lookup_table_entry *existing_lte;
        struct lookup_table_entry *lte;
        u8 value_hash[SHA1_HASH_SIZE];
        struct lookup_table_entry *existing_lte;
        struct lookup_table_entry *lte;
        u8 value_hash[SHA1_HASH_SIZE];
-       int ret;
-       int fd;
 
        if (!(mount_flags & WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR))
                return -ENOTSUP;
 
        if (!(mount_flags & WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR))
                return -ENOTSUP;
@@ -1551,7 +1542,7 @@ static int wimfs_setxattr(const char *path, const char *name,
        if (!new_ads_entry)
                return -ENOMEM;
 
        if (!new_ads_entry)
                return -ENOMEM;
 
-       sha1_buffer(value, size, value_hash);
+       sha1_buffer((const u8*)value, size, value_hash);
 
        existing_lte = __lookup_resource(w->lookup_table, value_hash);
 
 
        existing_lte = __lookup_resource(w->lookup_table, value_hash);
 
@@ -1559,7 +1550,7 @@ static int wimfs_setxattr(const char *path, const char *name,
                lte = existing_lte;
                lte->refcnt++;
        } else {
                lte = existing_lte;
                lte->refcnt++;
        } else {
-               char *value_copy;
+               u8 *value_copy;
                lte = new_lookup_table_entry();
                if (!lte)
                        return -ENOMEM;
                lte = new_lookup_table_entry();
                if (!lte)
                        return -ENOMEM;
@@ -1661,7 +1652,6 @@ static int wimfs_unlink(const char *path)
        struct dentry *dentry;
        struct lookup_table_entry *lte;
        int ret;
        struct dentry *dentry;
        struct lookup_table_entry *lte;
        int ret;
-       u8 *dentry_hash;
        unsigned stream_idx;
        
        ret = lookup_resource(w, path, get_lookup_flags(), &dentry,
        unsigned stream_idx;
        
        ret = lookup_resource(w, path, get_lookup_flags(), &dentry,
@@ -1780,7 +1770,7 @@ static int check_lte_refcnt(struct lookup_table_entry *lte, void *ignore)
                struct stream_list_head *head;
                WARNING("The following lookup table entry has a reference count "
                      "of %u, but", lte->refcnt);
                struct stream_list_head *head;
                WARNING("The following lookup table entry has a reference count "
                      "of %u, but", lte->refcnt);
-               WARNING("We found %u references to it", lte_group_size);
+               WARNING("We found %zu references to it", lte_group_size);
                next = lte->lte_group_list.next;
                head = container_of(next, struct stream_list_head, list);
                if (head->type == STREAM_TYPE_NORMAL) {
                next = lte->lte_group_list.next;
                head = container_of(next, struct stream_list_head, list);
                if (head->type == STREAM_TYPE_NORMAL) {
index 3ec0ae75526e89b153495a224d60d0be48302893..e8e86c1ecd5efcd1bd5cd360079773f7fb8c1d56 100644 (file)
@@ -61,7 +61,7 @@ extract_wim_resource_to_ntfs_attr(const struct lookup_table_entry *lte,
                                  ntfs_attr *na)
 {
        u64 bytes_remaining = wim_resource_size(lte);
                                  ntfs_attr *na)
 {
        u64 bytes_remaining = wim_resource_size(lte);
-       char buf[min(WIM_CHUNK_SIZE, bytes_remaining)];
+       u8 buf[min(WIM_CHUNK_SIZE, bytes_remaining)];
        u64 offset = 0;
        int ret = 0;
        u8 hash[SHA1_HASH_SIZE];
        u64 offset = 0;
        int ret = 0;
        u8 hash[SHA1_HASH_SIZE];
@@ -141,15 +141,6 @@ static int write_ntfs_data_streams(ntfs_inode *ni, const struct dentry *dentry,
        return ret;
 }
 
        return ret;
 }
 
-static bool in_same_dir(const char *path1, const char *path2)
-{
-       const char *p1 = strrchr(path1, '/');
-       const char *p2 = strrchr(path2, '/');
-       if (p1 - path1 != p2 - path2)
-               return false;
-       return memcmp(path1, path2,  p1 - path1) == 0;
-}
-
 /*
  * Makes a NTFS hard link
  *
 /*
  * Makes a NTFS hard link
  *
@@ -201,8 +192,7 @@ static int wim_apply_hardlink_ntfs(const struct dentry *from_dentry,
        *p = '\0';
        dir_name = from_dentry->full_path_utf8;
 
        *p = '\0';
        dir_name = from_dentry->full_path_utf8;
 
-       dir_ni = ntfs_pathname_to_inode(vol, NULL,
-                                       from_dentry->full_path_utf8);
+       dir_ni = ntfs_pathname_to_inode(vol, NULL, dir_name);
        if (!dir_ni) {
                ERROR_WITH_ERRNO("Could not find NTFS inode for `%s'",
                                 from_dentry->full_path_utf8);
        if (!dir_ni) {
                ERROR_WITH_ERRNO("Could not find NTFS inode for `%s'",
                                 from_dentry->full_path_utf8);
@@ -250,7 +240,7 @@ apply_file_attributes_and_security_data(ntfs_inode *ni,
                                SACL_SECURITY_INFORMATION;
                                
                if (!ntfs_inode_set_security(ni, selection,
                                SACL_SECURITY_INFORMATION;
                                
                if (!ntfs_inode_set_security(ni, selection,
-                                            sd->descriptors[dentry->security_id]))
+                                            (const char*)sd->descriptors[dentry->security_id]))
                {
                        ERROR_WITH_ERRNO("Failed to set security data on `%s'",
                                        dentry->full_path_utf8);
                {
                        ERROR_WITH_ERRNO("Failed to set security data on `%s'",
                                        dentry->full_path_utf8);
@@ -284,8 +274,8 @@ static int apply_reparse_data(ntfs_inode *ni, const struct dentry *dentry,
                return WIMLIB_ERR_INVALID_DENTRY;
        }
 
                return WIMLIB_ERR_INVALID_DENTRY;
        }
 
-       char reparse_data_buf[8 + wim_resource_size(lte)];
-       char *p = reparse_data_buf;
+       u8 reparse_data_buf[8 + wim_resource_size(lte)];
+       u8 *p = reparse_data_buf;
        p = put_u32(p, dentry->reparse_tag); /* ReparseTag */
        p = put_u16(p, wim_resource_size(lte)); /* ReparseDataLength */
        p = put_u16(p, 0); /* Reserved */
        p = put_u32(p, dentry->reparse_tag); /* ReparseTag */
        p = put_u16(p, wim_resource_size(lte)); /* ReparseDataLength */
        p = put_u16(p, 0); /* Reserved */
@@ -294,7 +284,7 @@ static int apply_reparse_data(ntfs_inode *ni, const struct dentry *dentry,
        if (ret != 0)
                return ret;
 
        if (ret != 0)
                return ret;
 
-       ret = ntfs_set_ntfs_reparse_data(ni, reparse_data_buf,
+       ret = ntfs_set_ntfs_reparse_data(ni, (char*)reparse_data_buf,
                                         wim_resource_size(lte) + 8, 0);
        if (ret != 0) {
                ERROR_WITH_ERRNO("Failed to set NTFS reparse data on `%s'",
                                         wim_resource_size(lte) + 8, 0);
        if (ret != 0) {
                ERROR_WITH_ERRNO("Failed to set NTFS reparse data on `%s'",
@@ -543,7 +533,6 @@ out_close_dir_ni:
                        ret = WIMLIB_ERR_NTFS_3G;
                ERROR_WITH_ERRNO("Failed to close directory inode");
        }
                        ret = WIMLIB_ERR_NTFS_3G;
                ERROR_WITH_ERRNO("Failed to close directory inode");
        }
-out_close_ni:
        if (ni && ntfs_inode_close(ni) != 0) {
                if (ret == 0)
                        ret = WIMLIB_ERR_NTFS_3G;
        if (ni && ntfs_inode_close(ni) != 0) {
                if (ret == 0)
                        ret = WIMLIB_ERR_NTFS_3G;
@@ -582,10 +571,8 @@ static int wim_apply_dentry_ntfs(struct dentry *dentry, void *arg)
        int extract_flags            = args->extract_flags;
        WIMStruct *w                 = args->w;
        ntfs_inode *dir_ni;
        int extract_flags            = args->extract_flags;
        WIMStruct *w                 = args->w;
        ntfs_inode *dir_ni;
-       int ret;
        char *p;
        char orig;
        char *p;
        char orig;
-       ntfs_inode *close_after_dir;
        const char *dir_name;
 
        if (dentry->extracted_file)
        const char *dir_name;
 
        if (dentry->extracted_file)
@@ -626,10 +613,8 @@ static int wim_apply_dentry_timestamps(struct dentry *dentry, void *arg)
 {
        struct ntfs_apply_args *args = arg;
        ntfs_volume *vol             = args->vol;
 {
        struct ntfs_apply_args *args = arg;
        ntfs_volume *vol             = args->vol;
-       int extract_flags            = args->extract_flags;
-       WIMStruct *w                 = args->w;
-       char *p;
-       char buf[24];
+       u8 *p;
+       u8 buf[24];
        ntfs_inode *ni;
        int ret = 0;
 
        ntfs_inode *ni;
        int ret = 0;
 
@@ -647,7 +632,7 @@ static int wim_apply_dentry_timestamps(struct dentry *dentry, void *arg)
        p = put_u64(p, dentry->creation_time);
        p = put_u64(p, dentry->last_write_time);
        p = put_u64(p, dentry->last_access_time);
        p = put_u64(p, dentry->creation_time);
        p = put_u64(p, dentry->last_write_time);
        p = put_u64(p, dentry->last_access_time);
-       ret = ntfs_inode_set_times(ni, buf, 3 * sizeof(u64), 0);
+       ret = ntfs_inode_set_times(ni, (const char*)buf, 3 * sizeof(u64), 0);
        if (ret != 0) {
                ERROR_WITH_ERRNO("Failed to set NTFS timestamps on `%s'",
                                 dentry->full_path_utf8);
        if (ret != 0) {
                ERROR_WITH_ERRNO("Failed to set NTFS timestamps on `%s'",
                                 dentry->full_path_utf8);
index 9dc0b9d49c683f6bf238c4d69dffa02a5ad92ca5..51434ac09666c7549ca2b8f24db438ec8272b97a 100644 (file)
@@ -121,7 +121,7 @@ static int lookup_sd(const u8 hash[SHA1_HASH_SIZE], struct sd_node *root)
  * the security ID for it.  If a new security descriptor cannot be allocated,
  * return -1.
  */
  * the security ID for it.  If a new security descriptor cannot be allocated,
  * return -1.
  */
-static int sd_set_add_sd(struct sd_set *sd_set, const u8 *descriptor,
+static int sd_set_add_sd(struct sd_set *sd_set, const char descriptor[],
                         size_t size)
 {
        u8 hash[SHA1_HASH_SIZE];
                         size_t size)
 {
        u8 hash[SHA1_HASH_SIZE];
@@ -132,7 +132,7 @@ static int sd_set_add_sd(struct sd_set *sd_set, const u8 *descriptor,
        u8 *descr_copy;
        struct wim_security_data *sd;
 
        u8 *descr_copy;
        struct wim_security_data *sd;
 
-       sha1_buffer(descriptor, size, hash);
+       sha1_buffer((const u8*)descriptor, size, hash);
        security_id = lookup_sd(hash, sd_set->root);
        if (security_id >= 0)
                return security_id;
        security_id = lookup_sd(hash, sd_set->root);
        if (security_id >= 0)
                return security_id;
@@ -242,7 +242,7 @@ static int capture_ntfs_streams(struct dentry *dentry, ntfs_inode *ni,
 
        ntfs_attr_search_ctx *actx;
        u8 attr_hash[SHA1_HASH_SIZE];
 
        ntfs_attr_search_ctx *actx;
        u8 attr_hash[SHA1_HASH_SIZE];
-       struct ntfs_location *ntfs_loc;
+       struct ntfs_location *ntfs_loc = NULL;
        struct lookup_table_entry *lte;
        int ret = 0;
 
        struct lookup_table_entry *lte;
        int ret = 0;
 
@@ -275,8 +275,6 @@ static int capture_ntfs_streams(struct dentry *dentry, ntfs_inode *ni,
                if (lte) {
                        lte->refcnt++;
                } else {
                if (lte) {
                        lte->refcnt++;
                } else {
-                       struct ntfs_location *ntfs_loc;
-
                        ntfs_loc = CALLOC(1, sizeof(*ntfs_loc));
                        if (!ntfs_loc)
                                goto out_put_actx;
                        ntfs_loc = CALLOC(1, sizeof(*ntfs_loc));
                        if (!ntfs_loc)
                                goto out_put_actx;
@@ -317,7 +315,7 @@ static int capture_ntfs_streams(struct dentry *dentry, ntfs_inode *ni,
                        dentry->lte = lte;
                } else {
                        struct ads_entry *new_ads_entry;
                        dentry->lte = lte;
                } else {
                        struct ads_entry *new_ads_entry;
-                       stream_name_utf8 = utf16_to_utf8((const u8*)attr_record_name(actx->attr),
+                       stream_name_utf8 = utf16_to_utf8((const char*)attr_record_name(actx->attr),
                                                         actx->attr->name_length,
                                                         &stream_name_utf16_len);
                        if (!stream_name_utf8)
                                                         actx->attr->name_length,
                                                         &stream_name_utf16_len);
                        if (!stream_name_utf8)
@@ -385,7 +383,7 @@ static int wim_ntfs_capture_filldir(void *dirent, const ntfschar *name,
 
        ret = -1;
 
 
        ret = -1;
 
-       utf8_name = utf16_to_utf8((const u8*)name, name_len * 2,
+       utf8_name = utf16_to_utf8((const char*)name, name_len * 2,
                                  &utf8_name_len);
        if (!utf8_name)
                goto out;
                                  &utf8_name_len);
        if (!utf8_name)
                goto out;
@@ -421,7 +419,6 @@ static int wim_ntfs_capture_filldir(void *dirent, const ntfschar *name,
                      child->file_name_utf8, ctx->parent->file_name_utf8);
                link_dentry(child, ctx->parent);
        }
                      child->file_name_utf8, ctx->parent->file_name_utf8);
                link_dentry(child, ctx->parent);
        }
-out_close_ni:
        ntfs_inode_close(ni);
 out_free_utf8_name:
        FREE(utf8_name);
        ntfs_inode_close(ni);
 out_free_utf8_name:
        FREE(utf8_name);
@@ -511,7 +508,7 @@ static int build_dentry_tree_ntfs_recursive(struct dentry **root_p,
                                      DACL_SECURITY_INFORMATION  |
                                      SACL_SECURITY_INFORMATION,
                                      NULL, 0, &sd_size);
                                      DACL_SECURITY_INFORMATION  |
                                      SACL_SECURITY_INFORMATION,
                                      NULL, 0, &sd_size);
-       u8 sd[sd_size];
+       char sd[sd_size];
        ret = ntfs_inode_get_security(ni,
                                      OWNER_SECURITY_INFORMATION |
                                      GROUP_SECURITY_INFORMATION |
        ret = ntfs_inode_get_security(ni,
                                      OWNER_SECURITY_INFORMATION |
                                      GROUP_SECURITY_INFORMATION |
index aaa0dac403fa2942e1520a2a7c452232718675c4..084cae994cc458c3c7ae3751ff9790fb81cef1ba 100644 (file)
@@ -599,7 +599,6 @@ static int compress_chunk(const u8 chunk[], unsigned chunk_size,
                          unsigned *compressed_chunk_len_ret,
                          int ctype)
 {
                          unsigned *compressed_chunk_len_ret,
                          int ctype)
 {
-       unsigned compressed_chunk_sz;
        int (*compress)(const void *, unsigned, void *, unsigned *);
        switch (ctype) {
        case WIM_COMPRESSION_TYPE_LZX:
        int (*compress)(const void *, unsigned, void *, unsigned *);
        switch (ctype) {
        case WIM_COMPRESSION_TYPE_LZX:
@@ -644,7 +643,6 @@ static int write_wim_resource_chunk(const u8 chunk[], unsigned chunk_size,
        } else {
                u8 *compressed_chunk = alloca(chunk_size);
                int ret;
        } else {
                u8 *compressed_chunk = alloca(chunk_size);
                int ret;
-               unsigned compressed_chunk_len;
 
                ret = compress_chunk(chunk, chunk_size, compressed_chunk,
                                     &out_chunk_size, out_ctype);
 
                ret = compress_chunk(chunk, chunk_size, compressed_chunk,
                                     &out_chunk_size, out_ctype);
@@ -678,7 +676,7 @@ finish_wim_resource_chunk_tab(struct chunk_table *chunk_tab,
 {
        size_t bytes_written;
        if (fseeko(out_fp, chunk_tab->file_offset, SEEK_SET) != 0) {
 {
        size_t bytes_written;
        if (fseeko(out_fp, chunk_tab->file_offset, SEEK_SET) != 0) {
-               ERROR_WITH_ERRNO("Failed to seek to byte "PRIu64" of output "
+               ERROR_WITH_ERRNO("Failed to seek to byte %"PRIu64" of output "
                                 "WIM file", chunk_tab->file_offset);
                return WIMLIB_ERR_WRITE;
        }
                                 "WIM file", chunk_tab->file_offset);
                return WIMLIB_ERR_WRITE;
        }
@@ -772,7 +770,7 @@ static int write_wim_resource(struct lookup_table_entry *lte,
                return 0;
 
        /* Buffer for reading chunks for the resource */
                return 0;
 
        /* Buffer for reading chunks for the resource */
-       char buf[min(WIM_CHUNK_SIZE, bytes_remaining)];
+       u8 buf[min(WIM_CHUNK_SIZE, bytes_remaining)];
 
        /* If we are writing a compressed resource and not doing a raw copy, we
         * need to initialize the chunk table */
 
        /* If we are writing a compressed resource and not doing a raw copy, we
         * need to initialize the chunk table */
@@ -888,7 +886,7 @@ static int write_wim_resource(struct lookup_table_entry *lte,
                /* Oops!  We compressed the resource to larger than the original
                 * size.  Write the resource uncompressed instead. */
                if (fseeko(out_fp, file_offset, SEEK_SET) != 0) {
                /* Oops!  We compressed the resource to larger than the original
                 * size.  Write the resource uncompressed instead. */
                if (fseeko(out_fp, file_offset, SEEK_SET) != 0) {
-                       ERROR_WITH_ERRNO("Failed to seek to byte "PRIu64" "
+                       ERROR_WITH_ERRNO("Failed to seek to byte %"PRIu64" "
                                         "of output WIM file", file_offset);
                        ret = WIMLIB_ERR_WRITE;
                        goto out_fclose;
                                         "of output WIM file", file_offset);
                        ret = WIMLIB_ERR_WRITE;
                        goto out_fclose;
@@ -973,7 +971,7 @@ int extract_wim_resource_to_fd(const struct lookup_table_entry *lte, int fd,
                               u64 size)
 {
        u64 bytes_remaining = size;
                               u64 size)
 {
        u64 bytes_remaining = size;
-       char buf[min(WIM_CHUNK_SIZE, bytes_remaining)];
+       u8 buf[min(WIM_CHUNK_SIZE, bytes_remaining)];
        u64 offset = 0;
        int ret = 0;
        u8 hash[SHA1_HASH_SIZE];
        u64 offset = 0;
        int ret = 0;
        u8 hash[SHA1_HASH_SIZE];
@@ -1099,7 +1097,6 @@ int write_dentry_resources(struct dentry *dentry, void *wim_p)
 int read_metadata_resource(WIMStruct *w, struct image_metadata *imd)
 {
        u8 *buf;
 int read_metadata_resource(WIMStruct *w, struct image_metadata *imd)
 {
        u8 *buf;
-       int ctype;
        u32 dentry_offset;
        int ret;
        struct dentry *dentry;
        u32 dentry_offset;
        int ret;
        struct dentry *dentry;
@@ -1120,7 +1117,7 @@ int read_metadata_resource(WIMStruct *w, struct image_metadata *imd)
         * no security descriptors) and WIM_DENTRY_DISK_SIZE is for the root
         * dentry. */
        if (metadata_len < 8 + WIM_DENTRY_DISK_SIZE) {
         * no security descriptors) and WIM_DENTRY_DISK_SIZE is for the root
         * dentry. */
        if (metadata_len < 8 + WIM_DENTRY_DISK_SIZE) {
-               ERROR("Expected at least %zu bytes for the metadata resource",
+               ERROR("Expected at least %u bytes for the metadata resource",
                      8 + WIM_DENTRY_DISK_SIZE);
                return WIMLIB_ERR_INVALID_RESOURCE_SIZE;
        }
                      8 + WIM_DENTRY_DISK_SIZE);
                return WIMLIB_ERR_INVALID_RESOURCE_SIZE;
        }
@@ -1235,7 +1232,7 @@ int write_metadata_resource(WIMStruct *w)
        int ret;
        u64 subdir_offset;
        struct dentry *root;
        int ret;
        u64 subdir_offset;
        struct dentry *root;
-       struct lookup_table_entry *lte, *duplicate_lte;
+       struct lookup_table_entry *lte;
        u64 metadata_original_size;
        const struct wim_security_data *sd;
        const unsigned random_tail_len = 20;
        u64 metadata_original_size;
        const struct wim_security_data *sd;
        const unsigned random_tail_len = 20;
index 2e83d0e966199aa44b3a14606ee9e38b781cb9c9..8fda950c6261f26e99832723921ff0272e969cd3 100644 (file)
@@ -61,7 +61,7 @@ int read_security_data(const u8 metadata_resource[], u64 metadata_resource_len,
 
        p = metadata_resource;
        p = get_u32(p, &sd->total_length);
 
        p = metadata_resource;
        p = get_u32(p, &sd->total_length);
-       p = get_u32(p, &sd->num_entries);
+       p = get_u32(p, (u32*)&sd->num_entries);
 
        if (sd->num_entries > 0x7fffffff) {
                ERROR("Security data has too many entries!");
 
        if (sd->num_entries > 0x7fffffff) {
                ERROR("Security data has too many entries!");
index e153f5338335b92e31ae181b11180bd9e14379d1..a0d633569e31bd221576d3cd226e126474650ce8 100644 (file)
@@ -46,7 +46,7 @@ static inline bool is_zero_hash(const u8 hash[SHA1_HASH_SIZE])
        return true;
 }
 
        return true;
 }
 
-static void zero_hash(u8 hash[SHA1_HASH_SIZE])
+static inline void zero_hash(u8 hash[SHA1_HASH_SIZE])
 {
        memset(hash, 0, SHA1_HASH_SIZE);
 }
 {
        memset(hash, 0, SHA1_HASH_SIZE);
 }
index 3773fb053012f63db8dee41ed0460fcfb9098895..60f5ebb601cbd57758ae4678311349623f565c57 100644 (file)
@@ -80,7 +80,7 @@ static ssize_t get_symlink_name(const u8 *resource, size_t resource_len,
        }
        if (header_size + substitute_name_offset + substitute_name_len > resource_len)
                return -EIO;
        }
        if (header_size + substitute_name_offset + substitute_name_len > resource_len)
                return -EIO;
-       link_target = utf16_to_utf8(p + substitute_name_offset,
+       link_target = utf16_to_utf8((const char *)p + substitute_name_offset,
                                    substitute_name_len,
                                    &link_target_len);
 
                                    substitute_name_len,
                                    &link_target_len);
 
@@ -135,20 +135,22 @@ void *make_symlink_reparse_data_buf(const char *symlink_target, size_t *len_ret)
        for (size_t i = 0; i < utf16_len / 2; i++)
                if (((u16*)name_utf16)[i] == to_le16('/'))
                        ((u16*)name_utf16)[i] = to_le16('\\');
        for (size_t i = 0; i < utf16_len / 2; i++)
                if (((u16*)name_utf16)[i] == to_le16('/'))
                        ((u16*)name_utf16)[i] = to_le16('\\');
-       size_t len = 12 + utf16_len * 2;
+       size_t len = 12 + utf16_len * 2 + 4;
        void *buf = MALLOC(len);
        if (!buf)
                goto out;
        /* XXX Fix absolute paths */
 
        u8 *p = buf;
        void *buf = MALLOC(len);
        if (!buf)
                goto out;
        /* XXX Fix absolute paths */
 
        u8 *p = buf;
-       p = put_u16(p, utf16_len); /* Substitute name offset */
+       p = put_u16(p, utf16_len + 2); /* Substitute name offset */
        p = put_u16(p, utf16_len); /* Substitute name length */
        p = put_u16(p, 0); /* Print name offset */
        p = put_u16(p, utf16_len); /* Print name length */
        p = put_u32(p, 1);
        p = put_u16(p, utf16_len); /* Substitute name length */
        p = put_u16(p, 0); /* Print name offset */
        p = put_u16(p, utf16_len); /* Print name length */
        p = put_u32(p, 1);
-       p = put_bytes(p, utf16_len, name_utf16);
-       p = put_bytes(p, utf16_len, name_utf16);
+       p = put_bytes(p, utf16_len, (const u8*)name_utf16);
+       p = put_u16(p, 0);
+       p = put_bytes(p, utf16_len, (const u8*)name_utf16);
+       p = put_u16(p, 0);
        /*DEBUG("utf16_len = %zu, len = %zu", utf16_len, len);*/
        *len_ret = len;
 out:
        /*DEBUG("utf16_len = %zu, len = %zu", utf16_len, len);*/
        *len_ret = len;
 out:
@@ -175,7 +177,7 @@ ssize_t dentry_readlink(const struct dentry *dentry, char *buf, size_t buf_len,
        if (wim_resource_size(lte) > 10000)
                return -EIO;
 
        if (wim_resource_size(lte) > 10000)
                return -EIO;
 
-       char res_buf[wim_resource_size(lte)];
+       u8 res_buf[wim_resource_size(lte)];
        ret = read_full_wim_resource(lte, res_buf);
        if (ret != 0)
                return -EIO;
        ret = read_full_wim_resource(lte, res_buf);
        if (ret != 0)
                return -EIO;
index 943fb8340020c801084ebda14d8b9c7a60838dd6..d7302e1b012794b9ffe09ab8e8f6aa6b30c97354 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -819,8 +819,6 @@ static int clone_windows_info(const struct windows_info *old,
 
 static int clone_image_info(const struct image_info *old, struct image_info *new)
 {
 
 static int clone_image_info(const struct image_info *old, struct image_info *new)
 {
-       int ret;
-
        new->dir_count              = old->dir_count;
        new->file_count             = old->file_count;
        new->total_bytes            = old->total_bytes;
        new->dir_count              = old->dir_count;
        new->file_count             = old->file_count;
        new->total_bytes            = old->total_bytes;
@@ -869,8 +867,6 @@ int xml_export_image(const struct wim_info *old_wim_info,
        struct wim_info *new_wim_info;
        struct image_info *image_info;
        int ret;
        struct wim_info *new_wim_info;
        struct image_info *image_info;
        int ret;
-       char *name;
-       char *desc;
 
        DEBUG("Copying XML data between WIM files for source image %d.", image);
 
 
        DEBUG("Copying XML data between WIM files for source image %d.", image);
 
index f1f2154ad70ed2d81a584d69820271b6fac3839b..faae7d4b40fd890d889ceb01b1bdff66d9d0f318 100755 (executable)
@@ -19,6 +19,8 @@ cleanup() {
        rm -rf dir* tmp* *.wim *.swm
 }
 trap cleanup exit
        rm -rf dir* tmp* *.wim *.swm
 }
 trap cleanup exit
+fusermount -u tmp || true
+rm -rf tmp || true
 
 # Make test directory
 mkdir dir
 
 # Make test directory
 mkdir dir