1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

r4591: - converted the other _p talloc functions to not need _p

- added #if TALLOC_DEPRECATED around the _p functions

- fixes the code that broke from the above

while doing this I fixed quite a number of places that were
incorrectly using the non type-safe talloc functions to use the type
safe ones. Some were even doing multiplies for array allocation, which
is potentially unsafe.
(This used to be commit 6e7754abd0c225527fb38363996a6e241b87b37e)
This commit is contained in:
Andrew Tridgell 2005-01-07 04:39:16 +00:00 committed by Gerald (Jerry) Carter
parent 066134f241
commit 11ce2cfd70
39 changed files with 136 additions and 105 deletions

View File

@ -379,7 +379,7 @@ NTSTATUS sam_make_server_info(TALLOC_CTX *mem_ctx, void *sam_ctx,
}
if (group_ret > 0 &&
!(groupSIDs = talloc_array_p(*server_info, struct dom_sid *, group_ret))) {
!(groupSIDs = talloc_array(*server_info, struct dom_sid *, group_ret))) {
talloc_free(*server_info);
return NT_STATUS_NO_MEMORY;
}

View File

@ -858,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_array(mem_ctx, 16, count, __location__);
val.data = talloc_array_size(mem_ctx, 16, count);
val.length = count*16;
if (!val.data) {
return -1;

View File

@ -154,6 +154,7 @@ extern int errno;
/* Lists, trees, caching, database... */
#include "version.h"
#include "xfile.h"
#define TALLOC_DEPRECATED 1
#include "lib/talloc/talloc.h"
#include "nt_status.h"
#include "structs.h"

View File

@ -229,7 +229,7 @@ ssize_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
outbuf = NULL;
convert:
destlen = 2 + (destlen*3);
ob = (char *)talloc_realloc(ctx, outbuf, destlen);
ob = talloc_realloc(ctx, outbuf, char, destlen);
if (!ob) {
DEBUG(0, ("convert_string_talloc: realloc failed!\n"));
talloc_free(outbuf);

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_array(mem_ctx, 3, v->data_len+1, "REG_BINARY");
ret = talloc_array_size(mem_ctx, 3, v->data_len+1);
asciip = ret;
for (i=0; i<v->data_len; i++) {
int str_rem = v->data_len * 3 - (asciip - ret);

View File

@ -932,7 +932,7 @@ static char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
}
len = vsnprintf(NULL, 0, fmt, ap2);
s = talloc_realloc(NULL, s, s_len + len+1);
s = talloc_realloc(NULL, s, char, s_len + len+1);
if (!s) return NULL;
VA_COPY(ap2, ap);
@ -961,7 +961,7 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...)
/*
alloc an array, checking for integer overflow in the array size
*/
void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name)
void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name)
{
if (count >= MAX_TALLOC_SIZE/el_size) {
return NULL;
@ -972,7 +972,7 @@ void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *
/*
alloc an zero array, checking for integer overflow in the array size
*/
void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name)
void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name)
{
if (count >= MAX_TALLOC_SIZE/el_size) {
return NULL;
@ -984,16 +984,12 @@ void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const c
/*
realloc an array, checking for integer overflow in the array size
*/
void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name)
void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name)
{
if (count >= MAX_TALLOC_SIZE/el_size) {
return NULL;
}
ptr = talloc_realloc(ctx, ptr, el_size * count);
if (ptr) {
talloc_set_name_const(ptr, name);
}
return ptr;
return _talloc_realloc(ctx, ptr, el_size * count, name);
}
/*

View File

@ -32,17 +32,26 @@ typedef void TALLOC_CTX;
#define __LINESTR__ _STRING_LINE2_(__LINE__)
#define __location__ __FILE__ ":" __LINESTR__
#ifndef TALLOC_DEPRECATED
#define TALLOC_DEPRECATED 0
#endif
/* useful macros for creating type checked pointers */
#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
#define talloc_p(ctx, type) talloc(ctx, type)
#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_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__)
#define talloc_zero_p(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
#define talloc_zero_array_p(ctx, type, count) (type *)talloc_zero_array(ctx, sizeof(type), count, __location__)
#define talloc_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__)
#define talloc_realloc_p(ctx, p, type, count) (type *)talloc_realloc_array(ctx, p, sizeof(type), count, __location__)
#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__)
#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, __location__)
#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, __location__)
#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__)
#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, __location__)
#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)
#define talloc_destroy(ctx) talloc_free(ctx)
@ -54,6 +63,14 @@ typedef void TALLOC_CTX;
#define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__)
#define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__)
#if TALLOC_DEPRECATED
#define talloc_zero_p(ctx, type) talloc_zero(ctx, type)
#define talloc_p(ctx, type) talloc(ctx, type)
#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count)
#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count)
#endif
#ifndef PRINTF_ATTRIBUTE
#define PRINTF_ATTRIBUTE(a1, a2)
#endif
@ -89,9 +106,9 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIB
char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
char *talloc_asprintf_append(char *s,
const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name);
void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name);
void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name);
void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name);
void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name);
void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name);
void *talloc_realloc_fn(const void *context, void *ptr, size_t size);
void *talloc_autofree_context(void);

View File

@ -5,7 +5,7 @@ Andrew Tridgell
September 2004
The most current version of this document is available at
http://samba.org/ftp/unpacked/samba4/talloc_guide.txt
http://samba.org/ftp/unpacked/samba4/source/lib/talloc/talloc_guide.txt
If you are used to talloc from Samba3 then please read this carefully,
as talloc has changed a lot.
@ -19,7 +19,7 @@ between a "talloc context" and a "talloc pointer". Any pointer
returned from talloc() is itself a valid talloc context. This means
you can do this:
struct foo *X = talloc_p(mem_ctx, struct foo);
struct foo *X = talloc(mem_ctx, struct foo);
X->name = talloc_strdup(X, "foo");
and the pointer X->name would be a "child" of the talloc context "X"
@ -34,7 +34,7 @@ talloc_free().
If you find this confusing, then I suggest you run the LOCAL-TALLOC
smbtorture test to watch talloc in action. You may also like to add
your own tests to source/torture/local/talloc.c to clarify how some
your own tests to source/lib/talloc/testsuite.c to clarify how some
particular situation is handled.
@ -270,13 +270,13 @@ particularly useful for creating a new temporary working context.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void *talloc_realloc(const void *context, void *ptr, size_t size);
(type *)talloc_realloc(const void *context, void *ptr, type, count);
The talloc_realloc() function changes the size of a talloc
The talloc_realloc() macro changes the size of a talloc
pointer. It has the following equivalences:
talloc_realloc(context, NULL, size) ==> talloc_size(context, size);
talloc_realloc(context, ptr, 0) ==> talloc_free(ptr);
talloc_realloc(context, NULL, type, 1) ==> talloc(context, type);
talloc_realloc(context, ptr, type, 0) ==> talloc_free(ptr);
The "context" argument is only used if "ptr" is not NULL, otherwise it
is ignored.
@ -286,6 +286,13 @@ will fail either due to a lack of memory, or because the pointer has
more than one parent (see talloc_reference()).
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void *talloc_realloc_size(const void *context, void *ptr, size_t size);
the talloc_realloc_size() function is useful when the type is not
known so the typesafe talloc_realloc() cannot be used.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void *talloc_steal(const void *new_ctx, const void *ptr);
@ -403,12 +410,18 @@ full talloc report on 'root' (total 18 bytes in 8 blocks)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void *talloc_zero(const void *ctx, size_t size);
(type *)talloc_zero(const void *ctx, type);
The talloc_zero() function is equivalent to:
The talloc_zero() macro is equivalent to:
ptr = talloc_size(ctx, size);
if (ptr) memset(ptr, 0, size);
ptr = talloc(ctx, type);
if (ptr) memset(ptr, 0, sizeof(type));
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void *talloc_zero_size(const void *ctx, size_t size)
The talloc_zero_size() function is useful when you don't have a known type
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
@ -469,25 +482,19 @@ string to the given string.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void *talloc_array_p(const void *ctx, type, uint_t count);
(type *)talloc_array(const void *ctx, type, uint_t count);
The talloc_array_p() macro is equivalent to:
The talloc_array() macro is equivalent to:
(type *)talloc_size(ctx, sizeof(type) * count);
except that it provides integer overflow protection for the multiply,
returning NULL if the multiply overflows.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void *talloc_realloc_p(const void *ctx, void *ptr, type, uint_t count);
void *talloc_array_size(const void *ctx, size_t size, uint_t count);
The talloc_realloc_p() macro is equivalent to:
(type *)talloc_realloc(ctx, ptr, sizeof(type) * count);
except that it provides integer overflow protection for the multiply,
returning NULL if the multiply overflows.
The talloc_array_size() function is useful when the type is not known
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

View File

@ -398,7 +398,7 @@ static BOOL test_misc(void)
talloc_report(root, stdout);
p2 = talloc_zero(p1, 20);
p2 = talloc_zero_size(p1, 20);
if (p2[19] != 0) {
printf("Failed to give zero memory\n");
return False;
@ -520,41 +520,41 @@ static BOOL test_realloc(void)
p1 = talloc_size(root, 10);
CHECK_SIZE(p1, 10);
p1 = talloc_realloc(NULL, p1, 20);
p1 = talloc_realloc_size(NULL, p1, 20);
CHECK_SIZE(p1, 20);
talloc_new(p1);
p2 = talloc_realloc(p1, NULL, 30);
p2 = talloc_realloc_size(p1, NULL, 30);
talloc_new(p1);
p2 = talloc_realloc(p1, p2, 40);
p2 = talloc_realloc_size(p1, p2, 40);
CHECK_SIZE(p2, 40);
CHECK_SIZE(root, 60);
CHECK_BLOCKS(p1, 4);
p1 = talloc_realloc(NULL, p1, 20);
p1 = talloc_realloc_size(NULL, p1, 20);
CHECK_SIZE(p1, 60);
talloc_increase_ref_count(p2);
if (talloc_realloc(NULL, p2, 5) != NULL) {
if (talloc_realloc_size(NULL, p2, 5) != NULL) {
printf("failed: talloc_realloc() on a referenced pointer should fail\n");
return False;
}
CHECK_BLOCKS(p1, 4);
talloc_realloc(NULL, p2, 0);
talloc_realloc(NULL, p2, 0);
talloc_realloc_size(NULL, p2, 0);
talloc_realloc_size(NULL, p2, 0);
CHECK_BLOCKS(p1, 3);
if (talloc_realloc(NULL, p1, 0x7fffffff) != NULL) {
if (talloc_realloc_size(NULL, p1, 0x7fffffff) != NULL) {
printf("failed: oversize talloc should fail\n");
return False;
}
talloc_realloc(NULL, p1, 0);
talloc_realloc_size(NULL, p1, 0);
CHECK_BLOCKS(root, 1);
CHECK_SIZE(root, 0);

View File

@ -52,9 +52,9 @@ static BOOL read_negTokenInit(struct asn1_data *asn1, struct spnego_negTokenInit
token->mechTypes = talloc_p(NULL, const char *);
for (i = 0; !asn1->has_error &&
0 < asn1_tag_remaining(asn1); i++) {
token->mechTypes =
talloc_realloc(NULL, token->mechTypes, (i + 2) *
sizeof(*token->mechTypes));
token->mechTypes = talloc_realloc(NULL,
token->mechTypes,
const char *, i+2);
asn1_read_OID(asn1, token->mechTypes + i);
if (token->mechTypes[i]) {
talloc_steal(token->mechTypes,

View File

@ -81,13 +81,13 @@ static BOOL smbcli_list_new_callback(void *private, union smb_search_data *file)
/* add file info to the dirlist pool */
tdl = talloc_realloc(state,
state->dirlist,
state->dirlist_len + sizeof(struct clilist_file_info));
struct clilist_file_info,
state->dirlist_len + 1);
if (!tdl) {
return False;
}
state->dirlist = tdl;
state->dirlist_len += sizeof(struct clilist_file_info);
state->dirlist_len++;
interpret_long_filename(state->info_level, file, &state->dirlist[state->total_received]);
@ -227,13 +227,14 @@ static BOOL smbcli_list_old_callback(void *private, union smb_search_data *file)
/* add file info to the dirlist pool */
tdl = talloc_realloc(state,
state->dirlist,
state->dirlist_len + sizeof(struct clilist_file_info));
struct clilist_file_info,
state->dirlist_len + 1);
if (!tdl) {
return False;
}
state->dirlist = tdl;
state->dirlist_len += sizeof(struct clilist_file_info);
state->dirlist_len++;
interpret_short_filename(state->info_level, file, &state->dirlist[state->total_received]);

View File

@ -52,7 +52,7 @@ static char *next_chunk(TALLOC_CTX *mem_ctx,
if (chunk_size+1 >= alloc_size) {
char *c2;
alloc_size += 1024;
c2 = talloc_realloc(mem_ctx, chunk, alloc_size);
c2 = talloc_realloc(mem_ctx, chunk, char, alloc_size);
if (!c2) {
errno = ENOMEM;
return NULL;

View File

@ -73,7 +73,7 @@ NTSTATUS smb_raw_changenotify_recv(struct smbcli_request *req,
}
/* allocate array */
parms->out.changes = talloc_array_p(mem_ctx, struct notify_changes, parms->out.num_changes);
parms->out.changes = talloc_array(mem_ctx, struct notify_changes, parms->out.num_changes);
if (!parms->out.changes) {
return NT_STATUS_NO_MEMORY;
}

View File

@ -203,7 +203,7 @@ static void smbcli_req_grow_allocation(struct smbcli_request *req, uint_t new_si
/* we need to realloc */
req->out.allocated = req->out.size + delta + REQ_OVER_ALLOCATION;
buf2 = talloc_realloc(req, req->out.buffer, req->out.allocated);
buf2 = talloc_realloc(req, req->out.buffer, uint8_t, req->out.allocated);
if (buf2 == NULL) {
smb_panic("out of memory in req_grow_allocation");
}
@ -950,7 +950,7 @@ size_t smbcli_blob_append_string(struct smbcli_session *session,
max_len = (strlen(str)+2) * MAX_BYTES_PER_CHAR;
blob->data = talloc_realloc(mem_ctx, blob->data, blob->length + max_len);
blob->data = talloc_realloc(mem_ctx, blob->data, uint8_t, blob->length + max_len);
if (!blob->data) {
return 0;
}

View File

@ -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_array(mem_ctx, 2, parms->out.setup_count, "setup");
parms->out.setup = talloc_array(mem_ctx, uint16_t, parms->out.setup_count);
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_array(mem_ctx, 2, parms->out.setup_count, "setup");
parms->out.setup = talloc_array(mem_ctx, uint16_t, parms->out.setup_count);
if (!parms->out.setup) {
req->status = NT_STATUS_NO_MEMORY;
return smbcli_request_destroy(req);

View File

@ -33,7 +33,7 @@ BOOL asn1_write(struct asn1_data *data, const void *p, int len)
if (data->has_error) return False;
if (data->length < data->ofs+len) {
uint8_t *newp;
newp = talloc_realloc(NULL, data->data, data->ofs+len);
newp = talloc_realloc(NULL, data->data, uint8_t, data->ofs+len);
if (!newp) {
asn1_free(data);
data->has_error = True;

View File

@ -239,7 +239,7 @@ enum ndr_err_code {
#define NDR_ALLOC_N_SIZE(ndr, s, n, elsize) do { \
(s) = talloc_array(ndr, elsize, n, __location__); \
(s) = talloc_array_size(ndr, elsize, n); \
if (!(s)) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Alloc %u * %u failed\n", n, elsize); \
} while (0)

View File

@ -173,7 +173,7 @@ NTSTATUS ndr_push_expand(struct ndr_push *ndr, uint32_t size)
if (size > ndr->alloc_size) {
ndr->alloc_size = size;
}
ndr->data = talloc_realloc(ndr, ndr->data, ndr->alloc_size);
ndr->data = talloc_realloc(ndr, ndr->data, uint8_t, ndr->alloc_size);
if (!ndr->data) {
return ndr_push_error(ndr, NDR_ERR_ALLOC, "Failed to push_expand to %u",
ndr->alloc_size);

View File

@ -811,6 +811,7 @@ static void dcerpc_request_recv_data(struct dcerpc_pipe *p,
if (length > 0) {
req->payload.data = talloc_realloc(req,
req->payload.data,
uint8_t,
req->payload.length + length);
if (!req->payload.data) {
req->status = NT_STATUS_NO_MEMORY;

View File

@ -94,7 +94,7 @@ static void smb_read_callback(struct smbcli_request *req)
}
/* initiate another read request, as we only got part of a fragment */
state->data.data = talloc_realloc(state, state->data.data, frag_length);
state->data.data = talloc_realloc(state, state->data.data, uint8_t, frag_length);
io->readx.in.mincnt = MIN(state->p->srv_max_xmit_frag,
frag_length - state->received);

View File

@ -151,7 +151,7 @@ static void sock_process_recv(struct dcerpc_pipe *p)
frag_length = dcerpc_get_frag_length(&sock->recv.data);
sock->recv.data.data = talloc_realloc(sock, sock->recv.data.data,
frag_length);
uint8_t, frag_length);
if (sock->recv.data.data == NULL) {
sock_dead(p, NT_STATUS_NO_MEMORY);
return;

View File

@ -137,9 +137,9 @@ NTSTATUS pvfs_list_start(struct pvfs_state *pvfs, struct pvfs_filename *name,
dir->no_wildcard = False;
dir->end_of_search = False;
dir->offset = 0;
dir->name_cache = talloc_zero_array_p(dir,
struct name_cache_entry,
NAME_CACHE_SIZE);
dir->name_cache = talloc_zero_array(dir,
struct name_cache_entry,
NAME_CACHE_SIZE);
if (dir->name_cache == NULL) {
talloc_free(dir);
return NT_STATUS_NO_MEMORY;

View File

@ -283,7 +283,7 @@ ssize_t pvfs_stream_write(struct pvfs_state *pvfs,
blob = data_blob(NULL, 0);
}
if (count+offset > blob.length) {
blob.data = talloc_realloc(blob.data, blob.data, count+offset);
blob.data = talloc_realloc(blob.data, blob.data, uint8_t, count+offset);
if (blob.data == NULL) {
errno = ENOMEM;
return -1;
@ -339,7 +339,7 @@ NTSTATUS pvfs_stream_truncate(struct pvfs_state *pvfs,
if (length <= blob.length) {
blob.length = length;
} else if (length > blob.length) {
blob.data = talloc_realloc(blob.data, blob.data, length);
blob.data = talloc_realloc(blob.data, blob.data, uint8_t, length);
if (blob.data == NULL) {
return NT_STATUS_NO_MEMORY;
}

View File

@ -51,7 +51,8 @@ again:
}
if (ret == -1 && errno == ERANGE) {
estimated_size *= 2;
blob->data = talloc_realloc(mem_ctx, blob->data, estimated_size);
blob->data = talloc_realloc(mem_ctx, blob->data,
uint8_t, estimated_size);
if (blob->data == NULL) {
return NT_STATUS_NO_MEMORY;
}

View File

@ -857,7 +857,9 @@ NTSTATUS dcesrv_input_process(struct dcesrv_connection *dce_conn)
}
call->pkt.u.request.stub_and_verifier.data =
talloc_realloc(call, call->pkt.u.request.stub_and_verifier.data, alloc_size);
talloc_realloc(call,
call->pkt.u.request.stub_and_verifier.data,
uint8_t, alloc_size);
if (!call->pkt.u.request.stub_and_verifier.data) {
return dcesrv_fault(call2, DCERPC_FAULT_OTHER);
}
@ -920,6 +922,7 @@ NTSTATUS dcesrv_input(struct dcesrv_connection *dce_conn, const DATA_BLOB *data)
dce_conn->partial_input.data = talloc_realloc(dce_conn,
dce_conn->partial_input.data,
uint8_t,
dce_conn->partial_input.length + data->length);
if (!dce_conn->partial_input.data) {
return NT_STATUS_NO_MEMORY;

View File

@ -42,7 +42,7 @@ static void nttrans_setup_reply(struct smbsrv_request *req,
{
trans->out.setup_count = setup_count;
if (setup_count != 0) {
trans->out.setup = talloc_zero_array_p(req, uint16_t, setup_count);
trans->out.setup = talloc_zero_array(req, uint16_t, setup_count);
}
trans->out.params = data_blob_talloc(req, NULL, param_size);
trans->out.data = data_blob_talloc(req, NULL, data_size);

View File

@ -2377,7 +2377,7 @@ void reply_sendtxt(struct smbsrv_request *req)
void reply_special(struct smbsrv_request *req)
{
uint8_t msg_type;
uint8_t *buf = talloc_zero_array_p(req, uint8_t, 4);
uint8_t *buf = talloc_zero_array(req, uint8_t, 4);
msg_type = CVAL(req->in.buffer,0);

View File

@ -83,7 +83,8 @@ static void req_setup_chain_reply(struct smbsrv_request *req, uint_t wct, uint_t
/* over allocate by a small amount */
req->out.allocated = req->out.size + REQ_OVER_ALLOCATION;
req->out.buffer = talloc_realloc(req, req->out.buffer, req->out.allocated);
req->out.buffer = talloc_realloc(req, req->out.buffer,
uint8_t, req->out.allocated);
if (!req->out.buffer) {
smbsrv_terminate_connection(req->smb_conn, "allocation failed");
return;
@ -236,7 +237,7 @@ static void req_grow_allocation(struct smbsrv_request *req, uint_t new_size)
/* we need to realloc */
req->out.allocated = req->out.size + delta + REQ_OVER_ALLOCATION;
buf2 = talloc_realloc(req, req->out.buffer, req->out.allocated);
buf2 = talloc_realloc(req, req->out.buffer, uint8_t, req->out.allocated);
if (buf2 == NULL) {
smb_panic("out of memory in req_grow_allocation");
}

View File

@ -108,7 +108,8 @@ static NTSTATUS receive_smb_request(struct smbsrv_connection *smb_conn, struct t
/* when we have a full NBT header, then allocate the packet */
if (req->in.size == NBT_HDR_SIZE) {
len = smb_len(req->in.buffer) + NBT_HDR_SIZE;
req->in.buffer = talloc_realloc(req, req->in.buffer, len);
req->in.buffer = talloc_realloc(req, req->in.buffer,
uint8_t, len);
if (req->in.buffer == NULL) {
return NT_STATUS_NO_MEMORY;
}

View File

@ -42,7 +42,8 @@ static BOOL trans2_grow_data_allocation(struct smbsrv_request *req,
if (new_size <= trans->out.data.length) {
return True;
}
trans->out.data.data = talloc_realloc(req, trans->out.data.data, new_size);
trans->out.data.data = talloc_realloc(req, trans->out.data.data,
uint8_t, new_size);
return (trans->out.data.data != NULL);
}
@ -83,7 +84,7 @@ static void trans2_setup_reply(struct smbsrv_request *req,
{
trans->out.setup_count = setup_count;
if (setup_count != 0) {
trans->out.setup = talloc_zero_array_p(req, uint16_t, setup_count);
trans->out.setup = talloc_zero_array(req, uint16_t, setup_count);
}
trans->out.params = data_blob_talloc(req, NULL, param_size);
trans->out.data = data_blob_talloc(req, NULL, data_size);

View File

@ -1358,7 +1358,7 @@ static BOOL handler_writex(int instance)
parm[0].writex.in.wmode = gen_bits_mask(0xFFFF);
parm[0].writex.in.remaining = gen_io_count();
parm[0].writex.in.count = gen_io_count();
parm[0].writex.in.data = talloc_zero(current_op.mem_ctx, parm[0].writex.in.count);
parm[0].writex.in.data = talloc_zero_size(current_op.mem_ctx, parm[0].writex.in.count);
GEN_COPY_PARM;
GEN_SET_FNUM(writex.in.fnum);

View File

@ -35,8 +35,8 @@ BOOL torture_local_idtree(void)
idr = idr_init(ctx);
ids = talloc_zero_array_p(ctx, int, n);
present = talloc_zero_array_p(ctx, int, n);
ids = talloc_zero_array(ctx, int, n);
present = talloc_zero_array(ctx, int, n);
for (i=0;i<n;i++) {
ids[i] = -1;

View File

@ -82,6 +82,7 @@ static void rap_cli_push_paramdesc(struct rap_call *call, char desc)
call->paramdesc = talloc_realloc(call->mem_ctx,
call->paramdesc,
uint8_t,
len+2);
call->paramdesc[len] = desc;
call->paramdesc[len+1] = '\0';
@ -151,7 +152,7 @@ static NTSTATUS rap_pull_string(TALLOC_CTX *mem_ctx, struct ndr_pull *ndr,
if ( string_offset + len + 1 > ndr->data_size )
return NT_STATUS_INVALID_PARAMETER;
*dest = talloc_zero(mem_ctx, len+1);
*dest = talloc_zero_size(mem_ctx, len+1);
pull_ascii(*dest, p, len+1, len, 0);
return NT_STATUS_OK;

View File

@ -90,7 +90,7 @@ static BOOL test_read(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
const char *test_data = "TEST DATA";
uint_t seed = time(NULL);
buf = talloc_zero(mem_ctx, maxsize);
buf = talloc_zero_size(mem_ctx, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
return False;
@ -214,7 +214,7 @@ static BOOL test_lockread(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
const char *test_data = "TEST DATA";
uint_t seed = time(NULL);
buf = talloc_zero(mem_ctx, maxsize);
buf = talloc_zero_size(mem_ctx, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
return False;
@ -357,7 +357,7 @@ static BOOL test_readx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
const char *test_data = "TEST DATA";
uint_t seed = time(NULL);
buf = talloc_zero(mem_ctx, maxsize);
buf = talloc_zero_size(mem_ctx, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
return False;
@ -551,7 +551,7 @@ static BOOL test_readbraw(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
const char *test_data = "TEST DATA";
uint_t seed = time(NULL);
buf = talloc_zero(mem_ctx, maxsize);
buf = talloc_zero_size(mem_ctx, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
return False;

View File

@ -960,9 +960,9 @@ static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
smbcli_close(cli->tree, fnum);
}
file = talloc_zero_array_p(mem_ctx, union smb_search_data, num_dirs);
file2 = talloc_zero_array_p(mem_ctx, union smb_search_data, num_dirs);
file3 = talloc_zero_array_p(mem_ctx, union smb_search_data, num_dirs);
file = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
file2 = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
file3 = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
printf("Search first on %d dirs\n", num_dirs);

View File

@ -104,7 +104,7 @@ static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
uint_t seed = time(NULL);
union smb_fileinfo finfo;
buf = talloc_zero(mem_ctx, maxsize);
buf = talloc_zero_size(mem_ctx, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
return False;
@ -221,7 +221,7 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
uint_t seed = time(NULL);
union smb_fileinfo finfo;
buf = talloc_zero(mem_ctx, maxsize);
buf = talloc_zero_size(mem_ctx, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
return False;
@ -397,7 +397,7 @@ static BOOL test_writeunlock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
uint_t seed = time(NULL);
union smb_fileinfo finfo;
buf = talloc_zero(mem_ctx, maxsize);
buf = talloc_zero_size(mem_ctx, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
return False;
@ -534,7 +534,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
uint_t seed = time(NULL);
union smb_fileinfo finfo;
buf = talloc_zero(mem_ctx, maxsize);
buf = talloc_zero_size(mem_ctx, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
return False;

View File

@ -878,7 +878,7 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa
TEST_SEC_DESC_EQUAL(account->sdbuf, lsa, &acct_handle);
found_priv_in_lsa = talloc_zero_array_p(mem_ctx, BOOL, account->privilege_entries);
found_priv_in_lsa = talloc_zero_array(mem_ctx, BOOL, account->privilege_entries);
e.in.handle = &acct_handle;

View File

@ -367,7 +367,7 @@ static BOOL test_QueryMultipleValues(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.num_values = 1;
r.in.buffer_size = r.out.buffer_size = talloc_p(mem_ctx, uint32);
*r.in.buffer_size = 0x20;
r.in.buffer = r.out.buffer = talloc_zero_array_p(mem_ctx, uint8, *r.in.buffer_size);
r.in.buffer = r.out.buffer = talloc_zero_array(mem_ctx, uint8, *r.in.buffer_size);
status = dcerpc_winreg_QueryMultipleValues(p, mem_ctx, &r);
if(NT_STATUS_IS_ERR(status)) {

View File

@ -146,7 +146,7 @@ static void show_functions(const struct dcerpc_interface_table *p)
mem_ctx = talloc_init("ndrdump");
st = talloc_zero(mem_ctx, f->struct_size);
st = talloc_zero_size(mem_ctx, f->struct_size);
if (!st) {
printf("Unable to allocate %d bytes\n", f->struct_size);
exit(1);