BugFix: fix ssl cert load crash issue

This commit is contained in:
Nick Peng
2021-01-24 01:03:57 +08:00
parent ac0ab0c916
commit 3e3859cfb1
2 changed files with 69 additions and 4 deletions

View File

@@ -1454,8 +1454,14 @@ int config_addtional_file(void *data, int argc, char *argv[])
if (conf_file[0] != '/') {
safe_strncpy(file_path_dir, conf_get_conf_file(), DNS_MAX_PATH);
dirname(file_path_dir);
if (snprintf(file_path, DNS_MAX_PATH, "%s/%s", file_path_dir, conf_file) < 0) {
return -1;
if (strncmp(file_path_dir, conf_get_conf_file(), sizeof(file_path_dir)) == 0) {
if (snprintf(file_path, DNS_MAX_PATH, "%s", conf_file) < 0) {
return -1;
}
} else {
if (snprintf(file_path, DNS_MAX_PATH, "%s/%s", file_path_dir, conf_file) < 0) {
return -1;
}
}
} else {
safe_strncpy(file_path, conf_file, DNS_MAX_PATH);