Skip to content

Commit 3adc4ec

Browse files
committed
Sync with v2.5.4
2 parents be08dee + 2435856 commit 3adc4ec

29 files changed

+486
-30
lines changed

Documentation/RelNotes/2.3.10.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Git v2.3.10 Release Notes
2+
=========================
3+
4+
Fixes since v2.3.9
5+
------------------
6+
7+
* xdiff code we use to generate diffs is not prepared to handle
8+
extremely large files. It uses "int" in many places, which can
9+
overflow if we have a very large number of lines or even bytes in
10+
our input files, for example. Cap the input size to soemwhere
11+
around 1GB for now.
12+
13+
* Some protocols (like git-remote-ext) can execute arbitrary code
14+
found in the URL. The URLs that submodules use may come from
15+
arbitrary sources (e.g., .gitmodules files in a remote
16+
repository), and can hurt those who blindly enable recursive
17+
fetch. Restrict the allowed protocols to well known and safe
18+
ones.

Documentation/RelNotes/2.4.10.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Git v2.4.10 Release Notes
2+
=========================
3+
4+
Fixes since v2.4.9
5+
------------------
6+
7+
* xdiff code we use to generate diffs is not prepared to handle
8+
extremely large files. It uses "int" in many places, which can
9+
overflow if we have a very large number of lines or even bytes in
10+
our input files, for example. Cap the input size to soemwhere
11+
around 1GB for now.
12+
13+
* Some protocols (like git-remote-ext) can execute arbitrary code
14+
found in the URL. The URLs that submodules use may come from
15+
arbitrary sources (e.g., .gitmodules files in a remote
16+
repository), and can hurt those who blindly enable recursive
17+
fetch. Restrict the allowed protocols to well known and safe
18+
ones.

Documentation/RelNotes/2.5.4.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Git v2.5.4 Release Notes
2+
========================
3+
4+
Fixes since v2.5.4
5+
------------------
6+
7+
* xdiff code we use to generate diffs is not prepared to handle
8+
extremely large files. It uses "int" in many places, which can
9+
overflow if we have a very large number of lines or even bytes in
10+
our input files, for example. Cap the input size to soemwhere
11+
around 1GB for now.
12+
13+
* Some protocols (like git-remote-ext) can execute arbitrary code
14+
found in the URL. The URLs that submodules use may come from
15+
arbitrary sources (e.g., .gitmodules files in a remote
16+
repository), and can hurt those who blindly enable recursive
17+
fetch. Restrict the allowed protocols to well known and safe
18+
ones.

Documentation/git.txt

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,19 @@ Documentation for older releases are available here:
4848
* release notes for
4949
link:RelNotes/2.6.0.txt[2.6].
5050

51-
* link:v2.5.3/git.html[documentation for release 2.5.3]
51+
* link:v2.5.4/git.html[documentation for release 2.5.4]
5252

5353
* release notes for
54+
link:RelNotes/2.5.4.txt[2.5.4],
5455
link:RelNotes/2.5.3.txt[2.5.3],
5556
link:RelNotes/2.5.2.txt[2.5.2],
5657
link:RelNotes/2.5.1.txt[2.5.1],
5758
link:RelNotes/2.5.0.txt[2.5].
5859

59-
* link:v2.4.9/git.html[documentation for release 2.4.9]
60+
* link:v2.4.10/git.html[documentation for release 2.4.10]
6061

6162
* release notes for
63+
link:RelNotes/2.4.10.txt[2.4.10],
6264
link:RelNotes/2.4.9.txt[2.4.9],
6365
link:RelNotes/2.4.8.txt[2.4.8],
6466
link:RelNotes/2.4.7.txt[2.4.7],
@@ -70,9 +72,10 @@ Documentation for older releases are available here:
7072
link:RelNotes/2.4.1.txt[2.4.1],
7173
link:RelNotes/2.4.0.txt[2.4].
7274

73-
* link:v2.3.9/git.html[documentation for release 2.3.9]
75+
* link:v2.3.10/git.html[documentation for release 2.3.10]
7476

7577
* release notes for
78+
link:RelNotes/2.3.10.txt[2.3.10],
7679
link:RelNotes/2.3.9.txt[2.3.9],
7780
link:RelNotes/2.3.8.txt[2.3.8],
7881
link:RelNotes/2.3.7.txt[2.3.7],
@@ -1092,6 +1095,33 @@ GIT_ICASE_PATHSPECS::
10921095
an operation has touched every ref (e.g., because you are
10931096
cloning a repository to make a backup).
10941097

1098+
`GIT_ALLOW_PROTOCOL`::
1099+
If set, provide a colon-separated list of protocols which are
1100+
allowed to be used with fetch/push/clone. This is useful to
1101+
restrict recursive submodule initialization from an untrusted
1102+
repository. Any protocol not mentioned will be disallowed (i.e.,
1103+
this is a whitelist, not a blacklist). If the variable is not
1104+
set at all, all protocols are enabled. The protocol names
1105+
currently used by git are:
1106+
1107+
- `file`: any local file-based path (including `file://` URLs,
1108+
or local paths)
1109+
1110+
- `git`: the anonymous git protocol over a direct TCP
1111+
connection (or proxy, if configured)
1112+
1113+
- `ssh`: git over ssh (including `host:path` syntax,
1114+
`git+ssh://`, etc).
1115+
1116+
- `rsync`: git over rsync
1117+
1118+
- `http`: git over http, both "smart http" and "dumb http".
1119+
Note that this does _not_ include `https`; if you want both,
1120+
you should specify both as `http:https`.
1121+
1122+
- any external helpers are named by their protocol (e.g., use
1123+
`hg` to allow the `git-remote-hg` helper)
1124+
10951125

10961126
Discussion[[Discussion]]
10971127
------------------------

builtin/blame.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,10 @@ static void pass_blame_to_parent(struct scoreboard *sb,
974974
fill_origin_blob(&sb->revs->diffopt, target, &file_o);
975975
num_get_patch++;
976976

977-
diff_hunks(&file_p, &file_o, 0, blame_chunk_cb, &d);
977+
if (diff_hunks(&file_p, &file_o, 0, blame_chunk_cb, &d))
978+
die("unable to generate diff (%s -> %s)",
979+
sha1_to_hex(parent->commit->object.sha1),
980+
sha1_to_hex(target->commit->object.sha1));
978981
/* The rest are the same as the parent */
979982
blame_chunk(&d.dstq, &d.srcq, INT_MAX, d.offset, INT_MAX, parent);
980983
*d.dstq = NULL;
@@ -1120,7 +1123,9 @@ static void find_copy_in_blob(struct scoreboard *sb,
11201123
* file_p partially may match that image.
11211124
*/
11221125
memset(split, 0, sizeof(struct blame_entry [3]));
1123-
diff_hunks(file_p, &file_o, 1, handle_split_cb, &d);
1126+
if (diff_hunks(file_p, &file_o, 1, handle_split_cb, &d))
1127+
die("unable to generate diff (%s)",
1128+
sha1_to_hex(parent->commit->object.sha1));
11241129
/* remainder, if any, all match the preimage */
11251130
handle_split(sb, ent, d.tlno, d.plno, ent->num_lines, parent, split);
11261131
}

builtin/merge-file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
7575
names[i] = argv[i];
7676
if (read_mmfile(mmfs + i, fname))
7777
return -1;
78-
if (buffer_is_binary(mmfs[i].ptr, mmfs[i].size))
78+
if (mmfs[i].size > MAX_XDIFF_SIZE ||
79+
buffer_is_binary(mmfs[i].ptr, mmfs[i].size))
7980
return error("Cannot merge binary files: %s",
8081
argv[i]);
8182
}

builtin/merge-tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ static void show_diff(struct merge_list *entry)
118118
if (!dst.ptr)
119119
size = 0;
120120
dst.size = size;
121-
xdi_diff(&src, &dst, &xpp, &xecfg, &ecb);
121+
if (xdi_diff(&src, &dst, &xpp, &xecfg, &ecb))
122+
die("unable to generate diff");
122123
free(src.ptr);
123124
free(dst.ptr);
124125
}

builtin/rerere.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ static int diff_two(const char *file1, const char *label1,
2929
xdemitconf_t xecfg;
3030
xdemitcb_t ecb;
3131
mmfile_t minus, plus;
32+
int ret;
3233

3334
if (read_mmfile(&minus, file1) || read_mmfile(&plus, file2))
34-
return 1;
35+
return -1;
3536

3637
printf("--- a/%s\n+++ b/%s\n", label1, label2);
3738
fflush(stdout);
@@ -40,11 +41,11 @@ static int diff_two(const char *file1, const char *label1,
4041
memset(&xecfg, 0, sizeof(xecfg));
4142
xecfg.ctxlen = 3;
4243
ecb.outf = outf;
43-
xdi_diff(&minus, &plus, &xpp, &xecfg, &ecb);
44+
ret = xdi_diff(&minus, &plus, &xpp, &xecfg, &ecb);
4445

4546
free(minus.ptr);
4647
free(plus.ptr);
47-
return 0;
48+
return ret;
4849
}
4950

5051
int cmd_rerere(int argc, const char **argv, const char *prefix)
@@ -104,7 +105,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
104105
for (i = 0; i < merge_rr.nr; i++) {
105106
const char *path = merge_rr.items[i].string;
106107
const char *name = (const char *)merge_rr.items[i].util;
107-
diff_two(rerere_path(name, "preimage"), path, path, path);
108+
if (diff_two(rerere_path(name, "preimage"), path, path, path))
109+
die("unable to generate diff for %s", name);
108110
}
109111
} else
110112
usage_with_options(rerere_usage, options);

combine-diff.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,10 @@ static void combine_diff(const struct object_id *parent, unsigned int mode,
419419
state.num_parent = num_parent;
420420
state.n = n;
421421

422-
xdi_diff_outf(&parent_file, result_file, consume_line, &state,
423-
&xpp, &xecfg);
422+
if (xdi_diff_outf(&parent_file, result_file, consume_line, &state,
423+
&xpp, &xecfg))
424+
die("unable to generate combined diff for %s",
425+
oid_to_hex(parent));
424426
free(parent_file.ptr);
425427

426428
/* Assign line numbers for this parent.

connect.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "url.h"
1010
#include "string-list.h"
1111
#include "sha1-array.h"
12+
#include "transport.h"
1213

1314
static char *server_capabilities;
1415
static const char *parse_feature_value(const char *, const char *, int *);
@@ -694,6 +695,8 @@ struct child_process *git_connect(int fd[2], const char *url,
694695
else
695696
target_host = xstrdup(hostandport);
696697

698+
transport_check_allowed("git");
699+
697700
/* These underlying connection commands die() if they
698701
* cannot connect.
699702
*/
@@ -727,6 +730,7 @@ struct child_process *git_connect(int fd[2], const char *url,
727730
int putty, tortoiseplink = 0;
728731
char *ssh_host = hostandport;
729732
const char *port = NULL;
733+
transport_check_allowed("ssh");
730734
get_host_and_port(&ssh_host, &port);
731735

732736
if (!port)
@@ -781,6 +785,7 @@ struct child_process *git_connect(int fd[2], const char *url,
781785
/* remove repo-local variables from the environment */
782786
conn->env = local_repo_env;
783787
conn->use_shell = 1;
788+
transport_check_allowed("file");
784789
}
785790
argv_array_push(&conn->args, cmd.buf);
786791

diff.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,9 @@ static void diff_words_show(struct diff_words_data *diff_words)
10411041
xpp.flags = 0;
10421042
/* as only the hunk header will be parsed, we need a 0-context */
10431043
xecfg.ctxlen = 0;
1044-
xdi_diff_outf(&minus, &plus, fn_out_diff_words_aux, diff_words,
1045-
&xpp, &xecfg);
1044+
if (xdi_diff_outf(&minus, &plus, fn_out_diff_words_aux, diff_words,
1045+
&xpp, &xecfg))
1046+
die("unable to generate word diff");
10461047
free(minus.ptr);
10471048
free(plus.ptr);
10481049
if (diff_words->current_plus != diff_words->plus.text.ptr +
@@ -2449,8 +2450,9 @@ static void builtin_diff(const char *name_a,
24492450
xecfg.ctxlen = strtoul(v, NULL, 10);
24502451
if (o->word_diff)
24512452
init_diff_words_data(&ecbdata, o, one, two);
2452-
xdi_diff_outf(&mf1, &mf2, fn_out_consume, &ecbdata,
2453-
&xpp, &xecfg);
2453+
if (xdi_diff_outf(&mf1, &mf2, fn_out_consume, &ecbdata,
2454+
&xpp, &xecfg))
2455+
die("unable to generate diff for %s", one->path);
24542456
if (o->word_diff)
24552457
free_diff_words_data(&ecbdata);
24562458
if (textconv_one)
@@ -2527,8 +2529,9 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
25272529
xpp.flags = o->xdl_opts;
25282530
xecfg.ctxlen = o->context;
25292531
xecfg.interhunkctxlen = o->interhunkcontext;
2530-
xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
2531-
&xpp, &xecfg);
2532+
if (xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
2533+
&xpp, &xecfg))
2534+
die("unable to generate diffstat for %s", one->path);
25322535
}
25332536

25342537
diff_free_filespec_data(one);
@@ -2574,8 +2577,9 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
25742577
memset(&xecfg, 0, sizeof(xecfg));
25752578
xecfg.ctxlen = 1; /* at least one context line */
25762579
xpp.flags = 0;
2577-
xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data,
2578-
&xpp, &xecfg);
2580+
if (xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data,
2581+
&xpp, &xecfg))
2582+
die("unable to generate checkdiff for %s", one->path);
25792583

25802584
if (data.ws_rule & WS_BLANK_AT_EOF) {
25812585
struct emit_callback ecbdata;
@@ -4510,8 +4514,10 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
45104514
xpp.flags = 0;
45114515
xecfg.ctxlen = 3;
45124516
xecfg.flags = 0;
4513-
xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data,
4514-
&xpp, &xecfg);
4517+
if (xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data,
4518+
&xpp, &xecfg))
4519+
return error("unable to generate patch-id diff for %s",
4520+
p->one->path);
45154521
}
45164522

45174523
git_SHA1_Final(sha1, &ctx);

diffcore-pickaxe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ static int diff_grep(mmfile_t *one, mmfile_t *two,
6262
ecbdata.hit = 0;
6363
xecfg.ctxlen = o->context;
6464
xecfg.interhunkctxlen = o->interhunkcontext;
65-
xdi_diff_outf(one, two, diffgrep_consume, &ecbdata,
66-
&xpp, &xecfg);
65+
if (xdi_diff_outf(one, two, diffgrep_consume, &ecbdata, &xpp, &xecfg))
66+
return 0;
6767
return ecbdata.hit;
6868
}
6969

git-submodule.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ require_work_tree
2222
wt_prefix=$(git rev-parse --show-prefix)
2323
cd_to_toplevel
2424

25+
# Restrict ourselves to a vanilla subset of protocols; the URLs
26+
# we get are under control of a remote repository, and we do not
27+
# want them kicking off arbitrary git-remote-* programs.
28+
#
29+
# If the user has already specified a set of allowed protocols,
30+
# we assume they know what they're doing and use that instead.
31+
: ${GIT_ALLOW_PROTOCOL=file:git:http:https:ssh}
32+
export GIT_ALLOW_PROTOCOL
33+
2534
command=
2635
branch=
2736
force=

http.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "version.h"
1010
#include "pkt-line.h"
1111
#include "gettext.h"
12+
#include "transport.h"
1213

1314
int active_requests;
1415
int http_is_verbose;
@@ -356,6 +357,7 @@ static void set_curl_keepalive(CURL *c)
356357
static CURL *get_curl_handle(void)
357358
{
358359
CURL *result = curl_easy_init();
360+
long allowed_protocols = 0;
359361

360362
if (!result)
361363
die("curl_easy_init failed");
@@ -425,11 +427,27 @@ static CURL *get_curl_handle(void)
425427
}
426428

427429
curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1);
430+
curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);
428431
#if LIBCURL_VERSION_NUM >= 0x071301
429432
curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
430433
#elif LIBCURL_VERSION_NUM >= 0x071101
431434
curl_easy_setopt(result, CURLOPT_POST301, 1);
432435
#endif
436+
#if LIBCURL_VERSION_NUM >= 0x071304
437+
if (is_transport_allowed("http"))
438+
allowed_protocols |= CURLPROTO_HTTP;
439+
if (is_transport_allowed("https"))
440+
allowed_protocols |= CURLPROTO_HTTPS;
441+
if (is_transport_allowed("ftp"))
442+
allowed_protocols |= CURLPROTO_FTP;
443+
if (is_transport_allowed("ftps"))
444+
allowed_protocols |= CURLPROTO_FTPS;
445+
curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS, allowed_protocols);
446+
#else
447+
if (transport_restrict_protocols())
448+
warning("protocol restrictions not applied to curl redirects because\n"
449+
"your curl version is too old (>= 7.19.4)");
450+
#endif
433451

434452
if (getenv("GIT_CURL_VERBOSE"))
435453
curl_easy_setopt(result, CURLOPT_VERBOSE, 1);

0 commit comments

Comments
 (0)