Fix improperly terminated region name check (#953)

This commit is contained in:
Eievui
2021-11-24 16:00:54 -05:00
committed by GitHub
parent 9d993d84e8
commit b7fe78cad8

View File

@@ -281,13 +281,12 @@ static void parseScrambleSpec(char const *spec)
// Now, determine which region type this is // Now, determine which region type this is
enum ScrambledRegion region = 0; enum ScrambledRegion region = 0;
while (region < SCRAMBLE_UNK) { for (; region < SCRAMBLE_UNK; region++) {
// If the strings match (case-insensitively), we got it! // If the strings match (case-insensitively), we got it!
// It's OK not to use `strncasecmp` because `regionName` is still // `strncasecmp` must be used here since `regionName` points
// NUL-terminated, since the encompassing spec is. // to the entire remaining argument.
if (!strcasecmp(scrambleSpecs[region].name, regionName)) if (!strncasecmp(scrambleSpecs[region].name, regionName, regionNameLen))
break; break;
region++;
} }
if (region == SCRAMBLE_UNK) if (region == SCRAMBLE_UNK)