diff options
author | Martin Schwenke <martin@meltin.net> | 2018-07-26 11:01:30 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2018-07-27 05:45:20 +0200 |
commit | 3b56f2002a35b55b46958178c79aee519f0c5880 (patch) | |
tree | 58f381853c5841880fa6c6290ea157e84e33217c /ctdb | |
parent | 5dd84bf5d73e4afab094834bc317da7884b9b9b3 (diff) | |
download | samba-3b56f2002a35b55b46958178c79aee519f0c5880.tar.gz |
ctdb-protocol: Fix compilation issue with strncpy()
When configured with --picky-developer and using -O3 with gcc 8.1:
../protocol/protocol_util.c: In function ‘ctdb_sock_addr_from_string’:
../protocol/protocol_util.c:282:2: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
strncpy(s, str, len+1);
^~~~~~~~~~~~~~~~~~~~~~
../protocol/protocol_util.c:277:8: note: length computed here
len = strlen(str);
^~~~~~~~~~~
Use strlcpy() instead and check the result.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13545
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/protocol/protocol_util.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c index c75555fa734..1b9a46ef8e2 100644 --- a/ctdb/protocol/protocol_util.c +++ b/ctdb/protocol/protocol_util.c @@ -274,13 +274,11 @@ int ctdb_sock_addr_from_string(const char *str, /* Parse out port number and then IP address */ - len = strlen(str); + len = strlcpy(s, str, sizeof(s)); if (len >= sizeof(s)) { return EINVAL; } - strncpy(s, str, len+1); - p = rindex(s, ':'); if (p == NULL) { return EINVAL; |