]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
19 months agoMerge branch 'jk/curl-avoid-deprecated-api' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:49 +0000 (14:15 -0800)] 
Merge branch 'jk/curl-avoid-deprecated-api' into maint-2.39

Deal with a few deprecation warning from cURL library.

* jk/curl-avoid-deprecated-api:
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT

19 months agoMerge branch 'jk/avoid-redef-system-functions' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:49 +0000 (14:15 -0800)] 
Merge branch 'jk/avoid-redef-system-functions' into maint-2.39

The jk/avoid-redef-system-functions-2.30 topic pre-merged for more
recent codebase.

* jk/avoid-redef-system-functions:

19 months agoMerge branch 'jk/avoid-redef-system-functions-2.30' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:47 +0000 (14:15 -0800)] 
Merge branch 'jk/avoid-redef-system-functions-2.30' into maint-2.39

Redefining system functions for a few functions did not follow our
usual "implement git_foo() and #define foo(args) git_foo(args)"
pattern, which has broken build for some folks.

* jk/avoid-redef-system-functions-2.30:
  git-compat-util: undefine system names before redeclaring them
  git-compat-util: avoid redefining system function names

19 months agoMerge branch 'tb/ci-concurrency' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:46 +0000 (14:15 -0800)] 
Merge branch 'tb/ci-concurrency' into maint-2.39

Avoid unnecessary builds in CI, with settings configured in
ci-config.

* tb/ci-concurrency:
  ci: avoid unnecessary builds

19 months agoMerge branch 'cw/ci-whitespace' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:45 +0000 (14:15 -0800)] 
Merge branch 'cw/ci-whitespace' into maint-2.39

CI updates.  We probably want a clean-up to move the long shell
script embedded in yaml file into a separate file, but that can
come later.

* cw/ci-whitespace:
  ci (check-whitespace): move to actions/checkout@v3
  ci (check-whitespace): add links to job output
  ci (check-whitespace): suggest fixes for errors

19 months agoMerge branch 'js/ci-disable-cmake-by-default' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:45 +0000 (14:15 -0800)] 
Merge branch 'js/ci-disable-cmake-by-default' into maint-2.39

Stop running win+VS build by default.

* js/ci-disable-cmake-by-default:
  ci: only run win+VS build & tests in Git for Windows' fork

19 months agoGit 2.39.2 v2.39.2
Johannes Schindelin [Mon, 6 Feb 2023 08:43:41 +0000 (09:43 +0100)] 
Git 2.39.2

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoSync with 2.38.4
Johannes Schindelin [Mon, 6 Feb 2023 08:43:39 +0000 (09:43 +0100)] 
Sync with 2.38.4

* maint-2.38:
  Git 2.38.4
  Git 2.37.6
  Git 2.36.5
  Git 2.35.7
  Git 2.34.7
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

19 months agoGit 2.38.4 v2.38.4
Johannes Schindelin [Mon, 6 Feb 2023 08:43:30 +0000 (09:43 +0100)] 
Git 2.38.4

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoSync with 2.37.6
Johannes Schindelin [Mon, 6 Feb 2023 08:43:28 +0000 (09:43 +0100)] 
Sync with 2.37.6

* maint-2.37:
  Git 2.37.6
  Git 2.36.5
  Git 2.35.7
  Git 2.34.7
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

19 months agoGit 2.37.6 v2.37.6
Johannes Schindelin [Mon, 6 Feb 2023 08:38:32 +0000 (09:38 +0100)] 
Git 2.37.6

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoSync with 2.36.5
Johannes Schindelin [Mon, 6 Feb 2023 08:38:31 +0000 (09:38 +0100)] 
Sync with 2.36.5

* maint-2.36:
  Git 2.36.5
  Git 2.35.7
  Git 2.34.7
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

19 months agoGit 2.36.5 v2.36.5
Johannes Schindelin [Mon, 6 Feb 2023 08:37:53 +0000 (09:37 +0100)] 
Git 2.36.5

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoSync with 2.35.7
Johannes Schindelin [Mon, 6 Feb 2023 08:37:52 +0000 (09:37 +0100)] 
Sync with 2.35.7

* maint-2.35:
  Git 2.35.7
  Git 2.34.7
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

19 months agoGit 2.35.7 v2.35.7
Johannes Schindelin [Mon, 6 Feb 2023 08:29:45 +0000 (09:29 +0100)] 
Git 2.35.7

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoSync with 2.34.7
Johannes Schindelin [Mon, 6 Feb 2023 08:29:44 +0000 (09:29 +0100)] 
Sync with 2.34.7

* maint-2.34:
  Git 2.34.7
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

19 months agoGit 2.34.7 v2.34.7
Johannes Schindelin [Mon, 6 Feb 2023 08:29:17 +0000 (09:29 +0100)] 
Git 2.34.7

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoSync with 2.33.7
Johannes Schindelin [Mon, 6 Feb 2023 08:29:16 +0000 (09:29 +0100)] 
Sync with 2.33.7

* maint-2.33:
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

19 months agoMerge branch 'jk/curl-avoid-deprecated-api'
Junio C Hamano [Fri, 20 Jan 2023 23:36:21 +0000 (15:36 -0800)] 
Merge branch 'jk/curl-avoid-deprecated-api'

Deal with a few deprecation warning from cURL library.

* jk/curl-avoid-deprecated-api:
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT

19 months agohttp: support CURLOPT_PROTOCOLS_STR
Jeff King [Tue, 17 Jan 2023 03:04:48 +0000 (22:04 -0500)] 
http: support CURLOPT_PROTOCOLS_STR

The CURLOPT_PROTOCOLS (and matching CURLOPT_REDIR_PROTOCOLS) flag was
deprecated in curl 7.85.0, and using it generate compiler warnings as of
curl 7.87.0. The path forward is to use CURLOPT_PROTOCOLS_STR, but we
can't just do so unilaterally, as it was only introduced less than a
year ago in 7.85.0.

Until that version becomes ubiquitous, we have to either disable the
deprecation warning or conditionally use the "STR" variant on newer
versions of libcurl. This patch switches to the new variant, which is
nice for two reasons:

  - we don't have to worry that silencing curl's deprecation warnings
    might cause us to miss other more useful ones

  - we'd eventually want to move to the new variant anyway, so this gets
    us set up (albeit with some extra ugly boilerplate for the
    conditional)

There are a lot of ways to split up the two cases. One way would be to
abstract the storage type (strbuf versus a long), how to append
(strbuf_addstr vs bitwise OR), how to initialize, which CURLOPT to use,
and so on. But the resulting code looks pretty magical:

  GIT_CURL_PROTOCOL_TYPE allowed = GIT_CURL_PROTOCOL_TYPE_INIT;
  if (...http is allowed...)
GIT_CURL_PROTOCOL_APPEND(&allowed, "http", CURLOPT_HTTP);

and you end up with more "#define GIT_CURL_PROTOCOL_TYPE" macros than
actual code.

On the other end of the spectrum, we could just implement two separate
functions, one that handles a string list and one that handles bits. But
then we end up repeating our list of protocols (http, https, ftp, ftp).

This patch takes the middle ground. The run-time code is always there to
handle both types, and we just choose which one to feed to curl.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agohttp: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
Jeff King [Tue, 17 Jan 2023 03:04:44 +0000 (22:04 -0500)] 
http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION

The IOCTLFUNCTION option has been deprecated, and generates a compiler
warning in recent versions of curl. We can switch to using SEEKFUNCTION
instead. It was added in 2008 via curl 7.18.0; our INSTALL file already
indicates we require at least curl 7.19.4.

But there's one catch: curl says we should use CURL_SEEKFUNC_{OK,FAIL},
and those didn't arrive until 7.19.5. One workaround would be to use a
bare 0/1 here (or define our own macros).  But let's just bump the
minimum required version to 7.19.5. That version is only a minor version
bump from our existing requirement, and is only a 2 month time bump for
versions that are almost 13 years old. So it's not likely that anybody
cares about the distinction.

Switching means we have to rewrite the ioctl functions into seek
functions. In some ways they are simpler (seeking is the only
operation), but in some ways more complex (the ioctl allowed only a full
rewind, but now we can seek to arbitrary offsets).

Curl will only ever use SEEK_SET (per their documentation), so I didn't
bother implementing anything else, since it would naturally be
completely untested. This seems unlikely to change, but I added an
assertion just in case.

Likewise, I doubt curl will ever try to seek outside of the buffer sizes
we've told it, but I erred on the defensive side here, rather than do an
out-of-bounds read.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agohttp-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
Jeff King [Tue, 17 Jan 2023 03:04:38 +0000 (22:04 -0500)] 
http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT

The two options do exactly the same thing, but the latter has been
deprecated and in recent versions of curl may produce a compiler
warning. Since the UPLOAD form is available everywhere (it was
introduced in the year 2000 by curl 7.1), we can just switch to it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoGit 2.33.7 v2.33.7
Johannes Schindelin [Mon, 6 Feb 2023 08:25:58 +0000 (09:25 +0100)] 
Git 2.33.7

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoSync with 2.32.6
Johannes Schindelin [Mon, 6 Feb 2023 08:25:56 +0000 (09:25 +0100)] 
Sync with 2.32.6

* maint-2.32:
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

19 months agoGit 2.32.6 v2.32.6
Johannes Schindelin [Mon, 6 Feb 2023 08:25:09 +0000 (09:25 +0100)] 
Git 2.32.6

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoSync with 2.31.7
Johannes Schindelin [Mon, 6 Feb 2023 08:25:08 +0000 (09:25 +0100)] 
Sync with 2.31.7

* maint-2.31:
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

19 months agoGit 2.31.7 v2.31.7
Johannes Schindelin [Mon, 6 Feb 2023 08:24:07 +0000 (09:24 +0100)] 
Git 2.31.7

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoSync with 2.30.8
Johannes Schindelin [Mon, 6 Feb 2023 08:24:06 +0000 (09:24 +0100)] 
Sync with 2.30.8

* maint-2.30:
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

19 months agoGit 2.30.8 v2.30.8
Junio C Hamano [Fri, 3 Feb 2023 22:58:10 +0000 (14:58 -0800)] 
Git 2.30.8

Signed-off-by: Junio C Hamano <gitster@pobox.com>
19 months agoMerge branch 'ps/apply-beyond-symlink' into maint-2.30
Junio C Hamano [Fri, 3 Feb 2023 22:57:27 +0000 (14:57 -0800)] 
Merge branch 'ps/apply-beyond-symlink' into maint-2.30

Fix a vulnerability (CVE-2023-23946) that allows crafted input to trick
`git apply` into writing files outside of the working tree.

* ps/apply-beyond-symlink:
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
19 months agoMerge branch 'tb/clone-local-symlinks' into maint-2.30
Taylor Blau [Wed, 25 Jan 2023 19:58:38 +0000 (14:58 -0500)] 
Merge branch 'tb/clone-local-symlinks' into maint-2.30

Resolve a security vulnerability (CVE-2023-22490) where `clone_local()`
is used in conjunction with non-local transports, leading to arbitrary
path exfiltration.

* tb/clone-local-symlinks:
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

19 months agoapply: fix writing behind newly created symbolic links
Patrick Steinhardt [Thu, 2 Feb 2023 10:54:34 +0000 (11:54 +0100)] 
apply: fix writing behind newly created symbolic links

When writing files git-apply(1) initially makes sure that none of the
files it is about to create are behind a symlink:

```
 $ git init repo
 Initialized empty Git repository in /tmp/repo/.git/
 $ cd repo/
 $ ln -s dir symlink
 $ git apply - <<EOF
 diff --git a/symlink/file b/symlink/file
 new file mode 100644
 index 0000000..e69de29
 EOF
 error: affected file 'symlink/file' is beyond a symbolic link
```

This safety mechanism is crucial to ensure that we don't write outside
of the repository's working directory. It can be fooled though when the
patch that is being applied creates the symbolic link in the first
place, which can lead to writing files in arbitrary locations.

Fix this by checking whether the path we're about to create is
beyond a symlink or not. Tightening these checks like this should be
fine as we already have these precautions in Git as explained
above. Ideally, we should update the check we do up-front before
starting to reflect the computed changes to the working tree so that
we catch this case as well, but as part of embargoed security work,
adding an equivalent check just before we try to write out a file
should serve us well as a reasonable first step.

Digging back into history shows that this vulnerability has existed
since at least Git v2.9.0. As Git v2.8.0 and older don't build on my
system anymore I cannot tell whether older versions are affected, as
well.

Reported-by: Joern Schneeweisz <jschneeweisz@gitlab.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 months agodir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
Taylor Blau [Wed, 25 Jan 2023 00:43:51 +0000 (19:43 -0500)] 
dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS

When using the dir_iterator API, we first stat(2) the base path, and
then use that as a starting point to enumerate the directory's contents.

If the directory contains symbolic links, we will immediately die() upon
encountering them without the `FOLLOW_SYMLINKS` flag. The same is not
true when resolving the top-level directory, though.

As explained in a previous commit, this oversight in 6f054f9fb3
(builtin/clone.c: disallow `--local` clones with symlinks, 2022-07-28)
can be used as an attack vector to include arbitrary files on a victim's
filesystem from outside of the repository.

Prevent resolving top-level symlinks unless the FOLLOW_SYMLINKS flag is
given, which will cause clones of a repository with a symlink'd
"$GIT_DIR/objects" directory to fail.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 months agoclone: delay picking a transport until after get_repo_path()
Taylor Blau [Wed, 25 Jan 2023 00:43:48 +0000 (19:43 -0500)] 
clone: delay picking a transport until after get_repo_path()

In the previous commit, t5619 demonstrates an issue where two calls to
`get_repo_path()` could trick Git into using its local clone mechanism
in conjunction with a non-local transport.

That sequence is:

 - the starting state is that the local path https:/example.com/foo is a
   symlink that points to ../../../.git/modules/foo. So it's dangling.

 - get_repo_path() sees that no such path exists (because it's
   dangling), and thus we do not canonicalize it into an absolute path

 - because we're using --separate-git-dir, we create .git/modules/foo.
   Now our symlink is no longer dangling!

 - we pass the url to transport_get(), which sees it as an https URL.

 - we call get_repo_path() again, on the url. This second call was
   introduced by f38aa83f9a (use local cloning if insteadOf makes a
   local URL, 2014-07-17). The idea is that we want to pull the url
   fresh from the remote.c API, because it will apply any aliases.

And of course now it sees that there is a local file, which is a
mismatch with the transport we already selected.

The issue in the above sequence is calling `transport_get()` before
deciding whether or not the repository is indeed local, and not passing
in an absolute path if it is local.

This is reminiscent of a similar bug report in [1], where it was
suggested to perform the `insteadOf` lookup earlier. Taking that
approach may not be as straightforward, since the intent is to store the
original URL in the config, but to actually fetch from the insteadOf
one, so conflating the two early on is a non-starter.

Note: we pass the path returned by `get_repo_path(remote->url[0])`,
which should be the same as `repo_name` (aside from any `insteadOf`
rewrites).

We *could* pass `absolute_pathdup()` of the same argument, which
86521acaca (Bring local clone's origin URL in line with that of a remote
clone, 2008-09-01) indicates may differ depending on the presence of
".git/" for a non-bare repo. That matters for forming relative submodule
paths, but doesn't matter for the second call, since we're just feeding
it to the transport code, which is fine either way.

[1]: https://lore.kernel.org/git/CAMoD=Bi41mB3QRn3JdZL-FGHs4w3C2jGpnJB-CqSndO7FMtfzA@mail.gmail.com/

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 months agot5619: demonstrate clone_local() with ambiguous transport
Taylor Blau [Wed, 25 Jan 2023 00:43:45 +0000 (19:43 -0500)] 
t5619: demonstrate clone_local() with ambiguous transport

When cloning a repository, Git must determine (a) what transport
mechanism to use, and (b) whether or not the clone is local.

Since f38aa83f9a (use local cloning if insteadOf makes a local URL,
2014-07-17), the latter check happens after the remote has been
initialized, and references the remote's URL instead of the local path.
This is done to make it possible for a `url.<base>.insteadOf` rule to
convert a remote URL into a local one, in which case the `clone_local()`
mechanism should be used.

However, with a specially crafted repository, Git can be tricked into
using a non-local transport while still setting `is_local` to "1" and
using the `clone_local()` optimization. The below test case
demonstrates such an instance, and shows that it can be used to include
arbitrary (known) paths in the working copy of a cloned repository on a
victim's machine[^1], even if local file clones are forbidden by
`protocol.file.allow`.

This happens in a few parts:

 1. We first call `get_repo_path()` to see if the remote is a local
    path. If it is, we replace the repo name with its absolute path.

 2. We then call `transport_get()` on the repo name and decide how to
    access it. If it was turned into an absolute path in the previous
    step, then we should always treat it like a file.

 3. We use `get_repo_path()` again, and set `is_local` as appropriate.
    But it's already too late to rewrite the repo name as an absolute
    path, since we've already fed it to the transport code.

The attack works by including a submodule whose URL corresponds to a
path on disk. In the below example, the repository "sub" is reachable
via the dumb HTTP protocol at (something like):

    http://127.0.0.1:NNNN/dumb/sub.git

However, the path "http:/127.0.0.1:NNNN/dumb" (that is, a top-level
directory called "http:", then nested directories "127.0.0.1:NNNN", and
"dumb") exists within the repository, too.

To determine this, it first picks the appropriate transport, which is
dumb HTTP. It then uses the remote's URL in order to determine whether
the repository exists locally on disk. However, the malicious repository
also contains an embedded stub repository which is the target of a
symbolic link at the local path corresponding to the "sub" repository on
disk (i.e., there is a symbolic link at "http:/127.0.0.1/dumb/sub.git",
pointing to the stub repository via ".git/modules/sub/../../../repo").

This stub repository fools Git into thinking that a local repository
exists at that URL and thus can be cloned locally. The affected call is
in `get_repo_path()`, which in turn calls `get_repo_path_1()`, which
locates a valid repository at that target.

This then causes Git to set the `is_local` variable to "1", and in turn
instructs Git to clone the repository using its local clone optimization
via the `clone_local()` function.

The exploit comes into play because the stub repository's top-level
"$GIT_DIR/objects" directory is a symbolic link which can point to an
arbitrary path on the victim's machine. `clone_local()` resolves the
top-level "objects" directory through a `stat(2)` call, meaning that we
read through the symbolic link and copy or hardlink the directory
contents at the destination of the link.

In other words, we can get steps (1) and (3) to disagree by leveraging
the dangling symlink to pick a non-local transport in the first step,
and then set is_local to "1" in the third step when cloning with
`--separate-git-dir`, which makes the symlink non-dangling.

This can result in data-exfiltration on the victim's machine when
sensitive data is at a known path (e.g., "/home/$USER/.ssh").

The appropriate fix is two-fold:

 - Resolve the transport later on (to avoid using the local
   clone optimization with a non-local transport).

 - Avoid reading through the top-level "objects" directory when
   (correctly) using the clone_local() optimization.

This patch merely demonstrates the issue. The following two patches will
implement each part of the above fix, respectively.

[^1]: Provided that any target directory does not contain symbolic
  links, in which case the changes from 6f054f9fb3 (builtin/clone.c:
  disallow `--local` clones with symlinks, 2022-07-28) will abort the
  clone.

Reported-by: yvvdwf <yvvdwf@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 months agoSync with maint-2.38
Junio C Hamano [Thu, 19 Jan 2023 21:49:08 +0000 (13:49 -0800)] 
Sync with maint-2.38

* maint-2.38:
  attr: adjust a mismatched data type

20 months agoSync with maint-2.37
Junio C Hamano [Thu, 19 Jan 2023 21:48:26 +0000 (13:48 -0800)] 
Sync with maint-2.37

* maint-2.37:
  attr: adjust a mismatched data type

20 months agoSync with maint-2.36
Junio C Hamano [Thu, 19 Jan 2023 21:48:17 +0000 (13:48 -0800)] 
Sync with maint-2.36

* maint-2.36:
  attr: adjust a mismatched data type

20 months agoSync with maint-2.35
Junio C Hamano [Thu, 19 Jan 2023 21:48:08 +0000 (13:48 -0800)] 
Sync with maint-2.35

* maint-2.35:
  attr: adjust a mismatched data type

20 months agoSync with maint-2.34
Junio C Hamano [Thu, 19 Jan 2023 21:48:00 +0000 (13:48 -0800)] 
Sync with maint-2.34

* maint-2.34:
  attr: adjust a mismatched data type

20 months agoSync with maint-2.33
Junio C Hamano [Thu, 19 Jan 2023 21:47:42 +0000 (13:47 -0800)] 
Sync with maint-2.33

* maint-2.33:
  attr: adjust a mismatched data type

20 months agoSync with maint-2.32
Junio C Hamano [Thu, 19 Jan 2023 21:46:04 +0000 (13:46 -0800)] 
Sync with maint-2.32

* maint-2.32:
  attr: adjust a mismatched data type

20 months agoSync with maint-2.31
Junio C Hamano [Thu, 19 Jan 2023 21:45:37 +0000 (13:45 -0800)] 
Sync with maint-2.31

* maint-2.31:
  attr: adjust a mismatched data type

20 months agoSync with maint-2.30
Junio C Hamano [Thu, 19 Jan 2023 21:45:23 +0000 (13:45 -0800)] 
Sync with maint-2.30

* maint-2.30:
  attr: adjust a mismatched data type

20 months agoattr: adjust a mismatched data type
Johannes Schindelin [Thu, 12 Jan 2023 00:05:02 +0000 (01:05 +0100)] 
attr: adjust a mismatched data type

On platforms where `size_t` does not have the same width as `unsigned
long`, passing a pointer to the former when a pointer to the latter is
expected can lead to problems.

Windows and 32-bit Linux are among the affected platforms.

In this instance, we want to store the size of the blob that was read in
that variable. However, `read_blob_data_from_index()` passes that
pointer to `read_object_file()` which expects an `unsigned long *`.
Which means that on affected platforms, the variable is not fully
populated and part of its value is left uninitialized. (On Big-Endian
platforms, this problem would be even worse.)

The consequence is that depending on the uninitialized memory's
contents, we may erroneously reject perfectly fine attributes.

Let's address this by passing a pointer to a variable of the expected
data type.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 months agohttp: support CURLOPT_PROTOCOLS_STR
Jeff King [Tue, 17 Jan 2023 03:04:48 +0000 (22:04 -0500)] 
http: support CURLOPT_PROTOCOLS_STR

The CURLOPT_PROTOCOLS (and matching CURLOPT_REDIR_PROTOCOLS) flag was
deprecated in curl 7.85.0, and using it generate compiler warnings as of
curl 7.87.0. The path forward is to use CURLOPT_PROTOCOLS_STR, but we
can't just do so unilaterally, as it was only introduced less than a
year ago in 7.85.0.

Until that version becomes ubiquitous, we have to either disable the
deprecation warning or conditionally use the "STR" variant on newer
versions of libcurl. This patch switches to the new variant, which is
nice for two reasons:

  - we don't have to worry that silencing curl's deprecation warnings
    might cause us to miss other more useful ones

  - we'd eventually want to move to the new variant anyway, so this gets
    us set up (albeit with some extra ugly boilerplate for the
    conditional)

There are a lot of ways to split up the two cases. One way would be to
abstract the storage type (strbuf versus a long), how to append
(strbuf_addstr vs bitwise OR), how to initialize, which CURLOPT to use,
and so on. But the resulting code looks pretty magical:

  GIT_CURL_PROTOCOL_TYPE allowed = GIT_CURL_PROTOCOL_TYPE_INIT;
  if (...http is allowed...)
GIT_CURL_PROTOCOL_APPEND(&allowed, "http", CURLOPT_HTTP);

and you end up with more "#define GIT_CURL_PROTOCOL_TYPE" macros than
actual code.

On the other end of the spectrum, we could just implement two separate
functions, one that handles a string list and one that handles bits. But
then we end up repeating our list of protocols (http, https, ftp, ftp).

This patch takes the middle ground. The run-time code is always there to
handle both types, and we just choose which one to feed to curl.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 months agohttp: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
Jeff King [Tue, 17 Jan 2023 03:04:44 +0000 (22:04 -0500)] 
http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION

The IOCTLFUNCTION option has been deprecated, and generates a compiler
warning in recent versions of curl. We can switch to using SEEKFUNCTION
instead. It was added in 2008 via curl 7.18.0; our INSTALL file already
indicates we require at least curl 7.19.4.

But there's one catch: curl says we should use CURL_SEEKFUNC_{OK,FAIL},
and those didn't arrive until 7.19.5. One workaround would be to use a
bare 0/1 here (or define our own macros).  But let's just bump the
minimum required version to 7.19.5. That version is only a minor version
bump from our existing requirement, and is only a 2 month time bump for
versions that are almost 13 years old. So it's not likely that anybody
cares about the distinction.

Switching means we have to rewrite the ioctl functions into seek
functions. In some ways they are simpler (seeking is the only
operation), but in some ways more complex (the ioctl allowed only a full
rewind, but now we can seek to arbitrary offsets).

Curl will only ever use SEEK_SET (per their documentation), so I didn't
bother implementing anything else, since it would naturally be
completely untested. This seems unlikely to change, but I added an
assertion just in case.

Likewise, I doubt curl will ever try to seek outside of the buffer sizes
we've told it, but I erred on the defensive side here, rather than do an
out-of-bounds read.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 months agohttp-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
Jeff King [Tue, 17 Jan 2023 03:04:38 +0000 (22:04 -0500)] 
http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT

The two options do exactly the same thing, but the latter has been
deprecated and in recent versions of curl may produce a compiler
warning. Since the UPLOAD form is available everywhere (it was
introduced in the year 2000 by curl 7.1), we can just switch to it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 months agoattr: adjust a mismatched data type
Johannes Schindelin [Thu, 12 Jan 2023 00:05:02 +0000 (01:05 +0100)] 
attr: adjust a mismatched data type

On platforms where `size_t` does not have the same width as `unsigned
long`, passing a pointer to the former when a pointer to the latter is
expected can lead to problems.

Windows and 32-bit Linux are among the affected platforms.

In this instance, we want to store the size of the blob that was read in
that variable. However, `read_blob_data_from_index()` passes that
pointer to `read_object_file()` which expects an `unsigned long *`.
Which means that on affected platforms, the variable is not fully
populated and part of its value is left uninitialized. (On Big-Endian
platforms, this problem would be even worse.)

The consequence is that depending on the uninitialized memory's
contents, we may erroneously reject perfectly fine attributes.

Let's address this by passing a pointer to a variable of the expected
data type.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 months agofsck: document the new `gitattributes` message IDs
Johannes Schindelin [Thu, 12 Jan 2023 19:43:31 +0000 (20:43 +0100)] 
fsck: document the new `gitattributes` message IDs

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoci (check-whitespace): move to actions/checkout@v3
Chris. Webster [Tue, 20 Dec 2022 00:35:47 +0000 (00:35 +0000)] 
ci (check-whitespace): move to actions/checkout@v3

Get rid of deprecation warnings in the CI runs.  Also gets the latest
security patches.

Signed-off-by: Chris. Webster <chris@webstech.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoci (check-whitespace): add links to job output
Chris. Webster [Tue, 20 Dec 2022 00:35:46 +0000 (00:35 +0000)] 
ci (check-whitespace): add links to job output

A message in the step log will refer to the Summary output.

The job summary output is using markdown to improve readability.  The
git commands and commits with errors are now in ordered lists.
Commits and files in error are links to the user's repository.

Signed-off-by: Chris. Webster <chris@webstech.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoci (check-whitespace): suggest fixes for errors
Chris. Webster [Tue, 20 Dec 2022 00:35:45 +0000 (00:35 +0000)] 
ci (check-whitespace): suggest fixes for errors

Make the errors more visible by adding them to the job summary and
display the git commands that will usually fix the problem.

Signed-off-by: Chris. Webster <chris@webstech.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoci: only run win+VS build & tests in Git for Windows' fork
Johannes Schindelin [Mon, 19 Dec 2022 14:50:14 +0000 (14:50 +0000)] 
ci: only run win+VS build & tests in Git for Windows' fork

It has been a frequent matter of contention that the win+VS jobs not
only take a long time to run, but are also more easily broken than the
other jobs (because they do not use the same `Makefile`-based builds as
all other jobs), and to make matters worse, these breakages are also
much harder to diagnose and fix than other jobs', especially for
contributors who are happy to stay away from Windows.

The purpose of these win+VS jobs is to maintain the CMake-based build
of Git, with the target audience being Visual Studio users on Windows
who are typically quite unfamiliar with `make` and POSIX shell
scripting, but the benefit of whose expertise we want for the Git
project nevertheless.

The CMake support was introduced for that specific purpose, and already
early on concerns were raised that it would put an undue burden on
contributors to ensure that these jobs pass in CI, when they do not have
access to Windows machines (nor want to have that).

This developer's initial hope was that it would be enough to fix win+VS
failures and provide the changes to be squashed into contributors'
patches, and that it would be worth the benefit of attracting
Windows-based developers' contributions.

Neither of these hopes have panned out.

To lower the frustration, and incidentally benefit from using way less
build minutes, let's just not run the win+VS jobs by default, which
appears to be the consensus of the mail thread leading up to
https://lore.kernel.org/git/xmqqk0311blt.fsf@gitster.g/

Since the Git for Windows project still needs to at least try to attract
more of said Windows-based developers, let's keep the jobs, but disable
them everywhere except in Git for Windows' fork. This will help because
Git for Windows' branch thicket is "continuously rebased" via automation
to the `shears/maint`, `shears/main`, `shears/next` and `shears/seen`
branches at https://github.com/git-for-windows/git. That way, the Git
for Windows project will still be notified early on about potential
breakages, but the Git project won't be burdened with fixing them
anymore, which seems to be the best compromise we can get on this issue.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoGit 2.39.1 v2.39.1
Junio C Hamano [Tue, 13 Dec 2022 12:25:28 +0000 (21:25 +0900)] 
Git 2.39.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoSync with 2.38.3
Junio C Hamano [Tue, 13 Dec 2022 12:25:15 +0000 (21:25 +0900)] 
Sync with 2.38.3

21 months agoGit 2.38.3 v2.38.3
Junio C Hamano [Tue, 13 Dec 2022 12:24:14 +0000 (21:24 +0900)] 
Git 2.38.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoSync with Git 2.37.5
Junio C Hamano [Tue, 13 Dec 2022 12:23:36 +0000 (21:23 +0900)] 
Sync with Git 2.37.5

21 months agoGit 2.37.5 v2.37.5
Junio C Hamano [Tue, 13 Dec 2022 12:20:47 +0000 (21:20 +0900)] 
Git 2.37.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoMerge branch 'maint-2.36' into maint-2.37
Junio C Hamano [Tue, 13 Dec 2022 12:20:35 +0000 (21:20 +0900)] 
Merge branch 'maint-2.36' into maint-2.37

21 months agoGit 2.36.4 v2.36.4
Junio C Hamano [Tue, 13 Dec 2022 12:19:24 +0000 (21:19 +0900)] 
Git 2.36.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoMerge branch 'maint-2.35' into maint-2.36
Junio C Hamano [Tue, 13 Dec 2022 12:19:11 +0000 (21:19 +0900)] 
Merge branch 'maint-2.35' into maint-2.36

21 months agoGit 2.35.6 v2.35.6
Junio C Hamano [Tue, 13 Dec 2022 12:17:26 +0000 (21:17 +0900)] 
Git 2.35.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoMerge branch 'maint-2.34' into maint-2.35
Junio C Hamano [Tue, 13 Dec 2022 12:17:10 +0000 (21:17 +0900)] 
Merge branch 'maint-2.34' into maint-2.35

21 months agoGit 2.34.6 v2.34.6
Junio C Hamano [Tue, 13 Dec 2022 12:15:39 +0000 (21:15 +0900)] 
Git 2.34.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoMerge branch 'maint-2.33' into maint-2.34
Junio C Hamano [Tue, 13 Dec 2022 12:15:22 +0000 (21:15 +0900)] 
Merge branch 'maint-2.33' into maint-2.34

21 months agoGit 2.33.6 v2.33.6
Junio C Hamano [Tue, 13 Dec 2022 12:13:48 +0000 (21:13 +0900)] 
Git 2.33.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoSync with Git 2.32.5
Junio C Hamano [Tue, 13 Dec 2022 12:13:11 +0000 (21:13 +0900)] 
Sync with Git 2.32.5

21 months agoGit 2.32.5 v2.32.5
Junio C Hamano [Tue, 13 Dec 2022 12:10:27 +0000 (21:10 +0900)] 
Git 2.32.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoMerge branch 'ps/attr-limits-with-fsck' into maint-2.32
Junio C Hamano [Tue, 13 Dec 2022 12:09:56 +0000 (21:09 +0900)] 
Merge branch 'ps/attr-limits-with-fsck' into maint-2.32

21 months agoSync with Git 2.31.6
Junio C Hamano [Tue, 13 Dec 2022 12:09:40 +0000 (21:09 +0900)] 
Sync with Git 2.31.6

21 months agoGit 2.31.6 v2.31.6
Junio C Hamano [Tue, 13 Dec 2022 12:04:03 +0000 (21:04 +0900)] 
Git 2.31.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoSync with Git 2.30.7
Junio C Hamano [Tue, 13 Dec 2022 12:02:20 +0000 (21:02 +0900)] 
Sync with Git 2.30.7

21 months agoGit 2.30.7 v2.30.7
Junio C Hamano [Tue, 13 Dec 2022 11:56:43 +0000 (20:56 +0900)] 
Git 2.30.7

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoGit 2.39 v2.39.0
Junio C Hamano [Mon, 12 Dec 2022 00:59:08 +0000 (09:59 +0900)] 
Git 2.39

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoMerge tag 'l10n-2.39.0-rnd1' of https://github.com/git-l10n/git-po
Junio C Hamano [Mon, 12 Dec 2022 00:20:49 +0000 (09:20 +0900)] 
Merge tag 'l10n-2.39.0-rnd1' of https://github.com/git-l10n/git-po

l10n-2.39.0-rnd1

* tag 'l10n-2.39.0-rnd1' of https://github.com/git-l10n/git-po:
  l10n: zh_TW.po: Git 2.39-rc2
  l10n: tr: v2.39.0 updates
  l10n: Update Catalan translation
  l10n: bg.po: Updated Bulgarian translation (5501t)
  l10n: de.po: update German translation
  l10n: zh_CN v2.39.0 round 1
  l10n: fr: v2.39 rnd 1
  l10n: po-id for 2.39 (round 1)
  l10n: sv.po: Update Swedish translation (5501t0f0)

21 months agoSync with Git 2.38.2
Junio C Hamano [Sun, 11 Dec 2022 00:34:51 +0000 (09:34 +0900)] 
Sync with Git 2.38.2

21 months agoGit 2.38.2 v2.38.2
Junio C Hamano [Sun, 11 Dec 2022 00:32:48 +0000 (09:32 +0900)] 
Git 2.38.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agol10n: zh_TW.po: Git 2.39-rc2
pan93412 [Sat, 10 Dec 2022 17:16:20 +0000 (01:16 +0800)] 
l10n: zh_TW.po: Git 2.39-rc2

Signed-off-by: pan93412 <pan93412@gmail.com>
21 months agoci: use a newer `github-script` version
Johannes Schindelin [Tue, 8 Nov 2022 10:13:28 +0000 (10:13 +0000)] 
ci: use a newer `github-script` version

The old version we currently use runs in node.js v12.x, which is being
deprecated in GitHub Actions. The new version uses node.js v16.x.

Incidentally, this also avoids the warning about the deprecated
`::set-output::` workflow command because the newer version of the
`github-script` Action uses the recommended new way to specify outputs.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
21 months agoMerge branch 'jx/ci-ubuntu-fix' into maint-2.38
Junio C Hamano [Sat, 10 Dec 2022 07:17:47 +0000 (16:17 +0900)] 
Merge branch 'jx/ci-ubuntu-fix' into maint-2.38

Adjust the GitHub CI to newer ubuntu release.

* jx/ci-ubuntu-fix:
  ci: install python on ubuntu
  ci: use the same version of p4 on both Linux and macOS
  ci: remove the pipe after "p4 -V" to catch errors
  github-actions: run gcc-8 on ubuntu-20.04 image

21 months agoSync with 'maint'
Junio C Hamano [Sat, 10 Dec 2022 05:02:22 +0000 (14:02 +0900)] 
Sync with 'maint'

21 months agoMerge branch 'js/ci-use-newer-up-down-artifact' into maint-2.38
Junio C Hamano [Sat, 10 Dec 2022 05:02:09 +0000 (14:02 +0900)] 
Merge branch 'js/ci-use-newer-up-down-artifact' into maint-2.38

CI fix.

* js/ci-use-newer-up-down-artifact:
  ci: avoid using deprecated {up,down}load-artifacts Action

21 months agoMerge branch 'ab/ci-use-macos-12' into maint-2.38
Junio C Hamano [Sat, 10 Dec 2022 05:02:09 +0000 (14:02 +0900)] 
Merge branch 'ab/ci-use-macos-12' into maint-2.38

CI fix.

* ab/ci-use-macos-12:
  CI: upgrade to macos-12, and pin OSX version

21 months agoMerge branch 'ab/ci-retire-set-output' into maint-2.38
Junio C Hamano [Sat, 10 Dec 2022 05:02:09 +0000 (14:02 +0900)] 
Merge branch 'ab/ci-retire-set-output' into maint-2.38

CI fix.

* ab/ci-retire-set-output:
  CI: migrate away from deprecated "set-output" syntax

21 months agoMerge branch 'ab/ci-musl-bash-fix' into maint-2.38
Junio C Hamano [Sat, 10 Dec 2022 05:02:09 +0000 (14:02 +0900)] 
Merge branch 'ab/ci-musl-bash-fix' into maint-2.38

CI fix.

* ab/ci-musl-bash-fix:
  CI: don't explicitly pick "bash" shell outside of Windows, fix regression

21 months agoMerge branch 'od/ci-use-checkout-v3-when-applicable' into maint-2.38
Junio C Hamano [Sat, 10 Dec 2022 05:02:09 +0000 (14:02 +0900)] 
Merge branch 'od/ci-use-checkout-v3-when-applicable' into maint-2.38

Update GitHub CI to use actions/checkout@v3; use of the older
checkout@v2 gets annoying deprecation notices.

* od/ci-use-checkout-v3-when-applicable:
  ci(main): upgrade actions/checkout to v3

21 months agoMerge branch 'js/ci-use-newer-up-down-artifact'
Junio C Hamano [Sat, 10 Dec 2022 05:01:06 +0000 (14:01 +0900)] 
Merge branch 'js/ci-use-newer-up-down-artifact'

CI fix.

* js/ci-use-newer-up-down-artifact:
  ci: avoid using deprecated {up,down}load-artifacts Action

21 months agoMerge branch 'ab/ci-use-macos-12'
Junio C Hamano [Sat, 10 Dec 2022 05:01:06 +0000 (14:01 +0900)] 
Merge branch 'ab/ci-use-macos-12'

CI fix.

* ab/ci-use-macos-12:
  CI: upgrade to macos-12, and pin OSX version

21 months agoMerge branch 'ab/ci-retire-set-output'
Junio C Hamano [Sat, 10 Dec 2022 05:01:05 +0000 (14:01 +0900)] 
Merge branch 'ab/ci-retire-set-output'

CI fix.

* ab/ci-retire-set-output:
  CI: migrate away from deprecated "set-output" syntax

21 months agoMerge branch 'ab/ci-musl-bash-fix'
Junio C Hamano [Sat, 10 Dec 2022 05:01:05 +0000 (14:01 +0900)] 
Merge branch 'ab/ci-musl-bash-fix'

CI fix.

* ab/ci-musl-bash-fix:
  CI: don't explicitly pick "bash" shell outside of Windows, fix regression

21 months agoMerge branch 'od/ci-use-checkout-v3-when-applicable'
Junio C Hamano [Sat, 10 Dec 2022 05:01:05 +0000 (14:01 +0900)] 
Merge branch 'od/ci-use-checkout-v3-when-applicable'

Update GitHub CI to use actions/checkout@v3; use of the older
checkout@v2 gets annoying deprecation notices.

* od/ci-use-checkout-v3-when-applicable:
  ci(main): upgrade actions/checkout to v3

21 months agomailmap: update email address of Matheus Tavares
Matheus Tavares [Fri, 9 Dec 2022 23:35:16 +0000 (20:35 -0300)] 
mailmap: update email address of Matheus Tavares

I haven't been very active in the community lately, but I'm soon going
to lose access to my previous commit email (@usp.br); so add my current
personal address to mailmap for any future message exchanges or patch
contributions.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agorebase --update-refs: avoid unintended ref deletion
Victoria Dye [Mon, 7 Nov 2022 17:47:52 +0000 (09:47 -0800)] 
rebase --update-refs: avoid unintended ref deletion

In b3b1a21d1a5 (sequencer: rewrite update-refs as user edits todo list,
2022-07-19), the 'todo_list_filter_update_refs()' step was added to handle
the removal of 'update-ref' lines from a 'rebase-todo'. Specifically, it
removes potential ref updates from the "update refs state" if a ref does not
have a corresponding 'update-ref' line.

However, because 'write_update_refs_state()' will not update the state if
the 'refs_to_oids' list was empty, removing *all* 'update-ref' lines will
result in the state remaining unchanged from how it was initialized (with
all refs' "after" OID being null). Then, when the ref update is applied, all
refs will be updated to null and consequently deleted.

To fix this, delete the 'update-refs' state file when 'refs_to_oids' is
empty. Additionally, add a tests covering "all update-ref lines removed"
cases.

Reported-by: herr.kaste <herr.kaste@gmail.com>
Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Helped-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
21 months agofsck: implement checks for gitattributes
Patrick Steinhardt [Thu, 1 Dec 2022 14:46:09 +0000 (15:46 +0100)] 
fsck: implement checks for gitattributes

Recently, a vulnerability was reported that can lead to an out-of-bounds
write when reading an unreasonably large gitattributes file. The root
cause of this error are multiple integer overflows in different parts of
the code when there are either too many lines, when paths are too long,
when attribute names are too long, or when there are too many attributes
declared for a pattern.

As all of these are related to size, it seems reasonable to restrict the
size of the gitattributes file via git-fsck(1). This allows us to both
stop distributing known-vulnerable objects via common hosting platforms
that have fsck enabled, and users to protect themselves by enabling the
`fetch.fsckObjects` config.

There are basically two checks:

    1. We verify that size of the gitattributes file is smaller than
       100MB.

    2. We verify that the maximum line length does not exceed 2048
       bytes.

With the preceding commits, both of these conditions would cause us to
either ignore the complete gitattributes file or blob in the first case,
or the specific line in the second case. Now with these consistency
checks added, we also grow the ability to stop distributing such files
in the first place when `receive.fsckObjects` is enabled.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agofsck: move checks for gitattributes
Patrick Steinhardt [Thu, 1 Dec 2022 14:46:05 +0000 (15:46 +0100)] 
fsck: move checks for gitattributes

Move the checks for gitattributes so that they can be extended more
readily.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agofsck: pull out function to check a set of blobs
Patrick Steinhardt [Thu, 1 Dec 2022 14:46:01 +0000 (15:46 +0100)] 
fsck: pull out function to check a set of blobs

In `fsck_finish()` we check all blobs for consistency that we have found
during the tree walk, but that haven't yet been checked. This is only
required for gitmodules right now, but will also be required for a new
check for gitattributes.

Pull out a function `fsck_blobs()` that allows the caller to check a set
of blobs for consistency.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agofsck: refactor `fsck_blob()` to allow for more checks
Patrick Steinhardt [Thu, 1 Dec 2022 14:45:57 +0000 (15:45 +0100)] 
fsck: refactor `fsck_blob()` to allow for more checks

In general, we don't need to validate blob contents as they are opaque
blobs about whose content Git doesn't need to care about. There are some
exceptions though when blobs are linked into trees so that they would be
interpreted by Git. We only have a single such check right now though,
which is the one for gitmodules that has been added in the context of
CVE-2018-11235.

Now we have found another vulnerability with gitattributes that can lead
to out-of-bounds writes and reads. So let's refactor `fsck_blob()` so
that it is more extensible and can check different types of blobs.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agoMerge branch 'ps/attr-limits' into maint-2.32
Junio C Hamano [Fri, 9 Dec 2022 08:03:49 +0000 (17:03 +0900)] 
Merge branch 'ps/attr-limits' into maint-2.32

21 months agoMerge branch 'ps/attr-limits' into maint-2.30
Junio C Hamano [Fri, 9 Dec 2022 07:05:52 +0000 (16:05 +0900)] 
Merge branch 'ps/attr-limits' into maint-2.30