summaryrefslogtreecommitdiff
path: root/source3/rpc_parse
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-03 21:51:29 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-03 21:51:29 +0000
commitdc963d7939c9f4f5f7850f9c92385c5484df51bb (patch)
tree3277d540441186c5219c5a65d93588012b9299a8 /source3/rpc_parse
parent59a7e6cef89a9bd519df64978f8c8f113d66d0ef (diff)
downloadsamba-dc963d7939c9f4f5f7850f9c92385c5484df51bb.tar.gz
samba-dc963d7939c9f4f5f7850f9c92385c5484df51bb.tar.bz2
samba-dc963d7939c9f4f5f7850f9c92385c5484df51bb.zip
dynamic mem allocation in net_srv_transport_enum() parsing.
(This used to be commit 6b919ebb4ed8c0082d8bffb299766bff9e718faf)
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r--source3/rpc_parse/parse_srv.c64
1 files changed, 60 insertions, 4 deletions
diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c
index c27f58ac26..c0530f8987 100644
--- a/source3/rpc_parse/parse_srv.c
+++ b/source3/rpc_parse/parse_srv.c
@@ -1207,13 +1207,25 @@ static BOOL srv_io_srv_tprt_info_0(char *desc, SRV_TPRT_INFO_0 *tp0, prs_struct
{
uint32 i;
uint32 num_entries = tp0->num_entries_read;
- if (num_entries > MAX_TPRT_ENTRIES)
- {
- num_entries = MAX_TPRT_ENTRIES; /* report this! */
- }
prs_uint32("num_entries_read2", ps, depth, &(tp0->num_entries_read2));
+ if (ps->io)
+ {
+ /* reading */
+ tp0->info_0 = (TPRT_INFO_0*)malloc(num_entries *
+ sizeof(tp0->info_0[0]));
+
+ tp0->info_0_str = (TPRT_INFO_0_STR*)malloc(num_entries *
+ sizeof(tp0->info_0_str[0]));
+
+ if (tp0->info_0 == NULL || tp0->info_0_str == NULL)
+ {
+ free_srv_tprt_info_0(tp0);
+ return False;
+ }
+ }
+
for (i = 0; i < num_entries; i++)
{
prs_grow(ps);
@@ -1231,10 +1243,33 @@ static BOOL srv_io_srv_tprt_info_0(char *desc, SRV_TPRT_INFO_0 *tp0, prs_struct
prs_align(ps);
}
+ if (!ps->io)
+ {
+ /* writing */
+ free_srv_tprt_info_0(tp0);
+ }
+
return True;
}
/*******************************************************************
+frees a structure.
+********************************************************************/
+void free_srv_tprt_info_0(SRV_TPRT_INFO_0 *tp0)
+{
+ if (tp0->info_0 != NULL)
+ {
+ free(tp0->info_0);
+ tp0->info_0 = NULL;
+ }
+ if (tp0->info_0_str != NULL)
+ {
+ free(tp0->info_0_str);
+ tp0->info_0_str = NULL;
+ }
+}
+
+/*******************************************************************
reads or writes a structure.
********************************************************************/
static BOOL srv_io_srv_tprt_ctr(char *desc, SRV_TPRT_INFO_CTR *ctr, prs_struct *ps, int depth)
@@ -1273,6 +1308,27 @@ static BOOL srv_io_srv_tprt_ctr(char *desc, SRV_TPRT_INFO_CTR *ctr, prs_struct
/*******************************************************************
reads or writes a structure.
********************************************************************/
+void free_srv_tprt_ctr(SRV_TPRT_INFO_CTR *ctr)
+{
+ switch (ctr->switch_value)
+ {
+ case 0:
+ {
+ free_srv_tprt_info_0(&(ctr->tprt.info0));
+ break;
+ }
+ default:
+ {
+ DEBUG(5,("no transport info at switch_value %d\n",
+ ctr->switch_value));
+ break;
+ }
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
BOOL make_srv_q_net_tprt_enum(SRV_Q_NET_TPRT_ENUM *q_n,
char *srv_name,
uint32 tprt_level, SRV_TPRT_INFO_CTR *ctr,