diff options
Diffstat (limited to 'src/core/lib/iomgr/unix_sockets_posix.cc')
-rw-r--r-- | src/core/lib/iomgr/unix_sockets_posix.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/core/lib/iomgr/unix_sockets_posix.cc b/src/core/lib/iomgr/unix_sockets_posix.cc index 154c58e98b..af862c00dc 100644 --- a/src/core/lib/iomgr/unix_sockets_posix.cc +++ b/src/core/lib/iomgr/unix_sockets_posix.cc @@ -39,7 +39,8 @@ void grpc_create_socketpair_if_unix(int sv[2]) { grpc_error* grpc_resolve_unix_domain_address(const char* name, grpc_resolved_addresses** addrs) { struct sockaddr_un* un; - if (strlen(name) > GPR_ARRAY_SIZE(((struct sockaddr_un*)nullptr)->sun_path) - 1) { + if (strlen(name) > + GPR_ARRAY_SIZE(((struct sockaddr_un*)nullptr)->sun_path) - 1) { char* err_msg; grpc_error* err; gpr_asprintf(&err_msg, @@ -56,7 +57,7 @@ grpc_error* grpc_resolve_unix_domain_address(const char* name, (grpc_resolved_address*)gpr_malloc(sizeof(grpc_resolved_address)); un = (struct sockaddr_un*)(*addrs)->addrs->addr; un->sun_family = AF_UNIX; - strcpy(un->sun_path, name); + strncpy(un->sun_path, name, sizeof(un->sun_path)); (*addrs)->addrs->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1; return GRPC_ERROR_NONE; } |