summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gustafsson2025-04-30 08:34:08 +0000
committerDaniel Gustafsson2025-04-30 08:34:08 +0000
commitd2a1ed1727a8ef45eab1a8ddb3d375c1ce839aac (patch)
treef3a2665f7218d99b7b3589731bf84412140fca31
parent991407ae86785ef38bb1ebfea679a70bcd76574d (diff)
Add missing string terminator
When copying the string strncpy won't add nul termination since the string length is equal to the length specified. Explicitly set a nul terminator after copying to properly terminate. Found via post-commit review. Author: Rahila Syed <[email protected]> Reviewed-by: Daniel Gustafsson <[email protected]> Discussion: https://postgr.es/m/CAH2L28vt16C9xTuK+K7QZvtA3kCNWXOEiT=gEekUw3Xxp9LVQw@mail.gmail.com
-rw-r--r--src/backend/utils/mmgr/mcxt.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index 506f2902986..786e92039b1 100644
--- a/src/backend/utils/mmgr/mcxt.c
+++ b/src/backend/utils/mmgr/mcxt.c
@@ -1663,6 +1663,7 @@ ProcessGetMemoryContextInterrupt(void)
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';
meminfo[max_stats - 1].ident = InvalidDsaPointer;
meminfo[max_stats - 1].path = InvalidDsaPointer;
meminfo[max_stats - 1].type = 0;