From 9c9b2b2ad0d90b97d3f35767534d3da19b4c3e03 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 27 Jan 2025 22:09:34 +0100 Subject: [PATCH] fix length check when reading a dictionary file --- client/src/fileutils.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/src/fileutils.c b/client/src/fileutils.c index c75018c3b..efd5d9ef4 100644 --- a/client/src/fileutils.c +++ b/client/src/fileutils.c @@ -2385,16 +2385,21 @@ int loadFileDICTIONARY_safe_ex(const char *preferredName, const char *suffix, vo } } - // add null terminator - line[keylen] = 0; + // The line start with # is comment, skip + if (line[0] == '#') { + continue; + } + + // remove newline/linefeed + str_cleanrn(line, strlen(line)); // smaller keys than expected is skipped if (strlen(line) < keylen) { continue; } - // The line start with # is comment, skip - if (line[0] == '#') { + // larger keys than expected is skipped + if (strlen(line) > keylen) { continue; } -- 2.11.4.GIT