Skip to content

Commit 11a458b

Browse files
committed
Sync with 2.4.10
2 parents ee6ad5f + a2558fb commit 11a458b

28 files changed

+466
-29
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/git.txt

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ Documentation for older releases are available here:
5151
link:RelNotes/2.5.1.txt[2.5.1],
5252
link:RelNotes/2.5.0.txt[2.5].
5353

54-
* link:v2.4.9/git.html[documentation for release 2.4.9]
54+
* link:v2.4.10/git.html[documentation for release 2.4.10]
5555

5656
* release notes for
57+
link:RelNotes/2.4.10.txt[2.4.10],
5758
link:RelNotes/2.4.9.txt[2.4.9],
5859
link:RelNotes/2.4.8.txt[2.4.8],
5960
link:RelNotes/2.4.7.txt[2.4.7],
@@ -65,9 +66,10 @@ Documentation for older releases are available here:
6566
link:RelNotes/2.4.1.txt[2.4.1],
6667
link:RelNotes/2.4.0.txt[2.4].
6768

68-
* link:v2.3.9/git.html[documentation for release 2.3.9]
69+
* link:v2.3.10/git.html[documentation for release 2.3.10]
6970

7071
* release notes for
72+
link:RelNotes/2.3.10.txt[2.3.10],
7173
link:RelNotes/2.3.9.txt[2.3.9],
7274
link:RelNotes/2.3.8.txt[2.3.8],
7375
link:RelNotes/2.3.7.txt[2.3.7],
@@ -1076,6 +1078,33 @@ GIT_ICASE_PATHSPECS::
10761078
an operation has touched every ref (e.g., because you are
10771079
cloning a repository to make a backup).
10781080

1081+
`GIT_ALLOW_PROTOCOL`::
1082+
If set, provide a colon-separated list of protocols which are
1083+
allowed to be used with fetch/push/clone. This is useful to
1084+
restrict recursive submodule initialization from an untrusted
1085+
repository. Any protocol not mentioned will be disallowed (i.e.,
1086+
this is a whitelist, not a blacklist). If the variable is not
1087+
set at all, all protocols are enabled. The protocol names
1088+
currently used by git are:
1089+
1090+
- `file`: any local file-based path (including `file://` URLs,
1091+
or local paths)
1092+
1093+
- `git`: the anonymous git protocol over a direct TCP
1094+
connection (or proxy, if configured)
1095+
1096+
- `ssh`: git over ssh (including `host:path` syntax,
1097+
`git+ssh://`, etc).
1098+
1099+
- `rsync`: git over rsync
1100+
1101+
- `http`: git over http, both "smart http" and "dumb http".
1102+
Note that this does _not_ include `https`; if you want both,
1103+
you should specify both as `http:https`.
1104+
1105+
- any external helpers are named by their protocol (e.g., use
1106+
`hg` to allow the `git-remote-hg` helper)
1107+
10791108

10801109
Discussion[[Discussion]]
10811110
------------------------

builtin/blame.c

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

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

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
@@ -1033,8 +1033,9 @@ static void diff_words_show(struct diff_words_data *diff_words)
10331033
xpp.flags = 0;
10341034
/* as only the hunk header will be parsed, we need a 0-context */
10351035
xecfg.ctxlen = 0;
1036-
xdi_diff_outf(&minus, &plus, fn_out_diff_words_aux, diff_words,
1037-
&xpp, &xecfg);
1036+
if (xdi_diff_outf(&minus, &plus, fn_out_diff_words_aux, diff_words,
1037+
&xpp, &xecfg))
1038+
die("unable to generate word diff");
10381039
free(minus.ptr);
10391040
free(plus.ptr);
10401041
if (diff_words->current_plus != diff_words->plus.text.ptr +
@@ -2441,8 +2442,9 @@ static void builtin_diff(const char *name_a,
24412442
xecfg.ctxlen = strtoul(v, NULL, 10);
24422443
if (o->word_diff)
24432444
init_diff_words_data(&ecbdata, o, one, two);
2444-
xdi_diff_outf(&mf1, &mf2, fn_out_consume, &ecbdata,
2445-
&xpp, &xecfg);
2445+
if (xdi_diff_outf(&mf1, &mf2, fn_out_consume, &ecbdata,
2446+
&xpp, &xecfg))
2447+
die("unable to generate diff for %s", one->path);
24462448
if (o->word_diff)
24472449
free_diff_words_data(&ecbdata);
24482450
if (textconv_one)
@@ -2519,8 +2521,9 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
25192521
xpp.flags = o->xdl_opts;
25202522
xecfg.ctxlen = o->context;
25212523
xecfg.interhunkctxlen = o->interhunkcontext;
2522-
xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
2523-
&xpp, &xecfg);
2524+
if (xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
2525+
&xpp, &xecfg))
2526+
die("unable to generate diffstat for %s", one->path);
25242527
}
25252528

25262529
diff_free_filespec_data(one);
@@ -2566,8 +2569,9 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
25662569
memset(&xecfg, 0, sizeof(xecfg));
25672570
xecfg.ctxlen = 1; /* at least one context line */
25682571
xpp.flags = 0;
2569-
xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data,
2570-
&xpp, &xecfg);
2572+
if (xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data,
2573+
&xpp, &xecfg))
2574+
die("unable to generate checkdiff for %s", one->path);
25712575

25722576
if (data.ws_rule & WS_BLANK_AT_EOF) {
25732577
struct emit_callback ecbdata;
@@ -4508,8 +4512,10 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
45084512
xpp.flags = 0;
45094513
xecfg.ctxlen = 3;
45104514
xecfg.flags = 0;
4511-
xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data,
4512-
&xpp, &xecfg);
4515+
if (xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data,
4516+
&xpp, &xecfg))
4517+
return error("unable to generate patch-id diff for %s",
4518+
p->one->path);
45134519
}
45144520

45154521
git_SHA1_Final(sha1, &ctx);

0 commit comments

Comments
 (0)