X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Ffiled%2Fxattr.c;h=fe43b042339d89f9ea09da8028b16b3fdd43e32c;hb=44c8fb4a8bd89c42465453970929d5fb2a2538de;hp=88e33a5a76bc1f1e7a29e2722370e00ede29be5e;hpb=e487b7a1633c7815701042616b794f784a899bc5;p=bacula%2Fbacula diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index 88e33a5a76..fe43b04233 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -84,6 +84,12 @@ static bool send_xattr_stream(JCR *jcr, int stream) return true; #endif + /* + * Sanity check + */ + if (jcr->xattr_data_len <= 0) + return true; + /* * Send header */ @@ -259,6 +265,7 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) jcr->last_fname, be.bstrerror()); Dmsg2(100, "llistxattr error file=%s ERR=%s\n", jcr->last_fname, be.bstrerror()); + return false; } else if (xattr_list_len == 0) { return true; @@ -286,6 +293,7 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) jcr->last_fname, be.bstrerror()); free(xattr_list); + return false; } xattr_list[xattr_list_len] = '\0'; @@ -295,11 +303,24 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) */ bp = xattr_list; while ((bp - xattr_list) + 1 < xattr_list_len) { +#if defined(HAVE_LINUX_OS) + /* + * On Linux you also get the acls in the extented attribute list. + * So we check if we are already backing up acls and if we do we + * don't store the extended attribute with the same info. + */ + if ((ff_pkt->flags & FO_ACL) == 0 || strcmp(bp, "system.posix_acl_access")) + count++; +#else count++; +#endif bp = strchr(bp, '\0') + 1; } + if (count == 0) + return true; + /* * Allocate enough room to hold all extended attributes. * After allocating the storage make sure its empty by zeroing it. @@ -319,11 +340,6 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) bp = xattr_list; while ((bp - xattr_list) + 1 < xattr_list_len) { #if defined(HAVE_LINUX_OS) - /* - * On Linux you also get the acls in the extented attribute list. - * So we check if we are already backing up acls and if we do we - * don't store the extended attribute with the same info. - */ if (ff_pkt->flags & FO_ACL && !strcmp(bp, "system.posix_acl_access")) { bp = strchr(bp, '\0') + 1;