1. 25 Oct, 2018 4 commits
  2. 21 Oct, 2018 12 commits
  3. 20 Oct, 2018 6 commits
  4. 19 Oct, 2018 9 commits
  5. 18 Oct, 2018 9 commits
    • util: avoid signed integer overflows in `git__strntol64` · b09c1c7b
      While `git__strntol64` tries to detect integer overflows when doing the
      necessary arithmetics to come up with the final result, it does the
      detection only after the fact. This check thus relies on undefined
      behavior of signed integer overflows. Fix this by instead checking
      up-front whether the multiplications or additions will overflow.
      
      Note that a detected overflow will not cause us to abort parsing the
      current sequence of digits. In the case of an overflow, previous
      behavior was to still set up the end pointer correctly to point to the
      first character immediately after the currently parsed number. We do not
      want to change this now as code may rely on the end pointer being set up
      correctly even if the parsed number is too big to be represented as
      64 bit integer.
      Patrick Steinhardt committed
    • tests: core::strtol: test for some more edge-cases · 39087ab8
      Some edge cases were currently completely untested, e.g. parsing numbers
      greater than INT64_{MIN,MAX}, truncating buffers by length and invalid
      characters. Add tests to verify that the system under test performs as
      expected.
      Patrick Steinhardt committed
    • util: remove `git__strtol32` · 8d7fa88a
      The function `git__strtol32` can easily be misused when untrusted data
      is passed to it that may not have been sanitized with trailing `NUL`
      bytes. As all usages of this function have now been removed, we can
      remove this function altogether to avoid future misuse of it.
      Patrick Steinhardt committed
    • 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