s3:smb2_server: avoid talloc_zero_array() in smbd_smb2_request_error_ex()
authorStefan Metzmacher <metze@samba.org>
Wed, 4 Dec 2013 14:24:29 +0000 (15:24 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 5 Mar 2014 21:59:22 +0000 (13:59 -0800)
It is only important that the content of info->data stays alive
for the lifetime of the request, but the DATA_BLOB structure itself
can be on the stack, while passing it as 'dyn' to smbd_smb2_request_done_ex().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb2_server.c

index becbbed66472d7c07aac6115025d3bd61a26a079..cda36221557b3dc24403388500b3fdfc44216786 100644 (file)
@@ -2632,6 +2632,7 @@ NTSTATUS smbd_smb2_request_error_ex(struct smbd_smb2_request *req,
                                    const char *location)
 {
        DATA_BLOB body;
+       DATA_BLOB _dyn;
        uint8_t *outhdr = SMBD_SMB2_OUT_HDR_PTR(req);
        size_t unread_bytes = smbd_smb2_unread_bytes(req);
 
@@ -2673,12 +2674,7 @@ NTSTATUS smbd_smb2_request_error_ex(struct smbd_smb2_request *req,
                 * *MUST BE* OUTVEC_ALLOC_SIZE. So we have room for
                 * 1 byte without having to do an alloc.
                 */
-               info = talloc_zero_array(req->out.vector,
-                                       DATA_BLOB,
-                                       1);
-               if (!info) {
-                       return NT_STATUS_NO_MEMORY;
-               }
+               info = &_dyn;
                info->data = ((uint8_t *)outhdr) +
                        OUTVEC_ALLOC_SIZE - 1;
                info->length = 1;