1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-02 00:22:11 +03:00

vfs_ceph_snapshots: fix root relative path handling

For file paths relative to root, ceph_snap_get_parent_path() may return
an empty parent dir string, in which case the CephFS snashot path should
be ".snap".

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14216

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
David Disseldorp
2019-12-12 22:14:50 +01:00
committed by Jeremy Allison
parent fca2d3e0d1
commit 54293f92cd

View File

@ -390,8 +390,12 @@ static int ceph_snap_get_shadow_copy_data(struct vfs_handle_struct *handle,
parent_dir = tmp;
}
ret = snprintf(snaps_path, sizeof(snaps_path), "%s/%s",
parent_dir, snapdir);
if (strlen(parent_dir) == 0) {
ret = strlcpy(snaps_path, snapdir, sizeof(snaps_path));
} else {
ret = snprintf(snaps_path, sizeof(snaps_path), "%s/%s",
parent_dir, snapdir);
}
if (ret >= sizeof(snaps_path)) {
ret = -EINVAL;
goto err_out;
@ -534,7 +538,11 @@ static int ceph_snap_gmt_convert_dir(struct vfs_handle_struct *handle,
/*
* Temporally use the caller's return buffer for this.
*/
ret = snprintf(_converted_buf, buflen, "%s/%s", name, snapdir);
if (strlen(name) == 0) {
ret = strlcpy(_converted_buf, snapdir, buflen);
} else {
ret = snprintf(_converted_buf, buflen, "%s/%s", name, snapdir);
}
if (ret >= buflen) {
ret = -EINVAL;
goto err_out;