summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* regex: make sure to link against PCRE2's regex functionscmn/pcre2Carlos Martín Nieto2019-09-011-0/+13
| | | | | | | | | | PCRE2's header defines just the basic names but that means that we'll link against libc's version while using PCRE2's struct definitions, leading to crashes. To work around this, package maintainers have added prefixes to the exported functions so we can link against them. But the definitions in the header are still of the basic names so we need to tell the compiler/linker to replace these names when linking.
* Merge pull request #5208 from mkostyuk/apply-removed-new-fileEdward Thomson2019-08-272-3/+42
|\ | | | | apply: git_apply_to_tree fails to apply patches that add new files
| * apply: free test dataEdward Thomson2019-08-271-1/+1
| |
| * apply: Test for git_apply_to_tree failures when new files are addedMax Kostyukevich2019-08-211-0/+36
| | | | | | | | | | Introduce an unit test to validate if git_apply_to_tree() fails when an applied patch adds new files.
| * apply: git_apply_to_tree fails to apply patches that add new filesMax Kostyukevich2019-08-201-3/+6
| | | | | | | | | | | | | | | | | | git_apply_to_tree() cannot be used apply patches with new files. An attempt to apply such a patch fails because git_apply_to_tree() tries to remove a non-existing file from an old index. The solution is to modify git_apply_to_tree() to git_index_remove() when the patch states that the modified files is removed.
* | Merge pull request #5189 from libgit2/ethomson/attrs_from_headEdward Thomson2019-08-2786-31/+459
|\ \ | | | | | | Optionally read `.gitattributes` from HEAD
| * | filter: test second-level in-repo `.gitattributes`ethomson/attrs_from_headEdward Thomson2019-08-111-0/+23
| | | | | | | | | | | | | | | Ensure that a `.gitattributes` file that is deeper in the tree is honored, not just an attributes file at the root.
| * | tests: add a subdirectory to crlf testsEdward Thomson2019-08-1112-5/+25
| | | | | | | | | | | | | | | Add a subdirectory in the crlf.git bare repository that has a second-level .gitattribute file.
| * | filter: test we can filter a blob in a bare repoEdward Thomson2019-08-1168-0/+134
| | |
| * | blob: optionally read attributes from repositoryEdward Thomson2019-08-112-0/+9
| | | | | | | | | | | | | | | | | | | | | When `GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD` is passed to `git_blob_filter`, read attributes from `gitattributes` files that are checked in to the repository at the HEAD revision. This passes the flag `GIT_FILTER_ATTRIBUTES_FROM_HEAD` to the filter functions.
| * | filter: optionally read attributes from repositoryEdward Thomson2019-08-112-0/+6
| | | | | | | | | | | | | | | | | | | | | When `GIT_FILTER_ATTRIBUTES_FROM_HEAD` is specified, configure the filter to read filter attributes from `gitattributes` files that are checked in to the repository at the HEAD revision. This passes the flag `GIT_ATTR_CHECK_INCLUDE_HEAD` to the attribute reading functions.
| * | attr: optionally read attributes from repositoryEdward Thomson2019-08-114-9/+65
| | | | | | | | | | | | | | | When `GIT_ATTR_CHECK_INCLUDE_HEAD` is specified, read `gitattribute` files that are checked into the repository at the HEAD revision.
| * | blob: allow blob filtering to ignore system gitattributesEdward Thomson2019-08-112-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Introduce `GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES`, which tells `git_blob_filter` to ignore the system-wide attributes file, usually `/etc/gitattributes`. This simply passes the appropriate flag to the attribute loading code.
| * | filter: add GIT_FILTER_NO_SYSTEM_ATTRIBUTES optionEdward Thomson2019-08-112-3/+11
| | | | | | | | | | | | | | | | | | Allow system-wide attributes (the ones specified in `/etc/gitattributes`) to be ignored if the flag `GIT_FILTER_NO_SYSTEM_ATTRIBUTES` is specified.
| * | filter: test that system attributes can be ignoredEdward Thomson2019-08-111-0/+27
| | | | | | | | | | | | | | | Test that we can optionally ignore system attributes when filtering a blob.
| * | filter: document GIT_FILTER_ALLOW_UNSAFEEdward Thomson2019-08-111-0/+2
| | |
| * | filter: ensure system attributes are readEdward Thomson2019-08-111-0/+54
| | | | | | | | | | | | | | | | | | By default, `/etc/gitattributes` (or the system equivalent) is read to provide attributes. Ensure that, by default, this is read when filtering blobs.
| * | blob: deprecate `git_blob_filtered_content`Edward Thomson2019-08-113-35/+23
| | | | | | | | | | | | Users should now use `git_blob_filter`.
| * | blob: convert users of git_blob_filtered_contentEdward Thomson2019-08-112-14/+14
| | | | | | | | | | | | Move users of `git_blob_filtered_content` to `git_blob_filter`.
| * | blob: introduce git_blob_filterEdward Thomson2019-08-112-4/+68
| | | | | | | | | | | | | | | Provide a function to filter blobs that allows for more functionality than the existing `git_blob_filtered_content` function.
| * | filter: add a crlf blob testEdward Thomson2019-07-211-0/+28
| | | | | | | | | | | | Add a LF->CRLF conversion test to the blob filter.
* | | Merge pull request #5196 from pks-t/pks/config-include-onbranchEdward Thomson2019-08-274-41/+187
|\ \ \ | | | | | | | | config: implement "onbranch" conditional
| * | | config: implement "onbranch" conditionalPatrick Steinhardt2019-08-012-1/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With Git v2.23.0, the conditional include mechanism gained another new conditional "onbranch". As the name says, it will cause a file to be included if the "onbranch" pattern matches the currently checked out branch. Implement this new condition and add a bunch of tests.
| * | | tests: config: catch OOM when assembling conditional configPatrick Steinhardt2019-08-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | When assembling contents of the conditionally including file, we use `git_buf_printf` and `git_buf_puts` without checking for error returns. Add `cl_git_pass` to fix this.
| * | | tests: config: assert behaviour around includesPatrick Steinhardt2019-08-012-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a few tests that verify some behaviour centered around includes. The first set of tests verifies that we correctly override values depending on the order of includes and other keys, the second set asserts that we can correctly snapshot configuration files with includes.
| * | | tests: config::snapshot: modernize testsPatrick Steinhardt2019-08-011-38/+36
| | | | | | | | | | | | | | | | | | | | | | | | Modernize the tests in config::snapshot to make them easier to understand. Most important, include a cleanup function that frees config and snapshot and unlink config files at the end of each test.
* | | | Merge pull request #5213 from boardwalk/dskorupski/fix_include_caseEdward Thomson2019-08-251-1/+1
|\ \ \ \ | | | | | | | | | | Fix include casing for case-sensitive filesystems.
| * | | | Fix include casing for case-sensitive filesystems.Dan Skorupski2019-08-241-1/+1
| | | | |
* | | | | Merge pull request #5054 from tniessen/util-use-64-bit-timerEdward Thomson2019-08-233-17/+7
|\ \ \ \ \ | | | | | | | | | | | | util: use 64 bit timer on Windows
| * | | | | cmake: move _WIN32_WINNT definitions to rootTobias Nießen2019-08-174-12/+5
| | | | | |
| * | | | | util: use 64 bit timer on WindowsTobias Nießen2019-07-291-15/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git__timer was originally implemented using a 32 bit timer since Windows XP did not support GetTickCount64. Windows XP was discontinued five years ago, so it should be safe to use the new API. As a benefit, we do not need to care about overflows for the next 585 million years.
| * | | | | cmake: fix _WIN32_WINNT for MinGWTobias Nießen2019-07-292-0/+10
| | | | | |
* | | | | | Merge pull request #5200 from pks-t/pks/memory-allocation-auditEdward Thomson2019-08-2312-59/+197
|\ \ \ \ \ \ | |_|_|_|_|/ |/| | | | | Memory allocation audit
| * | | | | util: do not perform allocations in insertsortPatrick Steinhardt2019-08-233-28/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our hand-rolled fallback sorting function `git__insertsort_r` does an in-place sort of the given array. As elements may not necessarily be pointers, it needs a way of swapping two values of arbitrary size, which is currently implemented by allocating a temporary buffer of the element's size. This is problematic, though, as the emulated `qsort` interface doesn't provide any return values and thus cannot signal an error if allocation of that temporary buffer has failed. Convert the function to swap via a temporary buffer allocated on the stack. Like this, it can `memcpy` contents of both elements in small batches without requiring a heap allocation. The buffer size has been chosen such that in most cases, a single iteration of copying will suffice. Most importantly, it can fully contain `git_oid` structures and pointers. Add a bunch of tests for the `git__qsort_r` interface to verify nothing breaks. Furthermore, this removes the declaration of `git__insertsort_r` and makes it static as it is not used anywhere else.
| * | | | | xdiff: catch memory allocation errorsPatrick Steinhardt2019-08-232-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The xdiff code contains multiple call sites where the results of `xdl_malloc` are not being checked for memory allocation errors. Add checks to fix possible segfaults due to `NULL` pointer accesses.
| * | | | | transports: http: check for memory allocation failuresPatrick Steinhardt2019-08-232-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When allocating a chunk that is used to write to HTTP streams, we do not check for memory allocation errors. This may lead us to write to a `NULL` pointer and thus cause a segfault. Fix this by adding a call to `GIT_ERROR_CHECK_ALLOC`.
| * | | | | trailer: check for memory allocation errorsPatrick Steinhardt2019-08-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "trailer.c" code has been copied mostly verbatim from git.git with minor adjustments, only. As git.git's `xmalloc` function, which aborts on memory allocation errors, has been swapped out for `git_malloc`, which doesn't abort, we may inadvertently access `NULL` pointers. Add checks to fix this.
| * | | | | posix: fix direct use of `malloc`Patrick Steinhardt2019-08-231-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In "posix.c" there are multiple callsites which execute `malloc` instead of `git__malloc`. Thus, users of library are not able to track these allocations with a custom allocator. Convert these call sites to use `git__malloc` instead.
| * | | | | indexer: catch OOM when adding expected OIDsPatrick Steinhardt2019-08-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When adding OIDs to the indexer's map of yet-to-be-seen OIDs to verify that packfiles are complete, we do so by first allocating a new OID and then calling `git_oidmap_set` on it. There was no check for memory allocation errors in place, though, leading to possible segfaults due to trying to copy data to a `NULL` pointer. Verify the result of `git__malloc` with `GIT_ERROR_CHECK_ALLOC` to fix the issue.
| * | | | | merge: check return value of `git_commit_list_insert`Patrick Steinhardt2019-08-231-16/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function `git_commit_list_insert` dynamically allocates memory and may thus fail to insert a given commit, but we didn't check for that in several places in "merge.c". Convert surrounding functions to return error codes and check whether `git_commit_list_insert` was successful, returning an error if not.
| * | | | | blame_git: detect memory allocation errorsPatrick Steinhardt2019-08-231-7/+21
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code in "blame_git.c" was mostly imported from git.git with only minor changes. One of these changes was to use our own allocators instead of git's `xmalloc`, but there's a subtle difference: `xmalloc` would abort the program if unable to allocate any memory, bit `git__malloc` doesn't. As we didn't check for memory allocation errors in some places, we might inadvertently dereference a `NULL` pointer in out-of-memory situations. Convert multiple functions to return proper error codes and add calls to `GIT_ERROR_CHECK_ALLOC` to fix this.
* | | | | Merge pull request #5187 from ianhattendorf/fix/clone-whitespaceEdward Thomson2019-08-143-2/+8
|\ \ \ \ \ | |_|/ / / |/| | | | clone: don't decode URL percent encodings
| * | | | clone: Remove whitespace ssh testIan Hattendorf2019-08-131-15/+0
| | | | | | | | | | | | | | | | | | | | Will add later when infrastructure is configured
| * | | | clone: Update whitespace test urlIan Hattendorf2019-08-121-4/+4
| | | | |
| * | | | clone: whitespace in url ssh testIan Hattendorf2019-07-252-2/+18
| | | | |
| * | | | git_net_url_parse: don't git_buf_decode_percent for pathIan Hattendorf2019-07-241-1/+1
| | | | |
| * | | | clone: whitespace in url testIan Hattendorf2019-07-241-0/+5
| | | | |
* | | | | Merge pull request #5202 from libgit2/users/ethomson/security_updatesEdward Thomson2019-08-135-3/+113
|\ \ \ \ \ | | | | | | | | | | | | Security updates from 0.28.3
| * | | | | changelog: include security updatesusers/ethomson/security_updatesEdward Thomson2019-08-131-0/+10
| | | | | |
| * | | | | commit_list: fix possible buffer overflow in `commit_quick_parse`Patrick Steinhardt2019-08-131-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function `commit_quick_parse` provides a way to quickly parse parts of a commit without storing or verifying most of its metadata. The first thing it does is calculating the number of parents by skipping "parent " lines until it finds the first non-parent line. Afterwards, this parent count is passed to `alloc_parents`, which will allocate an array to store all the parent. To calculate the amount of storage required for the parents array, `alloc_parents` simply multiplicates the number of parents with the respective elements's size. This already screams "buffer overflow", and in fact this problem is getting worse by the result being cast to an `uint32_t`. In fact, triggering this is possible: git-hash-object(1) will happily write a commit with multiple millions of parents for you. I've stopped at 67,108,864 parents as git-hash-object(1) unfortunately soaks up the complete object without streaming anything to disk and thus will cause an OOM situation at a later point. The point here is: this commit was about 4.1GB of size but compressed down to 24MB and thus easy to distribute. The above doesn't yet trigger the buffer overflow, thus. As the array's elements are all pointers which are 8 bytes on 64 bit, we need a total of 536,870,912 parents to trigger the overflow to `0`. The effect is that we're now underallocating the array and do an out-of-bound writes. As the buffer is kindly provided by the adversary, this may easily result in code execution. Extrapolating from the test file with 67m commits to the one with 536m commits results in a factor of 8. Thus the uncompressed contents would be about 32GB in size and the compressed ones 192MB. While still easily distributable via the network, only servers will have that amount of RAM and not cause an out-of-memory condition previous to triggering the overflow. This at least makes this attack not an easy vector for client-side use of libgit2.