From 9a219163fe484d104f529293b9e82430d4371b66 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 19 Jul 2010 07:48:06 +0200 Subject: [PATCH] Add xattr seg fault protection suggested by Marco for bug #1610 --- bacula/src/filed/xattr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index 97e5c5c208..a3e9410ffa 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -388,6 +388,7 @@ static bxattr_exit_code linux_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) */ bp = xattr_list; while ((bp - xattr_list) + 1 < xattr_list_len) { + int name_len; skip_xattr = false; /* @@ -416,7 +417,8 @@ static bxattr_exit_code linux_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) } } - if (skip_xattr) { + name_len = strlen(bp); + if (skip_xattr || name_len == 0) { bp = strchr(bp, '\0') + 1; continue; } @@ -431,7 +433,7 @@ static bxattr_exit_code linux_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) /* * Allocate space for storing the name. */ - current_xattr->name_length = strlen(bp); + current_xattr->name_length = name_len; current_xattr->name = (char *)malloc(current_xattr->name_length); memcpy((caddr_t)current_xattr->name, (caddr_t)bp, current_xattr->name_length); -- 2.39.5