]> wimlib.net Git - wimlib/blobdiff - src/mount_image.c
rebuild_wim(): Fix use of freed memory
[wimlib] / src / mount_image.c
index 905157c08101e111cfe78d6cc0fcfe7f05f60689..28a807d7afdfd7d26537a57a97d99e5203564841 100644 (file)
@@ -802,7 +802,7 @@ static int rebuild_wim(struct wimfs_context *ctx, int write_flags,
        }
 
        DEBUG("Calculating SHA1 checksums for all new staging files.");
-       list_for_each_entry(lte, &ctx->staging_list, staging_list) {
+       list_for_each_entry_safe(lte, tmp, &ctx->staging_list, staging_list) {
                ret = update_lte_of_staging_file(lte, w->lookup_table);
                if (ret != 0)
                        return ret;
@@ -1613,15 +1613,13 @@ static int wimfs_link(const char *to, const char *from)
        if (!inode)
                return -errno;
 
-       if (inode->i_attributes & FILE_ATTRIBUTE_REPARSE_POINT)
-               return -EEXIST;
-
-       if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY)
+       if (inode->i_attributes & (FILE_ATTRIBUTE_DIRECTORY |
+                                  FILE_ATTRIBUTE_REPARSE_POINT))
                return -EPERM;
 
        from_dentry_parent = get_parent_dentry(w, from);
        if (!from_dentry_parent)
-               return -ENOENT;
+               return -errno;
        if (!dentry_is_directory(from_dentry_parent))
                return -ENOTDIR;
 
@@ -1779,7 +1777,7 @@ static int wimfs_open(const char *path, struct fuse_file_info *fi)
        }
 
        ret = alloc_wimfs_fd(inode, stream_id, lte, &fd,
-                             wimfs_ctx_readonly(ctx));
+                            wimfs_ctx_readonly(ctx));
        if (ret != 0)
                return ret;
 
@@ -2002,7 +2000,7 @@ static int wimfs_rename(const char *from, const char *to)
                        return -ENOTDIR;
        }
 
-       ret = set_dentry_name(src, to);
+       ret = set_dentry_name(src, path_basename(to));
        if (ret != 0)
                return -ENOMEM;
        if (dst)