ref: b7fe78cad8a951aa08c3133478da175eb377e2fd
parent: 9d993d84e85eeb8dd304e48463d89865795e97ed
author: Eievui <14899090+GreenAndEievui@users.noreply.github.com>
date: Wed Nov 24 11:00:54 EST 2021
Fix improperly terminated region name check (#953)
--- a/src/link/main.c
+++ b/src/link/main.c
@@ -281,13 +281,12 @@
// 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)