From: Daniel Gustafsson Date: Wed, 30 Apr 2025 08:34:08 +0000 (+0200) Subject: Add missing string terminator X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=d2a1ed1727a8ef45eab1a8ddb3d375c1ce839aac;p=users%2Frhaas%2Fpostgres.git 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 Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/CAH2L28vt16C9xTuK+K7QZvtA3kCNWXOEiT=gEekUw3Xxp9LVQw@mail.gmail.com --- diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index 506f290298..786e92039b 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;