Tracker: Use strlcpy in FSMakeOriginalName.

Suggested by axeld on the mailing list a while back.
strlcpy/strlcat NULL-terminate within the passed buffer size,
so we have no need to subtract 1 here.
This commit is contained in:
Augustin Cavalier
2021-10-20 21:04:44 -04:00
parent 82df3fc639
commit d37e23576c
+2 -3
View File
@@ -2416,7 +2416,7 @@ FSMakeOriginalName(char* name, BDirectory* destDir, const char* suffix)
strlcpy(root, name, sizeof(root));
// save root name
strlcat(name, suffix, B_FILE_NAME_LENGTH - 1);
strlcat(name, suffix, B_FILE_NAME_LENGTH);
}
strlcpy(copybase, name, sizeof(copybase));
@@ -2440,8 +2440,7 @@ FSMakeOriginalName(char* name, BDirectory* destDir, const char* suffix)
}
}
ASSERT((strlen(tempName) <= (B_FILE_NAME_LENGTH - 1)));
strcpy(name, tempName);
strlcpy(name, tempName, B_FILE_NAME_LENGTH);
}