summaryrefslogtreecommitdiff
path: root/source3/include
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-07-27 00:47:19 +0000
committerJeremy Allison <jra@samba.org>2000-07-27 00:47:19 +0000
commit5ec1642809d9de83da8c88c65d6595c6eb0270f5 (patch)
treef6f4f1e0b3678394fca8b7c37f71084a1b166671 /source3/include
parent134a4b86548db77cba292c50fbd6b91ecaa69f14 (diff)
downloadsamba-5ec1642809d9de83da8c88c65d6595c6eb0270f5.tar.gz
samba-5ec1642809d9de83da8c88c65d6595c6eb0270f5.tar.bz2
samba-5ec1642809d9de83da8c88c65d6595c6eb0270f5.zip
Ok - this is a *BIG* change - but it fixes the problems with static strings
in the RPC code. This change was prompted by trying to save a long (>256) character comment in the printer properties page. The new system associates a TALLOC_CTX with the pipe struct, and frees the pool on return of a complete PDU. A global TALLOC_CTX is used for the odd buffer allocated in the BUFFERxx code, and is freed in the main loop. This code works with insure, and seems to be free of memory leaks and crashes (so far) but there are probably the occasional problem with code that uses UNISTRxx structs on the stack and expects them to contain storage without doing a init_unistrXX(). This means that rpcclient will probably be horribly broken. A TALLOC_CTX also needed associating with the struct cli_state also, to make the prs_xx code there work. The main interface change is the addition of a TALLOC_CTX to the prs_init calls - used for dynamic allocation in the prs_XXX calls. Now this is in place it should make dynamic allocation of all RPC memory on unmarshall *much* easier to fix. Jeremy. (This used to be commit 0ff2ce543ee54f7364e6d839db6d06e7ef1edcf4)
Diffstat (limited to 'source3/include')
-rw-r--r--source3/include/client.h2
-rw-r--r--source3/include/ntdomain.h26
-rw-r--r--source3/include/proto.h11
-rw-r--r--source3/include/rpc_misc.h10
-rw-r--r--source3/include/talloc.h3
5 files changed, 32 insertions, 20 deletions
diff --git a/source3/include/client.h b/source3/include/client.h
index 625277d856..748c7375e1 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -107,6 +107,8 @@ struct cli_state {
int win95;
uint32 capabilities;
+ TALLOC_CTX *mem_ctx;
+
/*
* Only used in NT domain calls.
*/
diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index fe6704c2ad..7a47f6150e 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -33,6 +33,8 @@
#include "rpc_creds.h"
+#include "talloc.h"
+
/*
* A bunch of stuff that was put into smb.h
* in the NTDOM branch - it didn't belong there.
@@ -64,6 +66,7 @@ typedef struct _prs_struct
uint32 buffer_size; /* Current allocated size of the buffer. */
uint32 grow_size; /* size requested via prs_grow() calls */
char *data_p; /* The buffer itself. */
+ TALLOC_CTX *mem_ctx; /* When unmarshalling, use this.... */
} prs_struct;
/*
@@ -131,17 +134,17 @@ typedef struct _input_data {
struct msrpc_state
{
- fstring pipe_name;
- struct user_creds usr;
- struct ntdom_info nt;
+ fstring pipe_name;
+ struct user_creds usr;
+ struct ntdom_info nt;
- int fd;
- BOOL redirect;
- BOOL initialised;
- char *inbuf;
- char *outbuf;
+ int fd;
+ BOOL redirect;
+ BOOL initialised;
+ char *inbuf;
+ char *outbuf;
- uint32 pid;
+ uint32 pid;
};
typedef struct pipes_struct
@@ -208,9 +211,8 @@ typedef struct pipes_struct
data that can be sent in the initial reply. */
int max_trans_reply;
- /* remote, server-side rpc redirection */
- struct msrpc_state *m;
-
+ /* talloc context to use when allocating memory on this pipe. */
+ TALLOC_CTX *mem_ctx;
} pipes_struct;
struct api_struct
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9ea50db15e..b6fce9edaa 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -271,6 +271,7 @@ int sys_pclose(int fd);
TALLOC_CTX *talloc_init(void);
void *talloc(TALLOC_CTX *t, size_t size);
+void talloc_destroy_pool(TALLOC_CTX *t);
void talloc_destroy(TALLOC_CTX *t);
/*The following definitions come from lib/time.c */
@@ -1663,6 +1664,7 @@ BOOL parse_lpq_entry(int snum,char *line,
/*The following definitions come from printing/nt_printing.c */
+#if OLD_NTDOMAIN
BOOL nt_printing_init(void);
int get_ntforms(nt_forms_struct **list);
int write_ntforms(nt_forms_struct **list, int number);
@@ -1694,6 +1696,7 @@ uint32 nt_printing_setsec(char *printername, SEC_DESC_BUF *secdesc_ctr);
BOOL nt_printing_getsec(char *printername, SEC_DESC_BUF **secdesc_ctr);
BOOL print_access_check(struct current_user *user, int snum,
uint32 required_access);
+#endif
/*The following definitions come from printing/pcap.c */
@@ -2146,6 +2149,7 @@ BOOL lsa_io_r_close(char *desc, LSA_R_CLOSE *r_c, prs_struct *ps, int depth);
/*The following definitions come from rpc_parse/parse_misc.c */
+void parse_talloc_free(void);
BOOL smb_io_time(char *desc, NTTIME *nttime, prs_struct *ps, int depth);
BOOL smb_io_lookup_level(char *desc, LOOKUP_LEVEL *level, prs_struct *ps, int depth);
uint32 get_enum_hnd(ENUM_HND *enh);
@@ -2174,7 +2178,6 @@ void init_buffer3_hex(BUFFER3 *str, char *buf);
void init_buffer3_bytes(BUFFER3 *str, uint8 *buf, int len);
BOOL smb_io_buffer3(char *desc, BUFFER3 *buf3, prs_struct *ps, int depth);
BOOL smb_io_buffer5(char *desc, BUFFER5 *buf5, prs_struct *ps, int depth);
-void free_buffer5(BUFFER5 *buf5);
void init_buffer2(BUFFER2 *str, uint8 *buf, int len);
BOOL smb_io_buffer2(char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *ps, int depth);
void init_buf_unistr2(UNISTR2 *str, uint32 *ptr, const char *buf);
@@ -2294,9 +2297,11 @@ BOOL net_io_r_sam_logoff(char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int
void prs_dump(char *name, int v, prs_struct *ps);
void prs_debug(prs_struct *ps, int depth, char *desc, char *fn_name);
-BOOL prs_init(prs_struct *ps, uint32 size, uint8 align, BOOL io);
+BOOL prs_init(prs_struct *ps, uint32 size, uint8 align, TALLOC_CTX *ctx, BOOL io);
BOOL prs_read(prs_struct *ps, int fd, size_t len, int timeout);
void prs_mem_free(prs_struct *ps);
+char *prs_alloc_mem(prs_struct *ps, size_t size);
+TALLOC_CTX *prs_get_mem_context(prs_struct *ps);
void prs_give_memory(prs_struct *ps, char *buf, uint32 size, BOOL is_dynamic);
char *prs_take_memory(prs_struct *ps, uint32 *psize);
BOOL prs_set_buffer_size(prs_struct *ps, uint32 newsize);
@@ -2333,7 +2338,7 @@ BOOL prs_uint32_pre(char *name, prs_struct *ps, int depth, uint32 *data32, uint3
BOOL prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32,
uint32 ptr_uint32, uint32 data_size);
int tdb_prs_store(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps);
-int tdb_prs_fetch(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps);
+int tdb_prs_fetch(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps, TALLOC_CTX *mem_ctx);
/*The following definitions come from rpc_parse/parse_reg.c */
diff --git a/source3/include/rpc_misc.h b/source3/include/rpc_misc.h
index 5ef4044cb4..6e585e7a0e 100644
--- a/source3/include/rpc_misc.h
+++ b/source3/include/rpc_misc.h
@@ -125,7 +125,7 @@ typedef struct unihdr2_info
typedef struct unistr_info
{
/* unicode characters. ***MUST*** be little-endian. ***MUST*** be null-terminated */
- uint16 buffer[MAX_UNISTRLEN];
+ uint16 *buffer;
} UNISTR;
/* BUFHDR - buffer header */
@@ -145,7 +145,7 @@ typedef struct buffer2_info
uint32 undoc;
uint32 buf_len;
/* unicode characters. ***MUST*** be little-endian. **NOT** necessarily null-terminated */
- uint16 buffer[MAX_UNISTRLEN];
+ uint16 *buffer;
} BUFFER2;
@@ -153,7 +153,7 @@ typedef struct buffer2_info
typedef struct buffer3_info
{
uint32 buf_max_len;
- uint8 buffer[MAX_BUFFERLEN]; /* data */
+ uint8 *buffer; /* Data */
uint32 buf_len;
} BUFFER3;
@@ -172,7 +172,7 @@ typedef struct unistr2_info
uint32 undoc;
uint32 uni_str_len;
/* unicode characters. ***MUST*** be little-endian. **NOT** necessarily null-terminated */
- uint16 buffer[MAX_UNISTRLEN];
+ uint16 *buffer;
} UNISTR2;
@@ -182,7 +182,7 @@ typedef struct string2_info
uint32 str_max_len;
uint32 undoc;
uint32 str_str_len;
- uint8 buffer[MAX_STRINGLEN]; /* uint8 characters. **NOT** necessarily null-terminated */
+ uint8 *buffer; /* uint8 characters. **NOT** necessarily null-terminated */
} STRING2;
diff --git a/source3/include/talloc.h b/source3/include/talloc.h
index df68166a5e..a0dc3d9795 100644
--- a/source3/include/talloc.h
+++ b/source3/include/talloc.h
@@ -1,3 +1,5 @@
+#ifndef _TALLOC_H_
+#define _TALLOC_H_
/*
Unix SMB/Netbios implementation.
Version 3.0
@@ -30,3 +32,4 @@ typedef struct {
struct talloc_chunk *list;
} TALLOC_CTX;
+#endif