fixed strncpy off-by-one errors
Former-commit-id: b8e106a72e71bf5d8abd7d6032ff950f9722db59
This commit is contained in:
parent
8f132802d8
commit
13dfc4f228
@ -2468,7 +2468,7 @@ void clusterBuildMessageHdr(clusterMsg *hdr, int type) {
|
|||||||
* first byte is zero, they'll do auto discovery. */
|
* first byte is zero, they'll do auto discovery. */
|
||||||
memset(hdr->myip,0,NET_IP_STR_LEN);
|
memset(hdr->myip,0,NET_IP_STR_LEN);
|
||||||
if (g_pserver->cluster_announce_ip) {
|
if (g_pserver->cluster_announce_ip) {
|
||||||
strncpy(hdr->myip,g_pserver->cluster_announce_ip,NET_IP_STR_LEN);
|
strncpy(hdr->myip,g_pserver->cluster_announce_ip,NET_IP_STR_LEN-1);
|
||||||
hdr->myip[NET_IP_STR_LEN-1] = '\0';
|
hdr->myip[NET_IP_STR_LEN-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3542,7 +3542,7 @@ void clusterCron(void) {
|
|||||||
* duplicating the string. This way later we can check if
|
* duplicating the string. This way later we can check if
|
||||||
* the address really changed. */
|
* the address really changed. */
|
||||||
prev_ip = zstrdup(prev_ip);
|
prev_ip = zstrdup(prev_ip);
|
||||||
strncpy(myself->ip,g_pserver->cluster_announce_ip,NET_IP_STR_LEN);
|
strncpy(myself->ip,g_pserver->cluster_announce_ip,NET_IP_STR_LEN-1);
|
||||||
myself->ip[NET_IP_STR_LEN-1] = '\0';
|
myself->ip[NET_IP_STR_LEN-1] = '\0';
|
||||||
} else {
|
} else {
|
||||||
myself->ip[0] = '\0'; /* Force autodetection. */
|
myself->ip[0] = '\0'; /* Force autodetection. */
|
||||||
|
@ -1930,7 +1930,7 @@ static int enumConfigSet(typeData data, sds value, int update, const char **err)
|
|||||||
}
|
}
|
||||||
sdsrange(enumerr,0,-3); /* Remove final ", ". */
|
sdsrange(enumerr,0,-3); /* Remove final ", ". */
|
||||||
|
|
||||||
strncpy(loadbuf, enumerr, LOADBUF_SIZE);
|
strncpy(loadbuf, enumerr, LOADBUF_SIZE-1);
|
||||||
loadbuf[LOADBUF_SIZE - 1] = '\0';
|
loadbuf[LOADBUF_SIZE - 1] = '\0';
|
||||||
|
|
||||||
sdsfree(enumerr);
|
sdsfree(enumerr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user