File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ bool opal_fd_is_blkdev(int fd)
138138const char * opal_fd_get_peer_name (int fd )
139139{
140140 char * str ;
141- const char * ret ;
141+ const char * ret = NULL ;
142142 struct sockaddr sa ;
143143 socklen_t slt = (socklen_t ) sizeof (sa );
144144
@@ -152,7 +152,7 @@ const char *opal_fd_get_peer_name(int fd)
152152#if OPAL_ENABLE_IPV6
153153 len = INET6_ADDRSTRLEN ;
154154#endif
155- str = malloc ( len );
155+ str = calloc ( 1 , len );
156156 if (NULL == str ) {
157157 return NULL ;
158158 }
@@ -176,7 +176,9 @@ const char *opal_fd_get_peer_name(int fd)
176176 }
177177#endif
178178 else {
179+ // This string is guaranteed to be <= INET_ADDRSTRLEN
179180 strncpy (str , "Unknown" , len );
181+ ret = str ;
180182 }
181183
182184 return ret ;
You can’t perform that action at this time.
0 commit comments