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