*/
struct iovec *vector;
int vector_count;
+ struct iovec _vector[1 + SMBD_SMB2_NUM_IOV_PER_REQ];
#define OUTVEC_ALLOC_SIZE (SMB2_HDR_BODY + 9)
uint8_t _hdr[OUTVEC_ALLOC_SIZE];
uint8_t _body[0x58];
static NTSTATUS smbd_smb2_request_setup_out(struct smbd_smb2_request *req)
{
+ TALLOC_CTX *mem_ctx;
struct iovec *vector;
int count;
int idx;
count = req->in.vector_count;
- vector = talloc_zero_array(req, struct iovec, count);
- if (vector == NULL) {
- return NT_STATUS_NO_MEMORY;
+ if (count <= ARRAY_SIZE(req->out._vector)) {
+ mem_ctx = req;
+ vector = req->out._vector;
+ } else {
+ vector = talloc_zero_array(req, struct iovec, count);
+ if (vector == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ mem_ctx = vector;
}
vector[0].iov_base = req->out.nbt_hdr;
if (idx == 1) {
outhdr = req->out._hdr;
} else {
- outhdr = talloc_zero_array(vector, uint8_t,
+ outhdr = talloc_zero_array(mem_ctx, uint8_t,
OUTVEC_ALLOC_SIZE);
if (outhdr == NULL) {
return NT_STATUS_NO_MEMORY;