huor commented on a change in pull request #1458: HAWQ-1729.fix memory wrong
usage
URL: https://github.com/apache/hawq/pull/1458#discussion_r306109817
##########
File path: 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 + 1] = 0;
Review comment:
local_name[IDENT_USERNAME_MAX] = '\0';
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services