The deduplication code uses realpath to store the real path of a provided
configuration file. The code then tries to compare these paths but
accidentally only comparse only the first CONF_DIR_LEN (256) bytes of the
path.

The number of bytes must be set to the same length as the path size slot in
the normalized buffer.

Fixes: db97c2a77e81 ("batctl: fix crash in bat-hosts parser on embedded 
systems")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 bat-hosts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bat-hosts.c b/bat-hosts.c
index 57e7d69..6ad8247 100644
--- a/bat-hosts.c
+++ b/bat-hosts.c
@@ -203,7 +203,7 @@ void bat_hosts_init(int read_opt)
                for (j = 0; j < i; j++) {
                        if (strncmp(normalized + (i * PATH_MAX),
                                    normalized + (j * PATH_MAX),
-                                   CONF_DIR_LEN) == 0) {
+                                   PATH_MAX) == 0) {
                                parse = 0;
                                break;
                        }

-- 
2.47.3

Reply via email to