Error[8]: Undefined offset: 329, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

上次写了一个rtsp协议分解,把rtsp得各个部分分解开来放入到map中,发现了一些错误。
如下字符

string strlines =
"OPTIONS rtsp ://192.168.0.129:8554 RTSP/1.0\r\n"
"CSeq: 1\r\n"
"User - Agent : RealMedia Player Version 6.0.9.1235 (linux - 2.0 - libc6 - i386 - gcc2.95)\r\n"
"ClientChallenge : 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime : [28 / 03 / 2003:22 : 50 : 23 00 : 00]\r\n"
"CompanyID : KnKV4M4I / B2FjJ1TToLycw ==\r\n"
"GUID : 00000000 - 0000 - 0000 - 0000 - 000000000000\r\n"
"RegionData : 0\r\n"
"ClientID : Linux_2.4_6.0.9.1235_play32_RN01_EN_586\r\n\r\n";

使用 fetch_head_info_rtsp函数出错,原因是rtsp 协议options 中请求无路由
如果是rtsp 😕/192.168.0.129:8554/live/1001 则没有错误,ok,修正这个错误,代码如下:

//适应rtsp协议
static int fetch_head_info_rtsp(std::string &lines, c_header_map &hmap)
{
	//we analyse the string like this:
	//OPTIONS rtsp://ip/live/1001 rtsp/1.0
	std::istringstream s(lines);
	std::string request;
	std::getline(s, request);
	size_t len = request.size();
	if (request[len - 1] != '\r')
	{
		//please use log instead of cout,of course ,now we just cout
		std::cout << "request not fit:" << request << std::endl;
		return -1;
	}
	request[len - 1] = ';'//we do not use this,instead, to use request[x]='//request.erase(request.end() - 1);'  
	size_t
	=
	2 i ; while(
	[ ++request]!=i' ' ) ;["method"

	hmap]=. substr request(0,); i::=
	std.string url substr request(+1i ) ;=7
	i ; //优化rtsp协议while (
	[ ++url]!=i' ' ) ;["baseurl"
	hmap]=. substr url(0,); i["protocol"
	hmap]=. substr url(+1i ) ;::&
	std=string [baseurl "baseurl" hmap];=7
	i ; //rtsp:////rtsp://192.168.0.129:8554 errorsize_t
    =
	. lenb size baseurl();while(
	++ <)i if lenb(
	{
		[ ]baseurl==i'/' ) break;
			}//while (baseurl[++i] != '/');
	[
	"route"
	hmap]=? "" i>=lenb:.substrbaseurl(+1i ) ;["url"
	hmap]=; :: url;

	std//while (std::getline(s, header) && header != "\r")string headerwhile

	(
	1 )if(
	{
		! ::getlinestd(,)s) headerbreak;
			size_t=
		. len size header();if(
		[ -header1len ] =='\r' ) [-
		{
			header1len ] =';' //remove last char //header.erase(header.end() - 1); size_t=
			.
			find end ( header": ",0); if(==
			:: ::end ) std//优化rtsp协议stringbreaknpos; ::
				=.
			stdsubstrstring key ( header0,);:: end=.
			stdsubstrstring value ( header+2)end ; []=
			hmap;key} } valuereturn
		(
	int
	) .size(hmap);}="OPTIONS rtsp ://192.168.0.129:8554/live/1001 RTSP/1.0\r\n"
"CSeq: 1\r\n"

这种常见错误为边界错误,使用单元测试解决。测试代码如下:

string strlines "User - Agent : RealMedia Player Version 6.0.9.1235 (linux - 2.0 - libc6 - i386 - gcc2.95)\r\n"
"ClientChallenge : 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime : [28 / 03 / 2003:22 : 50 : 23 00 : 00]\r\n"
"CompanyID : KnKV4M4I / B2FjJ1TToLycw ==\r\n"
"GUID : 00000000 - 0000 - 0000 - 0000 - 000000000000\r\n"
"RegionData : 0\r\n"
"ClientID : Linux_2.4_6.0.9.1235_play32_RN01_EN_586\r\n\r\n"
;
int
main(


) ;int=
{
	c_header_map mapsfetch_head_info_rtsp
	( size , );strlines<< maps<<;
	cout << size [ endl"route"
	cout ] maps<<;//int num = func_getpacket_num(NULL,1400); //cout << num << endl; endl//num = func_getpacket_num(NULL, 2800);
	//cout << num << endl;
	}
	[+++]
	[+++]
[+++]
)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 330, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

上次写了一个rtsp协议分解,把rtsp得各个部分分解开来放入到map中,发现了一些错误。
如下字符

string strlines =
"OPTIONS rtsp ://192.168.0.129:8554 RTSP/1.0\r\n"
"CSeq: 1\r\n"
"User - Agent : RealMedia Player Version 6.0.9.1235 (linux - 2.0 - libc6 - i386 - gcc2.95)\r\n"
"ClientChallenge : 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime : [28 / 03 / 2003:22 : 50 : 23 00 : 00]\r\n"
"CompanyID : KnKV4M4I / B2FjJ1TToLycw ==\r\n"
"GUID : 00000000 - 0000 - 0000 - 0000 - 000000000000\r\n"
"RegionData : 0\r\n"
"ClientID : Linux_2.4_6.0.9.1235_play32_RN01_EN_586\r\n\r\n";

使用 fetch_head_info_rtsp函数出错,原因是rtsp 协议options 中请求无路由
如果是rtsp 😕/192.168.0.129:8554/live/1001 则没有错误,ok,修正这个错误,代码如下:

//适应rtsp协议
static int fetch_head_info_rtsp(std::string &lines, c_header_map &hmap)
{
	//we analyse the string like this:
	//OPTIONS rtsp://ip/live/1001 rtsp/1.0
	std::istringstream s(lines);
	std::string request;
	std::getline(s, request);
	size_t len = request.size();
	if (request[len - 1] != '\r')
	{
		//please use log instead of cout,of course ,now we just cout
		std::cout << "request not fit:" << request << std::endl;
		return -1;
	}
	request[len - 1] = ';'//we do not use this,instead, to use request[x]='//request.erase(request.end() - 1);'  
	size_t
	=
	2 i ; while(
	[ ++request]!=i' ' ) ;["method"

	hmap]=. substr request(0,); i::=
	std.string url substr request(+1i ) ;=7
	i ; //优化rtsp协议while (
	[ ++url]!=i' ' ) ;["baseurl"
	hmap]=. substr url(0,); i["protocol"
	hmap]=. substr url(+1i ) ;::&
	std=string [baseurl "baseurl" hmap];=7
	i ; //rtsp:////rtsp://192.168.0.129:8554 errorsize_t
    =
	. lenb size baseurl();while(
	++ <)i if lenb(
	{
		[ ]baseurl==i'/' ) break;
			}//while (baseurl[++i] != '/');
	[
	"route"
	hmap]=? "" i>=lenb:.substrbaseurl(+1i ) ;["url"
	hmap]=; :: url;

	std//while (std::getline(s, header) && header != "\r")string headerwhile

	(
	1 )if(
	{
		! ::getlinestd(,)s) headerbreak;
			size_t=
		. len size header();if(
		[ -header1len ] =='\r' ) [-
		{
			header1len ] =';' //remove last char //header.erase(header.end() - 1); size_t=
			.
			find end ( header": ",0); if(==
			:: ::end ) std//优化rtsp协议stringbreaknpos; ::
				=.
			stdsubstrstring key ( header0,);:: end=.
			stdsubstrstring value ( header+2)end ; []=
			hmap;key} } valuereturn
		(
	int
	) .size(hmap);}="OPTIONS rtsp ://192.168.0.129:8554/live/1001 RTSP/1.0\r\n"
"CSeq: 1\r\n"

这种常见错误为边界错误,使用单元测试解决。测试代码如下:

string strlines "User - Agent : RealMedia Player Version 6.0.9.1235 (linux - 2.0 - libc6 - i386 - gcc2.95)\r\n"
"ClientChallenge : 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime : [28 / 03 / 2003:22 : 50 : 23 00 : 00]\r\n"
"CompanyID : KnKV4M4I / B2FjJ1TToLycw ==\r\n"
"GUID : 00000000 - 0000 - 0000 - 0000 - 000000000000\r\n"
"RegionData : 0\r\n"
"ClientID : Linux_2.4_6.0.9.1235_play32_RN01_EN_586\r\n\r\n"
;
int
main(


) ;int=
{
	c_header_map mapsfetch_head_info_rtsp
	( size , );strlines<< maps<<;
	cout << size [ endl"route"
	cout ] maps<<;//int num = func_getpacket_num(NULL,1400); //cout << num << endl; endl//num = func_getpacket_num(NULL, 2800);
	//cout << num << endl;
	}
	
	[+++]
[+++]
)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 331, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

上次写了一个rtsp协议分解,把rtsp得各个部分分解开来放入到map中,发现了一些错误。
如下字符

string strlines =
"OPTIONS rtsp ://192.168.0.129:8554 RTSP/1.0\r\n"
"CSeq: 1\r\n"
"User - Agent : RealMedia Player Version 6.0.9.1235 (linux - 2.0 - libc6 - i386 - gcc2.95)\r\n"
"ClientChallenge : 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime : [28 / 03 / 2003:22 : 50 : 23 00 : 00]\r\n"
"CompanyID : KnKV4M4I / B2FjJ1TToLycw ==\r\n"
"GUID : 00000000 - 0000 - 0000 - 0000 - 000000000000\r\n"
"RegionData : 0\r\n"
"ClientID : Linux_2.4_6.0.9.1235_play32_RN01_EN_586\r\n\r\n";

使用 fetch_head_info_rtsp函数出错,原因是rtsp 协议options 中请求无路由
如果是rtsp 😕/192.168.0.129:8554/live/1001 则没有错误,ok,修正这个错误,代码如下:

//适应rtsp协议
static int fetch_head_info_rtsp(std::string &lines, c_header_map &hmap)
{
	//we analyse the string like this:
	//OPTIONS rtsp://ip/live/1001 rtsp/1.0
	std::istringstream s(lines);
	std::string request;
	std::getline(s, request);
	size_t len = request.size();
	if (request[len - 1] != '\r')
	{
		//please use log instead of cout,of course ,now we just cout
		std::cout << "request not fit:" << request << std::endl;
		return -1;
	}
	request[len - 1] = ';'//we do not use this,instead, to use request[x]='//request.erase(request.end() - 1);'  
	size_t
	=
	2 i ; while(
	[ ++request]!=i' ' ) ;["method"

	hmap]=. substr request(0,); i::=
	std.string url substr request(+1i ) ;=7
	i ; //优化rtsp协议while (
	[ ++url]!=i' ' ) ;["baseurl"
	hmap]=. substr url(0,); i["protocol"
	hmap]=. substr url(+1i ) ;::&
	std=string [baseurl "baseurl" hmap];=7
	i ; //rtsp:////rtsp://192.168.0.129:8554 errorsize_t
    =
	. lenb size baseurl();while(
	++ <)i if lenb(
	{
		[ ]baseurl==i'/' ) break;
			}//while (baseurl[++i] != '/');
	[
	"route"
	hmap]=? "" i>=lenb:.substrbaseurl(+1i ) ;["url"
	hmap]=; :: url;

	std//while (std::getline(s, header) && header != "\r")string headerwhile

	(
	1 )if(
	{
		! ::getlinestd(,)s) headerbreak;
			size_t=
		. len size header();if(
		[ -header1len ] =='\r' ) [-
		{
			header1len ] =';' //remove last char //header.erase(header.end() - 1); size_t=
			.
			find end ( header": ",0); if(==
			:: ::end ) std//优化rtsp协议stringbreaknpos; ::
				=.
			stdsubstrstring key ( header0,);:: end=.
			stdsubstrstring value ( header+2)end ; []=
			hmap;key} } valuereturn
		(
	int
	) .size(hmap);}="OPTIONS rtsp ://192.168.0.129:8554/live/1001 RTSP/1.0\r\n"
"CSeq: 1\r\n"

这种常见错误为边界错误,使用单元测试解决。测试代码如下:

string strlines "User - Agent : RealMedia Player Version 6.0.9.1235 (linux - 2.0 - libc6 - i386 - gcc2.95)\r\n"
"ClientChallenge : 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime : [28 / 03 / 2003:22 : 50 : 23 00 : 00]\r\n"
"CompanyID : KnKV4M4I / B2FjJ1TToLycw ==\r\n"
"GUID : 00000000 - 0000 - 0000 - 0000 - 000000000000\r\n"
"RegionData : 0\r\n"
"ClientID : Linux_2.4_6.0.9.1235_play32_RN01_EN_586\r\n\r\n"
;
int
main(


) ;int=
{
	c_header_map mapsfetch_head_info_rtsp
	( size , );strlines<< maps<<;
	cout << size [ endl"route"
	cout ] maps<<;//int num = func_getpacket_num(NULL,1400); //cout << num << endl; endl//num = func_getpacket_num(NULL, 2800);
	//cout << num << endl;
	}
	
	
[+++]
)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
rtsp协议分解函数修订_C_内存溢出

rtsp协议分解函数修订

rtsp协议分解函数修订,第1张

上次写了一个rtsp协议分解,把rtsp得各个部分分解开来放入到map中,发现了一些错误。
如下字符

string strlines =
"OPTIONS rtsp ://192.168.0.129:8554 RTSP/1.0\r\n"
"CSeq: 1\r\n"
"User - Agent : RealMedia Player Version 6.0.9.1235 (linux - 2.0 - libc6 - i386 - gcc2.95)\r\n"
"ClientChallenge : 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime : [28 / 03 / 2003:22 : 50 : 23 00 : 00]\r\n"
"CompanyID : KnKV4M4I / B2FjJ1TToLycw ==\r\n"
"GUID : 00000000 - 0000 - 0000 - 0000 - 000000000000\r\n"
"RegionData : 0\r\n"
"ClientID : Linux_2.4_6.0.9.1235_play32_RN01_EN_586\r\n\r\n";

使用 fetch_head_info_rtsp函数出错,原因是rtsp 协议options 中请求无路由
如果是rtsp 😕/192.168.0.129:8554/live/1001 则没有错误,ok,修正这个错误,代码如下:

//适应rtsp协议
static int fetch_head_info_rtsp(std::string &lines, c_header_map &hmap)
{
	//we analyse the string like this:
	//OPTIONS rtsp://ip/live/1001 rtsp/1.0
	std::istringstream s(lines);
	std::string request;
	std::getline(s, request);
	size_t len = request.size();
	if (request[len - 1] != '\r')
	{
		//please use log instead of cout,of course ,now we just cout
		std::cout << "request not fit:" << request << std::endl;
		return -1;
	}
	request[len - 1] = ';'//we do not use this,instead, to use request[x]='//request.erase(request.end() - 1);'  
	size_t
	=
	2 i ; while(
	[ ++request]!=i' ' ) ;["method"

	hmap]=. substr request(0,); i::=
	std.string url substr request(+1i ) ;=7
	i ; //优化rtsp协议while (
	[ ++url]!=i' ' ) ;["baseurl"
	hmap]=. substr url(0,); i["protocol"
	hmap]=. substr url(+1i ) ;::&
	std=string [baseurl "baseurl" hmap];=7
	i ; //rtsp:////rtsp://192.168.0.129:8554 errorsize_t
    =
	. lenb size baseurl();while(
	++ <)i if lenb(
	{
		[ ]baseurl==i'/' ) break;
			}//while (baseurl[++i] != '/');
	[
	"route"
	hmap]=? "" i>=lenb:.substrbaseurl(+1i ) ;["url"
	hmap]=; :: url;

	std//while (std::getline(s, header) && header != "\r")string headerwhile

	(
	1 )if(
	{
		! ::getlinestd(,)s) headerbreak;
			size_t=
		. len size header();if(
		[ -header1len ] =='\r' ) [-
		{
			header1len ] =';' //remove last char //header.erase(header.end() - 1); size_t=
			.
			find end ( header": ",0); if(==
			:: ::end ) std//优化rtsp协议stringbreaknpos; ::
				=.
			stdsubstrstring key ( header0,);:: end=.
			stdsubstrstring value ( header+2)end ; []=
			hmap;key} } valuereturn
		(
	int
	) .size(hmap);}="OPTIONS rtsp ://192.168.0.129:8554/live/1001 RTSP/1.0\r\n"
"CSeq: 1\r\n"

这种常见错误为边界错误,使用单元测试解决。测试代码如下:

string strlines "User - Agent : RealMedia Player Version 6.0.9.1235 (linux - 2.0 - libc6 - i386 - gcc2.95)\r\n"
"ClientChallenge : 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime : [28 / 03 / 2003:22 : 50 : 23 00 : 00]\r\n"
"CompanyID : KnKV4M4I / B2FjJ1TToLycw ==\r\n"
"GUID : 00000000 - 0000 - 0000 - 0000 - 000000000000\r\n"
"RegionData : 0\r\n"
"ClientID : Linux_2.4_6.0.9.1235_play32_RN01_EN_586\r\n\r\n"
;
int
main(


) ;int=
{
	c_header_map mapsfetch_head_info_rtsp
	( size , );strlines<< maps<<;
	cout << size [ endl"route"
	cout ] maps<<;//int num = func_getpacket_num(NULL,1400); //cout << num << endl; endl//num = func_getpacket_num(NULL, 2800);
	//cout << num << endl;
	}
	
	

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1331129.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-12
下一篇 2022-06-12

发表评论

登录后才能评论

评论列表(0条)

保存