1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-29 16:21:20 +03:00

Convert strncpy to strlcpy

We try to avoid using strncpy() due to the ease of which it can
be misused.  Convert this callsite to use strlcpy() instead to
match similar codepaths in this file.

Suggested-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/2a796830-de2d-4030-b480-d673f6cc5d94@eisentraut.org
This commit is contained in:
Daniel Gustafsson 2025-04-30 23:00:47 +02:00
parent 2d6745a66b
commit 45e7e8ca9e

View File

@ -1664,8 +1664,7 @@ ProcessGetMemoryContextInterrupt(void)
num_individual_stats = context_id + 1;
meminfo[max_stats - 1].name = dsa_allocate(MemoryStatsDsaArea, namelen + 1);
nameptr = dsa_get_address(MemoryStatsDsaArea, meminfo[max_stats - 1].name);
strncpy(nameptr, "Remaining Totals", namelen);
nameptr[namelen] = '\0';
strlcpy(nameptr, "Remaining Totals", namelen + 1);
meminfo[max_stats - 1].ident = InvalidDsaPointer;
meminfo[max_stats - 1].path = InvalidDsaPointer;
meminfo[max_stats - 1].type = 0;