From: Volker Lendecke Date: Mon, 9 Dec 2024 07:09:53 +0000 (+0100) Subject: vfs: Simplify stream_dir() X-Git-Tag: tdb-1.4.13~279 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0dfaa08ce3807c1dae324dff4312d79e8eb40539;p=thirdparty%2Fsamba.git vfs: Simplify stream_dir() We know in advance how large "id_hex" is. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 1cd703ca60e..1c909512950 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -158,10 +158,10 @@ static char *stream_dir(vfs_handle_struct *handle, SMB_STRUCT_STAT base_sbuf_tmp; char *tmp = NULL; uint8_t first, second; - char *id_hex; struct file_id id; uint8_t id_buf[16]; bool check_valid; + char id_hex[sizeof(id_buf) * 2 + 1]; char *rootdir = NULL; struct smb_filename *rootdir_fname = NULL; struct smb_filename *tmp_fname = NULL; @@ -223,18 +223,11 @@ static char *stream_dir(vfs_handle_struct *handle, first = hash & 0xff; second = (hash >> 8) & 0xff; - id_hex = hex_encode_talloc(talloc_tos(), id_buf, sizeof(id_buf)); - - if (id_hex == NULL) { - errno = ENOMEM; - goto fail; - } + hex_encode_buf(id_hex, id_buf, sizeof(id_buf)); result = talloc_asprintf(talloc_tos(), "%s/%2.2X/%2.2X/%s", rootdir, first, second, id_hex); - TALLOC_FREE(id_hex); - if (result == NULL) { errno = ENOMEM; return NULL;