1. 05 Jun, 2020 1 commit
  2. 10 Dec, 2019 2 commits
  3. 24 Jun, 2019 1 commit
  4. 23 Jun, 2019 1 commit
  5. 15 Jun, 2019 1 commit
  6. 14 Jun, 2019 1 commit
    • tests: object: refactor largefile test to not use `p_fallocate` · 0c2d0d4b
      The `p_fallocate` platform is currently in use in our tests,
      only, but it proved to be quite burdensome to get it implemented
      in a cross-platform way. The only "real" user is the test
      object::tree::read::largefile, where it's used to allocate a
      large file in the filesystem only to commit it to the repo and
      read its object back again. We can simplify this quite a bit by
      just using an in-memory buffer of 4GB. Sure, this cannot be used
      on platforms with low resources. But creating 4GB files is not
      any better, and we already skip the test if the environment
      variable "GITTEST_INVASIVE_FS_SIZE" is not set. So we're arguably
      not worse off than before.
      Patrick Steinhardt committed
  7. 04 Apr, 2019 1 commit
  8. 30 Jan, 2019 1 commit
  9. 22 Jan, 2019 1 commit
  10. 01 Dec, 2018 2 commits
  11. 02 Nov, 2018 3 commits
    • tree: fix integer overflow when reading unreasonably large filemodes · 7fafec0e
      The `parse_mode` option uses an open-coded octal number parser. The
      parser is quite naive in that it simply parses until hitting a character
      that is not in the accepted range of '0' - '7', completely ignoring the
      fact that we can at most accept a 16 bit unsigned integer as filemode.
      If the filemode is bigger than UINT16_MAX, it will thus overflow and
      provide an invalid filemode for the object entry.
      
      Fix the issue by using `git__strntol32` instead and doing a bounds
      check. As this function already handles overflows, it neatly solves the
      problem.
      
      Note that previously, `parse_mode` was also skipping the character
      immediately after the filemode. In proper trees, this should be a simple
      space, but in fact the parser accepted any character and simply skipped
      over it. As a consequence of using `git__strntol32`, we now need to an
      explicit check for a trailing whitespace after having parsed the
      filemode. Because of the newly introduced error message, the test
      object::tree::parse::mode_doesnt_cause_oob_read needs adjustment to its
      error message check, which in fact is a good thing as it demonstrates
      that we now fail looking for the whitespace immediately following the
      filemode.
      
      Add a test that shows that we will fail to parse such invalid filemodes
      now.
      Patrick Steinhardt committed
    • tree: fix mode parsing reading out-of-bounds · f647bbc8
      When parsing a tree entry's mode, we will eagerly parse until we hit a
      character that is not in the accepted set of octal digits '0' - '7'. If
      the provided buffer is not a NUL terminated one, we may thus read
      out-of-bounds.
      
      Fix the issue by passing the buffer length to `parse_mode` and paying
      attention to it. Note that this is not a vulnerability in our usual code
      paths, as all object data read from the ODB is NUL terminated.
      Patrick Steinhardt committed
    • tree: add various tests exercising the tree parser · d4ad658a
      We currently don't have any tests that directly exercise the tree
      parser. This is due to the fact that the parsers for raw object data has
      only been recently introduce with commit ca4db5f4 (object: implement
      function to parse raw data, 2017-10-13), and previous to that the setup
      simply was too cumbersome as it always required going through the ODB.
      
      Now that we have the infrastructure, add a suite of tests that directly
      exercise the tree parser and various edge cases.
      Patrick Steinhardt committed
  12. 27 Jul, 2018 1 commit
  13. 18 Jul, 2018 1 commit
    • tree: accept null ids in existing trees when updating · 2dff7e28
      When we add entries to a treebuilder we validate them. But we validate even
      those that we're adding because they exist in the base tree. This disables
      using the normal mechanisms on these trees, even to fix them.
      
      Keep track of whether the entry we're appending comes from an existing tree and
      bypass the name and id validation if it's from existing data.
      Carlos Martín Nieto committed
  14. 13 Jul, 2018 1 commit
    • treewide: remove use of C++ style comments · 9994cd3f
      C++ style comment ("//") are not specified by the ISO C90 standard and
      thus do not conform to it. While libgit2 aims to conform to C90, we did
      not enforce it until now, which is why quite a lot of these
      non-conforming comments have snuck into our codebase. Do a tree-wide
      conversion of all C++ style comments to the supported C style comments
      to allow us enforcing strict C90 compliance in a later commit.
      Patrick Steinhardt committed
  15. 10 Jun, 2018 1 commit
  16. 28 Feb, 2018 1 commit
  17. 26 Jan, 2018 1 commit
    • tree: reject writing null-OID entries to a tree · c0487bde
      In commit a96d3cc3f (cache-tree: reject entries with null sha1,
      2017-04-21), the git.git project has changed its stance on null OIDs in
      tree objects. Previously, null OIDs were accepted in tree entries to
      help tools repair broken history. This resulted in some problems though
      in that many code paths mistakenly passed null OIDs to be added to a
      tree, which was not properly detected.
      
      Align our own code base according to the upstream change and reject
      writing tree entries early when the OID is all-zero.
      Patrick Steinhardt committed
  18. 14 Nov, 2016 1 commit
  19. 24 May, 2016 1 commit
  20. 19 May, 2016 2 commits
  21. 17 May, 2016 1 commit
    • Introduce a function to create a tree based on a different one · 9464f9eb
      Instead of going through the usual steps of reading a tree recursively
      into an index, modifying it and writing it back out as a tree, introduce
      a function to perform simple updates more efficiently.
      
      `git_tree_create_updated` avoids reading trees which are not modified
      and supports upsert and delete operations. It is not as versatile as
      modifying the index, but it makes some common operations much more
      efficient.
      Carlos Martín Nieto committed
  22. 20 Mar, 2016 1 commit
  23. 04 Mar, 2016 1 commit
  24. 28 Feb, 2016 3 commits
  25. 28 May, 2015 1 commit
  26. 04 Jan, 2015 1 commit
  27. 27 Dec, 2014 1 commit
  28. 17 Dec, 2014 1 commit
  29. 10 Jun, 2014 1 commit
    • treebuilder: use a map instead of vector to store the entries · 4d3f1f97
      Finding a filename in a vector means we need to resort it every time we
      want to read from it, which includes every time we want to write to it
      as well, as we want to find duplicate keys.
      
      A hash-map fits what we want to do much more accurately, as we do not
      care about sorting, but just the particular filename.
      
      We still keep removed entries around, as the interface let you assume
      they were going to be around until the treebuilder is cleared or freed,
      but in this case that involves an append to a vector in the filter case,
      which can now fail.
      
      The only time we care about sorting is when we write out the tree, so
      let's make that the only time we do any sorting.
      Carlos Martín Nieto committed
  30. 25 Jan, 2014 1 commit
  31. 03 Jan, 2014 2 commits
  32. 12 Dec, 2013 1 commit