Anti Crash Fix Maybe?
#1

Hello,

Few minutes ago my server was crashing every 5-10 minutes.
I think this was caused by a hacker.
Anyway I have run the gamemode with crashdetect and this came out >

[16:38:45] [debug] Run time error 4: "Array index out of bounds"
[16:38:45] [debug] Accessing element at index 65535 past array upper bound 79
[16:38:45] [debug] AMX backtrace:
[16:38:45] [debug] #0 0005ceb4 in public OnPlayerTakeDamage () from x_gamemode.amx

Which means for some reason a playerid which was 65535 came into OnPlayerTakeDamage, and this caused the server to crash.
So I added ,

if(issuerid > MAX_PLAYERS || playerid > MAX_PLAYERS) return 0;

Under OnPlayerTakeDamage (at the top).

Im not sure if it has been fixed, but the server hasn't been crashed since so I guess it did.

So if someone can confirm that this is working then others can use it too, to prevent crashers.
Reply
#2

That code dont have logic i think that can't be possible
Reply
#3

You only need to check if issuerid is not INVALID_PLAYER_ID and then do your code inside that.
Reply
#4

tried this?
pawn Код:
if(issuerid == INVALID_PLAYER_ID || playerid == INVALID_PLAYER_ID) return 1;
Because there is an array you have there with issuerid/playerid which is actually 65535 so it crashes.

pawn Код:
new var[5];

main() {
var[4] = 1; // Safe
var[10] = 1; // Crash
}
Reply
#5

@kirollos: No need to check for the playerid too. If the playerid was invalid, then the OnPlayerTakeDamage callback would not been called at all.
Reply
#6

Might be rak-samp bot lagging/crashing the server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)