From f1f88d4473af8a7a3500c55053bd56c6ecfc873f Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Fri, 1 Jun 2012 11:21:32 +0200 Subject: [PATCH] Fix bug #1874 crash with xattr support on a BTRFS filesystem Add some extra safeguards that structure are always initialized the way we think they should be and a special code path doesn't give freeing failures on non allocated memory. --- bacula/src/filed/xattr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index 40a5127d9a..b6884ea49b 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -448,6 +448,7 @@ static bxattr_exit_code aix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) * Each xattr valuepair starts with a magic so we can parse it easier. */ current_xattr = (xattr_t *)malloc(sizeof(xattr_t)); + memset(current_xattr, 0, sizeof(xattr_t)); current_xattr->magic = XATTR_MAGIC; expected_serialize_len += sizeof(current_xattr->magic); @@ -739,6 +740,7 @@ static bxattr_exit_code irix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) * Each xattr valuepair starts with a magic so we can parse it easier. */ current_xattr = (xattr_t *)malloc(sizeof(xattr_t)); + memset(current_xattr, 0, sizeof(xattr_t)); current_xattr->magic = XATTR_MAGIC; expected_serialize_len += sizeof(current_xattr->magic); @@ -1197,6 +1199,7 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) * Each xattr valuepair starts with a magic so we can parse it easier. */ current_xattr = (xattr_t *)malloc(sizeof(xattr_t)); + memset(current_xattr, 0, sizeof(xattr_t)); current_xattr->magic = XATTR_MAGIC; expected_serialize_len += sizeof(current_xattr->magic); @@ -1655,6 +1658,7 @@ static bxattr_exit_code bsd_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) * Each xattr valuepair starts with a magic so we can parse it easier. */ current_xattr = (xattr_t *)malloc(sizeof(xattr_t)); + memset(current_xattr, 0, sizeof(xattr_t)); current_xattr->magic = XATTR_MAGIC; expected_serialize_len += sizeof(current_xattr->magic); @@ -2082,6 +2086,7 @@ static bxattr_exit_code tru64_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) * Each xattr valuepair starts with a magic so we can parse it easier. */ current_xattr = (xattr_t *)malloc(sizeof(xattr_t)); + memset(current_xattr, 0, sizeof(xattr_t)); current_xattr->magic = XATTR_MAGIC; expected_serialize_len += sizeof(current_xattr->magic); -- 2.39.5