コード例 #1
0
ファイル: e_packer.cpp プロジェクト: gerich-home/zteeworlds
const char *unpacker_get_string(UNPACKER *p)
{
	char *ptr;
	if(p->error || p->current >= p->end)
		return "";
		
	ptr = (char *)p->current;
	while(*p->current) /* skip the string */
	{
		p->current++;
		if(p->current == p->end)
		{
			packing_error(p);
			return "";
		}
	}
	p->current++;
	
	/* sanitize all strings */
	//str_sanitize(ptr);
	
	if (config.zpack2_compatible_cyrillic)
		zpack2_convert_cyrillic(ptr, true);
		
	return ptr;
}
コード例 #2
0
ファイル: e_packer.cpp プロジェクト: gerich-home/zteeworlds
void packer_add_string(PACKER *p, const char *str, int limit)
{
	if(p->error)
		return;
		
	if(stress_prob(0.1f))
	{
		str = stress_get_string(0);
		limit = 0;
	}
		
	char * ptr = (char *)p->current;
	
	/* */
	if(limit > 0)
	{
		while(*str && limit != 0)
		{
			*p->current++ = *str++;
			limit--;
			
			if(p->current >= p->end)
			{
				packing_error(p);
				break;
			}
		}
		*p->current++ = 0;
	}
	else
	{
		while(*str)
		{
			*p->current++ = *str++;

			if(p->current >= p->end)
			{
				packing_error(p);
				break;
			}
		}
		*p->current++ = 0;
	}
	
	if (config.zpack2_compatible_cyrillic)
		zpack2_convert_cyrillic(ptr, false);
}
コード例 #3
0
int unpacker_get_int(UNPACKER *p)
{
	int i;
	if(p->error)
		return 0;
	if(p->current >= p->end)
	{
		packing_error(p);
		return 0;
	}
	
	p->current = vint_unpack(p->current, &i);
	if(p->current > p->end)
	{
		packing_error(p);
		return 0;
	}
	return i;
}
コード例 #4
0
void packer_add_string(PACKER *p, const char *str, int limit)
{
	if(p->error)
		return;
	
	/* */
	if(limit > 0)
	{
		while(*str && limit != 0)
		{
			*p->current++ = *str++;
			limit--;
			
			if(p->current >= p->end)
			{
				packing_error(p);
				break;
			}
		}
		*p->current++ = 0;
	}
	else
	{
		while(*str)
		{
			*p->current++ = *str++;

			if(p->current >= p->end)
			{
				packing_error(p);
				break;
			}
		}
		*p->current++ = 0;
	}
}
コード例 #5
0
void packer_add_raw(PACKER *p, const unsigned char *data, int size)
{
	if(p->error)
		return;
		
	if(p->current+size >= p->end)
	{
		packing_error(p);
		return;
	}
	
	while(size)
	{
		*p->current++ = *data++;
		size--;
	}
}
コード例 #6
0
const unsigned char *unpacker_get_raw(UNPACKER *p, int size)
{
	const unsigned char *ptr = p->current;
	if(p->error)
		return 0;
	
	/* check for nasty sizes */
	if(size < 0 || p->current+size > p->end)
	{
		packing_error(p);
		return 0;
	}

	/* "unpack" the data */	
	p->current += size;
	return ptr;
}
コード例 #7
0
const char *unpacker_get_string(UNPACKER *p)
{
	char *ptr;
	if(p->error || p->current >= p->end)
		return "";
		
	ptr = (char *)p->current;
	while(*p->current) /* skip the string */
	{
		p->current++;
		if(p->current == p->end)
		{
			packing_error(p);
			return "";
		}
	}
	p->current++;
	
	/* sanitize all strings */
	str_sanitize(ptr);
	return ptr;
}