Skip to content

Commit d2a1ed1

Browse files
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 <rahilasyed90@gmail.com> Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://postgr.es/m/CAH2L28vt16C9xTuK+K7QZvtA3kCNWXOEiT=gEekUw3Xxp9LVQw@mail.gmail.com
1 parent 991407a commit d2a1ed1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/backend/utils/mmgr/mcxt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,7 @@ ProcessGetMemoryContextInterrupt(void)
16631663
meminfo[max_stats - 1].name = dsa_allocate(MemoryStatsDsaArea, namelen + 1);
16641664
nameptr = dsa_get_address(MemoryStatsDsaArea, meminfo[max_stats - 1].name);
16651665
strncpy(nameptr, "Remaining Totals", namelen);
1666+
nameptr[namelen] = '\0';
16661667
meminfo[max_stats - 1].ident = InvalidDsaPointer;
16671668
meminfo[max_stats - 1].path = InvalidDsaPointer;
16681669
meminfo[max_stats - 1].type = 0;

0 commit comments

Comments
 (0)