Beispiel #1
0
BOOL prs_uint8s(BOOL charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len)
{
	int i;
	char *q = prs_mem_get(ps, len);
	if (q == NULL)
		return False;

	if (UNMARSHALLING(ps)) {
		for (i = 0; i < len; i++)
			data8s[i] = CVAL(q,i);
	} else {
		for (i = 0; i < len; i++)
			SCVAL(q, i, data8s[i]);
	}

    DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset ,name));
    if (charmode)
		print_asc(5, (unsigned char*)data8s, len);
	else {
    	for (i = 0; i < len; i++)
			DEBUG(5,("%02x ", data8s[i]));
	}
    DEBUG(5,("\n"));

	ps->data_offset += len;

	return True;
}
Beispiel #2
0
BOOL prs_werror(const char *name, prs_struct *ps, int depth, WERROR *status)
{
	char *q = prs_mem_get(ps, sizeof(uint32));
	if (q == NULL)
		return False;

	if (UNMARSHALLING(ps)) {
		if (ps->bigendian_data)
			*status = W_ERROR(RIVAL(q,0));
		else
			*status = W_ERROR(IVAL(q,0));
	} else {
		if (ps->bigendian_data)
			RSIVAL(q,0,W_ERROR_V(*status));
		else
			SIVAL(q,0,W_ERROR_V(*status));
	}

	DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth), ps->data_offset, name, 
		 dos_errstr(*status)));

	ps->data_offset += sizeof(uint32);

	return True;
}
Beispiel #3
0
BOOL prs_string2(BOOL charmode, const char *name, prs_struct *ps, int depth, STRING2 *str)
{
	int i;
	char *q = prs_mem_get(ps, str->str_max_len);
	if (q == NULL)
		return False;

	if (UNMARSHALLING(ps)) {
		str->buffer = (unsigned char *)prs_alloc_mem(ps,str->str_max_len);
		if (str->buffer == NULL)
			return False;
	}

	if (UNMARSHALLING(ps)) {
		for (i = 0; i < str->str_str_len; i++)
			str->buffer[i] = CVAL(q,i);
	} else {
		for (i = 0; i < str->str_str_len; i++)
			SCVAL(q, i, str->buffer[i]);
	}

    DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name));
    if (charmode)
		print_asc(5, (unsigned char*)str->buffer, str->str_str_len);
	else {
    	for (i = 0; i < str->str_str_len; i++)
			DEBUG(5,("%02x ", str->buffer[i]));
	}
    DEBUG(5,("\n"));

	ps->data_offset += str->str_str_len;

	return True;
}
Beispiel #4
0
/*******************************************************************
 Stream a null-terminated string.  
 ********************************************************************/
BOOL io_SMBSTR(char *name, io_struct *ps, int depth, SMBSTR *str, unsigned flags)
{
	size_t len;
	int start_offset = ps->data_offset;

	if (!(flags & PARSE_SCALARS)) return True;
	
	if (UNMARSHALLING(ps))
	{
		char *q;
		q = io_mem_get(ps, 0);
		if (q == NULL)
			return False;
		len = strlen(q);
		smbstr_initA(str, q, len);
		ps->data_offset += len + 1;
		DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth),
					start_offset, name, q));
	}
	else
	{
		uint8 *q;
		q = smbstrA(str); /* a typecast that don't happen, it's ok */
		len = smbstr_len(str)+1;

		if (!io_uint8s(name, ps, depth, &q, len, flags))
			return False;
	}

	return True;
}
Beispiel #5
0
bool prs_dcerpc_status(const char *name, prs_struct *ps, int depth, NTSTATUS *status)
{
	char *q = prs_mem_get(ps, sizeof(uint32));
	if (q == NULL)
		return False;

	if (UNMARSHALLING(ps)) {
		if (ps->bigendian_data)
			*status = NT_STATUS(RIVAL(q,0));
		else
			*status = NT_STATUS(IVAL(q,0));
	} else {
		if (ps->bigendian_data)
			RSIVAL(q,0,NT_STATUS_V(*status));
		else
			SIVAL(q,0,NT_STATUS_V(*status));
	}

	DEBUGADD(5,("%s%04x %s: %s\n", tab_depth(5,depth), ps->data_offset, name,
		 dcerpc_errstr(talloc_tos(), NT_STATUS_V(*status))));

	ps->data_offset += sizeof(uint32);

	return True;
}
Beispiel #6
0
BOOL prs_ntstatus(const char *name, prs_struct *ps, int depth, NTSTATUS *status)
{
	char *q = prs_mem_get(ps, sizeof(uint32));
	if (q == NULL)
		return False;

	if (UNMARSHALLING(ps)) {
		if (ps->bigendian_data)
			*status = NT_STATUS(RIVAL(q,0));
		else
			*status = NT_STATUS(IVAL(q,0));
	} else {
		if (ps->bigendian_data)
			RSIVAL(q,0,NT_STATUS_V(*status));
		else
			SIVAL(q,0,NT_STATUS_V(*status));
	}

	DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth), ps->data_offset, name, 
		 get_nt_error_msg(*status)));

	ps->data_offset += sizeof(uint32);

	return True;
}
Beispiel #7
0
static void dbg_rw_punival(BOOL charmode, const char *name, int depth, prs_struct *ps,
							char *in_buf, char *out_buf, int len)
{
	int i;

	if (UNMARSHALLING(ps)) {
		if (ps->bigendian_data) {
			for (i = 0; i < len; i++)
				SSVAL(out_buf,2*i,RSVAL(in_buf, 2*i));
		} else {
			for (i = 0; i < len; i++)
				SSVAL(out_buf, 2*i, SVAL(in_buf, 2*i));
		}
	} else {
		if (ps->bigendian_data) {
			for (i = 0; i < len; i++)
				RSSVAL(in_buf, 2*i, SVAL(out_buf,2*i));
		} else {
			for (i = 0; i < len; i++)
				SSVAL(in_buf, 2*i, SVAL(out_buf,2*i));
		}
	}

	DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name));
	if (charmode)
		print_asc(5, (unsigned char*)out_buf, 2*len);
	else {
		for (i = 0; i < len; i++)
			DEBUG(5,("%04x ", out_buf[i]));
	}
    DEBUG(5,("\n"));
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
char* samr_io_q_close(BOOL io, SAMR_Q_CLOSE *q_u, char *q, char *base, int align, int depth)
{
	if (q_u == NULL) return NULL;

	DEBUG(5,("%s%04x samr_io_q_unknown_1\n", tab_depth(depth), PTR_DIFF(q, base)));
	depth++;

	q = align_offset(q, base, align);

	q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
	q = align_offset(q, base, align);

	return q;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
char* samr_io_r_unknown_24(BOOL io, SAMR_R_UNKNOWN_24 *r_u, char *q, char *base, int align, int depth)
{
	if (r_u == NULL) return NULL;

	DEBUG(5,("%s%04x samr_io_r_unknown_24\n", tab_depth(depth), PTR_DIFF(q, base)));
	depth++;

	q = align_offset(q, base, align);

	DBG_RW_IVAL("ptr         ", depth, base, io, q, r_u->ptr         ); q += 4;
	DBG_RW_SVAL("unknown_0   ", depth, base, io, q, r_u->unknown_0   ); q += 2;
	DBG_RW_SVAL("unknown_1   ", depth, base, io, q, r_u->unknown_1   ); q += 2;
	DBG_RW_PCVAL(False, "padding_0   ", depth, base, io, q, r_u->padding_0   , sizeof(r_u->padding_0)); q += sizeof(r_u->padding_0);

	q = smb_io_time(io, &(r_u->expiry), q, base, align, depth); 
	DBG_RW_PCVAL(False, "padding_1   ", depth, base, io, q, r_u->padding_1   , sizeof(r_u->padding_1)); q += sizeof(r_u->padding_1);

	q = smb_io_unihdr (io, &(r_u->hdr_mach_acct), q, base, align, depth); 
	DBG_RW_IVAL("padding_2   ", depth, base, io, q, r_u->padding_2   ); q += 4;

	DBG_RW_IVAL("ptr_1       ", depth, base, io, q, r_u->ptr_1       ); q += 4;
	DBG_RW_PCVAL(False, "padding_3   ", depth, base, io, q, r_u->padding_3   , sizeof(r_u->padding_3)); q += sizeof(r_u->padding_3);
	DBG_RW_IVAL("padding_4   ", depth, base, io, q, r_u->padding_4   ); q += 4;

	DBG_RW_IVAL("ptr_2       ", depth, base, io, q, r_u->ptr_2       ); q += 4;
	DBG_RW_IVAL("padding_5   ", depth, base, io, q, r_u->padding_5   ); q += 4;

	DBG_RW_IVAL("ptr_3       ", depth, base, io, q, r_u->ptr_3       ); q += 4;
	DBG_RW_PCVAL(False, "padding_6   ", depth, base, io, q, r_u->padding_6   , sizeof(r_u->padding_6)); q += sizeof(r_u->padding_6);

	DBG_RW_IVAL("unknown_id_0", depth, base, io, q, r_u->unknown_id_0); q += 4;
	DBG_RW_SVAL("unknown_2   ", depth, base, io, q, r_u->unknown_2   ); q += 2;
	DBG_RW_IVAL("unknown_3   ", depth, base, io, q, r_u->unknown_3   ); q += 4;
	DBG_RW_SVAL("unknown_4   ", depth, base, io, q, r_u->unknown_4   ); q += 2;
	DBG_RW_SVAL("unknown_5   ", depth, base, io, q, r_u->unknown_5   ); q += 2;

	DBG_RW_PCVAL(False, "padding_7   ", depth, base, io, q, r_u->padding_7   , sizeof(r_u->padding_7)); q += sizeof(r_u->padding_7);
	DBG_RW_IVAL("padding_8   ", depth, base, io, q, r_u->padding_8   ); q += 4;
	
	q = smb_io_unistr2(io, &(r_u->uni_mach_acct), q, base, align, depth); 
	q = align_offset(q, base, align);

	DBG_RW_PCVAL(False, "padding_9   ", depth, base, io, q, r_u->padding_9   , sizeof(r_u->padding_9)); q += sizeof(r_u->padding_9);

	DBG_RW_IVAL("status", depth, base, io, q, r_u->status); q += 4;

	return q;
}
Beispiel #10
0
/*******************************************************************
reads or writes a structure.
********************************************************************/
char* samr_io_r_open_secret(BOOL io, SAMR_R_OPEN_SECRET *r_u, char *q, char *base, int align, int depth)
{
	if (r_u == NULL) return NULL;

	DEBUG(5,("%s%04x samr_io_r_open_secret\n", tab_depth(depth), PTR_DIFF(q, base)));
	depth++;

	q = align_offset(q, base, align);

	q = smb_io_pol_hnd(io, &(r_u->pol), q, base, align, depth); 
	q = align_offset(q, base, align);

	DBG_RW_IVAL("status", depth, base, io, q, r_u->status); q += 4;

	return q;
}
Beispiel #11
0
BOOL prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8)
{
	char *q = prs_mem_get(ps, 1);
	if (q == NULL)
		return False;

    if (UNMARSHALLING(ps))
		*data8 = CVAL(q,0);
	else
		SCVAL(q,0,*data8);

    DEBUG(5,("%s%04x %s: %02x\n", tab_depth(depth), ps->data_offset, name, *data8));

	ps->data_offset += 1;

	return True;
}
Beispiel #12
0
/*******************************************************************
reads or writes a structure.
********************************************************************/
char* samr_io_q_open_policy(BOOL io, SAMR_Q_OPEN_POLICY *q_u, char *q, char *base, int align, int depth)
{
	if (q_u == NULL) return NULL;

	DEBUG(5,("%s%04x samr_io_q_open_policy\n", tab_depth(depth), PTR_DIFF(q, base)));
	depth++;

	q = align_offset(q, base, align);

	DBG_RW_IVAL("ptr_srv_name", depth, base, io, q, q_u->ptr_srv_name); q += 4;
	q = smb_io_unistr2(io, &(q_u->uni_srv_name), q, base, align, depth); 

	q = align_offset(q, base, align);

	DBG_RW_IVAL("unknown_0   ", depth, base, io, q, q_u->unknown_0   ); q += 4;

	return q;
}
Beispiel #13
0
/*******************************************************************
reads or writes a structure.
********************************************************************/
char* samr_io_q_unknown_24(BOOL io, SAMR_Q_UNKNOWN_24 *q_u, char *q, char *base, int align, int depth)
{
	if (q_u == NULL) return NULL;

	DEBUG(5,("%s%04x samr_io_q_unknown_24\n", tab_depth(depth), PTR_DIFF(q, base)));
	depth++;

	q = align_offset(q, base, align);

	q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
	q = align_offset(q, base, align);

	DBG_RW_SVAL("unknown_0", depth, base, io, q, q_u->unknown_0); q += 2; /* 0x0015 or 0x0011 */

	q = align_offset(q, base, align);

	return q;
}
Beispiel #14
0
/*******************************************************************
reads or writes a structure.
********************************************************************/
char* samr_io_q_open_secret(BOOL io, SAMR_Q_OPEN_SECRET *q_u, char *q, char *base, int align, int depth)
{
	if (q_u == NULL) return NULL;

	DEBUG(5,("%s%04x samr_io_q_open_secret\n", tab_depth(depth), PTR_DIFF(q, base)));
	depth++;

	q = align_offset(q, base, align);

	q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
	q = align_offset(q, base, align);

	DBG_RW_IVAL("unknown_0", depth, base, io, q, q_u->unknown_0); q += 4;

	q = smb_io_dom_sid(io, &(q_u->dom_sid), q, base, align, depth); 
	q = align_offset(q, base, align);

	return q;
}
Beispiel #15
0
/*******************************************************************
reads or writes a structure.
********************************************************************/
char* samr_io_r_lookup_rids(BOOL io, SAMR_R_LOOKUP_RIDS *r_u, char *q, char *base, int align, int depth)
{
	if (r_u == NULL) return NULL;

	DEBUG(5,("%s%04x samr_io_r_lookup_rids\n", tab_depth(depth), PTR_DIFF(q, base)));
	depth++;

	q = align_offset(q, base, align);

	DBG_RW_IVAL("num_entries ", depth, base, io, q, r_u->num_entries ); q += 4;
	DBG_RW_IVAL("undoc_buffer", depth, base, io, q, r_u->undoc_buffer); q += 4;
	DBG_RW_IVAL("num_entries2", depth, base, io, q, r_u->num_entries2); q += 4;

	q = smb_io_dom_rid3(io, &(r_u->dom_rid[0]), q, base, align, depth);

	DBG_RW_IVAL("num_entries3", depth, base, io, q, r_u->num_entries3); q += 4;

	DBG_RW_IVAL("status", depth, base, io, q, r_u->status); q += 4;

	return q;
}
Beispiel #16
0
bool prs_uint16s(bool charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len)
{
	int i;
	char *q = prs_mem_get(ps, len * sizeof(uint16));
	if (q == NULL)
		return False;

	if (UNMARSHALLING(ps)) {
		if (ps->bigendian_data) {
			for (i = 0; i < len; i++)
				data16s[i] = RSVAL(q, 2*i);
		} else {
			for (i = 0; i < len; i++)
				data16s[i] = SVAL(q, 2*i);
		}
	} else {
		if (ps->bigendian_data) {
			for (i = 0; i < len; i++)
				RSSVAL(q, 2*i, data16s[i]);
		} else {
			for (i = 0; i < len; i++)
				SSVAL(q, 2*i, data16s[i]);
		}
	}

	DEBUGADD(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
	if (charmode)
		print_asc(5, (unsigned char*)data16s, 2*len);
	else {
		for (i = 0; i < len; i++)
			DEBUGADD(5,("%04x ", data16s[i]));
	}
	DEBUGADD(5,("\n"));

	ps->data_offset += (len * sizeof(uint16));

	return True;
}
Beispiel #17
0
BOOL prs_uint32s(BOOL charmode, const char *name, prs_struct *ps, int depth, uint32 *data32s, int len)
{
	int i;
	char *q = prs_mem_get(ps, len * sizeof(uint32));
	if (q == NULL)
		return False;

	if (UNMARSHALLING(ps)) {
		if (ps->bigendian_data) {
			for (i = 0; i < len; i++)
				data32s[i] = RIVAL(q, 4*i);
		} else {
			for (i = 0; i < len; i++)
				data32s[i] = IVAL(q, 4*i);
		}
	} else {
		if (ps->bigendian_data) {
			for (i = 0; i < len; i++)
				RSIVAL(q, 4*i, data32s[i]);
		} else {
			for (i = 0; i < len; i++)
				SIVAL(q, 4*i, data32s[i]);
		}
	}

	DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name));
	if (charmode)
		print_asc(5, (unsigned char*)data32s, 4*len);
	else {
		for (i = 0; i < len; i++)
			DEBUG(5,("%08x ", data32s[i]));
	}
    DEBUG(5,("\n"));

	ps->data_offset += (len * sizeof(uint32));

	return True;
}
Beispiel #18
0
/*******************************************************************
reads or writes a structure.
********************************************************************/
char* samr_io_q_unknown_32(BOOL io, SAMR_Q_UNKNOWN_32 *q_u, char *q, char *base, int align, int depth)
{
	if (q_u == NULL) return NULL;

	DEBUG(5,("%s%04x samr_io_q_unknown_32\n", tab_depth(depth), PTR_DIFF(q, base)));
	depth++;

	q = align_offset(q, base, align);

	q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
	q = align_offset(q, base, align);

	q = smb_io_unihdr (io, &(q_u->hdr_mach_acct), q, base, align, depth); 
	q = smb_io_unistr2(io, &(q_u->uni_mach_acct), q, base, align, depth); 

	q = align_offset(q, base, align);

	DBG_RW_IVAL("unknown_0", depth, base, io, q, q_u->unknown_0); q += 4;
	DBG_RW_SVAL("unknown_1", depth, base, io, q, q_u->unknown_1); q += 2;
	DBG_RW_SVAL("unknown_2", depth, base, io, q, q_u->unknown_2); q += 2;

	return q;
}
Beispiel #19
0
/*******************************************************************
 Stream a null-terminated string.  
 ********************************************************************/
BOOL io_SMBCHR(char *name, io_struct *ps, int depth, char **str, unsigned flags)
{
	char *q;
	uint8 *start;
	int i;
	size_t len;
	int start_offset = ps->data_offset;

	if (!(flags & PARSE_SCALARS)) return True;
	
	if (UNMARSHALLING(ps)) {
		*str = io_mem_get(ps, 0);
		if (*str == NULL)
			return False;
		len = strlen(*str);
		ps->data_offset += len + 1;
	}
	else
	{
		len = strlen(*str)+1;
		start = (uint8*)q;

		for(i = 0; i < len; i++) {
			q = io_mem_get(ps, 1);
			if (q == NULL)
				return False;

			RW_CVAL(ps->io, q, (*str)[i],0);
			ps->data_offset++;
		}
	}

	DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth),
				start_offset, name, *str));
	return True;
}
Beispiel #20
0
/*******************************************************************
reads or writes a structure.
********************************************************************/
char* samr_io_q_lookup_rids(BOOL io, SAMR_Q_LOOKUP_RIDS *q_u, char *q, char *base, int align, int depth)
{
	if (q_u == NULL) return NULL;

	DEBUG(5,("%s%04x samr_io_q_lookup_rids\n", tab_depth(depth), PTR_DIFF(q, base)));
	depth++;

	q = align_offset(q, base, align);

	q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
	q = align_offset(q, base, align);

	DBG_RW_IVAL("num_rids1", depth, base, io, q, q_u->num_rids1); q += 4;
	DBG_RW_IVAL("rid      ", depth, base, io, q, q_u->rid      ); q += 4;
	DBG_RW_IVAL("ptr      ", depth, base, io, q, q_u->ptr      ); q += 4;
	DBG_RW_IVAL("num_rids2", depth, base, io, q, q_u->num_rids2); q += 4;

	q = smb_io_unihdr (io, &(q_u->hdr_mach_acct), q, base, align, depth); 
	q = smb_io_unistr2(io, &(q_u->uni_mach_acct), q, base, align, depth); 

	q = align_offset(q, base, align);

	return q;
}
Beispiel #21
0
bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16_t *data16)
{
	char *q = prs_mem_get(ps, sizeof(uint16_t));
	if (q == NULL)
		return False;

	if (UNMARSHALLING(ps)) {
		if (ps->bigendian_data)
			*data16 = RSVAL(q,0);
		else
			*data16 = SVAL(q,0);
	} else {
		if (ps->bigendian_data)
			RSSVAL(q,0,*data16);
		else
			SSVAL(q,0,*data16);
	}

	DEBUGADD(5,("%s%04x %s: %04x\n", tab_depth(5,depth), ps->data_offset, name, *data16));

	ps->data_offset += sizeof(uint16_t);

	return True;
}
Beispiel #22
0
BOOL prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32)
{
	char *q = prs_mem_get(ps, sizeof(uint32));
	if (q == NULL)
		return False;

	if (UNMARSHALLING(ps)) {
		if (ps->bigendian_data)
			*data32 = RIVAL(q,0);
		else
			*data32 = IVAL(q,0);
	} else {
		if (ps->bigendian_data)
			RSIVAL(q,0,*data32);
		else
			SIVAL(q,0,*data32);
	}

	DEBUG(5,("%s%04x %s: %08x\n", tab_depth(depth), ps->data_offset, name, *data32));

	ps->data_offset += sizeof(uint32);

	return True;
}
Beispiel #23
0
BOOL prs_unistr(const char *name, prs_struct *ps, int depth, UNISTR *str)
{
	unsigned int len = 0;
	unsigned char *p = (unsigned char *)str->buffer;
	uint8 *start;
	char *q;
	uint32 max_len;
	uint16* ptr;

	if (MARSHALLING(ps)) {

		for(len = 0; str->buffer[len] != 0; len++)
			;

		q = prs_mem_get(ps, (len+1)*2);
		if (q == NULL)
			return False;

		start = (uint8*)q;

		for(len = 0; str->buffer[len] != 0; len++) 
		{
			if(ps->bigendian_data) 
			{
				/* swap bytes - p is little endian, q is big endian. */
				q[0] = (char)p[1];
				q[1] = (char)p[0];
				p += 2;
				q += 2;
			} 
			else 
			{
				q[0] = (char)p[0];
				q[1] = (char)p[1];
				p += 2;
				q += 2;
			}
		}

		/*
		 * even if the string is 'empty' (only an \0 char)
		 * at this point the leading \0 hasn't been parsed.
		 * so parse it now
		 */

		q[0] = 0;
		q[1] = 0;
		q += 2;

		len++;

		DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name));
		print_asc(5, (unsigned char*)start, 2*len);	
		DEBUG(5, ("\n"));
	}
	else { /* unmarshalling */
	
		uint32 alloc_len = 0;
		q = ps->data_p + prs_offset(ps);

		/*
		 * Work out how much space we need and talloc it.
		 */
		max_len = (ps->buffer_size - ps->data_offset)/sizeof(uint16);

		/* the test of the value of *ptr helps to catch the circumstance
		   where we have an emtpty (non-existent) string in the buffer */
		for ( ptr = (uint16 *)q; *ptr && (alloc_len <= max_len); alloc_len++)
			/* do nothing */ 
			;

		/* should we allocate anything at all? */
		str->buffer = (uint16 *)prs_alloc_mem(ps,alloc_len * sizeof(uint16));
		if ((str->buffer == NULL) && (alloc_len > 0))
			return False;

		p = (unsigned char *)str->buffer;

		len = 0;
		/* the (len < alloc_len) test is to prevent us from overwriting
		   memory that is not ours...if we get that far, we have a non-null
		   terminated string in the buffer and have messed up somewhere */
		while ((len < alloc_len) && (*(uint16 *)q != 0))
		{
			if(ps->bigendian_data) 
			{
				/* swap bytes - q is big endian, p is little endian. */
				p[0] = (unsigned char)q[1];
				p[1] = (unsigned char)q[0];
				p += 2;
				q += 2;
			} else {

				p[0] = (unsigned char)q[0];
				p[1] = (unsigned char)q[1];
				p += 2;
				q += 2;
			}

			len++;
		} 
		if (len < alloc_len)
		{
			/* NULL terminate the UNISTR */
			str->buffer[len++] = '\0';
		}

		DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name));
		print_asc(5, (unsigned char*)str->buffer, 2*len);	
		DEBUG(5, ("\n"));
	}

	/* set the offset in the prs_struct; 'len' points to the
	   terminiating NULL in the UNISTR so we need to go one more
	   uint16 */
	ps->data_offset += (len)*2;
	
	return True;
}
Beispiel #24
0
/*******************************************************************
 debug output for parsing info.

 XXXX side-effect of this function is to increase the debug depth XXXX

 ********************************************************************/
void prs_debug(prs_struct *ps, int depth, const char *desc, const char *fn_name)
{
	DEBUG(5+depth, ("%s%06x %s %s\n", tab_depth(depth), ps->data_offset, fn_name, desc));
}