]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs: Simplify stream_dir()
authorVolker Lendecke <vl@samba.org>
Mon, 9 Dec 2024 07:09:53 +0000 (08:09 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 18 Dec 2024 08:25:34 +0000 (08:25 +0000)
We know in advance how large "id_hex" is.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_streams_depot.c

index 1cd703ca60e2ad3fb33b9258e27817beaf1b229c..1c909512950f7bd2cde70e048320d7aaddaef211 100644 (file)
@@ -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;