From 84eaa0aba56c9cf668ca5f3ac8225078ab7dd459 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 5 Mar 2013 16:14:06 -0600 Subject: [PATCH] wimfs_setxattr(): Only remove existing xattr if successful --- src/mount_image.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 -- 2.43.0