Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory safety issues #260

Merged
merged 10 commits into from
Jan 6, 2022
Next Next commit
ucl_lex_json_string: fix out-of-bounds read
If the string ends with a '\', the function tried to read the next
character before checking bounds. This commit move the bounds check
before the read to avoid the out-of-bounds read.

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21578
  • Loading branch information
alpire committed Jan 4, 2022
commit ac8d76023386fb1f1b31b47cd294e28831929c96
4 changes: 2 additions & 2 deletions src/ucl_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,13 +1053,13 @@ ucl_lex_json_string (struct ucl_parser *parser,
}
else if (c == '\\') {
ucl_chunk_skipc (chunk, p);
c = *p;
if (p >= chunk->end) {
ucl_set_err (parser, UCL_ESYNTAX, "unfinished escape character",
&parser->err);
return false;
}
else if (ucl_test_character (c, UCL_CHARACTER_ESCAPE)) {
c = *p;
if (ucl_test_character (c, UCL_CHARACTER_ESCAPE)) {
if (c == 'u') {
ucl_chunk_skipc (chunk, p);
for (i = 0; i < 4 && p < chunk->end; i ++) {
Expand Down