summaryrefslogtreecommitdiff
path: root/src/cluster.c
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2021-11-29 16:30:35 +0800
committerGitHub <noreply@github.com>2021-11-29 10:30:35 +0200
commit980bb3ae19ecb3c3e112242e076bb8ceff521cf1 (patch)
treeb1e38736b2105f4b6005167f4c864b64b372d145 /src/cluster.c
parentd56ded89c54943ed69a5811e6b6cc55b8ecdce6e (diff)
downloadredis-980bb3ae19ecb3c3e112242e076bb8ceff521cf1.tar.gz
Add REDIS_CFLAGS='-Werror' to CI tests (#9828)
Update CI so that warnings cause build failures. Also fix a warning in `test-sanitizer-address`: ``` In function ‘strncpy’, inlined from ‘clusterUpdateMyselfIp’ at cluster.c:545:13: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 46 equals destination size [-Werror=stringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ```
Diffstat (limited to 'src/cluster.c')
-rw-r--r--src/cluster.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cluster.c b/src/cluster.c
index 215137505..cbc4cd184 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -542,7 +542,7 @@ void clusterUpdateMyselfIp(void) {
* duplicating the string. This way later we can check if
* the address really changed. */
prev_ip = zstrdup(prev_ip);
- strncpy(myself->ip,server.cluster_announce_ip,NET_IP_STR_LEN);
+ strncpy(myself->ip,server.cluster_announce_ip,NET_IP_STR_LEN-1);
myself->ip[NET_IP_STR_LEN-1] = '\0';
} else {
myself->ip[0] = '\0'; /* Force autodetection. */
@@ -2538,7 +2538,7 @@ void clusterBuildMessageHdr(clusterMsg *hdr, int type) {
* first byte is zero, they'll do auto discovery. */
memset(hdr->myip,0,NET_IP_STR_LEN);
if (server.cluster_announce_ip) {
- strncpy(hdr->myip,server.cluster_announce_ip,NET_IP_STR_LEN);
+ strncpy(hdr->myip,server.cluster_announce_ip,NET_IP_STR_LEN-1);
hdr->myip[NET_IP_STR_LEN-1] = '\0';
}