1. 18 Oct, 2018 7 commits
    • global: replace remaining use of `git__strtol32` · 2613fbb2
      Replace remaining uses of the `git__strtol32` function. While these uses
      are all safe as the strings were either sanitized or from a trusted
      source, we want to remove `git__strtol32` altogether to avoid future
      misuse.
      Patrick Steinhardt committed
    • tree-cache: avoid out-of-bound reads when parsing trees · 21652ee9
      We use the `git__strtol32` function to parse the child and entry count
      of treecaches from the index, which do not accept a buffer length. As
      the buffer that is being passed in is untrusted data and may thus be
      malformed and may not contain a terminating `NUL` byte, we can overrun
      the buffer and thus perform an out-of-bounds read.
      
      Fix the issue by uzing `git__strntol32` instead.
      Patrick Steinhardt committed
    • util: remove unsafe `git__strtol64` function · 68deb2cc
      The function `git__strtol64` does not take a maximum buffer length as
      parameter. This has led to some unsafe usages of this function, and as
      such we may consider it as being unsafe to use. As we have now
      eradicated all usages of this function, let's remove it completely to
      avoid future misuse.
      Patrick Steinhardt committed
    • config: remove last instance of `git__strntol64` · 1a2efd10
      When parsing integers from configuration values, we use `git__strtol64`.
      This is fine to do, as we always sanitize values and can thus be sure
      that they'll have a terminating `NUL` byte. But as this is the last
      call-site of `git__strtol64`, let's just pass in the length explicitly
      by calling `strlen` on the value to be able to remove `git__strtol64`
      altogether.
      Patrick Steinhardt committed
    • signature: avoid out-of-bounds reads when parsing signature dates · 3db9aa6f
      We use `git__strtol64` and `git__strtol32` to parse the trailing commit
      or author date and timezone of signatures. As signatures are usually
      part of a commit or tag object and thus essentially untrusted data, the
      buffer may be misformatted and may not be `NUL` terminated. This may
      lead to an out-of-bounds read.
      
      Fix the issue by using `git__strntol64` and `git__strntol32` instead.
      Patrick Steinhardt committed
    • index: avoid out-of-bounds read when reading reuc entry stage · 600ceadd
      We use `git__strtol64` to parse file modes of the index entries, which
      does not limit the parsed buffer length. As the index can be essentially
      treated as "untrusted" in that the data stems from the file system, it
      may be misformatted and may not contain terminating `NUL` bytes. This
      may lead to out-of-bounds reads when trying to parse index entries with
      such malformatted modes.
      
      Fix the issue by using `git__strntol64` instead.
      Patrick Steinhardt committed
    • commit_list: avoid use of strtol64 without length limit · 1a3fa1f5
      When quick-parsing a commit, we use `git__strtol64` to parse the
      commit's time. The buffer that's passed to `commit_quick_parse` is the
      raw data of an ODB object, though, whose data may not be properly
      formatted and also does not have to be `NUL` terminated. This may lead
      to out-of-bound reads.
      
      Use `git__strntol64` to avoid this problem.
      Patrick Steinhardt committed
  2. 17 Oct, 2018 3 commits
  3. 15 Oct, 2018 3 commits
  4. 13 Oct, 2018 1 commit
  5. 12 Oct, 2018 1 commit
  6. 11 Oct, 2018 4 commits
    • Apply code review feedback · 463c21e2
      Nelson Elhage committed
    • fuzzers: add object parsing fuzzer · a1d5fd06
      Add a simple fuzzer that exercises our object parser code. The fuzzer
      is quite trivial in that it simply passes the input data directly to
      `git_object__from_raw` for each of the four object types.
      Patrick Steinhardt committed
    • object: properly propagate errors on parsing failures · 6562cdda
      When failing to parse a raw object fromits data, we free the
      partially parsed object but then fail to propagate the error to the
      caller. This may lead callers to operate on objects with invalid memory,
      which will sooner or later cause the program to segfault.
      
      Fix the issue by passing up the error code returned by `parse_raw`.
      Patrick Steinhardt committed
    • fuzzers: initialize libgit2 in standalone driver · 6956a954
      The standalone driver for libgit2's fuzzing targets makes use of
      functions from libgit2 itself. While this is totally fine to do, we need
      to make sure to always have libgit2 initialized via `git_libgit2_init`
      before we call out to any of these. While this happens in most cases as
      we call `LLVMFuzzerInitialize`, which is provided by our fuzzers and
      which right now always calls `git_libgit2_init`, one exception to this
      rule is our error path when not enough arguments have been given. In
      this case, we will call `git_vector_free_deep` without libgit2 having
      been initialized. As we did not set up our allocation functions in that
      case, this will lead to a segmentation fault.
      
      Fix the issue by always initializing and shutting down libgit2 in the
      standalone driver. Note that we cannot let this replace the
      initialization in `LLVMFuzzerInitialize`, as it is required when using
      the "real" fuzzers by LLVM without our standalone driver. It's no
      problem to call the initialization and deinitialization functions
      multiple times, though.
      Patrick Steinhardt committed
  7. 09 Oct, 2018 2 commits
  8. 07 Oct, 2018 3 commits
  9. 06 Oct, 2018 1 commit
    • ignore unsupported http authentication schemes · 475db39b
      auth_context_match returns 0 instead of -1 for unknown schemes to
      not fail in situations where some authentication schemes are supported
      and others are not.
      
      apply_credentials is adjusted to handle auth_context_match returning
      0 without producing authentication context.
      Anders Borum committed
  10. 05 Oct, 2018 12 commits
  11. 04 Oct, 2018 3 commits