From: Shachar Sharon Date: Wed, 22 May 2024 13:28:32 +0000 (+0300) Subject: vfs_ceph: use talloc in realpath hook X-Git-Tag: tdb-1.4.11~288 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=0bc917b01fcf3b6a22b60c1bb57b379b1374a216;p=thirdparty%2Fsamba.git vfs_ceph: use talloc in realpath hook Prefer talloc_asprintf over asprintf when resolving realpath. Re-format code using 'git clang-format'. Signed-off-by: Shachar Sharon Reviewed-by: Andrew Bartlett Reviewed-by: David Disseldorp Reviewed-by: Ralph Boehme Reviewed-by: Guenther Deschner Reviewed-by: Anoop C S --- diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 6c96d27dccc..c81a7d2d99c 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -1513,27 +1513,26 @@ static struct smb_filename *cephwrap_realpath(struct vfs_handle_struct *handle, const char *path = smb_fname->base_name; size_t len = strlen(path); struct smb_filename *result_fname = NULL; - int r = -1; - if (len && (path[0] == '/')) { - r = asprintf(&result, "%s", path); + if (path[0] == '/') { + result = talloc_strdup(ctx, path); } else if ((len >= 2) && (path[0] == '.') && (path[1] == '/')) { if (len == 2) { - r = asprintf(&result, "%s", cwd); + result = talloc_strdup(ctx, cwd); } else { - r = asprintf(&result, "%s/%s", cwd, &path[2]); + result = talloc_asprintf(ctx, "%s/%s", cwd, &path[2]); } } else { - r = asprintf(&result, "%s/%s", cwd, path); + result = talloc_asprintf(ctx, "%s/%s", cwd, path); } - if (r < 0) { + if (result == NULL) { return NULL; } DBG_DEBUG("[CEPH] realpath(%p, %s) = %s\n", handle, path, result); result_fname = synthetic_smb_fname(ctx, result, NULL, NULL, 0, 0); - SAFE_FREE(result); + TALLOC_FREE(result); return result_fname; }