From 40c084afde0fde42fdc35563b99f6414683bd2f7 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Mon, 8 Jun 2026 15:42:18 +0530 Subject: [PATCH 1/6] Update rrd_config.c --- src/rrd_config.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rrd_config.c b/src/rrd_config.c index 6be2a759d..2356085d7 100644 --- a/src/rrd_config.c +++ b/src/rrd_config.c @@ -86,6 +86,13 @@ static bool file_exists(const char *filepath) { return (stat(filepath, &st) == 0); } +// Helper: check if file exists and has non-zero size +static bool file_non_empty(const char *filepath) { + if (!filepath) return false; + struct stat st; + return (stat(filepath, &st) == 0 && st.st_size > 0); +} + int rrd_config_load(rrd_config_t *config) { if (!config) return -1; @@ -139,9 +146,9 @@ int rrd_config_load(rrd_config_t *config) { __FUNCTION__); const char *dcm_file = NULL; - if (strcmp(config->build_type, "prod") != 0 && file_exists("/opt/dcm.properties")) { + if (strcmp(config->build_type, "prod") != 0 && file_non_empty("/opt/dcm.properties")) { dcm_file = "/opt/dcm.properties"; - } else if (file_exists("/etc/dcm.properties")) { + } else if (strcmp(config->build_type, "prod") == 0 && file_exists("/etc/dcm.properties")) { dcm_file = "/etc/dcm.properties"; } From c65904853dbec8ee8b10dff3f66a8a2e5a041940 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Mon, 8 Jun 2026 16:05:22 +0530 Subject: [PATCH 2/6] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/rrd_config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rrd_config.c b/src/rrd_config.c index 2356085d7..3db1e1b51 100644 --- a/src/rrd_config.c +++ b/src/rrd_config.c @@ -90,7 +90,8 @@ static bool file_exists(const char *filepath) { static bool file_non_empty(const char *filepath) { if (!filepath) return false; struct stat st; - return (stat(filepath, &st) == 0 && st.st_size > 0); + return (stat(filepath, &st) == 0 && S_ISREG(st.st_mode) && st.st_size > 0); +} } int rrd_config_load(rrd_config_t *config) { From 8c8c7e029bea9791259c20d357eb7110dfad878a Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Mon, 8 Jun 2026 16:22:38 +0530 Subject: [PATCH 3/6] Update rrd_config.c --- src/rrd_config.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rrd_config.c b/src/rrd_config.c index 3db1e1b51..1a87850e7 100644 --- a/src/rrd_config.c +++ b/src/rrd_config.c @@ -92,7 +92,6 @@ static bool file_non_empty(const char *filepath) { struct stat st; return (stat(filepath, &st) == 0 && S_ISREG(st.st_mode) && st.st_size > 0); } -} int rrd_config_load(rrd_config_t *config) { if (!config) return -1; From 7896ce096412b3c53279655a48e7b8c67538d52c Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Mon, 8 Jun 2026 16:26:56 +0530 Subject: [PATCH 4/6] Update rrd_config.c --- src/rrd_config.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/rrd_config.c b/src/rrd_config.c index 1a87850e7..7d5558cf1 100644 --- a/src/rrd_config.c +++ b/src/rrd_config.c @@ -79,15 +79,8 @@ static int execute_command(const char *cmd, char *output, size_t output_size) { return (status == 0 && strlen(output) > 0) ? 0 : -1; } -// Helper: check if file exists -static bool file_exists(const char *filepath) { - if (!filepath) return false; - struct stat st; - return (stat(filepath, &st) == 0); -} - // Helper: check if file exists and has non-zero size -static bool file_non_empty(const char *filepath) { +static bool file_exists(const char *filepath) { if (!filepath) return false; struct stat st; return (stat(filepath, &st) == 0 && S_ISREG(st.st_mode) && st.st_size > 0); @@ -146,7 +139,7 @@ int rrd_config_load(rrd_config_t *config) { __FUNCTION__); const char *dcm_file = NULL; - if (strcmp(config->build_type, "prod") != 0 && file_non_empty("/opt/dcm.properties")) { + if (strcmp(config->build_type, "prod") != 0 && file_exists("/opt/dcm.properties")) { dcm_file = "/opt/dcm.properties"; } else if (strcmp(config->build_type, "prod") == 0 && file_exists("/etc/dcm.properties")) { dcm_file = "/etc/dcm.properties"; From 8d2647642170838ab474d15deab0d62883bf2b7e Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Mon, 8 Jun 2026 16:28:05 +0530 Subject: [PATCH 5/6] Update rrd_config.c --- src/rrd_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrd_config.c b/src/rrd_config.c index 7d5558cf1..1d6be7b1a 100644 --- a/src/rrd_config.c +++ b/src/rrd_config.c @@ -141,7 +141,7 @@ int rrd_config_load(rrd_config_t *config) { const char *dcm_file = NULL; if (strcmp(config->build_type, "prod") != 0 && file_exists("/opt/dcm.properties")) { dcm_file = "/opt/dcm.properties"; - } else if (strcmp(config->build_type, "prod") == 0 && file_exists("/etc/dcm.properties")) { + } else if ( file_exists("/etc/dcm.properties")) { dcm_file = "/etc/dcm.properties"; } From 2fb5a0159dced79c58da526c6bc6ccbc55afb9ae Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Mon, 8 Jun 2026 16:28:37 +0530 Subject: [PATCH 6/6] Update rrd_config.c --- src/rrd_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrd_config.c b/src/rrd_config.c index 1d6be7b1a..af5b2e29a 100644 --- a/src/rrd_config.c +++ b/src/rrd_config.c @@ -141,7 +141,7 @@ int rrd_config_load(rrd_config_t *config) { const char *dcm_file = NULL; if (strcmp(config->build_type, "prod") != 0 && file_exists("/opt/dcm.properties")) { dcm_file = "/opt/dcm.properties"; - } else if ( file_exists("/etc/dcm.properties")) { + } else if (file_exists("/etc/dcm.properties")) { dcm_file = "/etc/dcm.properties"; }