Github user sl4mmy commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/559#discussion_r200184176
--- Diff: src/c/src/zookeeper.c ---
@@ -4357,7 +4357,7 @@ int zoo_add_auth(zhandle_t *zh,const char*
scheme,const char* cert,
static const char* format_endpoint_info(const struct sockaddr_storage* ep)
{
static char buf[128] = { 0 };
- char addrstr[128] = { 0 };
+ char addrstr[INET6_ADDRSTRLEN] = { 0 };
--- End diff --
Check and check, it is 46 and ZK does not override it. I apologize if my
wording wasn't clear enough, but the issue that GCC 8 errors on is the fact
that buf and addrstr are both size 128, but later on in the call to
`sprintf(3)` we write `addrstr + ':' + port` into buf. GCC 8 sees that buf &
addrstr are both potentially 128 characters long, so the `sprintf(3)` could
*potentially* overflow buf when it tacks on the colon & port. Of course, we
know that will never happen, but GCC 8 doesn't. So by resizing the declaration
of addrstr we safely avoid any confusion or doubt.
---