libsmb: Simplify cli_smb2_ftruncate
authorVolker Lendecke <vl@samba.org>
Sun, 17 Mar 2019 11:24:05 +0000 (12:24 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 20 Mar 2019 22:07:45 +0000 (22:07 +0000)
We don't need to talloc 8 bytes, they can live on the stack. When we
go async, this can go into the state struct.

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

index 4a6f285567cebd5df0aa859eb0c3ddd09c2e8c31..1bcb764fb904281badea604cf71a1ef2f35f033a 100644 (file)
@@ -4847,7 +4847,8 @@ NTSTATUS cli_smb2_ftruncate(struct cli_state *cli,
                        uint64_t newsize)
 {
        NTSTATUS status;
-       DATA_BLOB inbuf = data_blob_null;
+       uint8_t buf[8] = {0};
+       DATA_BLOB inbuf = { .data = buf, .length = sizeof(buf) };
        struct smb2_hnd *ph = NULL;
        TALLOC_CTX *frame = talloc_stackframe();
 
@@ -4871,13 +4872,7 @@ NTSTATUS cli_smb2_ftruncate(struct cli_state *cli,
                goto fail;
        }
 
-       inbuf = data_blob_talloc_zero(frame, 8);
-       if (inbuf.data == NULL) {
-               status = NT_STATUS_NO_MEMORY;
-               goto fail;
-       }
-
-       SBVAL(inbuf.data, 0, newsize);
+       SBVAL(buf, 0, newsize);
 
        /* setinfo on the handle with info_type SMB2_SETINFO_FILE (1),
           level 20 (SMB_FILE_END_OF_FILE_INFORMATION - 1000). */