This is an automated email from the ASF dual-hosted git repository.
nkalmar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 4b45ff1 ZOOKEEPER-3741: fix buffer length in C client causing warning
with new gcc
4b45ff1 is described below
commit 4b45ff1bda65b27d2771322d4613fccfb8a726b0
Author: Mate Szalay-Beko <[email protected]>
AuthorDate: Thu Feb 27 14:22:06 2020 +0100
ZOOKEEPER-3741: fix buffer length in C client causing warning with new gcc
We get a warning that we are trying to call like
`sprintf(buf,"%s:%d",addrstr,port);`, and both `buf` and `addrstr` are 128 long
char arrays. So in theory, we can overflow. The fix is to increase the length
of the destination string array (`buf`).
Actually this problem only causing compile time warning / failure only on
the 3.5.5 and 3.5.6. On 3.5.7 this was fixed and on 3.6+ branches the compiler
can not detect the problem due to some code refactoring made by ZOOKEEPER-3068,
but the issue is still present on the master branch.
Author: Mate Szalay-Beko <[email protected]>
Reviewers: Enrico Olivelli <[email protected]>, Norbert Kalmar
<[email protected]>
Closes #1273 from symat/ZOOKEEPER-3741
---
zookeeper-client/zookeeper-client-c/src/zookeeper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/zookeeper-client/zookeeper-client-c/src/zookeeper.c
b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
index 5f3cb5d..0c143e7 100644
--- a/zookeeper-client/zookeeper-client-c/src/zookeeper.c
+++ b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
@@ -4956,7 +4956,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 };
+ static char buf[134] = { 0 };
char addrstr[INET6_ADDRSTRLEN] = { 0 };
const char *fmtstring;
void *inaddr;