summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* http: ensure the scheme supports the credentialsethomson/creds_for_schemeIan Hattendorf2019-08-231-4/+9
| | | | | | When a server responds with multiple scheme support - for example, Negotiate and NTLM are commonly used together - we need to ensure that we choose a scheme that supports the credentials.
* http: allow dummy negotiation scheme to fail to actEdward Thomson2019-08-212-5/+8
| | | | | | | | | | | The dummy negotiation scheme is used for known authentication strategies that do not wish to act. For example, when a server requests the "Negotiate" scheme but libgit2 is not built with Negotiate support, and will use the "dummy" strategy which will simply not act. Instead of setting `out` to NULL and returning a successful code, return `GIT_PASSTHROUGH` to indicate that it did not act and catch that error code.
* 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.
| * | config: validate ownership of C:\ProgramData\Git\config before using itJohannes Schindelin2019-08-133-1/+97
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the VirtualStore feature is in effect, it is safe to let random users write into C:\ProgramData because other users won't see those files. This seemed to be the case when we introduced support for C:\ProgramData\Git\config. However, when that feature is not in effect (which seems to be the case in newer Windows 10 versions), we'd rather not use those files unless they come from a trusted source, such as an administrator. This change imitates the strategy chosen by PowerShell's native OpenSSH port to Windows regarding host key files: if a system file is owned neither by an administrator, a system account, or the current user, it is ignored.
* | Merge pull request #5113 from pks-t/pks/stash-perfEdward Thomson2019-08-114-14/+168
|\ \ | | | | | | stash: avoid recomputing tree when committing worktree
| * | stash: avoid recomputing tree when committing worktreePatrick Steinhardt2019-07-201-14/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When creating a new stash, we need to create there separate commits storing differences stored in the index, untracked changes as well as differences in the working directory. The first two will only be done conditionally if the equivalent options "git stash --keep-index --include-untracked" are being passed to `git_stash_save`, but even when only creating a stash of worktree changes we're much slower than git.git. Using our new stash example: $ time git stash Saved working directory and index state WIP on (no branch): 2f7d9d47575e Linux 5.1.7 real 0m0.528s user 0m0.309s sys 0m0.381s $ time lg2 stash real 0m27.165s user 0m13.645s sys 0m6.403s As can be seen, libgit2 is more than 50x slower than git.git! When creating the stash commit that includes all worktree changes, we create a completely new index to prepare for the new commit and populate it with the entries contained in the index' tree. Here comes the catch: by populating the index with a tree's contents, we do not have any stat caches in the index. This means that we have to re-validate every single file from the worktree and see whether it has changed. The issue can be fixed by populating the new index with the repo's existing index instead of with the tree. This retains all stat cache information, and thus we really only need to check files that have changed stat information. This is semantically equivalent to what we previously did: previously, we used the tree of the commit computed from the index. Now we're just using the index directly. And, in fact, the cache is doing wonders: time lg2 stash real 0m1.836s user 0m1.166s sys 0m0.663s We're now performing 15x faster than before and are only 3x slower than git.git now.
| * | examples: implement git-stash examplePatrick Steinhardt2019-07-203-0/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | Implement a new example that resembles the git-stash(1) command. Right now, it only provides the apply, list, save and pop subcommands without any options. This example is mostly used to test libgit2's stashing performance on big repositories.
* | | Merge pull request #5121 from pks-t/pks/variadic-errorsEdward Thomson2019-08-116-16/+39
|\ \ \ | | | | | | | | Variadic macros
| * | | unix: posix: avoid use of variadic macro `p_snprintf`Patrick Steinhardt2019-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The macro `p_snprintf` is implemented as a variadic macro that calls `snprintf` directly with `__VA_ARGS__`. In C89, variadic macros are not allowed, but as the arguments of `p_snprintf` and `snprintf` are matching 1:1, we can fix this by simply removing the parameter list from `p_snprintf`.
| * | | apply: remove use of variadic error macroPatrick Steinhardt2019-08-011-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | The macro `apply_err` is implemented as a variadic macro, which are not defined by C89. Convert it to a variadic function, instead.
| * | | parse: remove use of variadic macros which are not C89 compliantPatrick Steinhardt2019-08-012-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The macro `git_parse_error` is implemented in a variadic way so that it's possible to pass printf-style parameters. Unfortunately, variadic macros are not defined by C89 and thus we cannot use that functionality. But as we have implemented `git_error_vset` in the previous commit, we can now just use that instead. Convert `git_parse_error` to a variadic function and use `git_error_vset` to fix the compliance violation. While at it, move the function to "patch_parse.c".
| * | | errors: introduce `git_error_vset` functionPatrick Steinhardt2019-08-012-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, we only provide a `git_error_set` that has a variadic function signature. It's impossible to drive this function in a C89-compliant way from other functions that have a variadic signature, though, like for example `git_parse_error`. Implement a new `git_error_vset` function that gets a `va_list` as parameter, fixing the above problem.
* | | | Merge pull request #4913 from implausible/feature/signing-rebase-commitsPatrick Steinhardt2019-08-095-14/+335
|\ \ \ \ | | | | | | | | | | Add sign capability to git_rebase_commit
| * | | | fixup: strange indentationTyler Ang-Wanek2019-08-071-5/+5
| | | | |
| * | | | documentation: add small explanation for commit signingTyler Ang-Wanek2019-07-021-1/+7
| | | | |
| * | | | fixup: code cleanup around rebase commit signingTyler Ang-Wanek2019-07-022-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Use ci_git_fail_with where appropriate. Use correct initializer for callback.
| * | | | rebase: always use git_commit_create_with_signatureTyler Ang-Wanek2019-07-021-32/+28
| | | | | | | | | | | | | | | | | | | | This simplifies the flow of rebase_commit__create because it doesn't have to juggle 2 different commit flows (one with signature and one without).
| * | | | commit: git_commit_create_with_signature should support null signatureTyler Ang-Wanek2019-07-022-9/+13
| | | | | | | | | | | | | | | | | | | | If provided with a null signature, skip adding the signature header and create the commit anyway.
| * | | | fixup: Leverage git_error_set_after_callback_functionTyler Ang-Wanek2019-07-021-7/+7
| | | | |
| * | | | Include "commit.h" in "rebase.h" for git_commit_signing_cbTyler Ang-Wanek2019-06-251-0/+1
| | | | |
| * | | | Clear error before calling signing_cb, set error if one has not been setTyler Wanek2019-02-211-1/+3
| | | | | | | | | | | | | | | | | | | | We should clear the error before calling the signing_cb to allow the signing_cb to set its own errors. If the CB did not provide an error, we should set our own generic error before exiting rebase_commit__create
| * | | | Set git_error when signing_cb returns an error codeTyler Wanek2019-02-201-1/+3
| | | | |
| * | | | fixup: More generic signing_cb for future flexibilityTyler Wanek2019-01-244-26/+26
| | | | | | | | | | | | | | | | | | | | | | | | | In the case that we want to build merge + commit, cherrypick + commit, or even just build a commit with signing callback, `git_rebase_commit_signature_cb` particular callback should be made more generic. We also renamed `signature_cb` to `signing_cb` to improve clarity on the purpose of the callback (build a difference between a git_signature and the act of signing). So we've ended up with `git_commit_signing_cb`.
| * | | | Update formatting of newly added rebase sign test suiteTyler Wanek2019-01-231-124/+124
| | | | |
| * | | | Single callback for commit signing in rebase w/ git_bufTyler Wanek2019-01-233-74/+49
| | | | | | | | | | | | | | | Reduces the number of callbacks for signing a commit during a rebase operation to just one callback. That callback has 2 out git_buf parameters for signature and signature field. We use git_buf here, because we cannot make any assumptions about the heap allocator a user of the library might be using.
| * | | | Add tests for signing rebase commitsTyler Wanek2019-01-231-0/+252
| | | | |
| * | | | Add signing callbacks for git_rebase_commit in git_rebase_optionsTyler Wanek2019-01-232-5/+94
| | | | | | | | | | | | | | | | | | | | 2 callbacks have been added to git_rebase_options, git_rebase_commit_signature_cb and git_rebase_commit_signature_field_cb. When git_rebase_commit_signature_cb is present in git_rebase_options, it will be called whenever git_rebase_commit is performed, giving an opportunity to sign the commit. The signing procedure can be skipped if the callback specifies passthrough as the error. The git_rebase_commit_signature_field_cb will only be called if the other callback is present or did not passthrough, and it provides means to specify which field a signature is for. Git_rebase_options was chosen as the home for these callbacks as it keeps backwards compatibility with the current rebase api.
* | | | | Merge pull request #5197 from pks-t/pks/remote-ifdeffed-blockEdward Thomson2019-08-021-29/+0
|\ \ \ \ \ | | | | | | | | | | | | remote: remove unused block of code
| * | | | | remote: remove unused block of codePatrick Steinhardt2019-08-021-29/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In "remote.c", we have a chunk of code that is #ifdef'fed out via `#if 0` with a comment that we could export it as a helper function. The code was implemented in 2013 and ifdef'fed in 2014, which shows that there's clearly no interest in having such a helper at all. As this block has recently created some confusion about `p_getenv` due to it containing the only reference to that function in our codebase, let's remove this block altogether.
* | | | | | Merge pull request #5146 from scottfurry/StaticFixesExamplesPatrick Steinhardt2019-08-023-8/+8
|\ \ \ \ \ \ | | | | | | | | | | | | | | Adjust printf specifiers in examples code
| * | | | | | Adjust printf specifiers in examples codeScott Furry2019-08-013-8/+8
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Static analysis of example code found multiple findings of `printf` usage where filling value is members of git_indexer_progress object. Specifier used was for signed int but git_indexer_progress members are typed as unsigned ints. `printf` specifiers were altered to match type.
* | | | | | Merge pull request #5191 from eaigner/masterPatrick Steinhardt2019-08-021-1/+11
|\ \ \ \ \ \ | | | | | | | | | | | | | | config: check if we are running in a sandboxed environment
| * | | | | | config: check if we are running in a sandboxed environmentErik Aigner2019-08-011-1/+11
| | |_|_|_|/ | |/| | | | | | | | | | On macOS the $HOME environment variable returns the path to the sandbox container instead of the actual user $HOME for sandboxed apps. To get the correct path, we have to get it from the password file entry.
* | | | | | Merge pull request #5184 from novalis/fix-examplePatrick Steinhardt2019-08-011-1/+1
|\ \ \ \ \ \ | |_|/ / / / |/| | | | | Fix example checkout to forbid rather than require --
| * | | | | Fix example checkout to forbid rather than require --David Turner2019-07-241-1/+1
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | Make the example program for checkout follow git syntax, where "--" indicates a file. This was likely just a strcmp return value confusion.
* | | | | Merge pull request #5183 from pks-t/pks/editorconfigPatrick Steinhardt2019-08-011-3/+5
|\ \ \ \ \ | | | | | | | | | | | | editorconfig: update to match our coding style
| * | | | | editorconfig: update to match our coding stylePatrick Steinhardt2019-07-241-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update editorconfig to match our coding style. Most importantly, we set up the tab width to be 8 characters instead of the default and use 2 spaces to indent YAML files.
* | | | | | Merge pull request #5125 from albfan/wip/albfan/diff_buffersPatrick Steinhardt2019-08-017-61/+147
|\ \ \ \ \ \ | | | | | | | | | | | | | | Compare buffers in diff example
| * | | | | | examples: consolidate includes into "common.h"Patrick Steinhardt2019-07-055-26/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consolidate all standard includes and defines into "common.h". This lets us avoid having to handle platform-specific things in multiple places.
| * | | | | | Compare buffers in diff exampleAlberto Fanjul2019-07-053-35/+129
| | | | | | |
* | | | | | | Merge pull request #5135 from j143-bot/jdev01Patrick Steinhardt2019-08-011-0/+58
|\ \ \ \ \ \ \ | |_|_|_|_|/ / |/| | | | | | Include ahead_behind in the test suite
| * | | | | | Implement test for graph ahead and behindJanardhan Pulivarthi2019-07-221-0/+58
| | |_|/ / / | |/| | | |