diff options
author | Craig Tiller <ctiller@google.com> | 2017-01-27 16:19:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-27 16:19:29 -0800 |
commit | 53ac4157321bc9c3b61830b775b4d2be05dc447e (patch) | |
tree | a2e33f7f536263dbae52e9b1ad8687bdc15818f3 /src/core/lib | |
parent | 3d760aef16c984a18a754069691db55b342da57e (diff) | |
parent | e6f01f6b962c4063956e737d6c8c01e27560d4b8 (diff) |
Merge pull request #8464 from y-zeng/str_length
Check the length of unix socket path name
Diffstat (limited to 'src/core/lib')
-rw-r--r-- | src/core/lib/iomgr/unix_sockets_posix.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/core/lib/iomgr/unix_sockets_posix.c b/src/core/lib/iomgr/unix_sockets_posix.c index 030acd9811..1233cec04e 100644 --- a/src/core/lib/iomgr/unix_sockets_posix.c +++ b/src/core/lib/iomgr/unix_sockets_posix.c @@ -45,6 +45,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/useful.h> void grpc_create_socketpair_if_unix(int sv[2]) { GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0); @@ -53,7 +54,16 @@ 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 *)0)->sun_path) - 1) { + char *err_msg; + grpc_error *err; + gpr_asprintf(&err_msg, + "Path name should not have more than %" PRIuPTR " characters.", + GPR_ARRAY_SIZE(un->sun_path) - 1); + err = GRPC_ERROR_CREATE(err_msg); + gpr_free(err_msg); + return err; + } *addrs = gpr_malloc(sizeof(grpc_resolved_addresses)); (*addrs)->naddrs = 1; (*addrs)->addrs = gpr_malloc(sizeof(grpc_resolved_address)); |