From 65da0d66b4e89951078ebc43a5343780e4e700d6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 7 Jul 2000 21:12:53 +0000 Subject: Fix misuse of StrNCpy to copy and add null to non-null-terminated data. Does not work since it fetches one byte beyond the source data, and when the phase of the moon is wrong, the source data is smack up against the end of backend memory and you get SIGSEGV. Don't laugh, this is a fix for an actual user bug report. --- contrib/miscutil/misc_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'contrib/miscutil/misc_utils.c') diff --git a/contrib/miscutil/misc_utils.c b/contrib/miscutil/misc_utils.c index f5a98683280..e7949d32aa6 100644 --- a/contrib/miscutil/misc_utils.c +++ b/contrib/miscutil/misc_utils.c @@ -99,9 +99,9 @@ active_listeners(text *relname) if (relname && (VARSIZE(relname) > VARHDRSZ)) { + MemSet(listen_name, 0, NAMEDATALEN); len = MIN(VARSIZE(relname) - VARHDRSZ, NAMEDATALEN - 1); - strncpy(listen_name, VARDATA(relname), len); - listen_name[len] = '\0'; + memcpy(listen_name, VARDATA(relname), len); ScanKeyEntryInitialize(&key, 0, Anum_pg_listener_relname, F_NAMEEQ, -- cgit v1.2.3