Commit Graph

10902 Commits

Author SHA1 Message Date
Carlos Martín Nieto
37a0165f8d examples: adjust merge to git_commit_create_on
This should be a good place to eventually make use of `_fromstate` depending on
what we're trying to show in this example.
2018-03-22 16:35:23 +01:00
Carlos Martín Nieto
e8eba1cfd8 commit: rearrange _fromstate and _on_head variants
We now have `_fromstate` and `_fromstate_on_head`, the latter of which updates
the current branch to point to the new commit.
2018-03-22 16:23:20 +01:00
Carlos Martín Nieto
b31cd43e7e Update CHANGELOG with the commit function changes 2018-03-22 16:23:20 +01:00
Carlos Martín Nieto
c3d0633800 commit: provide functions with and without a reference name
Currently git_commit_create() takes on creating a commit and updating a
reference. Provide a better interface by splitting up each of the
concerns into named functions for each.

git_commit_create() will only create the commit, it will not modify any
reference. git_commit_create_on() takes a reference name to update and
git_commit_create_on_head() is a convenience function to update HEAD.
2018-03-22 16:23:20 +01:00
Carlos Martín Nieto
8f212f64a0 commit: introduce _fromstate()
This variant of the commit creation function takes the reference to
update, the tree and the parents from the current branch, index and
merging state, allowing for simpler use of a common use-case.
2018-03-22 16:09:34 +01:00
Edward Thomson
72e60347ff Merge pull request #4588 from libgit2/ethomson/bitbucket
online tests: update auth for bitbucket test
2018-03-20 23:16:36 +00:00
Edward Thomson
54bf4d14fa online tests: update auth for bitbucket test
Update the settings to use a specific read-only token for accessing our
test repositories in Bitbucket.
2018-03-20 07:47:27 -07:00
Edward Thomson
5585e358b2 Merge pull request #4563 from libgit2/ethomson/ssh-unescape
Refactor `gitno_extract_url_parts`
v0.27.0-rc3
2018-03-20 00:59:21 +00:00
Edward Thomson
9108959a1a buf: add tests for percent decoding 2018-03-19 16:08:01 -07:00
Edward Thomson
0e4f3d9d46 gitno_extract_url_parts: decode hostnames
RFC 3986 says that hostnames can be percent encoded.  Percent decode
hostnames in our URLs.
2018-03-19 16:08:01 -07:00
Edward Thomson
05551ca091 Remove now unnecessary gitno_unescape 2018-03-19 16:08:01 -07:00
Edward Thomson
60e7848e1e gitno_extract_url_parts: use git_bufs
Now that we can decode percent-encoded strings as part of `git_buf`s,
use that decoder in `gitno_extract_url_parts`.
2018-03-19 16:08:01 -07:00
Edward Thomson
6f57790657 ssh urls: use git_buf_decode_percent
Use `git_buf_decode_percent` so that we can avoid allocating a temporary
buffer.
2018-03-19 16:08:01 -07:00
Edward Thomson
8070a357fb Introduce git_buf_decode_percent
Introduce a function to take a percent-encoded string (URI encoded,
described by RFC 1738) and decode it into a `git_buf`.
2018-03-19 16:08:01 -07:00
Steven King Jr
30333e820e Update tests 2018-03-19 16:08:01 -07:00
Steven King Jr
16210877c9 Unescape repo before constructing ssh request 2018-03-19 16:08:01 -07:00
Steven King Jr
8a2cdbd310 Rename unescape and make non-static 2018-03-19 16:08:01 -07:00
Edward Thomson
3198577522 Merge pull request #4584 from libgit2/ethomson/bitbucket
online::clone: skip creds fallback test
2018-03-19 23:07:44 +00:00
Edward Thomson
03c5877810 online::clone: skip creds fallback test
At present, we have three online tests against bitbucket: one which
specifies the credentials in the payload, one which specifies the
correct credentials in the URL and a final one that specifies the
incorrect credentials in the URL.  Bitbucket has begun responding to the
latter test with a 403, which causes us to fail.

Break these three tests into separate tests so that we can skip the
latter until this is resolved on Bitbucket's end or until we can change
the test to a different provider.
2018-03-19 15:45:20 -07:00
Patrick Steinhardt
937e7e2640 Merge pull request #4544 from josharian/docs
pathspec: improve git_pathspec_flag_t doc rendering
2018-03-13 13:04:38 +00:00
Edward Thomson
7b66bfe2c9 Merge pull request #4575 from pks-t/pks/index-secfixes-master
Index parsing fixes
2018-03-12 10:09:49 +01:00
Edward Thomson
358cc2e2ea Merge pull request #4396 from libgit2/cmn/config-regex-is-normalised
config: specify how we match the regular expressions
2018-03-12 09:50:00 +01:00
Carlos Martín Nieto
2f89bd90bc config: explicitly state that subsections are case-sensitive 2018-03-11 12:36:13 +01:00
Patrick Steinhardt
3db1af1f37 index: error out on unreasonable prefix-compressed path lengths
When computing the complete path length from the encoded
prefix-compressed path, we end up just allocating the complete path
without ever checking what the encoded path length actually is. This can
easily lead to a denial of service by just encoding an unreasonable long
path name inside of the index. Git already enforces a maximum path
length of 4096 bytes. As we also have that enforcement ready in some
places, just make sure that the resulting path is smaller than
GIT_PATH_MAX.

Reported-by: Krishna Ram Prakash R <krp@gtux.in>
Reported-by: Vivek Parikh <viv0411.parikh@gmail.com>
2018-03-10 10:24:18 +00:00
Patrick Steinhardt
3207ddb010 index: fix out-of-bounds read with invalid index entry prefix length
The index format in version 4 has prefix-compressed entries, where every
index entry can compress its path by using a path prefix of the previous
entry. Since implmenting support for this index format version in commit
5625d86b9 (index: support index v4, 2016-05-17), though, we do not
correctly verify that the prefix length that we want to reuse is
actually smaller or equal to the amount of characters than the length of
the previous index entry's path. This can lead to a an integer underflow
and subsequently to an out-of-bounds read.

Fix this by verifying that the prefix is actually smaller than the
previous entry's path length.

Reported-by: Krishna Ram Prakash R <krp@gtux.in>
Reported-by: Vivek Parikh <viv0411.parikh@gmail.com>
2018-03-10 10:23:26 +00:00
Patrick Steinhardt
58a6fe94cb index: convert read_entry to return entry size via an out-param
The function `read_entry` does not conform to our usual coding style of
returning stuff via the out parameter and to use the return value for
reporting errors. Due to most of our code conforming to that pattern, it
has become quite natural for us to actually return `-1` in case there is
any error, which has also slipped in with commit 5625d86b9 (index:
support index v4, 2016-05-17). As the function returns an `size_t` only,
though, the return value is wrapped around, causing the caller of
`read_tree` to continue with an invalid index entry. Ultimately, this
can lead to a double-free.

Improve code and fix the bug by converting the function to return the
index entry size via an out parameter and only using the return value to
indicate errors.

Reported-by: Krishna Ram Prakash R <krp@gtux.in>
Reported-by: Vivek Parikh <viv0411.parikh@gmail.com>
2018-03-10 10:23:10 +00:00
Patrick Steinhardt
d11c4a1a46 Merge pull request #4571 from jacquesg/overflow
Integer overflow
2018-03-08 13:13:04 +01:00
Jacques Germishuys
e666495b79 cmake: enable shift count overflow warning 2018-03-08 08:31:49 +02:00
Jacques Germishuys
5f6383ca50 diff: ensure an unsigned number is shifted 2018-03-08 08:17:29 +02:00
Edward Thomson
515683c7bd Merge pull request #4567 from pks-t/pks/zlib-update
deps: upgrade embedded zlib to version 1.2.11
2018-03-07 12:39:28 +00:00
Patrick Steinhardt
4c5330cb83 deps: upgrade embedded zlib to version 1.2.11
The current version of zlib bundled with libgit2 is version 1.2.8. This
version has several CVEs assigned:

- CVE-2016-9843
- CVE-2016-9841
- CVE-2016-9842
- CVE-2016-9840

Upgrade the bundled version to the current release 1.2.11, which has
these vulnerabilities fixes.
2018-03-07 10:33:41 +00:00
Edward Thomson
2d2a60258f Merge pull request #4541 from libgit2/cmn/odb-streaming-read-changelog
CHANGELOG: mention the change to `git_odb_open_rstream`
2018-03-04 12:17:17 +00:00
Edward Thomson
adf7d0940e Merge pull request #4559 from jacquesg/worktree-const
Worktree lock reason should be const
2018-03-04 12:17:06 +00:00
Jacques Germishuys
53e692af36 worktree: rename parameter creason to reason 2018-03-03 10:03:14 +02:00
Jacques Germishuys
1235607648 worktree: lock reason should be const 2018-03-02 12:41:04 +02:00
Carlos Martín Nieto
8353e4b5ff CHANGELOG: mention the change to git_odb_open_rstream 2018-03-02 10:25:05 +00:00
Patrick Steinhardt
8a8ea1db12 Merge pull request #4552 from libgit2/cmn/config-header-common
Cast less blindly between configuration objects
2018-02-28 18:14:52 +01:00
Edward Thomson
e8e490b276 Merge pull request #4554 from pks-t/pks/curl-init
curl: initialize and cleanup global curl state
2018-02-28 17:01:47 +00:00
Carlos Martín Nieto
9cd0c6f1f1 config: return an error if config_refresh is called on a snapshot
Instead of treating it as a no-op, treat it as a programming error and return
the same kind of error as if you called to set or delete variables on a
snapshot.
2018-02-28 16:01:16 +01:00
Patrick Steinhardt
17bef3b836 Merge pull request #4553 from libgit2/cmn/tree-write-initialise
tree: initialize the id we use for testing submodule insertions
2018-02-28 15:01:43 +01:00
Patrick Steinhardt
fb884c6267 Merge pull request #4555 from libgit2/ethomson/strncmp_stdcall
win32: strncmp -> git__strncmp for win32 STDCALL
2018-02-28 14:59:09 +01:00
Patrick Steinhardt
2022b00447 curl: explicitly initialize and cleanup global curl state
Our curl-based streams make use of the easy curl interface. This
interface automatically initializes and de-initializes the global curl
state by calling out to `curl_global_init` and `curl_global_cleanup`.
Thus, all global state will be repeatedly re-initialized when creating
multiple curl streams in succession. Despite being inefficient, this is
not thread-safe due to `curl_global_init` being not thread-safe itself.
Thus a multi-threaded programing handling multiple curl streams at the
same time is inherently racy.

Fix the issue by globally initializing and cleaning up curl's state.
2018-02-28 13:27:07 +00:00
Edward Thomson
a33deeb4ae win32: strncmp -> git__strncmp
The win32 C library is compiled cdecl, however when configured with
`STDCALL=ON`, our functions (and function pointers) will use the stdcall
calling convention.  You cannot set a `__stdcall` function pointer to a
`__cdecl` function, so it's easier to just use our `git__strncmp`
instead of sorting that mess out.
2018-02-28 12:20:23 +00:00
Carlos Martín Nieto
a554d588cc tree: initialize the id we use for testing submodule insertions
Instead of laving it uninitialized and relying on luck for it to be non-zero,
let's give it a dummy hash so we make valgrind happy (in this case the hash
comes from `sha1sum </dev/null`.
2018-02-28 12:21:08 +01:00
Carlos Martín Nieto
2424e64c4e config: harden our use of the backend objects a bit
When we create an iterator we don't actually know that we have a live config
object and we must instead only rely on the header. We fixed it to use this in a
previous commit, but this makes it harder to misuse by converting to use the
header object in the typecast.

We also guard inside the `config_refresh` function against being given a
snapshot (although callers right now do check).
2018-02-28 12:06:02 +01:00
Carlos Martín Nieto
1785de4e5c config: move the level field into the header
We use it in a few places where we might have a full object or a snapshot so
move it to where we can actually access it.
2018-02-28 11:46:17 +01:00
Carlos Martín Nieto
c1524b2e1c config: move the repository to the diskfile header
We pass this around and when creating a new iterator we need to read the
repository pointer.

Put it in a common place so we can reach it regardless of whether we got a full
object or a snapshot.
2018-02-28 11:33:11 +01:00
Edward Thomson
c9d59c6140 Merge pull request #4545 from libgit2/ethomson/checkout_filemode
Respect core.filemode in checkout
v0.27.0-rc2
2018-02-27 12:45:21 +00:00
Edward Thomson
b4dde78a77 Merge pull request #4550 from libgit2/ethomson/winhttp
winhttp: enable TLS 1.2
2018-02-27 12:43:47 +00:00
Edward Thomson
5ecb62206a winhttp: enable TLS 1.2 on Windows 7 and earlier
Versions of Windows prior to Windows 8 do not enable TLS 1.2 by default,
though support may exist.  Try to enable TLS 1.2 support explicitly on
connections.

This request may fail if the operating system does not have TLS 1.2
support - the initial release of Vista lacks TLS 1.2 support (though
it is available as a software update) and XP completely lacks TLS 1.2
support.  If this request does fail, the HTTP context is still valid,
and still maintains the original protocol support.  So we ignore the
failure from this operation.
2018-02-27 11:25:32 +00:00