From: Kern Sibbald Date: Mon, 19 Jul 2010 05:48:06 +0000 (+0200) Subject: Add xattr seg fault protection suggested by Marco for bug #1610 X-Git-Tag: Release-7.0.0~1675 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9a219163fe484d104f529293b9e82430d4371b66;p=bacula%2Fbacula Add xattr seg fault protection suggested by Marco for bug #1610 --- 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);