mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-27 23:35:36 +03:00
Fix UTF-8 character parsing due to improper casting (#401)
Upcasting of -ve signed characters (char) to signed integers (cell) results in -ve signed integers which don't represent valid printable characters. eg. UTF-8 Character '中' (0xE4 0xB8 0xAD) when casted results in 0xFFFFFFE4 0xFFFFFFB8 0xFFFFFFAD which are not valid printable characters.
This commit is contained in:
parent
9b3839de70
commit
a30172f8a6
@ -708,7 +708,7 @@ static cell AMX_NATIVE_CALL parse(AMX *amx, cell *params) /* 3 param */
|
|||||||
c = *get_amxaddr(amx, params[iarg++]);
|
c = *get_amxaddr(amx, params[iarg++]);
|
||||||
|
|
||||||
while (c-- && *arg)
|
while (c-- && *arg)
|
||||||
*cptr++ = (cell)*arg++;
|
*cptr++ = (unsigned char)*arg++;
|
||||||
*cptr = 0;
|
*cptr = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1006,7 +1006,7 @@ static cell AMX_NATIVE_CALL argparse(AMX *amx, cell *params)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (size_t(bufpos - buffer) < buflen)
|
if (size_t(bufpos - buffer) < buflen)
|
||||||
*bufpos++ = input[i];
|
*bufpos++ = (unsigned char)input[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
*bufpos = '\0';
|
*bufpos = '\0';
|
||||||
@ -1068,7 +1068,7 @@ do_copy:
|
|||||||
{
|
{
|
||||||
start = &(string[i]);
|
start = &(string[i]);
|
||||||
while (end--)
|
while (end--)
|
||||||
*right++ = (cell)*start++;
|
*right++ = (unsigned char)*start++;
|
||||||
}
|
}
|
||||||
*right = '\0';
|
*right = '\0';
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user