41 files changed:
return NT_STATUS_NET_WRITE_FAULT;
}
return NT_STATUS_NET_WRITE_FAULT;
}
- *r = talloc(mem_ctx, dcerpc_table_$name.calls[opnum].struct_size);
+ *r = talloc_size(mem_ctx, dcerpc_table_$name.calls[opnum].struct_size);
if (!*r) {
return NT_STATUS_NO_MEMORY;
}
if (!*r) {
return NT_STATUS_NO_MEMORY;
}
return NT_STATUS_NET_WRITE_FAULT;
}
return NT_STATUS_NET_WRITE_FAULT;
}
- *r = talloc(mem_ctx, dcerpc_table_$name.calls[opnum].struct_size);
+ *r = talloc_size(mem_ctx, dcerpc_table_$name.calls[opnum].struct_size);
if (!*r) {
return NT_STATUS_NO_MEMORY;
}
if (!*r) {
return NT_STATUS_NO_MEMORY;
}
{
struct ldb_wrap *sam_ctx = ctx;
struct ldb_val val;
{
struct ldb_wrap *sam_ctx = ctx;
struct ldb_val val;
- val.data = talloc(mem_ctx, 16);
- val.length = 16;
+ val.data = talloc_memdup(mem_ctx, hash.hash, 16);
if (!val.data) {
return -1;
}
if (!val.data) {
return -1;
}
- memcpy(val.data, hash.hash, 16);
return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, &val);
}
return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, &val);
}
struct ldb_wrap *sam_ctx = ctx;
struct ldb_val val;
int i;
struct ldb_wrap *sam_ctx = ctx;
struct ldb_val val;
int i;
- val.data = talloc(mem_ctx, count*16);
+ val.data = talloc_array(mem_ctx, 16, count, __location__);
val.length = count*16;
if (!val.data) {
return -1;
val.length = count*16;
if (!val.data) {
return -1;
}
/* rebuild the normlaized component and put it here */
}
/* rebuild the normlaized component and put it here */
- component->component = dest = talloc(component, size);
+ component->component = dest = talloc_size(component, size);
for (i = 0; i < component->attr_num; i++) {
if (i != 0) {
*dest = '+';
for (i = 0; i < component->attr_num; i++) {
if (i != 0) {
*dest = '+';
}
/* rebuild the normlaized dn and put it here */
}
/* rebuild the normlaized dn and put it here */
- dn->dn = dest = talloc(dn, size);
+ dn->dn = dest = talloc_size(dn, size);
for (i = 0; i < dn->comp_num; i++) {
if (i != 0) {
*dest = ',';
for (i = 0; i < dn->comp_num; i++) {
if (i != 0) {
*dest = ',';
if (p) {
ret.data = talloc_memdup(NULL, p, length);
} else {
if (p) {
ret.data = talloc_memdup(NULL, p, length);
} else {
- ret.data = talloc(NULL, length);
+ ret.data = talloc_size(NULL, length);
}
if (ret.data == NULL) {
ret.length = 0;
}
if (ret.data == NULL) {
ret.length = 0;
size_t i;
size_t list_len = strlen(list);
size_t i;
size_t list_len = strlen(list);
- char *retstr = talloc(mem_ctx, len + 1);
+ char *retstr = talloc_array_p(mem_ctx, char, len + 1);
if (!retstr) return NULL;
generate_random_buffer((uint8_t *)retstr, len);
if (!retstr) return NULL;
generate_random_buffer((uint8_t *)retstr, len);
return ret;
case REG_BINARY:
return ret;
case REG_BINARY:
- ret = talloc(mem_ctx, v->data_len * 3 + 2);
+ ret = talloc_array(mem_ctx, 3, v->data_len+1, "REG_BINARY");
asciip = ret;
for (i=0; i<v->data_len; i++) {
int str_rem = v->data_len * 3 - (asciip - ret);
asciip = ret;
for (i=0; i<v->data_len; i++) {
int str_rem = v->data_len * 3 - (asciip - ret);
if (dat_len&0x7FFFFFFF) {
if (dat_len&0x7FFFFFFF) {
- char *dtmp = (char *)talloc(mem_ctx, dat_len&0x7FFFFFFF);
+ char *dtmp = talloc_size(mem_ctx, dat_len&0x7FFFFFFF);
if ((dat_len&0x80000000) == 0) { /* The data is pointed to by the offset */
char *dat_ptr = LOCN(regf->base, dat_off);
if ((dat_len&0x80000000) == 0) { /* The data is pointed to by the offset */
char *dat_ptr = LOCN(regf->base, dat_off);
/* useful macros for creating type checked pointers */
#define talloc(ctx, size) talloc_named_const(ctx, size, __location__)
/* useful macros for creating type checked pointers */
#define talloc(ctx, size) talloc_named_const(ctx, size, __location__)
+#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__)
#define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__)
#define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
#define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
#define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__)
#define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
#define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
- p1 = talloc(root, 0x7fffffff);
+ p1 = talloc_size(root, 0x7fffffff);
if (p1) {
printf("failed: large talloc allowed\n");
return False;
if (p1) {
printf("failed: large talloc allowed\n");
return False;
+ p1 = talloc_size(root, 10);
CHECK_SIZE(p1, 10);
p1 = talloc_realloc(NULL, p1, 20);
CHECK_SIZE(p1, 10);
p1 = talloc_realloc(NULL, p1, 20);
printf("TESTING REALLOC WITH CHILD\n");
printf("TESTING REALLOC WITH CHILD\n");
- root = talloc(NULL, 0);
+ root = talloc_new(NULL);
el1 = talloc_p(root, struct el1);
el1->list = talloc_p(el1, struct el2 *);
el1 = talloc_p(root, struct el1);
el1->list = talloc_p(el1, struct el2 *);
printf("TESTING STEAL\n");
printf("TESTING STEAL\n");
- root = talloc(NULL, 0);
+ root = talloc_new(NULL);
p1 = talloc_array_p(root, char, 10);
CHECK_SIZE(p1, 10);
p1 = talloc_array_p(root, char, 10);
CHECK_SIZE(p1, 10);
CHECK_SIZE(NULL, 3);
talloc_free(p1);
CHECK_SIZE(NULL, 3);
talloc_free(p1);
- root = talloc(NULL, 0);
+ root = talloc_new(NULL);
p1 = talloc_realloc_fn(root, NULL, 10);
CHECK_BLOCKS(root, 2);
p1 = talloc_realloc_fn(root, NULL, 10);
CHECK_BLOCKS(root, 2);
*/
static BOOL test_speed(void)
{
*/
static BOOL test_speed(void)
{
- void *ctx = talloc(NULL, 0);
+ void *ctx = talloc_new(NULL);
unsigned count;
struct timeval tv;
unsigned count;
struct timeval tv;
count = 0;
do {
void *p1, *p2, *p3;
count = 0;
do {
void *p1, *p2, *p3;
- p1 = talloc(ctx, count);
+ p1 = talloc_size(ctx, count);
p2 = talloc_strdup(p1, "foo bar");
p2 = talloc_strdup(p1, "foo bar");
+ p3 = talloc_size(p1, 300);
talloc_free(p1);
count += 3;
} while (timeval_elapsed(&tv) < 5.0);
talloc_free(p1);
count += 3;
} while (timeval_elapsed(&tv) < 5.0);
/* this takes advantage of the fact that upper/lower can't
change the length of a character by more than 1 byte */
/* this takes advantage of the fact that upper/lower can't
change the length of a character by more than 1 byte */
- dest = talloc(ctx, 2*(strlen(src))+1);
+ dest = talloc_size(ctx, 2*(strlen(src))+1);
if (dest == NULL) {
return NULL;
}
if (dest == NULL) {
return NULL;
}
/* this takes advantage of the fact that upper/lower can't
change the length of a character by more than 1 byte */
/* this takes advantage of the fact that upper/lower can't
change the length of a character by more than 1 byte */
- dest = talloc(ctx, 2*(strlen(src))+1);
+ dest = talloc_size(ctx, 2*(strlen(src))+1);
if (dest == NULL) {
return NULL;
}
if (dest == NULL) {
return NULL;
}
if (!s || !*s) {
return talloc_strdup(mem_ctx, "");
}
if (!s || !*s) {
return talloc_strdup(mem_ctx, "");
}
- ret = talloc(mem_ctx, strlen(s)+2);
+ ret = talloc_size(mem_ctx, strlen(s)+2);
if (!ret) {
return ret;
}
if (!ret) {
return ret;
}
- ret = talloc(mem_ctx, ARRAY_SIZE(attr_strs)+1);
+ ret = talloc_size(mem_ctx, ARRAY_SIZE(attr_strs)+1);
if (!ret) {
return NULL;
}
if (!ret) {
return NULL;
}
static const uint8_t *get_challenge(const struct ntlmssp_state *ntlmssp_state)
{
static const uint8_t *get_challenge(const struct ntlmssp_state *ntlmssp_state)
{
- uint8_t *chal = talloc(ntlmssp_state, 8);
+ uint8_t *chal = talloc_size(ntlmssp_state, 8);
generate_random_buffer(chal, 8);
return chal;
generate_random_buffer(chal, 8);
return chal;
static const char *blob2string_talloc(TALLOC_CTX *mem_ctx,
DATA_BLOB blob)
{
static const char *blob2string_talloc(TALLOC_CTX *mem_ctx,
DATA_BLOB blob)
{
- char *result = talloc(mem_ctx, blob.length+1);
+ char *result = talloc_size(mem_ctx, blob.length+1);
memcpy(result, blob.data, blob.length);
result[blob.length] = '\0';
return result;
memcpy(result, blob.data, blob.length);
result[blob.length] = '\0';
return result;
asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0));
pwlen = asn1_tag_remaining(data);
if (pwlen != 0) {
asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0));
pwlen = asn1_tag_remaining(data);
if (pwlen != 0) {
- char *pw = talloc(msg->mem_ctx, pwlen+1);
+ char *pw = talloc_size(msg->mem_ctx, pwlen+1);
asn1_read(data, pw, pwlen);
pw[pwlen] = '\0';
r->creds.password = pw;
asn1_read(data, pw, pwlen);
pw[pwlen] = '\0';
r->creds.password = pw;
asn1_start_tag(data,
ASN1_APPLICATION_SIMPLE(LDAP_TAG_DelRequest));
len = asn1_tag_remaining(data);
asn1_start_tag(data,
ASN1_APPLICATION_SIMPLE(LDAP_TAG_DelRequest));
len = asn1_tag_remaining(data);
- dn = talloc(msg->mem_ctx, len+1);
+ dn = talloc_size(msg->mem_ctx, len+1);
if (dn == NULL)
break;
asn1_read(data, dn, len);
if (dn == NULL)
break;
asn1_read(data, dn, len);
char *newsup;
asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0));
len = asn1_tag_remaining(data);
char *newsup;
asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0));
len = asn1_tag_remaining(data);
- newsup = talloc(msg->mem_ctx, len+1);
+ newsup = talloc_size(msg->mem_ctx, len+1);
if (newsup == NULL)
break;
asn1_read(data, newsup, len);
if (newsup == NULL)
break;
asn1_read(data, newsup, len);
if (!ldap_find_single_value(msg, attr, &blob))
return False;
if (!ldap_find_single_value(msg, attr, &blob))
return False;
- *value = talloc(mem_ctx, blob.length+1);
+ *value = talloc_size(mem_ctx, blob.length+1);
if (*value == NULL)
return False;
if (*value == NULL)
return False;
if (transport->recv_buffer.received == NBT_HDR_SIZE) {
/* we've got a full header */
transport->recv_buffer.req_size = smb_len(transport->recv_buffer.header) + NBT_HDR_SIZE;
if (transport->recv_buffer.received == NBT_HDR_SIZE) {
/* we've got a full header */
transport->recv_buffer.req_size = smb_len(transport->recv_buffer.header) + NBT_HDR_SIZE;
- transport->recv_buffer.buffer = talloc(transport,
- NBT_HDR_SIZE+transport->recv_buffer.req_size);
+ transport->recv_buffer.buffer = talloc_size(transport,
+ NBT_HDR_SIZE+transport->recv_buffer.req_size);
if (transport->recv_buffer.buffer == NULL) {
smbcli_transport_dead(transport);
return;
if (transport->recv_buffer.buffer == NULL) {
smbcli_transport_dead(transport);
return;
/* over allocate by a small amount */
req->out.allocated = req->out.size + REQ_OVER_ALLOCATION;
/* over allocate by a small amount */
req->out.allocated = req->out.size + REQ_OVER_ALLOCATION;
- req->out.buffer = talloc(req, req->out.allocated);
+ req->out.buffer = talloc_size(req, req->out.allocated);
if (!req->out.buffer) {
return NULL;
}
if (!req->out.buffer) {
return NULL;
}
/* allocate it */
if (total_data != 0) {
/* allocate it */
if (total_data != 0) {
- tdata = talloc(mem_ctx, total_data);
+ tdata = talloc_size(mem_ctx, total_data);
if (!tdata) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge data buffer to %d bytes\n", total_data));
req->status = NT_STATUS_NO_MEMORY;
if (!tdata) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge data buffer to %d bytes\n", total_data));
req->status = NT_STATUS_NO_MEMORY;
}
if (total_param != 0) {
}
if (total_param != 0) {
- tparam = talloc(mem_ctx, total_param);
+ tparam = talloc_size(mem_ctx, total_param);
if (!tparam) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge param buffer to %d bytes\n", total_param));
req->status = NT_STATUS_NO_MEMORY;
if (!tparam) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge param buffer to %d bytes\n", total_param));
req->status = NT_STATUS_NO_MEMORY;
if (parms->out.setup_count > 0) {
int i;
if (parms->out.setup_count > 0) {
int i;
- parms->out.setup = talloc(mem_ctx, 2 * parms->out.setup_count);
+ parms->out.setup = talloc_array(mem_ctx, 2, parms->out.setup_count, "setup");
if (!parms->out.setup) {
req->status = NT_STATUS_NO_MEMORY;
return smbcli_request_destroy(req);
if (!parms->out.setup) {
req->status = NT_STATUS_NO_MEMORY;
return smbcli_request_destroy(req);
if (parms->out.setup_count > 0) {
int i;
if (parms->out.setup_count > 0) {
int i;
- parms->out.setup = talloc(mem_ctx, 2 * parms->out.setup_count);
+ parms->out.setup = talloc_array(mem_ctx, 2, parms->out.setup_count, "setup");
if (!parms->out.setup) {
req->status = NT_STATUS_NO_MEMORY;
return smbcli_request_destroy(req);
if (!parms->out.setup) {
req->status = NT_STATUS_NO_MEMORY;
return smbcli_request_destroy(req);
}
maxlen = sid->num_auths * 11 + 25;
}
maxlen = sid->num_auths * 11 + 25;
- ret = talloc(mem_ctx, maxlen);
+ ret = talloc_size(mem_ctx, maxlen);
if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)");
ia = (sid->id_auth[5]) +
if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)");
ia = (sid->id_auth[5]) +
- buf = talloc(NULL, len);
+ buf = talloc_size(NULL, len);
if (buf == NULL)
return False;
if (buf == NULL)
return False;
data->has_error = True;
return False;
}
data->has_error = True;
return False;
}
- *s = talloc(NULL, len+1);
+ *s = talloc_size(NULL, len+1);
if (! *s) {
data->has_error = True;
return False;
if (! *s) {
data->has_error = True;
return False;
ndr->flags = 0;
ndr->alloc_size = NDR_BASE_MARSHALL_SIZE;
ndr->flags = 0;
ndr->alloc_size = NDR_BASE_MARSHALL_SIZE;
- ndr->data = talloc(ndr, ndr->alloc_size);
+ ndr->data = talloc_array_p(ndr, uint8_t, ndr->alloc_size);
if (!ndr->data) {
return NULL;
}
if (!ndr->data) {
return NULL;
}
NTSTATUS status;
DATA_BLOB blob2;
NTSTATUS status;
DATA_BLOB blob2;
- st = talloc(mem_ctx, struct_size);
+ st = talloc_size(mem_ctx, struct_size);
if (!st) {
return NT_STATUS_NO_MEMORY;
}
if (!st) {
return NT_STATUS_NO_MEMORY;
}
NTSTATUS status;
DATA_BLOB blob, blob2;
NTSTATUS status;
DATA_BLOB blob, blob2;
- st = talloc(mem_ctx, struct_size);
+ st = talloc_size(mem_ctx, struct_size);
if (!st) {
return NT_STATUS_NO_MEMORY;
}
if (!st) {
return NT_STATUS_NO_MEMORY;
}
case RAW_FILEINFO_STREAM_INFORMATION:
info->stream_info.out.num_streams = info2->generic.out.num_streams;
if (info->stream_info.out.num_streams > 0) {
case RAW_FILEINFO_STREAM_INFORMATION:
info->stream_info.out.num_streams = info2->generic.out.num_streams;
if (info->stream_info.out.num_streams > 0) {
- info->stream_info.out.streams = talloc(req,
- info->stream_info.out.num_streams * sizeof(struct stream_struct));
+ info->stream_info.out.streams =
+ talloc_array_p(req,
+ struct stream_struct,
+ info->stream_info.out.num_streams);
if (!info->stream_info.out.streams) {
DEBUG(2,("ntvfs_map_fileinfo: no memory for %d streams\n",
info->stream_info.out.num_streams));
if (!info->stream_info.out.streams) {
DEBUG(2,("ntvfs_map_fileinfo: no memory for %d streams\n",
info->stream_info.out.num_streams));
case RAW_FILEINFO_ALL_EAS:
info->all_eas.out.num_eas = info2->generic.out.num_eas;
if (info->all_eas.out.num_eas > 0) {
case RAW_FILEINFO_ALL_EAS:
info->all_eas.out.num_eas = info2->generic.out.num_eas;
if (info->all_eas.out.num_eas > 0) {
- info->all_eas.out.eas = talloc(req,
- info->all_eas.out.num_eas * sizeof(struct ea_struct));
+ info->all_eas.out.eas = talloc_array_p(req,
+ struct ea_struct,
+ info->all_eas.out.num_eas);
if (!info->all_eas.out.eas) {
DEBUG(2,("ntvfs_map_fileinfo: no memory for %d eas\n",
info->all_eas.out.num_eas));
if (!info->all_eas.out.eas) {
DEBUG(2,("ntvfs_map_fileinfo: no memory for %d eas\n",
info->all_eas.out.num_eas));
char *dest, *d;
/* the length is bounded by the length of the two strings combined */
char *dest, *d;
/* the length is bounded by the length of the two strings combined */
- dest = talloc(mem_ctx, strlen(fname) + strlen(pattern) + 1);
+ dest = talloc_size(mem_ctx, strlen(fname) + strlen(pattern) + 1);
if (dest == NULL) {
return NULL;
}
if (dest == NULL) {
return NULL;
}
- ret = talloc(mem_ctx, len+1);
+ ret = talloc_size(mem_ctx, len+1);
if (ret == NULL) {
talloc_free(s);
return NT_STATUS_NO_MEMORY;
if (ret == NULL) {
talloc_free(s);
return NT_STATUS_NO_MEMORY;
mode_t mode;
NTSTATUS status;
size_t buf_size = 0x10000;
mode_t mode;
NTSTATUS status;
size_t buf_size = 0x10000;
- char *buf = talloc(name2, buf_size);
+ char *buf = talloc_size(name2, buf_size);
if (buf == NULL) {
return NT_STATUS_NO_MEMORY;
if (buf == NULL) {
return NT_STATUS_NO_MEMORY;
close(fd1);
mode = pvfs_fileperms(pvfs, name1->dos.attrib);
close(fd1);
mode = pvfs_fileperms(pvfs, name1->dos.attrib);
if (!lp_talloc)
lp_talloc = talloc_init("lp_talloc");
if (!lp_talloc)
lp_talloc = talloc_init("lp_talloc");
- ret = (char *)talloc(lp_talloc, len + 100); /* leave room for substitution */
+ ret = talloc_array_p(lp_talloc, char, len + 100); /* leave room for substitution */
- r->out.out_data = talloc(mem_ctx, r->in.len);
+ r->out.out_data = talloc_memdup(mem_ctx, r->in.in_data, r->in.len);
if (!r->out.out_data) {
return NT_STATUS_NO_MEMORY;
}
if (!r->out.out_data) {
return NT_STATUS_NO_MEMORY;
}
- memcpy(r->out.out_data, r->in.in_data, r->in.len);
return NT_STATUS_NET_WRITE_FAULT;
}
return NT_STATUS_NET_WRITE_FAULT;
}
- *r = talloc(mem_ctx, table->calls[opnum].struct_size);
+ *r = talloc_size(mem_ctx, table->calls[opnum].struct_size);
if (!*r) {
return NT_STATUS_NO_MEMORY;
}
if (!*r) {
return NT_STATUS_NO_MEMORY;
}
/* useful wrapper for talloc with NO_MEMORY reply */
#define REQ_TALLOC(ptr, size) do { \
/* useful wrapper for talloc with NO_MEMORY reply */
#define REQ_TALLOC(ptr, size) do { \
- ptr = talloc(req, size); \
+ ptr = talloc_size(req, size); \
if (!ptr) { \
req_reply_error(req, NT_STATUS_NO_MEMORY); \
return; \
if (!ptr) { \
req_reply_error(req, NT_STATUS_NO_MEMORY); \
return; \
/* before calling the backend we setup the raw buffer. This
* saves a copy later */
req->out.size = io.readbraw.in.maxcnt + NBT_HDR_SIZE;
/* before calling the backend we setup the raw buffer. This
* saves a copy later */
req->out.size = io.readbraw.in.maxcnt + NBT_HDR_SIZE;
- req->out.buffer = talloc(req, req->out.size);
+ req->out.buffer = talloc_size(req, req->out.size);
if (req->out.buffer == NULL) {
goto failed;
}
if (req->out.buffer == NULL) {
goto failed;
}
failed:
/* any failure in readbraw is equivalent to reading zero bytes */
req->out.size = 4;
failed:
/* any failure in readbraw is equivalent to reading zero bytes */
req->out.size = 4;
- req->out.buffer = talloc(req, req->out.size);
+ req->out.buffer = talloc_size(req, req->out.size);
SIVAL(req->out.buffer, 0, 0); /* init NBT header */
req_send_reply_nosign(req);
SIVAL(req->out.buffer, 0, 0); /* init NBT header */
req_send_reply_nosign(req);
/* over allocate by a small amount */
req->out.allocated = req->out.size + REQ_OVER_ALLOCATION;
/* over allocate by a small amount */
req->out.allocated = req->out.size + REQ_OVER_ALLOCATION;
- req->out.buffer = talloc(req, req->out.allocated);
+ req->out.buffer = talloc_size(req, req->out.allocated);
if (!req->out.buffer) {
smbsrv_terminate_connection(req->smb_conn, "allocation failed");
return;
if (!req->out.buffer) {
smbsrv_terminate_connection(req->smb_conn, "allocation failed");
return;
/* useful wrapper for talloc with NO_MEMORY reply */
#define REQ_TALLOC(ptr) do { \
/* useful wrapper for talloc with NO_MEMORY reply */
#define REQ_TALLOC(ptr) do { \
- ptr = talloc(req, sizeof(*(ptr))); \
+ ptr = talloc_size(req, sizeof(*(ptr))); \
if (!ptr) { \
req_reply_error(req, NT_STATUS_NO_MEMORY); \
return; \
if (!ptr) { \
req_reply_error(req, NT_STATUS_NO_MEMORY); \
return; \
- ucs_name = talloc(mem_ctx, (1+u_name_len)*2);
+ ucs_name = talloc_size(mem_ctx, (1+u_name_len)*2);
if (!ucs_name) {
printf("Failed to create UCS2 Name - talloc() failure\n");
return NT_STATUS_NO_MEMORY;
if (!ucs_name) {
printf("Failed to create UCS2 Name - talloc() failure\n");
return NT_STATUS_NO_MEMORY;
parm[0].readx.in.mincnt = gen_io_count();
parm[0].readx.in.maxcnt = gen_io_count();
parm[0].readx.in.remaining = gen_io_count();
parm[0].readx.in.mincnt = gen_io_count();
parm[0].readx.in.maxcnt = gen_io_count();
parm[0].readx.in.remaining = gen_io_count();
- parm[0].readx.out.data = talloc(current_op.mem_ctx,
- MAX(parm[0].readx.in.mincnt, parm[0].readx.in.maxcnt));
+ parm[0].readx.out.data = talloc_size(current_op.mem_ctx,
+ MAX(parm[0].readx.in.mincnt, parm[0].readx.in.maxcnt));
GEN_COPY_PARM;
GEN_SET_FNUM(readx.in.fnum);
GEN_COPY_PARM;
GEN_SET_FNUM(readx.in.fnum);
} while (nlocks == 0);
if (nlocks > 0) {
} while (nlocks == 0);
if (nlocks > 0) {
- parm[0].lockx.in.locks = talloc(current_op.mem_ctx,
- sizeof(parm[0].lockx.in.locks[0]) * nlocks);
+ parm[0].lockx.in.locks = talloc_array_p(current_op.mem_ctx,
+ struct smb_lock_entry,
+ nlocks);
for (n=0;n<nlocks;n++) {
parm[0].lockx.in.locks[n].pid = gen_pid();
parm[0].lockx.in.locks[n].offset = gen_offset();
for (n=0;n<nlocks;n++) {
parm[0].lockx.in.locks[n].pid = gen_pid();
parm[0].lockx.in.locks[n].offset = gen_offset();
- buf = talloc(mem_ctx, strlen(value)+11);
+ buf = talloc_size(mem_ctx, strlen(value)+11);
ret = smbcli_read(cli->tree, fnum, buf, 0, strlen(value)+11);
if (ret != strlen(value)) {
ret = smbcli_read(cli->tree, fnum, buf, 0, strlen(value)+11);
if (ret != strlen(value)) {
printf("\nTesting EchoData\n");
printf("\nTesting EchoData\n");
- data_in = talloc(mem_ctx, len);
- data_out = talloc(mem_ctx, len);
+ data_in = talloc_size(mem_ctx, len);
+ data_out = talloc_size(mem_ctx, len);
for (i=0;i<len;i++) {
data_in[i] = i;
}
for (i=0;i<len;i++) {
data_in[i] = i;
}
printf("\nTesting SourceData\n");
printf("\nTesting SourceData\n");
- data_out = talloc(mem_ctx, len);
+ data_out = talloc_size(mem_ctx, len);
r.in.len = len;
r.out.data = data_out;
r.in.len = len;
r.out.data = data_out;
printf("\nTesting SinkData\n");
printf("\nTesting SinkData\n");
- data_in = talloc(mem_ctx, len);
+ data_in = talloc_size(mem_ctx, len);
for (i=0;i<len;i++) {
data_in[i] = i+1;
}
for (i=0;i<len;i++) {
data_in[i] = i+1;
}
generate_random_buffer(ninfo.challenge,
sizeof(ninfo.challenge));
ninfo.nt.length = 24;
generate_random_buffer(ninfo.challenge,
sizeof(ninfo.challenge));
ninfo.nt.length = 24;
- ninfo.nt.data = talloc(mem_ctx, 24);
+ ninfo.nt.data = talloc_size(mem_ctx, 24);
SMBNTencrypt(password, ninfo.challenge, ninfo.nt.data);
ninfo.lm.length = 24;
SMBNTencrypt(password, ninfo.challenge, ninfo.nt.data);
ninfo.lm.length = 24;
- ninfo.lm.data = talloc(mem_ctx, 24);
+ ninfo.lm.data = talloc_size(mem_ctx, 24);
SMBencrypt(password, ninfo.challenge, ninfo.lm.data);
r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
SMBencrypt(password, ninfo.challenge, ninfo.lm.data);
r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
sizeof(ninfo.challenge));
if (nt_hash) {
ninfo.nt.length = 24;
sizeof(ninfo.challenge));
if (nt_hash) {
ninfo.nt.length = 24;
- ninfo.nt.data = talloc(mem_ctx, 24);
+ ninfo.nt.data = talloc_size(mem_ctx, 24);
SMBOWFencrypt(nt_hash->hash, ninfo.challenge, ninfo.nt.data);
} else {
ninfo.nt.length = 0;
SMBOWFencrypt(nt_hash->hash, ninfo.challenge, ninfo.nt.data);
} else {
ninfo.nt.length = 0;
if (lm_hash) {
ninfo.lm.length = 24;
if (lm_hash) {
ninfo.lm.length = 24;
- ninfo.lm.data = talloc(mem_ctx, 24);
+ ninfo.lm.data = talloc_size(mem_ctx, 24);
SMBOWFencrypt(lm_hash->hash, ninfo.challenge, ninfo.lm.data);
} else {
ninfo.lm.length = 0;
SMBOWFencrypt(lm_hash->hash, ninfo.challenge, ninfo.lm.data);
} else {
ninfo.lm.length = 0;
generate_random_buffer(ninfo.challenge,
sizeof(ninfo.challenge));
ninfo.nt.length = 24;
generate_random_buffer(ninfo.challenge,
sizeof(ninfo.challenge));
ninfo.nt.length = 24;
- ninfo.nt.data = talloc(mem_ctx, 24);
+ ninfo.nt.data = talloc_size(mem_ctx, 24);
SMBNTencrypt(password, ninfo.challenge, ninfo.nt.data);
ninfo.lm.length = 24;
SMBNTencrypt(password, ninfo.challenge, ninfo.nt.data);
ninfo.lm.length = 24;
- ninfo.lm.data = talloc(mem_ctx, 24);
+ ninfo.lm.data = talloc_size(mem_ctx, 24);
SMBencrypt(password, ninfo.challenge, ninfo.lm.data);
SMBencrypt(password, ninfo.challenge, ninfo.lm.data);
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
r.in.buf_size = r.out.bytes_needed;
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
r.in.buf_size = r.out.bytes_needed;
- r.out.service = talloc(mem_ctx, r.out.bytes_needed);
+ r.out.service = talloc_size(mem_ctx, r.out.bytes_needed);
status = dcerpc_svcctl_EnumServicesStatusW(p, mem_ctx, &r);
status = dcerpc_svcctl_EnumServicesStatusW(p, mem_ctx, &r);
l.in.domain_handle = &domain_handle;
l.in.num_rids = g.out.rids->count;
l.in.domain_handle = &domain_handle;
l.in.num_rids = g.out.rids->count;
- l.in.rids = talloc(mem_ctx,
- g.out.rids->count * sizeof(uint32_t));
+ l.in.rids = talloc_array_p(mem_ctx, uint32_t, g.out.rids->count);
for (i=0; i<g.out.rids->count; i++)
l.in.rids[i] = g.out.rids->rid[i].rid;
for (i=0; i<g.out.rids->count; i++)
l.in.rids[i] = g.out.rids->rid[i].rid;
- data = talloc(mem_ctx, size);
+ data = talloc_size(mem_ctx, size);
size = getxattr(argv[1], "security.ntacl", data, size);
size = getxattr(argv[1], "security.ntacl", data, size);