summaryrefslogtreecommitdiff
path: root/builtin/merge-file.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-25 17:58:09 -0400
committerJunio C Hamano <gitster@pobox.com>2015-09-28 14:58:13 -0700
commit83c4d380171a2ecd24dd2e04072692ec54a7aaa5 (patch)
tree7d06636113e07f74fa407b8e673595d3045d8a41 /builtin/merge-file.c
parentdcd1742e56ebb944c4ff62346da4548e1e3be675 (diff)
downloadgit-83c4d380171a2ecd24dd2e04072692ec54a7aaa5.tar.gz
merge-file: enforce MAX_XDIFF_SIZE on incoming files
The previous commit enforces MAX_XDIFF_SIZE at the interfaces to xdiff: xdi_diff (which calls xdl_diff) and ll_xdl_merge (which calls xdl_merge). But we have another direct call to xdl_merge in merge-file.c. If it were written today, this probably would just use the ll_merge machinery. But it predates that code, and uses slightly different options to xdl_merge (e.g., ZEALOUS_ALNUM). We could try to abstract out an xdi_merge to match the existing xdi_diff, but even that is difficult. Rather than simply report error, we try to treat large files as binary, and that distinction would happen outside of xdi_merge. The simplest fix is to just replicate the MAX_XDIFF_SIZE check in merge-file.c. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge-file.c')
-rw-r--r--builtin/merge-file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 232b76857c..04ae36a452 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -75,7 +75,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
names[i] = argv[i];
if (read_mmfile(mmfs + i, fname))
return -1;
- if (buffer_is_binary(mmfs[i].ptr, mmfs[i].size))
+ if (mmfs[i].size > MAX_XDIFF_SIZE ||
+ buffer_is_binary(mmfs[i].ptr, mmfs[i].size))
return error("Cannot merge binary files: %s",
argv[i]);
}