Incorrect character.
#1

Hello!

When I ban a user, I input their name, ip, reason etc. however when it stores in the data, it shows a strange character for the ip.
Код:
CMD:ban(playerid, params[]) {
	new banid, length, reason[STR_SIZE];
	if(mData[playerid][Logged] == true && pData[playerid][Logged] == true && mData[playerid][aLevel] >= 1) {
		if(sscanf(params, "iiS()["#STR_SIZE"]", banid, length, reason)) return SCM(playerid, GREY, "[Usage]: /ban [playerid] [length] [reason]");
		else {
			if(banid != INVALID_PLAYER_ID) {
				if(mData[banid][Logged] == true && pData[banid][Logged] == true) {
					if(!isnull(reason)) { format(str, sizeof(str), "%s has been banned by %s [Reason: %s]", PlayerName(banid), PlayerName(playerid), reason); }
					else { format(str, sizeof(str), "%s has been banned by %s", PlayerName(banid), PlayerName(playerid)); }
					SGM(RED, str);
					MySQL::format(query, "INSERT INTO bandata (ID, Username, IP, Author, Date, Type, Length, Reason) VALUES ('%i', '%s', '%s', '%s', '%s', 0, '%i', '%e')", mData[banid][ID], mData[banid][Username], mData[banid][IP], mData[playerid][Username], Unix(1), length, reason);
					MySQL::slowQuery(query, false);
					Kick(banid);
				} else { return SCM(playerid, GREY, PLAYERNOTLOGGEDIN); }
			} else { return SCM(playerid, GREY, INVALIDPLAYER); }
		}
	} else { return SCM(playerid, GREY, CMDNOTALLOWED); }
	return 1;
}

It's strange because the ip is being stored as a string which shouldn't do anything unless it was an unrecognised character.. but it is just a 1... "127.0.0.1"
Reply
#2

How do you get the IP? It's stored ?
I think the problem can from here :
PHP код:
mData[banid][Username
Reply
#3

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
How do you get the IP? It's stored ?
I think the problem can from here :
PHP код:
mData[banid][Username
I've stored it here..
Код:
enum Master_Data {
	ID,
	Username[MAX_PLAYER_NAME],
	IP[16],
	aLevel,
	bool:Tutorial,
	Slot1[128],
	Slot2[128],
	Slot3[128],
	bool:Registered,
	bool:Logged
}
Reply
#4

It smells like buffer overflow, but I can't quite place my finger on it. You may want to check if mData[banid][Username] is terminated by a null character.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
It smells like buffer overflow, but I can't quite place my finger on it. You may want to check if mData[banid][Username] is terminated by a null character.
It doesn't seem like it, I check the players Username and IP in "OnPlayerConnect" and that is what shows the bandata, I printed the mData[playerid][IP] when it is first checked and stored, and it shows the full IP. Even when I execute the command it shows the full IP, however just when it stores into the database it doesn't work.
Reply
#6

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)