Skip to content

Commit 83c4d38

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dcd1742 commit 83c4d38

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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
}

0 commit comments

Comments
 (0)