aboutsummaryrefslogtreecommitdiff
path: root/ext2fs
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-10-03 18:12:17 +0200
committerRichard Braun <rbraun@sceen.net>2017-01-06 20:36:09 +0100
commit08336418301f68c87e29e3735aa83cee1bc3c9b7 (patch)
tree9e5b38bd36a3d41de56b8899dd93dd68c651f001 /ext2fs
parent76266d8cd0db429093e144a67ef66a0a6532c799 (diff)
downloadhurd-08336418301f68c87e29e3735aa83cee1bc3c9b7.tar.gz
hurd-08336418301f68c87e29e3735aa83cee1bc3c9b7.tar.bz2
hurd-08336418301f68c87e29e3735aa83cee1bc3c9b7.zip
ext2fs: Fix block leak in xattr code.
* ext2fs/xattr.c (ext2_set_xattr): Avoid allocating and leaking a block if the caller tries to delete an extended attribute from a node that has no extended attribute in the first place.
Diffstat (limited to 'ext2fs')
-rw-r--r--ext2fs/xattr.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext2fs/xattr.c b/ext2fs/xattr.c
index 4592d5e4..41e8c89c 100644
--- a/ext2fs/xattr.c
+++ b/ext2fs/xattr.c
@@ -686,6 +686,14 @@ ext2_set_xattr (struct node *np, const char *name, const char *value,
ei = dino_ref (np->cache_id);
blkno = ei->i_file_acl;
+ /* Avoid allocating a block if this is a request to delete data. */
+ if (blkno == 0 && value == NULL)
+ {
+ block = NULL;
+ err = ENODATA;
+ goto cleanup;
+ }
+
if (blkno == 0)
{
/* Allocate and initialize new block */