strmid writing to wrong varible
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
The problem is more likely that your salt is not terminated with a null terminator. When you print a string memory is read until the next null terminator is found. If there isn't a null terminator at the end of the string then it'll just continue reading into adjacent memory where other variables are stored. That's called buffer overflow.

Do you mind showing your RandomString method?
Here you go:

Код:
stock RandomString(strDest[], strLen = 10)
{
	while(strLen--)
	{
		strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
	}
}
Quote:
Originally Posted by Misiur
Посмотреть сообщение
If string is 72 characters long you need 73 characters. Why?
First of all know that strings in PAWN are no different than an array. Basically those are the same:
pawn Код:
new str[] = "Hello";
// same as
new str[] = { 'H', 'e', 'l', 'l', 'o', '\0' };
Notice that '\0'. All string functions depend on it to know when the string ends. So, if you overwrite it with a character, printf for example does not know that string ended and reads memory until it meets '\0'. In your case, from eEmail

#e: Damn internet outage
This is how they're defined:

Код:
new password[ACCOUNT_MAX_PASSWORD_SIZE], password_hash[128], email[ACCOUNT_MAX_EMAIL_SIZE];
	    
if(sscanf(params, "s["#ACCOUNT_MAX_PASSWORD_SIZE"]s["#ACCOUNT_MAX_EMAIL_SIZE"]", password, email))
{
    SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /register [pass] [email]");
    return 1;
}
So i should just +1 on array sizes?
Reply


Messages In This Thread
strmid writing to wrong varible - by wallee - 06.09.2017, 05:10
Re: strmid writing to wrong varible - by nG Inverse - 06.09.2017, 05:43
Re: strmid writing to wrong varible - by wallee - 06.09.2017, 07:13
Re: strmid writing to wrong varible - by Vince - 06.09.2017, 08:25
Re: strmid writing to wrong varible - by Misiur - 06.09.2017, 08:32
Re: strmid writing to wrong varible - by wallee - 06.09.2017, 20:13
Re: strmid writing to wrong varible - by wallee - 07.09.2017, 02:31
Re: strmid writing to wrong varible - by Paulice - 07.09.2017, 04:17
Re: strmid writing to wrong varible - by wallee - 07.09.2017, 19:21

Forum Jump:


Users browsing this thread: 1 Guest(s)