You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by hu...@apache.org on 2019/07/23 03:50:38 UTC

[hawq] branch master updated: HAWQ-1729.fix memory wrong usage

This is an automated email from the ASF dual-hosted git repository.

huor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hawq.git


The following commit(s) were added to refs/heads/master by this push:
     new 6630c54  HAWQ-1729.fix memory wrong usage
6630c54 is described below

commit 6630c5470fb0c2149eefb9e3b49933c7aa69e3e4
Author: ZongtianHou <ho...@outlook.com>
AuthorDate: Tue Jul 23 10:41:42 2019 +0800

    HAWQ-1729.fix memory wrong usage
---
 src/backend/libpq/auth.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index 1475ca0..782c277 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -383,12 +383,19 @@ internal_client_authentication(Port *port)
 			/* 
 			 * Internal connection via a domain socket -- use ident
 			 */
-			char *local_name;
+			char local_name[IDENT_USERNAME_MAX + 1];
 			char remote_name[IDENT_USERNAME_MAX + 1];
 			struct passwd *pw;
 
 			pw = getpwuid(geteuid());
-			local_name = pw->pw_name;
+
+			/*
+			 * copy local name out because another getpwuid call is performed in
+			 * ident_unix(), which causes memory freed referenced by pw
+			 */
+
+			local_name[IDENT_USERNAME_MAX] = '\0';
+			strncpy(local_name, pw->pw_name, IDENT_USERNAME_MAX);
 
 			remote_name[0] = '\0';