Fix strncpy warnings - add "-1" for NULL

This commit is contained in:
2018-07-03 13:28:27 +03:00
parent 2891540d65
commit 2bbb3cfc51

View File

@@ -338,7 +338,7 @@ static int test_conf_syntax(void)
} else } else
strncpy(conf.rmps.agent_tls_crt, strncpy(conf.rmps.agent_tls_crt,
tmp + 1, tmp + 1,
sizeof(conf.rmps.agent_tls_crt)); sizeof(conf.rmps.agent_tls_crt) - 1);
} else if (!strcmp(buf, "rmps.agent_tls_key")) { } else if (!strcmp(buf, "rmps.agent_tls_key")) {
if (access(tmp + 1, F_OK) == -1) { if (access(tmp + 1, F_OK) == -1) {
log(ERROR, "%s is missing", tmp + 1); log(ERROR, "%s is missing", tmp + 1);
@@ -349,10 +349,10 @@ static int test_conf_syntax(void)
} else } else
strncpy(conf.rmps.agent_tls_key, strncpy(conf.rmps.agent_tls_key,
tmp + 1, tmp + 1,
sizeof(conf.rmps.agent_tls_key)); sizeof(conf.rmps.agent_tls_key) - 1);
} else if (!strcmp(buf, "rmps.cipherlist")) { } else if (!strcmp(buf, "rmps.cipherlist")) {
strncpy(conf.rmps.cipherlist, strncpy(conf.rmps.cipherlist,
tmp + 1, sizeof(conf.rmps.cipherlist)); tmp + 1, sizeof(conf.rmps.cipherlist) - 1);
} else if (!strcmp(buf, "rmps.cafile")) { } else if (!strcmp(buf, "rmps.cafile")) {
if (access(tmp + 1, F_OK) == -1) { if (access(tmp + 1, F_OK) == -1) {
log(ERROR, "%s is missing", tmp + 1); log(ERROR, "%s is missing", tmp + 1);
@@ -362,7 +362,7 @@ static int test_conf_syntax(void)
failed = 1; failed = 1;
} else } else
strncpy(conf.rmps.cafile, strncpy(conf.rmps.cafile,
tmp + 1, sizeof(conf.rmps.cafile)); tmp + 1, sizeof(conf.rmps.cafile) - 1);
} else if (!strcmp(buf, "rmps.client_tls_crt")) { } else if (!strcmp(buf, "rmps.client_tls_crt")) {
if (access(tmp + 1, F_OK) == -1) { if (access(tmp + 1, F_OK) == -1) {
log(ERROR, "%s is missing", tmp + 1); log(ERROR, "%s is missing", tmp + 1);
@@ -373,7 +373,7 @@ static int test_conf_syntax(void)
} else } else
strncpy(conf.rmps.client_tls_crt, strncpy(conf.rmps.client_tls_crt,
tmp + 1, tmp + 1,
sizeof(conf.rmps.client_tls_crt)); sizeof(conf.rmps.client_tls_crt) - 1);
} else if (!strcmp(buf, "rmps.client_tls_key")) { } else if (!strcmp(buf, "rmps.client_tls_key")) {
if (access(tmp + 1, F_OK) == -1) { if (access(tmp + 1, F_OK) == -1) {
log(ERROR, "%s is missing", tmp + 1); log(ERROR, "%s is missing", tmp + 1);
@@ -384,7 +384,7 @@ static int test_conf_syntax(void)
} else } else
strncpy(conf.rmps.client_tls_key, strncpy(conf.rmps.client_tls_key,
tmp + 1, tmp + 1,
sizeof(conf.rmps.client_tls_key)); sizeof(conf.rmps.client_tls_key) - 1);
} else } else
log(ERROR, "Unknown config entry on line %d: %s", log(ERROR, "Unknown config entry on line %d: %s",
j, buf); j, buf);