Skip to content

Commit

Permalink
fix length check when reading a dictionary file
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed Jan 27, 2025
1 parent 5b1fadb commit 9c9b2b2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions client/src/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 9c9b2b2

Please sign in to comment.