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
Merged

Fix memory safety issues #260

merged 10 commits into from
Jan 6, 2022

Commits on Jan 4, 2022

  1. 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
    alpire committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    ac8d760 View commit details
    Browse the repository at this point in the history
  2. ucl_parse_value: fix out-of-bounds read

    If the string ends with a Multiline terminator without a newline, the
    function tried to read the next character to check for a newline without
    checking if the pointer was past the end of the buffer. This commit adds
    a bounds check and return early with an error in case of missing
    newline.
    
    Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21579
    alpire committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    08de358 View commit details
    Browse the repository at this point in the history
  3. ucl_check_variable: fix out_len on unterminated variable

    If the input contains '${' but no following '}', ucl_check_variable
    should still increment out_len since ucl_expand_variable will copy the
    '$' in the destination buffer.
    
    Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24591
    alpire committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    3a94514 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    54a5b59 View commit details
    Browse the repository at this point in the history
  5. ucl_strnstr: fix out-of-bounds read

    The strncmp call could read past the bounds of the haystack. The loop
    now stop when the remaining data in the haystack cannot contain the
    needle.
    
    Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28135
    alpire committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    852f752 View commit details
    Browse the repository at this point in the history
  6. ucl_expand_variable: fix out-of-bounds read

    If the input ends in '$', calling ucl_check_variable will result in an
    out-of-bounds read.
    
    Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34755
    alpire committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    f9e5446 View commit details
    Browse the repository at this point in the history
  7. ucl_object_copy_internal: use memcpy instead of strdup

    Keys may have null bytes, when they are decoded from json in
    ucl_unescape_json_string and contain \u0000. Not copying the full key
    resulted in out-of-bounds reads. The copy now relies on memcpy and
    keylen instead of strdup.
    
    Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38579
    Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38675
    alpire committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    a9c0965 View commit details
    Browse the repository at this point in the history

Commits on Jan 5, 2022

  1. ucl_chunk_skipc: avoid out-of-bounds read

    This macro is often used in loops before checking whether the end of
    chunk condition. Adding a bounds check in there prevents reading past
    the buffer.
    alpire committed Jan 5, 2022
    Configuration menu
    Copy the full SHA
    9e0e06f View commit details
    Browse the repository at this point in the history
  2. ucl_expand_single_variable: better bounds check

    This commit improves variable expansion and adds:
    - an in_len argument to the function in order to avoid reading past the
      end of the src buffer
    - a check that the variable name is followed by '}' in strict mode
    - extra bounds check to prevent out of bounds reads and writes
    alpire committed Jan 5, 2022
    Configuration menu
    Copy the full SHA
    9b898ea View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    110428d View commit details
    Browse the repository at this point in the history