[ 
https://issues.apache.org/jira/browse/HAWQ-1729?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16890632#comment-16890632
 ] 

ASF GitHub Bot commented on HAWQ-1729:
--------------------------------------

huor commented on 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:
us...@infra.apache.org


> fix memory wrong usage
> ----------------------
>
>                 Key: HAWQ-1729
>                 URL: https://issues.apache.org/jira/browse/HAWQ-1729
>             Project: Apache HAWQ
>          Issue Type: Bug
>            Reporter: Zongtian Hou
>            Assignee: Radar Lei
>            Priority: Major
>
> memory usage is wrong



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to