@@ -86,22 +86,30 @@ static int merge_file__xdiff(
8686
8787 memset (& xmparam , 0x0 , sizeof (xmparam_t ));
8888
89+ if (ours -> size > LONG_MAX ||
90+ theirs -> size > LONG_MAX ||
91+ (ancestor && ancestor -> size > LONG_MAX )) {
92+ git_error_set (GIT_ERROR_MERGE , "failed to merge files" );
93+ error = -1 ;
94+ goto done ;
95+ }
96+
8997 if (ancestor ) {
9098 xmparam .ancestor = (options .ancestor_label ) ?
9199 options .ancestor_label : ancestor -> path ;
92100 ancestor_mmfile .ptr = (char * )ancestor -> ptr ;
93- ancestor_mmfile .size = ancestor -> size ;
101+ ancestor_mmfile .size = ( long ) ancestor -> size ;
94102 }
95103
96104 xmparam .file1 = (options .our_label ) ?
97105 options .our_label : ours -> path ;
98106 our_mmfile .ptr = (char * )ours -> ptr ;
99- our_mmfile .size = ours -> size ;
107+ our_mmfile .size = ( long ) ours -> size ;
100108
101109 xmparam .file2 = (options .their_label ) ?
102110 options .their_label : theirs -> path ;
103111 their_mmfile .ptr = (char * )theirs -> ptr ;
104- their_mmfile .size = theirs -> size ;
112+ their_mmfile .size = ( long ) theirs -> size ;
105113
106114 if (options .favor == GIT_MERGE_FILE_FAVOR_OURS )
107115 xmparam .favor = XDL_MERGE_FAVOR_OURS ;
@@ -115,6 +123,8 @@ static int merge_file__xdiff(
115123
116124 if (options .flags & GIT_MERGE_FILE_STYLE_DIFF3 )
117125 xmparam .style = XDL_MERGE_DIFF3 ;
126+ if (options .flags & GIT_MERGE_FILE_STYLE_ZDIFF3 )
127+ xmparam .style = XDL_MERGE_ZEALOUS_DIFF3 ;
118128
119129 if (options .flags & GIT_MERGE_FILE_IGNORE_WHITESPACE )
120130 xmparam .xpp .flags |= XDF_IGNORE_WHITESPACE ;
0 commit comments