uint32 buffer2_to_uint32(const BUFFER2 *str);
void buffer2_to_multistr(char *dest, const BUFFER2 *str, size_t maxlen);
void buffer4_to_str(char *dest, const BUFFER4 *str, size_t maxlen);
+BOOL copy_unistr2(UNISTR2 *str, const UNISTR2 *from);
+UNISTR2 *unistr2_dup(const UNISTR2 *name);
+void unistr2_free(UNISTR2 *name);
/*The following definitions come from libsmb/clientgen.c */
BOOL make_buffer2(BUFFER2 *str, const char *buf, int len);
BOOL smb_io_buffer2(char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *ps, int depth);
BOOL make_buf_unistr2(UNISTR2 *str, uint32 *ptr, char *buf);
-BOOL copy_unistr2(UNISTR2 *str, const UNISTR2 *from);
-UNISTR2 *unistr2_dup(const UNISTR2 *name);
-void unistr2_free(UNISTR2 *name);
BOOL make_string2(STRING2 *str, char *buf, int len);
BOOL smb_io_string2(char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth);
BOOL make_unistr2(UNISTR2 *str, const char *buf, int len);
uint32 num_vcs, uint32 trans_addr_len,
char *trans_name, char *trans_addr,
char *addr_name);
+void free_srv_tprt_info_0(SRV_TPRT_INFO_0 *tp0);
+void free_srv_tprt_ctr(SRV_TPRT_INFO_CTR *ctr);
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,
uint32 ptr_tprt_info; /* Buffer */
uint32 num_entries_read2; /* EntriesRead */
- TPRT_INFO_0 info_0 [MAX_TPRT_ENTRIES]; /* transport entry pointers */
- TPRT_INFO_0_STR info_0_str[MAX_TPRT_ENTRIES]; /* transport entry strings */
+ TPRT_INFO_0 *info_0; /* transport entry pointers */
+ TPRT_INFO_0_STR *info_0_str; /* transport entry strings */
} SRV_TPRT_INFO_0;
{
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);
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.
********************************************************************/
return True;
}
+/*******************************************************************
+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.
********************************************************************/
{
DEBUG(5,("cmd_srv_enum_tprt: query failed\n"));
}
+
+ free_srv_tprt_ctr(&ctr);
}
/****************************************************************************