Click here to Skip to main content
15,901,426 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Proxy authentication failed error code is 407. Same code works fine without proxy. Pin
amar_mhetre13-Oct-10 2:56
amar_mhetre13-Oct-10 2:56 
QuestionDebug assersion error Pin
MKC00213-Oct-10 0:33
MKC00213-Oct-10 0:33 
AnswerRe: Debug assersion error Pin
Niklas L13-Oct-10 0:35
Niklas L13-Oct-10 0:35 
GeneralRe: Debug assersion error Pin
MKC00215-Oct-10 2:37
MKC00215-Oct-10 2:37 
AnswerRe: Debug assersion error Pin
David Crow13-Oct-10 8:16
David Crow13-Oct-10 8:16 
GeneralRe: Debug assersion error Pin
MKC00215-Oct-10 2:40
MKC00215-Oct-10 2:40 
QuestionRe: Debug assersion error Pin
David Crow15-Oct-10 2:49
David Crow15-Oct-10 2:49 
AnswerRe: Debug assersion error Pin
MKC00216-Oct-10 3:11
MKC00216-Oct-10 3:11 
AnswerRe: Debug assersion error Pin
David Crow16-Oct-10 11:24
David Crow16-Oct-10 11:24 
GeneralRe: Debug assersion error [modified] Pin
MKC00217-Oct-10 18:49
MKC00217-Oct-10 18:49 
AnswerRe: Debug assersion error Pin
David Crow18-Oct-10 9:56
David Crow18-Oct-10 9:56 
QuestionFile creation date and time Pin
john563212-Oct-10 21:09
john563212-Oct-10 21:09 
AnswerRe: File creation date and time Pin
trotwa12-Oct-10 21:27
trotwa12-Oct-10 21:27 
GeneralRe: File creation date and time Pin
Richard MacCutchan12-Oct-10 22:39
mveRichard MacCutchan12-Oct-10 22:39 
AnswerRe: File creation date and time Pin
CPallini12-Oct-10 21:30
mveCPallini12-Oct-10 21:30 
GeneralRe: File creation date and time Pin
bleedingfingers12-Oct-10 21:55
bleedingfingers12-Oct-10 21:55 
GeneralRe: File creation date and time Pin
CPallini12-Oct-10 22:01
mveCPallini12-Oct-10 22:01 
AnswerRe: File creation date and time Pin
Sauro Viti12-Oct-10 21:32
professionalSauro Viti12-Oct-10 21:32 
GeneralRe: File creation date and time Pin
john563212-Oct-10 23:23
john563212-Oct-10 23:23 
GeneralRe: File creation date and time Pin
Sauro Viti12-Oct-10 23:35
professionalSauro Viti12-Oct-10 23:35 
QuestionHow to hide the RibbonButton???? [modified] Pin
kwanghee choi12-Oct-10 20:10
kwanghee choi12-Oct-10 20:10 
AnswerRe: How to hide the RibbonButton???? Pin
Code-o-mat13-Oct-10 5:02
Code-o-mat13-Oct-10 5:02 
Questionsscanf_s invalidating pointers. Need help Pin
Hipcrostino12-Oct-10 20:03
Hipcrostino12-Oct-10 20:03 
Hi,

Normally I can figure this stuff out, but not this one. I have just upgraded my program from VC6 to VS 2010. Quite a jump. It allows me to do things like actually debug now which is fantastic. Anyway, I have found a problem that I do not understand.

Basically there is a function (which I did not code originally) that is used to convert a hex string into a binary buffer.
ULONG util_ConvertHexStringToBin(char *pszHexString, void *pBinaryBuffer, unsigned int uiBufferSize)
{	//Parses the contents of the null terminated text string representing a hexidecimal value, and converts
	//each pair of hex digits as a byte.  The function will convert no more than uiBufferSize bytes worth
	//of hex digits and will also terminate when all hex digit pairs have been parsed.
	//Returns the size of the resulting binary block
	unsigned int	uiHexPairs;
	unsigned int	uiByteIndex;
	char			*pszParse = NULL;
	BYTE			ucTempByte;

	
	uiHexPairs = strlen(pszHexString)/2; //String length divided by 2
	pszParse = pszHexString;

	uiByteIndex = 0;

	//Loop while still HEX pairs to parse and still bytes to fill in Buffer
	while (uiByteIndex < uiBufferSize && uiByteIndex < uiHexPairs)
	{
	    sscanf_s(pszParse, "%2x", &ucTempByte);
	   ((BYTE *)pBinaryBuffer)[uiByteIndex] = ucTempByte;
		pszParse += 2; //Advance string parse pointer 
		uiByteIndex++; //Advance byte index within buffer
	}
		
	return uiByteIndex;
}


The problem is, as soon as sscanf_s is called, pszParse becomes invalid. I've seen other strange things too, like the uiByteIndex being reset to 0 when calling sscanf_s. I have tried sscanf as well with the same results.

The problem this is at the edge of my c++ knowledge. Its acting like the memory where these varables are stored is free and being overwritten, but this shouldn't be the case. I'm getting different results all the time with this function and this worries me a lot!

Any help, or suggestion on where to look for help would be appreciated.
AnswerRe: sscanf_s invalidating pointers. Need help Pin
Cedric Moonen12-Oct-10 20:22
Cedric Moonen12-Oct-10 20:22 
GeneralRe: sscanf_s invalidating pointers. Need help Pin
Hipcrostino12-Oct-10 20:32
Hipcrostino12-Oct-10 20:32 

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.