diff options
author | Justus Winter <justus@gnupg.org> | 2016-10-03 18:12:17 +0200 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2016-11-10 15:31:02 +0100 |
commit | 329fa96fee612114d4df81b44589edc524c604a8 (patch) | |
tree | a42c679d331f2d636dbb326977d5293108944f47 | |
parent | c37320e7570232b6fd4a6d3486cd898deebb0920 (diff) |
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.
-rw-r--r-- | ext2fs/xattr.c | 8 |
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 */ |