diff options
author | David Garcia Quintas <dgq@google.com> | 2017-02-23 09:11:24 -0800 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2017-02-23 09:31:56 -0800 |
commit | e2869fee8db5f7a94858b551089c45bbb1bd943b (patch) | |
tree | 184ce5e2281df27ccd48e59460cadb15a28a3699 /src/core/ext | |
parent | f05359f6975003197d83ec5a1b78893e01000f99 (diff) |
Simply return 0 on input path too long
Diffstat (limited to 'src/core/ext')
-rw-r--r-- | src/core/ext/client_channel/parse_address.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/ext/client_channel/parse_address.c b/src/core/ext/client_channel/parse_address.c index 4b8222824b..17cfc9795b 100644 --- a/src/core/ext/client_channel/parse_address.c +++ b/src/core/ext/client_channel/parse_address.c @@ -49,12 +49,12 @@ int parse_unix(grpc_uri *uri, grpc_resolved_address *resolved_addr) { struct sockaddr_un *un = (struct sockaddr_un *)resolved_addr->addr; - + const size_t maxlen = sizeof(un->sun_path); + const size_t path_len = strnlen(uri->path, maxlen); + if (path_len == maxlen) return 0; un->sun_family = AF_UNIX; - strncpy(un->sun_path, uri->path, sizeof(un->sun_path) - 1 /* null term'd */); - un->sun_path[sizeof(un->sun_path) - 1] = '\0'; - resolved_addr->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1; - + strcpy(un->sun_path, uri->path); + resolved_addr->len = path_len + sizeof(un->sun_family) + 1; return 1; } |