diff --git a/src/findlib/bfile.c b/src/findlib/bfile.c index bdde2c9848c..e4a43de7640 100644 --- a/src/findlib/bfile.c +++ b/src/findlib/bfile.c @@ -1173,6 +1173,10 @@ int bclose(BFILE *bfd) { int status; + if (bfd->fid == -1) { + return 0; + } + Dmsg1(400, "Close file %d\n", bfd->fid); if (bfd->cmd_plugin && plugin_bclose) { @@ -1180,9 +1184,6 @@ int bclose(BFILE *bfd) bfd->fid = -1; bfd->cmd_plugin = false; } else { - if (bfd->fid == -1) { - return 0; - } #if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED) if (bfd->m_flags & O_RDONLY) { fdatasync(bfd->fid); /* sync the file */ diff --git a/src/findlib/xattr.c b/src/findlib/xattr.c index 1912dbf0a22..2623d05c1d4 100644 --- a/src/findlib/xattr.c +++ b/src/findlib/xattr.c @@ -206,7 +206,7 @@ uint32_t serialize_xattr_stream(JCR *jcr, ser_bytes(current_xattr->value, current_xattr->value_length); Dmsg3(100, "Backup xattr named %s, value %*s\n", - current_xattr->name, current_xattr->value, current_xattr->value); + current_xattr->name, current_xattr->value_length, current_xattr->value); } else { Dmsg1(100, "Backup empty xattr named %s\n", current_xattr->name); } diff --git a/src/plugins/filed/cephfs-fd.c b/src/plugins/filed/cephfs-fd.c index 7eecee7fbcc..05e8e83d7a8 100644 --- a/src/plugins/filed/cephfs-fd.c +++ b/src/plugins/filed/cephfs-fd.c @@ -1678,6 +1678,11 @@ static bRC getXattr(bpContext *ctx, xattr_pkt *xp) Jmsg(ctx, M_ERROR, "ceph_llistxattr(%s) failed: %s\n", xp->fname, be.bstrerror(-status)); return bRC_Error; } + } else if (status == 0) { + /* + * Nothing to do. + */ + return bRC_OK; } /* @@ -1686,6 +1691,16 @@ static bRC getXattr(bpContext *ctx, xattr_pkt *xp) break; } + /* + * Data from llistxattr is in the following form: + * + * user.name1\0system.name1\0user.name2\0 + * + * We add an extra \0 at the end so we have an unique terminator + * to know when we hit the end of the list. + */ + p_ctx->xattr_list = check_pool_memory_size(p_ctx->xattr_list, status + 1); + p_ctx->xattr_list[status] = '\0'; p_ctx->next_xattr_name = p_ctx->xattr_list; p_ctx->processing_xattr = true; } @@ -1769,16 +1784,19 @@ static bRC getXattr(bpContext *ctx, xattr_pkt *xp) * See if there are more xattr to process. */ bp = strchr(p_ctx->next_xattr_name, '\0'); - if (++bp != '\0') { - p_ctx->next_xattr_name = bp; - return bRC_More; - } else { - /* - * No more reset processing_xattr flag. - */ - p_ctx->processing_xattr = false; - return bRC_OK; + if (bp) { + bp++; + if (*bp != '\0') { + p_ctx->next_xattr_name = bp; + return bRC_More; + } } + + /* + * No more reset processing_xattr flag. + */ + p_ctx->processing_xattr = false; + return bRC_OK; } static bRC setXattr(bpContext *ctx, xattr_pkt *xp) diff --git a/src/plugins/filed/gfapi-fd.c b/src/plugins/filed/gfapi-fd.c index 42ba64a3f72..7d81ed5b376 100644 --- a/src/plugins/filed/gfapi-fd.c +++ b/src/plugins/filed/gfapi-fd.c @@ -1908,6 +1908,11 @@ static bRC getXattr(bpContext *ctx, xattr_pkt *xp) Jmsg(ctx, M_ERROR, "glfs_llistxattr(%s) failed: %s\n", xp->fname, be.bstrerror()); return bRC_Error; } + } else if (status == 0) { + /* + * Nothing to do. + */ + return bRC_OK; } /* @@ -1916,6 +1921,16 @@ static bRC getXattr(bpContext *ctx, xattr_pkt *xp) break; } + /* + * Data from llistxattr is in the following form: + * + * user.name1\0system.name1\0user.name2\0 + * + * We add an extra \0 at the end so we have an unique terminator + * to know when we hit the end of the list. + */ + p_ctx->xattr_list = check_pool_memory_size(p_ctx->xattr_list, status + 1); + p_ctx->xattr_list[status] = '\0'; p_ctx->next_xattr_name = p_ctx->xattr_list; p_ctx->processing_xattr = true; } @@ -2000,16 +2015,19 @@ static bRC getXattr(bpContext *ctx, xattr_pkt *xp) * See if there are more xattr to process. */ bp = strchr(p_ctx->next_xattr_name, '\0'); - if (++bp != '\0') { - p_ctx->next_xattr_name = bp; - return bRC_More; - } else { - /* - * No more reset processing_xattr flag. - */ - p_ctx->processing_xattr = false; - return bRC_OK; + if (bp) { + bp++; + if (*bp != '\0') { + p_ctx->next_xattr_name = bp; + return bRC_More; + } } + + /* + * No more reset processing_xattr flag. + */ + p_ctx->processing_xattr = false; + return bRC_OK; } static bRC setXattr(bpContext *ctx, xattr_pkt *xp)