1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

r4549: got rid of a lot more uses of plain talloc(), instead using

talloc_size() or talloc_array_p() where appropriate.

also fixed a memory leak in pvfs_copy_file() (failed to free a memory
context)
(This used to be commit 89b74b5354)
This commit is contained in:
Andrew Tridgell 2005-01-06 03:06:58 +00:00 committed by Gerald (Jerry) Carter
parent 0b54d9236f
commit ddc10d4d37
41 changed files with 83 additions and 80 deletions

View File

@ -90,7 +90,7 @@ static NTSTATUS $name\__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_C
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;
}

View File

@ -94,7 +94,7 @@ static NTSTATUS $name\__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_C
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;
}

View File

@ -841,12 +841,11 @@ int samdb_msg_add_hash(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
{
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;
}
memcpy(val.data, hash.hash, 16);
val.length = 16;
return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, &val);
}
@ -859,7 +858,7 @@ int samdb_msg_add_hashes(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg
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;

View File

@ -272,7 +272,7 @@ struct ldap_dn *ldap_parse_dn(void *mem_ctx, const char *orig_dn)
}
/* 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 = '+';
@ -303,7 +303,7 @@ struct ldap_dn *ldap_parse_dn(void *mem_ctx, const char *orig_dn)
}
/* 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 = ',';

View File

@ -37,7 +37,7 @@ DATA_BLOB data_blob_named(const void *p, size_t length, const char *name)
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;

View File

@ -268,7 +268,7 @@ char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *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);

View File

@ -63,7 +63,7 @@ char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct registry_value *v)
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);

View File

@ -917,7 +917,7 @@ static WERROR vk_to_val(TALLOC_CTX *mem_ctx, struct registry_key *parent, VK_HDR
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);

View File

@ -34,6 +34,7 @@ typedef void TALLOC_CTX;
/* 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)

View File

@ -335,7 +335,7 @@ static BOOL test_misc(void)
root = talloc_new(NULL);
p1 = talloc(root, 0x7fffffff);
p1 = talloc_size(root, 0x7fffffff);
if (p1) {
printf("failed: large talloc allowed\n");
return False;
@ -517,7 +517,7 @@ static BOOL test_realloc(void)
root = talloc_new(NULL);
p1 = talloc(root, 10);
p1 = talloc_size(root, 10);
CHECK_SIZE(p1, 10);
p1 = talloc_realloc(NULL, p1, 20);
@ -581,7 +581,7 @@ static BOOL test_realloc_child(void)
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 *);
@ -607,7 +607,7 @@ static BOOL test_steal(void)
printf("TESTING STEAL\n");
root = talloc(NULL, 0);
root = talloc_new(NULL);
p1 = talloc_array_p(root, char, 10);
CHECK_SIZE(p1, 10);
@ -645,7 +645,7 @@ static BOOL test_steal(void)
talloc_free(root);
p1 = talloc(NULL, 3);
p1 = talloc_new(NULL);
CHECK_SIZE(NULL, 3);
talloc_free(p1);
@ -661,7 +661,7 @@ static BOOL test_ldb(void)
printf("TESTING LDB\n");
root = talloc(NULL, 0);
root = talloc_new(NULL);
p1 = talloc_realloc_fn(root, NULL, 10);
CHECK_BLOCKS(root, 2);
@ -709,7 +709,7 @@ static BOOL test_unref_reparent(void)
*/
static BOOL test_speed(void)
{
void *ctx = talloc(NULL, 0);
void *ctx = talloc_new(NULL);
unsigned count;
struct timeval tv;
@ -719,9 +719,9 @@ static BOOL test_speed(void)
count = 0;
do {
void *p1, *p2, *p3;
p1 = talloc(ctx, count);
p1 = talloc_size(ctx, count);
p2 = talloc_strdup(p1, "foo bar");
p3 = talloc(p1, 300);
p3 = talloc_size(p1, 300);
talloc_free(p1);
count += 3;
} while (timeval_elapsed(&tv) < 5.0);

View File

@ -669,7 +669,7 @@ char *strlower_talloc(TALLOC_CTX *ctx, const char *src)
/* 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;
}
@ -704,7 +704,7 @@ char *strupper_talloc(TALLOC_CTX *ctx, const char *src)
/* 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;
}
@ -1030,7 +1030,7 @@ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s)
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;
}
@ -1133,7 +1133,7 @@ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib)
};
char *ret;
ret = talloc(mem_ctx, ARRAY_SIZE(attr_strs)+1);
ret = talloc_size(mem_ctx, ARRAY_SIZE(attr_strs)+1);
if (!ret) {
return NULL;
}

View File

@ -109,7 +109,7 @@ void debug_ntlmssp_flags(uint32_t neg_flags)
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;

View File

@ -660,7 +660,7 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result)
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;
@ -859,7 +859,7 @@ BOOL ldap_decode(struct asn1_data *data, struct ldap_message *msg)
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;
@ -1040,7 +1040,7 @@ BOOL ldap_decode(struct asn1_data *data, struct ldap_message *msg)
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);
@ -1073,7 +1073,7 @@ BOOL ldap_decode(struct asn1_data *data, struct ldap_message *msg)
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);

View File

@ -649,7 +649,7 @@ BOOL ldap_find_single_string(struct ldap_message *msg, const char *attr,
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;

View File

@ -462,8 +462,8 @@ static void smbcli_transport_process_recv(struct smbcli_transport *transport)
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;

View File

@ -83,7 +83,7 @@ struct smbcli_request *smbcli_request_setup_nonsmb(struct smbcli_transport *tran
/* 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;
}

View File

@ -87,7 +87,7 @@ NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
/* 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;
@ -97,7 +97,7 @@ NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
}
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;
@ -111,7 +111,7 @@ NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
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);
@ -439,7 +439,7 @@ NTSTATUS smb_raw_nttrans_recv(struct smbcli_request *req,
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);

View File

@ -98,7 +98,7 @@ char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
}
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]) +

View File

@ -424,7 +424,7 @@ BOOL asn1_read_sequence_until(int sock, struct asn1_data *data,
len = b;
}
buf = talloc(NULL, len);
buf = talloc_size(NULL, len);
if (buf == NULL)
return False;
@ -548,7 +548,7 @@ BOOL asn1_read_GeneralString(struct asn1_data *data, char **s)
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;

View File

@ -128,7 +128,7 @@ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx)
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;
}

View File

@ -1032,7 +1032,7 @@ static NTSTATUS dcerpc_ndr_validate_in(struct dcerpc_pipe *p,
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;
}
@ -1096,7 +1096,7 @@ static NTSTATUS dcerpc_ndr_validate_out(struct dcerpc_pipe *p,
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;
}

View File

@ -713,8 +713,10 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info
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));
@ -751,8 +753,9 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info
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));

View File

@ -35,7 +35,7 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx,
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;
}

View File

@ -412,7 +412,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, const char **fname, uint_t
}
/* rebuild the name */
ret = talloc(mem_ctx, len+1);
ret = talloc_size(mem_ctx, len+1);
if (ret == NULL) {
talloc_free(s);
return NT_STATUS_NO_MEMORY;

View File

@ -89,7 +89,7 @@ NTSTATUS pvfs_copy_file(struct pvfs_state *pvfs,
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;
@ -134,6 +134,7 @@ NTSTATUS pvfs_copy_file(struct pvfs_state *pvfs,
}
}
talloc_free(buf);
close(fd1);
mode = pvfs_fileperms(pvfs, name1->dos.attrib);

View File

@ -1086,7 +1086,7 @@ static const char *lp_string(const char *s)
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 */
if (!ret)
return NULL;

View File

@ -37,11 +37,10 @@ static NTSTATUS echo_EchoData(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
return NT_STATUS_OK;
}
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;
}
memcpy(r->out.out_data, r->in.in_data, r->in.len);
return NT_STATUS_OK;
}

View File

@ -77,7 +77,7 @@ static NTSTATUS remote_op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CT
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;
}

View File

@ -45,7 +45,7 @@
/* 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; \
@ -696,7 +696,7 @@ void reply_readbraw(struct smbsrv_request *req)
/* 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;
}
@ -720,7 +720,7 @@ void reply_readbraw(struct smbsrv_request *req)
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);

View File

@ -120,7 +120,7 @@ void req_setup_reply(struct smbsrv_request *req, uint_t wct, uint_t buflen)
/* 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;

View File

@ -45,7 +45,7 @@
/* 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; \

View File

@ -41,7 +41,7 @@ static NTSTATUS unicode_open(struct smbcli_tree *tree,
int i;
NTSTATUS status;
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;

View File

@ -1330,8 +1330,8 @@ static BOOL handler_readx(int instance)
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);
@ -1392,8 +1392,9 @@ static BOOL handler_lockingx(int instance)
} 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();

View File

@ -71,7 +71,7 @@ static BOOL check_stream(struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
return False;
}
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)) {

View File

@ -62,8 +62,8 @@ static BOOL test_echodata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
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;
}
@ -109,7 +109,7 @@ static BOOL test_sourcedata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
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;
@ -144,7 +144,7 @@ static BOOL test_sinkdata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
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;
}

View File

@ -346,10 +346,10 @@ static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
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;
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));

View File

@ -58,7 +58,7 @@ static NTSTATUS test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
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;
@ -67,7 +67,7 @@ static NTSTATUS test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
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;

View File

@ -79,10 +79,10 @@ static BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
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;
ninfo.lm.data = talloc(mem_ctx, 24);
ninfo.lm.data = talloc_size(mem_ctx, 24);
SMBencrypt(password, ninfo.challenge, ninfo.lm.data);

View File

@ -50,7 +50,7 @@ static BOOL test_EnumServicesStatus(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
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);

View File

@ -730,8 +730,7 @@ static NTSTATUS test_getgroups(struct smbcli_transport *transport,
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;

View File

@ -112,7 +112,7 @@ int main(int argc, char **argv)
exit(1);
}
data = talloc(mem_ctx, size);
data = talloc_size(mem_ctx, size);
size = getxattr(argv[1], "security.ntacl", data, size);