Jump to content

Home

Corrupt stack


Dom_152

Recommended Posts

OK I'm having this really weird problem. I have an array of 19 characters to hold one IP read from a file. Once it's read one it will do some comparing to see if that IP is banned and such. But something strange is happening when I copy data from the file buffer to my IP array:

 

Everything is fine for the first 3 bits:

2nsuwle.jpg

 

But as soon as it tries to do the next part for some weird reason all of the userinfo seems to be dumped straight into my array even though it only has 19 spaces and the userinfo is over 1000!

2uq23x0.jpg

 

Once it's got one whole IP and it's been compared the IP array is emptied and the process starts again for however many IPs there are in the file but the same thing happens everytime! Then once it's finished reading through the file it tells me the stack around variable 'IP' is corrupt. Anyone know what this means because i think this might be what's causing this odd behaviour.

Link to comment
Share on other sites

Oops sorry:

 

for(i = 0; i < len+1; i++)
{
if(buffer[i] != ' ') 
{					
	if(buffer[i] == ',')
	{				
		if(Q_stricmp(IP, value) == 0)
			return "You have been banned from this server.";
		else
		{
		        memcpy(IP, " ", sizeof(IP));
			num = 0;						
			continue;
		}
	}

	IP[num] = buffer[i];
	G_LogPrintf("IPString: %s\n", IP);

	num++;				
}
}

Link to comment
Share on other sites

  • 2 weeks later...

OK this is annoying it's now happening with my word censor as well! It's just dumping random information into my 'word' variable:

 

char *buffer; 
char real_buffer[MAX_STRING_CHARS];	
char word[1024];
fileHandle_t wordList;
int len = 0;
int num = 0;
int i = 0;
int y = 0;
char *wordStart;
int offset;
int pos = 0;

if(real_buffer[i] != '\n')
{
       word[num] = real_buffer[i];			
num++;	
}
else if(real_buffer[i] == '\n')
{
cmdEnt(ent, va("print \"%s\n\"", word));

if(wordStart = JAXtra_StriStr(word, p))
{
	cmdEnt(ent, va("print \"%s\n\"", wordStart));
	//Find where this word starts in the msg 
	offset = wordStart - p;

	cmdEnt(ent, va("print \"%i\n\"", offset));					

	//Start starring out the word
	for(y = offset; y < strlen(word); y++)
	{
		p[y] = '*';
	}

	//Empty out and reset the word counter
	memcpy(word, " ", sizeof(" "));
	num = 0;
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...