James Peach created ZOOKEEPER-3064:
--------------------------------------
Summary: Format overflow warning when building with Clang 6
Key: ZOOKEEPER-3064
URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3064
Project: ZooKeeper
Issue Type: Task
Reporter: James Peach
Building ZK 3.4.8 with gcc (GCC) 8.1.1 20180502 (Red Hat 8.1.1-1)
{noformat}
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./include -I./tests -I./generated
-Wall -Werror -g -O2 -D_GNU_SOURCE -MT zookeeper.lo -MD -MP -MF
.deps/zookeeper.Tpo -c src/zookeeper.c -fPIC -DPIC -o zookeeper.o
...
src/zookeeper.c: In function ‘format_endpoint_info’:
src/zookeeper.c:3504:21: error: ‘%d’ directive writing between 1 and 5 bytes
into a region of size between 0 and 127 [-Werror=format-overflow=]
sprintf(buf,"%s:%d",addrstr,ntohs(port));
^~
src/zookeeper.c:3504:17: note: directive argument in the range [0, 65535]
sprintf(buf,"%s:%d",addrstr,ntohs(port));
^~~~~~~
src/zookeeper.c:3504:5: note: ‘sprintf’ output between 3 and 134 bytes into a
destination of size 128
sprintf(buf,"%s:%d",addrstr,ntohs(port));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{noformat}
Looks like gcc wants
[format_endpoint_info|https://github.com/apache/zookeeper/blob/master/src/c/src/zookeeper.c#L4357]
to use snprintf.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)