From: Eric Biggers Date: Tue, 5 Mar 2013 22:14:06 +0000 (-0600) Subject: wimfs_setxattr(): Only remove existing xattr if successful X-Git-Tag: v1.2.6~1 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=84eaa0aba56c9cf668ca5f3ac8225078ab7dd459;ds=sidebyside wimfs_setxattr(): Only remove existing xattr if successful --- diff --git a/src/mount_image.c b/src/mount_image.c index ca490688..b9e900bc 100644 --- a/src/mount_image.c +++ b/src/mount_image.c @@ -2115,7 +2115,6 @@ static int wimfs_setxattr(const char *path, const char *name, 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; @@ -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); - 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