mirror of
https://github.com/ioquake/jedi-academy.git
synced 2024-11-22 04:11:57 +00:00
bounds check values in BG_LegalizedForcePowers()
This commit is contained in:
parent
df117b922f
commit
8be8413a0b
1 changed files with 12 additions and 3 deletions
|
@ -454,14 +454,17 @@ qboolean BG_LegalizedForcePowers(char *powerOut, int maxRank, qboolean freeSaber
|
||||||
if (powerLen >= 128)
|
if (powerLen >= 128)
|
||||||
{ //This should not happen. If it does, this is obviously a bogus string.
|
{ //This should not happen. If it does, this is obviously a bogus string.
|
||||||
//They can have this string. Because I said so.
|
//They can have this string. Because I said so.
|
||||||
strcpy(powerBuf, "7-1-032330000000001333");
|
Q_strncpyz(powerBuf, "7-1-032330000000001333", sizeof(powerBuf));
|
||||||
maintainsValidity = qfalse;
|
maintainsValidity = qfalse;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(powerBuf, powerOut); //copy it as the original
|
Q_strncpyz(powerBuf, powerOut, sizeof(powerBuf)); //copy it as the original
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (maxRank < 1 || maxRank > MAX_FORCE_RANK)
|
||||||
|
maxRank = 1; // set to rank 1 on invalid rank
|
||||||
|
|
||||||
//first of all, print the max rank into the string as the rank
|
//first of all, print the max rank into the string as the rank
|
||||||
strcpy(powerOut, va("%i-", maxRank));
|
strcpy(powerOut, va("%i-", maxRank));
|
||||||
|
|
||||||
|
@ -503,9 +506,15 @@ qboolean BG_LegalizedForcePowers(char *powerOut, int maxRank, qboolean freeSaber
|
||||||
c = 0;
|
c = 0;
|
||||||
while (i < 128 && powerBuf[i] && powerBuf[i] != '\n' && c < NUM_FORCE_POWERS)
|
while (i < 128 && powerBuf[i] && powerBuf[i] != '\n' && c < NUM_FORCE_POWERS)
|
||||||
{
|
{
|
||||||
|
int forcePowerLevel;
|
||||||
readBuf[0] = powerBuf[i];
|
readBuf[0] = powerBuf[i];
|
||||||
readBuf[1] = 0;
|
readBuf[1] = 0;
|
||||||
final_Powers[c] = atoi(readBuf);
|
forcePowerLevel = atoi(readBuf);
|
||||||
|
if (forcePowerLevel < FORCE_LEVEL_0 || forcePowerLevel >= NUM_FORCE_POWER_LEVELS)
|
||||||
|
{
|
||||||
|
forcePowerLevel = FORCE_LEVEL_0; // set invalid levels to 0
|
||||||
|
}
|
||||||
|
final_Powers[c] = forcePowerLevel;
|
||||||
c++;
|
c++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue