Click here to Skip to main content
15,913,758 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to declare and use an array of pointer on functions? Pin
Cedric Moonen8-Jul-05 1:15
Cedric Moonen8-Jul-05 1:15 
GeneralRe: how to declare and use an array of pointer on functions? Pin
t!bast8-Jul-05 1:29
t!bast8-Jul-05 1:29 
AnswerRe: how to declare and use an array of pointer on functions? Pin
David Crow8-Jul-05 3:40
David Crow8-Jul-05 3:40 
GeneralCommand Handler problem in Dialog Pin
ugur_basak7-Jul-05 22:42
ugur_basak7-Jul-05 22:42 
GeneralRe: Command Handler problem in Dialog Pin
Jose Lamas Rios8-Jul-05 3:10
Jose Lamas Rios8-Jul-05 3:10 
GeneralRe: Command Handler problem in Dialog Pin
ugur_basak8-Jul-05 3:28
ugur_basak8-Jul-05 3:28 
Questionhow to protect files like this? Pin
szcococut7-Jul-05 22:24
szcococut7-Jul-05 22:24 
AnswerRe: how to protect files like this? Pin
khan++7-Jul-05 23:34
khan++7-Jul-05 23:34 
GeneralRe: how to protect files like this? Pin
toxcct8-Jul-05 0:51
toxcct8-Jul-05 0:51 
GeneralRe: how to protect files like this? Pin
khan++8-Jul-05 1:21
khan++8-Jul-05 1:21 
GeneralRe: how to protect files like this? Pin
toxcct8-Jul-05 1:27
toxcct8-Jul-05 1:27 
GeneralRe: how to protect files like this? Pin
khan++8-Jul-05 1:54
khan++8-Jul-05 1:54 
AnswerRe: how to protect files like this? Pin
David Crow8-Jul-05 3:46
David Crow8-Jul-05 3:46 
GeneralCView: Change background color Pin
a_du7-Jul-05 22:12
a_du7-Jul-05 22:12 
GeneralRe: CView: Change background color Pin
khan++7-Jul-05 23:56
khan++7-Jul-05 23:56 
GeneralRe: CView: Change background color Pin
Anonymous10-Jul-05 0:13
Anonymous10-Jul-05 0:13 
GeneralRe: CView: Change background color Pin
TuPacMansur7-Jul-10 13:27
TuPacMansur7-Jul-10 13:27 
GeneralUpsized database 100x slower in SQLServer Pin
mbaker17-Jul-05 21:46
mbaker17-Jul-05 21:46 
GeneralRe: Upsized database 100x slower in SQLServer Pin
Blake V. Miller8-Jul-05 16:58
Blake V. Miller8-Jul-05 16:58 
GeneralRe: Upsized database 100x slower in SQLServer Pin
Anonymous8-Jul-05 23:12
Anonymous8-Jul-05 23:12 
GeneralRe: Upsized database 100x slower in SQLServer Pin
Blake V. Miller12-Jul-05 17:14
Blake V. Miller12-Jul-05 17:14 
Questionwhich of these is the handle to my windowless app? Pin
awah7-Jul-05 21:45
awah7-Jul-05 21:45 
AnswerRe: which of these is the handle to my windowless app? Pin
khan++7-Jul-05 23:51
khan++7-Jul-05 23:51 
Generalproblem : strtok,strcpy,crashes when garbage strings are handled Pin
awah7-Jul-05 21:37
awah7-Jul-05 21:37 
strtok,strcpy,crashes when garbage strings are handled

this is especially so in winsock applications
in my application, i expect " value1^value2^value^&############"
and use strtok to extract value 1,2 and 3
and "&" indicates that there are no more values to be collected

where #### = garbaage
others can send a garbage long string like
"##################################"

and my application would crash

is there anyway to tell strtok/strcpy to handle this?

will a check on strlen help?

more info on my function

struct broken_msg<br />
{<br />
	void break_msg(char* full_msg)<br />
	{<br />
		char seps[] = "^";<br />
		char *token;<br />
		token = strtok( full_msg, seps ); <== CRASHES HERE<br />
		if(strlen(token) < 150)<br />
		{<br />
			strcpy(parm0,token);<br />
		}<br />
	<br />
		if(  stricmp("&" ,token )   )<br />
		{<br />
			token = strtok( NULL, seps );<br />
			if(strlen(token) < 150)<br />
			{<br />
				strcpy(parm1,token);<br />
			}<br />
		}<br />
		if(  stricmp("&" ,token )   )<br />
		{<br />
			token = strtok( NULL, seps );<br />
			if(strlen(token) < 150)<br />
			{<br />
				strcpy(parm2,token);<br />
			}<br />
<br />
		}<br />
		if(  stricmp("&" ,token )   )<br />
		{<br />
			token = strtok( NULL, seps ); <br />
			if(strlen(token) < 150)<br />
			{<br />
				strcpy(parm3,token);<br />
			}<br />
<br />
		}<br />
	}<br />
<br />
<br />
	char parm0[150];<br />
	char parm1[150];<br />
	char parm2[150];<br />
	char parm3[150];<br />
};

GeneralRe: problem : strtok,strcpy,crashes when garbage strings are handled Pin
khan++7-Jul-05 23:47
khan++7-Jul-05 23:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.