Skip to content

Commit 45e7e8c

Browse files
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
1 parent 2d6745a commit 45e7e8c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/backend/utils/mmgr/mcxt.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,8 +1664,7 @@ ProcessGetMemoryContextInterrupt(void)
16641664
num_individual_stats = context_id + 1;
16651665
meminfo[max_stats - 1].name = dsa_allocate(MemoryStatsDsaArea, namelen + 1);
16661666
nameptr = dsa_get_address(MemoryStatsDsaArea, meminfo[max_stats - 1].name);
1667-
strncpy(nameptr, "Remaining Totals", namelen);
1668-
nameptr[namelen] = '\0';
1667+
strlcpy(nameptr, "Remaining Totals", namelen + 1);
16691668
meminfo[max_stats - 1].ident = InvalidDsaPointer;
16701669
meminfo[max_stats - 1].path = InvalidDsaPointer;
16711670
meminfo[max_stats - 1].type = 0;

0 commit comments

Comments
 (0)