]> wimlib.net Git - wimlib/commitdiff
wimfs_setxattr(): Only remove existing xattr if successful
authorEric Biggers <ebiggers3@gmail.com>
Tue, 5 Mar 2013 22:14:06 +0000 (16:14 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 5 Mar 2013 22:14:06 +0000 (16:14 -0600)
src/mount_image.c

index ca490688658e867273720b021750a02b8af61527..b9e900bca93ee5f2dace39df29306e97421913ab 100644 (file)
@@ -2115,7 +2115,6 @@ static int wimfs_setxattr(const char *path, const char *name,
        if (existing_ads_entry) {
                if (flags & XATTR_CREATE)
                        return -EEXIST;
        if (existing_ads_entry) {
                if (flags & XATTR_CREATE)
                        return -EEXIST;
-               inode_remove_ads(inode, ads_idx, ctx->wim->lookup_table);
        } else {
                if (flags & XATTR_REPLACE)
                        return -ENOATTR;
        } else {
                if (flags & XATTR_REPLACE)
                        return -ENOATTR;
@@ -2123,7 +2122,13 @@ static int wimfs_setxattr(const char *path, const char *name,
 
        ret = inode_add_ads_with_data(inode, name, (const u8*)value,
                                      size, ctx->wim->lookup_table);
 
        ret = inode_add_ads_with_data(inode, name, (const u8*)value,
                                      size, ctx->wim->lookup_table);
-       return ret ? -ENOMEM : 0;
+       if (ret == 0) {
+               if (existing_ads_entry)
+                       inode_remove_ads(inode, ads_idx, ctx->wim->lookup_table);
+       } else {
+               ret = -ENOMEM;
+       }
+       return ret;
 }
 #endif
 
 }
 #endif