Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions opal/util/fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ bool opal_fd_is_blkdev(int fd)
const char *opal_fd_get_peer_name(int fd)
{
char *str;
const char *ret;
const char *ret = NULL;
struct sockaddr sa;
socklen_t slt = (socklen_t) sizeof(sa);

Expand All @@ -152,7 +152,7 @@ const char *opal_fd_get_peer_name(int fd)
#if OPAL_ENABLE_IPV6
len = INET6_ADDRSTRLEN;
#endif
str = malloc(len);
str = calloc(1, len);
if (NULL == str) {
return NULL;
}
Expand All @@ -176,7 +176,9 @@ const char *opal_fd_get_peer_name(int fd)
}
#endif
else {
// This string is guaranteed to be <= INET_ADDRSTRLEN
strncpy(str, "Unknown", len);
ret = str;
}

return ret;
Expand Down