From: Volker Lendecke Date: Tue, 29 Sep 2020 08:45:52 +0000 (+0200) Subject: libcli: Use GUID_to_ndr_buf() in smb2_create_send() X-Git-Tag: talloc-2.3.2~306 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=39180ca2d8932946aee3327668966098b9f229e0;p=thirdparty%2Fsamba.git libcli: Use GUID_to_ndr_buf() in smb2_create_send() Avoid talloc/free Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c index eb0f6a421cd..c91b1501107 100644 --- a/source4/libcli/smb2/create.c +++ b/source4/libcli/smb2/create.c @@ -109,7 +109,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create if (io->in.durable_open_v2) { uint8_t data[32]; uint32_t flags = 0; - DATA_BLOB guid_blob; + struct GUID_ndr_buf guid_buf = { .buf = {0}, }; SIVAL(data, 0, io->in.timeout); if (io->in.persistent_open) { @@ -117,13 +117,12 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create } SIVAL(data, 4, flags); SBVAL(data, 8, 0x0); /* reserved */ - status = GUID_to_ndr_blob(&io->in.create_guid, req, /* TALLOC_CTX */ - &guid_blob); + status = GUID_to_ndr_buf(&io->in.create_guid, &guid_buf); if (!NT_STATUS_IS_OK(status)) { talloc_free(req); return NULL; } - memcpy(data+16, guid_blob.data, 16); + memcpy(data+16, guid_buf.buf, sizeof(guid_buf.buf)); status = smb2_create_blob_add(req, &blobs, SMB2_CREATE_TAG_DH2Q, @@ -147,17 +146,16 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create if (io->in.durable_handle_v2) { uint8_t data[36]; - DATA_BLOB guid_blob; + struct GUID_ndr_buf guid_buf = { .buf = {0}, }; uint32_t flags = 0; smb2_push_handle(data, io->in.durable_handle_v2); - status = GUID_to_ndr_blob(&io->in.create_guid, req, /* TALLOC_CTX */ - &guid_blob); + status = GUID_to_ndr_buf(&io->in.create_guid, &guid_buf); if (!NT_STATUS_IS_OK(status)) { talloc_free(req); return NULL; } - memcpy(data+16, guid_blob.data, 16); + memcpy(data+16, guid_buf.buf, sizeof(guid_buf.buf)); if (io->in.persistent_open) { flags = SMB2_DHANDLE_FLAG_PERSISTENT; } @@ -247,19 +245,17 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create if (io->in.app_instance_id) { uint8_t data[20]; - DATA_BLOB guid_blob; + struct GUID_ndr_buf guid_buf = { .buf = {0}, }; SSVAL(data, 0, 20); /* structure size */ SSVAL(data, 2, 0); /* reserved */ - status = GUID_to_ndr_blob(io->in.app_instance_id, - req, /* TALLOC_CTX */ - &guid_blob); + status = GUID_to_ndr_buf(io->in.app_instance_id, &guid_buf); if (!NT_STATUS_IS_OK(status)) { talloc_free(req); return NULL; } - memcpy(data+4, guid_blob.data, 16); + memcpy(data+4, guid_buf.buf, sizeof(guid_buf.buf)); status = smb2_create_blob_add(req, &blobs, SMB2_CREATE_TAG_APP_INSTANCE_ID,