<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/connect.c, branch v2.35.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.35.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.35.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2021-10-04T04:49:21Z</updated>
<entry>
<title>Merge branch 'ah/connect-parse-feature-v0-fix'</title>
<updated>2021-10-04T04:49:21Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-10-04T04:49:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3a757d0369a6cd83d401d83ae062705c56242474'/>
<id>urn:sha1:3a757d0369a6cd83d401d83ae062705c56242474</id>
<content type='text'>
Protocol v0 clients can get stuck parsing a malformed feature line.

* ah/connect-parse-feature-v0-fix:
  connect: also update offset for features without values
</content>
</entry>
<entry>
<title>connect: also update offset for features without values</title>
<updated>2021-09-27T17:34:41Z</updated>
<author>
<name>Andrzej Hunt</name>
<email>andrzej@ahunt.org</email>
</author>
<published>2021-09-26T15:58:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=44d2aec6e8795ac22b9121b3d2ecf43589e8ecd2'/>
<id>urn:sha1:44d2aec6e8795ac22b9121b3d2ecf43589e8ecd2</id>
<content type='text'>
parse_feature_value() takes an offset, and uses it to seek past the
point in features_list that we've already seen. However if the feature
being searched for does not specify a value, the offset is not
updated. Therefore if we call parse_feature_value() in a loop on a
value-less feature, we'll keep on parsing the same feature over and over
again. This usually isn't an issue: there's no point in using
next_server_feature_value() to search for repeated instances of the same
capability unless that capability typically specifies a value - but a
broken server could send a response that omits the value for a feature
even when we are expecting a value.

Therefore we add an offset update calculation for the no-value case,
which helps ensure that loops using next_server_feature_value() will
always terminate.

next_server_feature_value(), and the offset calculation, were first
added in 2.28 in 2c6a403d96 (connect: add function to parse multiple
v1 capability values, 2020-05-25).

Thanks to Peff for authoring the test.

Co-authored-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Andrzej Hunt &lt;andrzej@ahunt.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>connect, protocol: log negotiated protocol version</title>
<updated>2021-08-10T18:46:33Z</updated>
<author>
<name>Josh Steadmon</name>
<email>steadmon@google.com</email>
</author>
<published>2021-08-10T17:20:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=626beebdf85a6ea5561dd8a0c912c9e9fb5622b4'/>
<id>urn:sha1:626beebdf85a6ea5561dd8a0c912c9e9fb5622b4</id>
<content type='text'>
It is useful for performance monitoring and debugging purposes to know
the wire protocol used for remote operations. This may differ from the
version set in local configuration due to differences in version and/or
configuration between the server and the client. Therefore, log the
negotiated wire protocol version via trace2, for both clients and
servers.

Signed-off-by: Josh Steadmon &lt;steadmon@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hash: provide per-algorithm null OIDs</title>
<updated>2021-04-27T07:31:39Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2021-04-26T01:02:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=14228447c9ce664a4e9c31ba10344ec5e4ea4ba5'/>
<id>urn:sha1:14228447c9ce664a4e9c31ba10344ec5e4ea4ba5</id>
<content type='text'>
Up until recently, object IDs did not have an algorithm member, only a
hash.  Consequently, it was possible to share one null (all-zeros)
object ID among all hash algorithms.  Now that we're going to be
handling objects from multiple hash algorithms, it's important to make
sure that all object IDs have a correct algorithm field.

Introduce a per-algorithm null OID, and add it to struct hash_algo.
Introduce a wrapper function as well, and use it everywhere we used to
use the null_oid constant.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jt/clone-unborn-head'</title>
<updated>2021-02-18T01:21:40Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-02-18T01:21:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=69571dfe219f48614e0e0ae7e28efae0be297764'/>
<id>urn:sha1:69571dfe219f48614e0e0ae7e28efae0be297764</id>
<content type='text'>
"git clone" tries to locally check out the branch pointed at by
HEAD of the remote repository after it is done, but the protocol
did not convey the information necessary to do so when copying an
empty repository.  The protocol v2 learned how to do so.

* jt/clone-unborn-head:
  clone: respect remote unborn HEAD
  connect, transport: encapsulate arg in struct
  ls-refs: report unborn targets of symrefs
</content>
</entry>
<entry>
<title>clone: respect remote unborn HEAD</title>
<updated>2021-02-05T21:49:55Z</updated>
<author>
<name>Jonathan Tan</name>
<email>jonathantanmy@google.com</email>
</author>
<published>2021-02-05T20:48:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4f37d45706514a4b3d0259d26f719678a0cf3521'/>
<id>urn:sha1:4f37d45706514a4b3d0259d26f719678a0cf3521</id>
<content type='text'>
Teach Git to use the "unborn" feature introduced in a previous patch as
follows: Git will always send the "unborn" argument if it is supported
by the server. During "git clone", if cloning an empty repository, Git
will use the new information to determine the local branch to create. In
all other cases, Git will ignore it.

Signed-off-by: Jonathan Tan &lt;jonathantanmy@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>connect, transport: encapsulate arg in struct</title>
<updated>2021-02-05T21:49:54Z</updated>
<author>
<name>Jonathan Tan</name>
<email>jonathantanmy@google.com</email>
</author>
<published>2021-02-05T20:48:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=39835409d10de2402c4b3e10dba20286989627d4'/>
<id>urn:sha1:39835409d10de2402c4b3e10dba20286989627d4</id>
<content type='text'>
In a future patch we plan to return the name of an unborn current branch
from deep in the callchain to a caller via a new pointer parameter that
points at a variable in the caller when the caller calls
get_remote_refs() and transport_get_remote_refs().

In preparation for that, encapsulate the existing ref_prefixes
parameter into a struct. The aforementioned unborn current branch will
go into this new struct in the future patch.

Signed-off-by: Jonathan Tan &lt;jonathantanmy@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/forbid-lf-in-git-url'</title>
<updated>2021-01-25T22:19:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-01-25T22:19:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c7b1aaf6d6bb5746a98831854313ca8fccea600d'/>
<id>urn:sha1:c7b1aaf6d6bb5746a98831854313ca8fccea600d</id>
<content type='text'>
Newline characters in the host and path part of git:// URL are
now forbidden.

* jk/forbid-lf-in-git-url:
  fsck: reject .gitmodules git:// urls with newlines
  git_connect_git(): forbid newlines in host and path
</content>
</entry>
<entry>
<title>git_connect_git(): forbid newlines in host and path</title>
<updated>2021-01-07T22:25:44Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2021-01-07T09:43:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a02ea577174ab8ed18f847cf1693f213e0b9c473'/>
<id>urn:sha1:a02ea577174ab8ed18f847cf1693f213e0b9c473</id>
<content type='text'>
When we connect to a git:// server, we send an initial request that
looks something like:

  002dgit-upload-pack repo.git\0host=example.com

If the repo path contains a newline, then it's included literally, and
we get:

  002egit-upload-pack repo
  .git\0host=example.com

This works fine if you really do have a newline in your repository name;
the server side uses the pktline framing to parse the string, not
newlines. However, there are many _other_ protocols in the wild that do
parse on newlines, such as HTTP. So a carefully constructed git:// URL
can actually turn into a valid HTTP request. For example:

  git://localhost:1234/%0d%0a%0d%0aGET%20/%20HTTP/1.1 %0d%0aHost:localhost%0d%0a%0d%0a

becomes:

  0050git-upload-pack /
  GET / HTTP/1.1
  Host:localhost

  host=localhost:1234

on the wire. Again, this isn't a problem for a real Git server, but it
does mean that feeding a malicious URL to Git (e.g., through a
submodule) can cause it to make unexpected cross-protocol requests.
Since repository names with newlines are presumably quite rare (and
indeed, we already disallow them in git-over-http), let's just disallow
them over this protocol.

Hostnames could likewise inject a newline, but this is unlikely a
problem in practice; we'd try resolving the hostname with a newline in
it, which wouldn't work. Still, it doesn't hurt to err on the side of
caution there, since we would not expect them to work in the first
place.

The ssh and local code paths are unaffected by this patch. In both cases
we're trying to run upload-pack via a shell, and will quote the newline
so that it makes it intact. An attacker can point an ssh url at an
arbitrary port, of course, but unless there's an actual ssh server
there, we'd never get as far as sending our shell command anyway.  We
_could_ similarly restrict newlines in those protocols out of caution,
but there seems little benefit to doing so.

The new test here is run alongside the git-daemon tests, which cover the
same protocol, but it shouldn't actually contact the daemon at all.  In
theory we could make the test more robust by setting up an actual
repository with a newline in it (so that our clone would succeed if our
new check didn't kick in). But a repo directory with newline in it is
likely not portable across all filesystems. Likewise, we could check
git-daemon's log that it was not contacted at all, but we do not
currently record the log (and anyway, it would make the test racy with
the daemon's log write). We'll just check the client-side stderr to make
sure we hit the expected code path.

Reported-by: Harold Kim &lt;h.kim@flatt.tech&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/leakfix'</title>
<updated>2020-08-27T21:04:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-08-27T21:04:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0d9a8e33f9fd07efa10072576df01a9cae5d89e6'/>
<id>urn:sha1:0d9a8e33f9fd07efa10072576df01a9cae5d89e6</id>
<content type='text'>
Code clean-up.

* jk/leakfix:
  submodule--helper: fix leak of core.worktree value
  config: fix leak in git_config_get_expiry_in_days()
  config: drop git_config_get_string_const()
  config: fix leaks from git_config_get_string_const()
  checkout: fix leak of non-existent branch names
  submodule--helper: use strbuf_release() to free strbufs
  clear_pattern_list(): clear embedded hashmaps
</content>
</entry>
</feed>
