Replace strncpy with strlcpy

Replace strncpy with strlcpy, since destination size equals
maximum number of characters to copy.
Pointed by gcc8 [-Werror=stringop-truncation]

Change-Id: I528a35bd071b1d13f16dcec2e8c2007b5bb072b2
Reviewed-on: https://review.haiku-os.org/473
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Murai Takashi
2018-08-19 20:36:01 +00:00
committed by waddlesplash
parent 3a50df1bd0
commit d9863ca8dc
+1 -1
View File
@@ -1581,7 +1581,7 @@ MemSizeToString(char string[], size_t size, system_info* info)
snprintf(string, size, "%d", inaccessibleMemory);
message.ReplaceFirst("%inaccessible", string);
strncpy(string, message.String(), size);
strlcpy(string, message.String(), size);
} else {
snprintf(string, size, B_TRANSLATE("%d MiB total"),
int(info->max_pages * (B_PAGE_SIZE / 1048576.0f) + 0.5f));