From 329fa96fee612114d4df81b44589edc524c604a8 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 3 Oct 2016 18:12:17 +0200 Subject: 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. --- ext2fs/xattr.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 */ -- cgit v1.2.3