Dom_152 Posted November 12, 2006 Share Posted November 12, 2006 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: 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! 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 More sharing options...
ensiform Posted November 12, 2006 Share Posted November 12, 2006 Might be helpful to see some of your code being used. Link to comment Share on other sites More sharing options...
Dom_152 Posted November 12, 2006 Author Share Posted November 12, 2006 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 More sharing options...
ensiform Posted November 13, 2006 Share Posted November 13, 2006 What's the point of that when ClientConnect already has ip checking? Link to comment Share on other sites More sharing options...
Dom_152 Posted November 13, 2006 Author Share Posted November 13, 2006 It only checks a the Cvar g_bannedips or something like that and that Cvar is cleared every time the server restarts. I'm reading IPs from a file. Link to comment Share on other sites More sharing options...
ensiform Posted November 13, 2006 Share Posted November 13, 2006 That's still a poor way to do it; add the cvar to jampgame or jampserver depending on which is being used and it wont clear everytime lol. Link to comment Share on other sites More sharing options...
Dom_152 Posted November 25, 2006 Author Share Posted November 25, 2006 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.