r2671: we're getting too many errors caused by the talloc_realloc() API not
authorAndrew Tridgell <tridge@samba.org>
Mon, 27 Sep 2004 01:36:19 +0000 (01:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:20 +0000 (12:59 -0500)
taking a context (so when you pass a NULL pointer you end up with
memory in a top level context). Fixed it by changing the API to take a
context. The context is only used if the pointer you are reallocing is
NULL.
(This used to be commit 8dc23821c9f54b2f13049b5e608a0cafb81aa540)

30 files changed:
source4/include/talloc.h
source4/lib/charcnv.c
source4/lib/registry/common/reg_interface.c
source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c
source4/lib/socket/socket_ipv4.c
source4/lib/talloc.c
source4/lib/util_str.c
source4/libcli/auth/spnego_parse.c
source4/libcli/clilist.c
source4/libcli/ldap/ldap.c
source4/libcli/ldap/ldap_ldif.c
source4/libcli/raw/raweas.c
source4/libcli/raw/rawfileinfo.c
source4/libcli/raw/rawrequest.c
source4/libcli/util/asn1.c
source4/librpc/ndr/ndr.c
source4/librpc/rpc/dcerpc.c
source4/librpc/rpc/dcerpc_smb.c
source4/librpc/rpc/dcerpc_tcp.c
source4/ntvfs/ipc/ipc_rap.c
source4/ntvfs/ntvfs_base.c
source4/ntvfs/posix/pvfs_dirlist.c
source4/ntvfs/simple/svfs.h
source4/ntvfs/simple/svfs_util.c
source4/rpc_server/dcerpc_server.c
source4/rpc_server/epmapper/rpc_epmapper.c
source4/smb_server/request.c
source4/smb_server/trans2.c
source4/torture/rap/rap.c
source4/torture/raw/search.c

index e329bdb308a3c1a90eb4bcf3f6cc0aa47651a71c..635f77d043475b59b94cee46fe87f0c0711c0fc7 100644 (file)
@@ -34,10 +34,10 @@ typedef void TALLOC_CTX;
 
 /* useful macros for creating type checked pointers */
 #define talloc(ctx, size) talloc_named_const(ctx, size, __location__)
-#define talloc_realloc(ptr, size) _talloc_realloc(ptr, 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_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__)
-#define talloc_realloc_p(p, type, count) (type *)talloc_realloc_array(p, sizeof(type), count, __location__)
+#define talloc_realloc_p(ctx, p, type, count) (type *)talloc_realloc_array(ctx, p, sizeof(type), count, __location__)
 #define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)
 
 #define talloc_destroy(ctx) talloc_free(ctx)
index 2ee2bd9baeed96358acfc42b7d5a596f6fff72eb..33c49504d85188da58d00915b2aa3d28cfed02a9 100644 (file)
@@ -208,11 +208,7 @@ ssize_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
        outbuf = NULL;
 convert:
        destlen = destlen * 2;
-       if (outbuf == NULL) {
-               ob = talloc_array_p(ctx, char, destlen);
-       } else {
-               ob = (char *)talloc_realloc(outbuf, destlen);
-       }
+       ob = (char *)talloc_realloc(ctx, outbuf, destlen);
        if (!ob) {
                DEBUG(0, ("convert_string_talloc: realloc failed!\n"));
                talloc_free(outbuf);
@@ -245,7 +241,7 @@ convert:
        
        destlen = destlen - o_len;
        /* +2 for mandetory null termination, UTF8 or UTF16 */
-       *dest = (char *)talloc_realloc(ob,destlen+2);
+       *dest = (char *)talloc_realloc(ctx, ob, destlen+2);
        if (!*dest) {
                DEBUG(0, ("convert_string_talloc: out of memory!\n"));
                talloc_free(ob);
index ec6188be71f70b28999e31b21131bc78842242de..ba92369194c998e374054bfaed141b6d3a732766 100644 (file)
@@ -190,7 +190,7 @@ WERROR reg_import_hive(struct registry_context *h, const char *backend, const ch
 
        /* Add hive to context */
        h->num_hives++;
-       h->hives = talloc_realloc_p(h->hives, struct registry_hive *, h->num_hives);
+       h->hives = talloc_realloc_p(h, h->hives, struct registry_hive *, h->num_hives);
        h->hives[h->num_hives-1] = ret;
 
        return WERR_OK;
index 1c887fc411e1f6c426f3dcfb885df041729428b6..3dd73162be669d17f78c08e2d4c6a94e852e484c 100644 (file)
@@ -90,7 +90,7 @@ WERROR rpc_list_hives (TALLOC_CTX *mem_ctx, const char *location, const char *cr
        int i = 0;
        *hives = talloc_p(mem_ctx, char *);
        for(i = 0; known_hives[i].name; i++) {
-               *hives = talloc_realloc_p(*hives, char *, i+2);
+               *hives = talloc_realloc_p(mem_ctx, *hives, char *, i+2);
                (*hives)[i] = talloc_strdup(mem_ctx, known_hives[i].name);
        }
        (*hives)[i] = NULL;
index c98e5534ca4f449c629ef77a43231d6c0ee63026..88bf611b67aeed065faf6e8d1c064fa5566ccc43 100644 (file)
@@ -184,7 +184,7 @@ static NTSTATUS ipv4_tcp_accept(struct socket_context *sock, struct socket_conte
 }
 
 static NTSTATUS ipv4_tcp_recv(struct socket_context *sock, TALLOC_CTX *mem_ctx,
-                                       DATA_BLOB *blob, size_t wantlen, uint32_t flags)
+                             DATA_BLOB *blob, size_t wantlen, uint32_t flags)
 {
        ssize_t gotlen;
        void *buf;
@@ -235,7 +235,7 @@ static NTSTATUS ipv4_tcp_recv(struct socket_context *sock, TALLOC_CTX *mem_ctx,
        }
 
        blob->length = gotlen;
-       blob->data = talloc_realloc(buf, gotlen);
+       blob->data = talloc_realloc(mem_ctx, buf, gotlen);
        if (!blob->data) {
                return NT_STATUS_NO_MEMORY;
        }
index 8193f9c384d967b60471049a85a1a20949804b8b..7266ff8a45f16cc6a00a86391084437afe8ae6c1 100644 (file)
@@ -287,9 +287,10 @@ int talloc_free(void *ptr)
 
 
 /*
-  A talloc version of realloc 
+  A talloc version of realloc. The context argument is only used if
+  ptr is NULL
 */
-void *_talloc_realloc(void *ptr, size_t size, const char *name)
+void *_talloc_realloc(void *context, void *ptr, size_t size, const char *name)
 {
        struct talloc_chunk *tc;
        void *new_ptr;
@@ -302,7 +303,7 @@ void *_talloc_realloc(void *ptr, size_t size, const char *name)
 
        /* realloc(NULL) is equavalent to malloc() */
        if (ptr == NULL) {
-               return talloc_named_const(NULL, size, name);
+               return talloc_named_const(context, size, name);
        }
 
        tc = talloc_chunk_from_ptr(ptr);
@@ -550,7 +551,7 @@ static char *talloc_vasprintf_append(char *s,
                                     const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
 
 static char *talloc_vasprintf_append(char *s,
-                             const char *fmt, va_list ap)
+                                    const char *fmt, va_list ap)
 {      
        int len, s_len;
        va_list ap2;
@@ -564,7 +565,7 @@ static char *talloc_vasprintf_append(char *s,
        }
        len = vsnprintf(NULL, 0, fmt, ap2);
 
-       s = talloc_realloc(s, s_len + len+1);
+       s = talloc_realloc(NULL, s, s_len + len+1);
        if (!s) return NULL;
 
        VA_COPY(ap2, ap);
@@ -607,13 +608,13 @@ void *talloc_array(void *ctx, size_t el_size, uint_t count, const char *name)
 /*
   realloc an array, checking for integer overflow in the array size
 */
-void *talloc_realloc_array(void *ptr, size_t el_size, uint_t count, const char *name)
+void *talloc_realloc_array(void *ctx, void *ptr, size_t el_size, uint_t count, const char *name)
 {
        if (count == 0 ||
            count >= MAX_TALLOC_SIZE/el_size) {
                return NULL;
        }
-       ptr = talloc_realloc(ptr, el_size * count);
+       ptr = talloc_realloc(ctx, ptr, el_size * count);
        if (ptr) {
                talloc_set_name_const(ptr, name);
        }
@@ -632,5 +633,5 @@ void *talloc_ldb_alloc(void *context, void *ptr, size_t size)
                talloc_free(ptr);
                return NULL;
        }
-       return talloc_realloc(ptr, size);
+       return talloc_realloc(context, ptr, size);
 }
index f8aadf8f592773a45205e0d0afcaa978a0c3b173..0e58face16182a927883ebc1b6bac9740f8fa509 100644 (file)
@@ -1428,8 +1428,9 @@ BOOL add_string_to_array(TALLOC_CTX *mem_ctx,
 {
        char *dup_str = talloc_strdup(mem_ctx, str);
 
-       *strings = talloc_realloc(*strings,
-                                 ((*num)+1) * sizeof(**strings));
+       *strings = talloc_realloc_p(mem_ctx,
+                                   *strings,
+                                   const char *, ((*num)+1));
 
        if ((*strings == NULL) || (dup_str == NULL))
                return False;
index 20b766a4e23b9c0e91a131636081a475ea55956c..07dba61ddefaf04ab585a2bc68665a29cd0172a2 100644 (file)
@@ -51,7 +51,7 @@ static BOOL read_negTokenInit(ASN1_DATA *asn1, struct spnego_negTokenInit *token
                        for (i = 0; !asn1->has_error &&
                                     0 < asn1_tag_remaining(asn1); i++) {
                                token->mechTypes = 
-                                       talloc_realloc(token->mechTypes, (i + 2) *
+                                       talloc_realloc(NULL, token->mechTypes, (i + 2) *
                                                       sizeof(*token->mechTypes));
                                asn1_read_OID(asn1, token->mechTypes + i);
                                if (token->mechTypes[i]) {
index 529d4f81a363c9aa7043fde3820628569c12477c..2659e8141990c3070e654aec176d258f26943775 100644 (file)
@@ -83,7 +83,8 @@ static BOOL smbcli_list_new_callback(void *private, union smb_search_data *file)
        file_info *tdl;
  
        /* add file info to the dirlist pool */
-       tdl = talloc_realloc(state->dirlist,
+       tdl = talloc_realloc(state, 
+                            state->dirlist,
                             state->dirlist_len + sizeof(struct file_info));
 
        if (!tdl) {
@@ -225,7 +226,8 @@ static BOOL smbcli_list_old_callback(void *private, union smb_search_data *file)
        file_info *tdl;
        
        /* add file info to the dirlist pool */
-       tdl = talloc_realloc(state->dirlist,
+       tdl = talloc_realloc(state,
+                            state->dirlist,
                             state->dirlist_len + sizeof(struct file_info));
 
        if (!tdl) {
index a94a4f2f30449d75d50f7d6b5bdff372d0c29098..af21962265aff110076c2506d7e8f5b66a3f716c 100644 (file)
@@ -179,9 +179,10 @@ static struct ldap_parse_tree *ldap_parse_filterlist(TALLOC_CTX *mem_ctx,
 
        while (*s && (next = ldap_parse_filter(mem_ctx, &s))) {
                struct ldap_parse_tree **e;
-               e = talloc_realloc(ret->u.list.elements,
-                                  sizeof(struct ldap_parse_tree) *
-                                  (ret->u.list.num_elements+1));
+               e = talloc_realloc_p(ret,
+                                    ret->u.list.elements,
+                                    struct ldap_parse_tree *,
+                                    ret->u.list.num_elements+1);
                if (!e) {
                        errno = ENOMEM;
                        return NULL;
index 2ec3b827ceb188051d07de61349cbaccba8d0cbc..8fe50b6d0846082d9e1a82d12fb56d012d5904c2 100644 (file)
@@ -51,7 +51,7 @@ static char *next_chunk(TALLOC_CTX *mem_ctx,
                if (chunk_size+1 >= alloc_size) {
                        char *c2;
                        alloc_size += 1024;
-                       c2 = talloc_realloc(chunk, alloc_size);
+                       c2 = talloc_realloc(mem_ctx, chunk, alloc_size);
                        if (!c2) {
                                errno = ENOMEM;
                                return NULL;
@@ -156,11 +156,12 @@ static int next_attr(char **s, const char **attr, struct ldap_val *value)
 }
 
 BOOL add_value_to_attrib(TALLOC_CTX *mem_ctx, struct ldap_val *value,
-                               struct ldap_attribute *attrib)
+                        struct ldap_attribute *attrib)
 {
-       attrib->values = talloc_realloc(attrib->values,
-                                       sizeof(*attrib->values) *
-                                       (attrib->num_values+1));
+       attrib->values = talloc_realloc_p(mem_ctx, 
+                                         attrib->values,
+                                         DATA_BLOB,
+                                         attrib->num_values+1);
        if (attrib->values == NULL)
                return False;
 
@@ -175,8 +176,10 @@ BOOL add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
                                       struct ldap_attribute **attribs,
                                       int *num_attribs)
 {
-       *attribs = talloc_realloc(*attribs,
-                                 sizeof(**attribs) * (*num_attribs+1));
+       *attribs = talloc_realloc_p(mem_ctx,
+                                   *attribs,
+                                   struct ldap_attribute,
+                                   *num_attribs+1);
 
        if (*attribs == NULL)
                return False;
@@ -207,9 +210,10 @@ static BOOL fill_add_attributes(struct ldap_message *msg, char **chunk)
                }
 
                if (attrib == NULL) {
-                       r->attributes = talloc_realloc(r->attributes,
-                                                      sizeof(*r->attributes) *
-                                                      (r->num_attributes+1));
+                       r->attributes = talloc_realloc_p(msg->mem_ctx,
+                                                        r->attributes,
+                                                        struct ldap_attribute,
+                                                        r->num_attributes+1);
                        if (r->attributes == NULL)
                                return False;
 
@@ -231,8 +235,7 @@ BOOL add_mod_to_array_talloc(TALLOC_CTX *mem_ctx,
                                    struct ldap_mod **mods,
                                    int *num_mods)
 {
-       *mods = talloc_realloc(*mods,
-                              sizeof(**mods) * ((*num_mods)+1));
+       *mods = talloc_realloc_p(mem_ctx, *mods, struct ldap_mod, (*num_mods)+1);
 
        if (*mods == NULL)
                return False;
index d78f10fe1a512e739ac2dc6b1285c446afc72bf5..e07fbcd2884d0452f6ac6eedaf9be993078ace08 100644 (file)
@@ -128,7 +128,7 @@ NTSTATUS ea_pull_list(const DATA_BLOB *blob,
                blob2.data = blob->data + ofs;
                blob2.length = ea_size - ofs;
 
-               *eas = talloc_realloc(*eas, sizeof(**eas) * (n+1));
+               *eas = talloc_realloc(mem_ctx, *eas, sizeof(**eas) * (n+1));
                if (! *eas) return NT_STATUS_NO_MEMORY;
 
                len = ea_pull_struct(&blob2, mem_ctx, &(*eas)[n]);
index aac8f2657bf2582659682b5e910247a48f805f8f..cbb666b7ce0ae0f53e3b5dd2c44173f6677228ea 100644 (file)
@@ -174,8 +174,10 @@ static NTSTATUS smb_raw_info_backend(struct smbcli_session *session,
                while (blob->length - ofs >= 24) {
                        uint_t n = parms->stream_info.out.num_streams;
                        parms->stream_info.out.streams = 
-                               talloc_realloc(parms->stream_info.out.streams,
-                                              (n+1) * sizeof(parms->stream_info.out.streams[0]));
+                               talloc_realloc_p(mem_ctx,
+                                                parms->stream_info.out.streams,
+                                                struct stream_struct,
+                                                n+1);
                        if (!parms->stream_info.out.streams) {
                                return NT_STATUS_NO_MEMORY;
                        }
index a94e79662846bd4e523653a31836cf5840bd09c7..a15d681a5c743b0131cf68e145b8d8d92cb7d7ae 100644 (file)
@@ -213,7 +213,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->out.buffer, req->out.allocated);
+       buf2 = talloc_realloc(req, req->out.buffer, req->out.allocated);
        if (buf2 == NULL) {
                smb_panic("out of memory in req_grow_allocation");
        }
@@ -911,7 +911,7 @@ size_t smbcli_blob_append_string(struct smbcli_session *session,
 
        max_len = (strlen(str)+2) * MAX_BYTES_PER_CHAR;         
 
-       blob->data = talloc_realloc(blob->data, blob->length + max_len);
+       blob->data = talloc_realloc(mem_ctx, blob->data, blob->length + max_len);
        if (!blob->data) {
                return 0;
        }
index 3dc5abc09ae18779003a9e48d2d9cdbd733fe61d..4ff335399a715ac36a42c01cec83b460cf667b3f 100644 (file)
@@ -32,7 +32,7 @@ BOOL asn1_write(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(data->data, data->ofs+len);
+               newp = talloc_realloc(NULL, data->data, data->ofs+len);
                if (!newp) {
                        asn1_free(data);
                        data->has_error = True;
index 13c74121a6ca635ccc2d365f117ae14c77ecf4a5..959616fc787a8d8a8601e87692d2f2c4ef5218b9 100644 (file)
@@ -179,7 +179,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->data, ndr->alloc_size);
+       ndr->data = talloc_realloc(ndr, ndr->data, ndr->alloc_size);
        if (!ndr->data) {
                return ndr_push_error(ndr, NDR_ERR_ALLOC, "Failed to push_expand to %u",
                                      ndr->alloc_size);
index 352db37d2be56bafc43e379598595a23fda4f9bd..d41eebbf2fa47385eeaf1ed11d5e763a4ac1798b 100644 (file)
@@ -781,7 +781,8 @@ static void dcerpc_request_recv_data(struct dcerpc_pipe *p,
        length = pkt.u.response.stub_and_verifier.length;
 
        if (length > 0) {
-               req->payload.data = talloc_realloc(req->payload.data, 
+               req->payload.data = talloc_realloc(req, 
+                                                  req->payload.data, 
                                                   req->payload.length + length);
                if (!req->payload.data) {
                        req->status = NT_STATUS_NO_MEMORY;
index 09c5f3772ce58c144d371033001815fe157a8d99..7000bcd20d5c4751e50af49986d34f1bd3cfd9c3 100644 (file)
@@ -92,7 +92,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->data.data, frag_length);
+       state->data.data = talloc_realloc(state, state->data.data, frag_length);
 
        io->readx.in.mincnt = MIN(state->p->srv_max_xmit_frag, 
                                  frag_length - state->received);
index acf3d58262e4a2f85b28797dd9e80adacf6325a2..6940c7705d3e4381684b5c4903c7ddceffa06dd2 100644 (file)
@@ -141,7 +141,7 @@ static void tcp_process_recv(struct dcerpc_pipe *p)
                }
                frag_length = dcerpc_get_frag_length(&tcp->recv.data);
 
-               tcp->recv.data.data = talloc_realloc(tcp->recv.data.data,
+               tcp->recv.data.data = talloc_realloc(tcp, tcp->recv.data.data,
                                                     frag_length);
                if (tcp->recv.data.data == NULL) {
                        tcp_sock_dead(p, NT_STATUS_NO_MEMORY);
index 32b2fa2181b77553ca838653ca8ba99d3509b959..840c389d6cf1a54a5e521ba35de26bde9edfac4f 100644 (file)
@@ -178,9 +178,10 @@ static NTSTATUS rap_push_string(struct ndr_push *data_push,
        NDR_CHECK(ndr_push_uint16(data_push, heap->offset));
        NDR_CHECK(ndr_push_uint16(data_push, 0));
 
-       heap->strings = talloc_realloc(heap->strings,
-                                      sizeof(*heap->strings) *
-                                      (heap->num_strings + 1));
+       heap->strings = talloc_realloc_p(heap->mem_ctx,
+                                        heap->strings,
+                                        const char *,
+                                        heap->num_strings + 1);
 
        if (heap->strings == NULL)
                return NT_STATUS_NO_MEMORY;
index 03873ce6973571195c20606942072da0896018bc..72f4759cd5637cd5d2717556275d76fc5d9fd0bc 100644 (file)
@@ -153,11 +153,8 @@ NTSTATUS ntvfs_init_connection(struct smbsrv_request *req)
 */
 void ntvfs_set_private(struct smbsrv_tcon *tcon, int depth, void *value)
 {
-       if (!tcon->ntvfs_private_list) {
-               tcon->ntvfs_private_list = talloc_array_p(tcon, void *, depth+1);
-       } else {
-               tcon->ntvfs_private_list = talloc_realloc_p(tcon->ntvfs_private_list, 
-                                                           void *, depth+1);
-       }
+       tcon->ntvfs_private_list = talloc_realloc_p(tcon, 
+                                                   tcon->ntvfs_private_list, 
+                                                   void *, depth+1);
        tcon->ntvfs_private_list[depth] = value;
 }
index 0137424dc4dc55a8a9270779c491640f36c50e62..85c307a1b287485e26215892379aa9493957b915 100644 (file)
@@ -89,11 +89,6 @@ NTSTATUS pvfs_list(struct pvfs_state *pvfs, struct pvfs_filename *name, struct p
                return NT_STATUS_NO_MEMORY;
        }
        
-       dir->names = talloc(dir, 0);
-       if (!dir->names) {
-               return NT_STATUS_NO_MEMORY;
-       }
-
        odir = opendir(name->full_name);
        if (!odir) { 
                return pvfs_map_errno(pvfs, errno); 
@@ -110,7 +105,7 @@ NTSTATUS pvfs_list(struct pvfs_state *pvfs, struct pvfs_filename *name, struct p
                
                if (dir->count >= allocated) {
                        allocated = (allocated + 100) * 1.2;
-                       dir->names = talloc_realloc_p(dir->names, const char *, allocated);
+                       dir->names = talloc_realloc_p(dir, dir->names, const char *, allocated);
                        if (!dir->names) { 
                                closedir(odir);
                                return NT_STATUS_NO_MEMORY;
index 33b7cb7011e96176091532ad8313b8620610d60b..d3bafb42e37f87896ee1e67750379549c60886b1 100644 (file)
@@ -17,7 +17,7 @@ struct svfs_private {
 struct svfs_dir {
        uint_t count;
        char *unix_dir;
-       struct {
+       struct svfs_dirfile {
                char *name;
                struct stat st;
        } *files;
index 2e64920fc87fa6c9acfe7549c5adeb044eae40d0..b6b71714870cfaff47cd06d0e6790e86982b545e 100644 (file)
@@ -61,7 +61,7 @@ struct svfs_dir *svfs_list_unix(TALLOC_CTX *mem_ctx, struct smbsrv_request *req,
        uint_t allocated = 0;
        char *low_mask;
 
-       dir = talloc(mem_ctx, sizeof(struct svfs_dir));
+       dir = talloc_p(mem_ctx, struct svfs_dir);
        if (!dir) { return NULL; }
 
        dir->count = 0;
@@ -105,7 +105,7 @@ struct svfs_dir *svfs_list_unix(TALLOC_CTX *mem_ctx, struct smbsrv_request *req,
                
                if (dir->count >= allocated) {
                        allocated = (allocated + 100) * 1.2;
-                       dir->files = talloc_realloc(dir->files, allocated * sizeof(dir->files[0]));
+                       dir->files = talloc_realloc_p(dir, dir->files, struct svfs_dirfile, allocated);
                        if (!dir->files) { 
                                closedir(odir);
                                return NULL;
index 46029ce8dc564076d984f3818cd3a6345a0f2159..5ab434baed4374c46b7915b06d8fc8c08a0b152a 100644 (file)
@@ -819,7 +819,7 @@ NTSTATUS dcesrv_input_process(struct dcesrv_connection *dce_conn)
                }
 
                call->pkt.u.request.stub_and_verifier.data = 
-                       talloc_realloc(call->pkt.u.request.stub_and_verifier.data, alloc_size);
+                       talloc_realloc(call, call->pkt.u.request.stub_and_verifier.data, alloc_size);
                if (!call->pkt.u.request.stub_and_verifier.data) {
                        return dcesrv_fault(call2, DCERPC_FAULT_OTHER);
                }
@@ -874,7 +874,8 @@ NTSTATUS dcesrv_input(struct dcesrv_connection *dce_conn, const DATA_BLOB *data)
 {
        NTSTATUS status;
 
-       dce_conn->partial_input.data = talloc_realloc(dce_conn->partial_input.data,
+       dce_conn->partial_input.data = talloc_realloc(dce_conn,
+                                                     dce_conn->partial_input.data,
                                                      dce_conn->partial_input.length + data->length);
        if (!dce_conn->partial_input.data) {
                return NT_STATUS_NO_MEMORY;
index 37f1c372e08af67e53f14ad07651af6b49b43c84..54a996e82a92e689f2573a1bed363efc07add71b 100644 (file)
@@ -123,13 +123,14 @@ static uint32_t build_ep_list(TALLOC_CTX *mem_ctx,
        struct dcesrv_endpoint *d;
        uint32_t total = 0;
 
-       (*eps) = talloc(mem_ctx, 0);
-       
+       *eps = NULL;
+
        for (d=endpoint_list; d; d=d->next) {
                struct dcesrv_if_list *iface;
 
                for (iface=d->interface_list;iface;iface=iface->next) {
-                       (*eps) = talloc_realloc_p(*eps, 
+                       (*eps) = talloc_realloc_p(mem_ctx, 
+                                                 *eps, 
                                                  struct dcesrv_ep_iface,
                                                  total + 1);
                        if (!*eps) {
index 3d78c0a55da5d16dabf7ad05f3bbe906163fcf0b..5c1694f18a4b696b095b6e68491c6ee1a837d4c7 100644 (file)
@@ -72,7 +72,7 @@ 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->out.buffer, req->out.allocated);
+       req->out.buffer = talloc_realloc(req, req->out.buffer, req->out.allocated);
        if (!req->out.buffer) {
                smbsrv_terminate_connection(req->smb_conn, "allocation failed");
        }
@@ -186,7 +186,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->out.buffer, req->out.allocated);
+       buf2 = talloc_realloc(req, req->out.buffer, req->out.allocated);
        if (buf2 == NULL) {
                smb_panic("out of memory in req_grow_allocation");
        }
index e681c9fe2998affb5b1985396262f05da204f7cc..34e79061df6184af29d7ad5f701876f751f38d65 100644 (file)
@@ -39,7 +39,7 @@ static void trans2_grow_data_allocation(struct smbsrv_request *req,
        if (new_size <= trans->out.data.length) {
                return;
        }
-       trans->out.data.data = talloc_realloc(trans->out.data.data, new_size);
+       trans->out.data.data = talloc_realloc(req, trans->out.data.data, new_size);
 }
 
 
index 7dc9e7fcbcbea8831097aa985426b201f46f0710..407aadbc0eacb465e6898d102277994cc2afa3b7 100644 (file)
@@ -79,7 +79,8 @@ static void rap_cli_push_paramdesc(struct rap_call *call, char desc)
        if (call->paramdesc != NULL)
                len = strlen(call->paramdesc);
 
-       call->paramdesc = talloc_realloc(call->paramdesc,
+       call->paramdesc = talloc_realloc(call->mem_ctx,
+                                        call->paramdesc,
                                         len+2);
        call->paramdesc[len] = desc;
        call->paramdesc[len+1] = '\0';
index d0873e2ef434b0583a30fd60f0afe2f40928c0a8..e5c682575c746f7d148aa36f2d5e948e203c0407 100644 (file)
@@ -410,8 +410,10 @@ static BOOL multiple_search_callback(void *private, union smb_search_data *file)
 
 
        data->count++;
-       data->list = talloc_realloc(data->list, 
-                                   data->count * (sizeof(data->list[0])));
+       data->list = talloc_realloc_p(data->mem_ctx,
+                                     data->list, 
+                                     union smb_search_data,
+                                     data->count);
 
        data->list[data->count-1] = *file;