From 524c67fec10d1f053ba1ee40a3d2e3f621d59698 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Sun, 7 Oct 2012 21:32:18 +0200 Subject: [PATCH] fix #1938 about PATH_MAX on hurd --- bacula/src/filed/xattr.c | 25 ++++++++++++++++++++----- bacula/src/filed/xattr.h | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index b1a0840777..faf86d578c 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -2430,7 +2430,7 @@ static int os_default_xattr_streams[1] = { * This code creates a temporary cache with entries for each xattr which has * a link count > 1 (which indicates it has one or more hard linked counterpart(s)) */ -static xattr_link_cache_entry_t *find_xattr_link_cache_entry(JCR *jcr, ino_t inum) +static inline xattr_link_cache_entry_t *find_xattr_link_cache_entry(JCR *jcr, ino_t inum) { xattr_link_cache_entry_t *ptr; @@ -2442,14 +2442,14 @@ static xattr_link_cache_entry_t *find_xattr_link_cache_entry(JCR *jcr, ino_t inu return NULL; } -static void add_xattr_link_cache_entry(JCR *jcr, ino_t inum, char *target) +static inline void add_xattr_link_cache_entry(JCR *jcr, ino_t inum, char *target) { xattr_link_cache_entry_t *ptr; ptr = (xattr_link_cache_entry_t *)malloc(sizeof(xattr_link_cache_entry_t)); memset(ptr, 0, sizeof(xattr_link_cache_entry_t)); ptr->inum = inum; - bstrncpy(ptr->target, target, sizeof(ptr->target)); + ptr->target = bstrdup(target); if (!jcr->xattr_data->u.build->link_cache) { jcr->xattr_data->u.build->link_cache = New(alist(10, not_owned_by_alist)); @@ -2457,6 +2457,22 @@ static void add_xattr_link_cache_entry(JCR *jcr, ino_t inum, char *target) jcr->xattr_data->u.build->link_cache->append(ptr); } +static inline void drop_xattr_link_cache(JCR *jcr) +{ + xattr_link_cache_entry_t *ptr; + + /* + * Walk the list of xattr link cache entries and free allocated memory on traversing. + */ + foreach_alist(ptr, jcr->xattr_data->u.build->link_cache) { + free(ptr->target); + free(ptr); + } + + delete jcr->xattr_data->u.build->link_cache; + jcr->xattr_data->u.build->link_cache = NULL; +} + #if defined(HAVE_SYS_NVPAIR_H) && defined(_PC_SATTR_ENABLED) /* * This function returns true if a non default extended system attribute @@ -3680,8 +3696,7 @@ static bxattr_exit_code solaris_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) retval = solaris_save_xattrs(jcr, NULL, NULL); chdir(cwd); if (jcr->xattr_data->u.build->link_cache) { - delete jcr->xattr_data->u.build->link_cache; - jcr->xattr_data->u.build->link_cache = NULL; + drop_xattr_link_cache(jcr); } } return retval; diff --git a/bacula/src/filed/xattr.h b/bacula/src/filed/xattr.h index d54b9124fe..cb1c68e451 100644 --- a/bacula/src/filed/xattr.h +++ b/bacula/src/filed/xattr.h @@ -57,7 +57,7 @@ struct xattr_t { */ struct xattr_link_cache_entry_t { uint32_t inum; - char target[PATH_MAX]; + char *target; }; #define BXATTR_FLAG_SAVE_NATIVE 0x01 -- 2.39.5