<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/git.git/xdiff-interface.c, branch v2.7.0-rc2</title>
<subtitle>Git
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/git.git/atom?h=v2.7.0-rc2</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/atom?h=v2.7.0-rc2'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/'/>
<updated>2015-09-28T21:57:23Z</updated>
<entry>
<title>xdiff: reject files larger than ~1GB</title>
<updated>2015-09-28T21:57:23Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-09-24T23:12:45Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=dcd1742e56ebb944c4ff62346da4548e1e3be675'/>
<id>urn:sha1:dcd1742e56ebb944c4ff62346da4548e1e3be675</id>
<content type='text'>
The xdiff code is not prepared to handle extremely large
files. It uses "int" in many places, which can overflow if
we have a very large number of lines or even bytes in our
input files. This can cause us to produce incorrect diffs,
with no indication that the output is wrong. Or worse, we
may even underallocate a buffer whose size is the result of
an overflowing addition.

We're much better off to tell the user that we cannot diff
or merge such a large file. This patch covers both cases,
but in slightly different ways:

  1. For merging, we notice the large file and cleanly fall
     back to a binary merge (which is effectively "we cannot
     merge this").

  2. For diffing, we make the binary/text distinction much
     earlier, and in many different places. For this case,
     we'll use the xdi_diff as our choke point, and reject
     any diff there before it hits the xdiff code.

     This means in most cases we'll die() immediately after.
     That's not ideal, but in practice we shouldn't
     generally hit this code path unless the user is trying
     to do something tricky. We already consider files
     larger than core.bigfilethreshold to be binary, so this
     code would only kick in when that is circumvented
     (either by bumping that value, or by using a
     .gitattribute to mark a file as diffable).

     In other words, we can avoid being "nice" here, because
     there is already nice code that tries to do the right
     thing. We are adding the suspenders to the nice code's
     belt, so notice when it has been worked around (both to
     protect the user from malicious inputs, and because it
     is better to die() than generate bogus output).

The maximum size was chosen after experimenting with feeding
large files to the xdiff code. It's just under a gigabyte,
which leaves room for two obvious cases:

  - a diff3 merge conflict result on files of maximum size X
    could be 3*X plus the size of the markers, which would
    still be only about 3G, which fits in a 32-bit int.

  - some of the diff code allocates arrays of one int per
    record. Even if each file consists only of blank lines,
    then a file smaller than 1G will have fewer than 1G
    records, and therefore the int array will fit in 4G.

Since the limit is arbitrary anyway, I chose to go under a
gigabyte, to leave a safety margin (e.g., we would not want
to overflow by allocating "(records + 1) * sizeof(int)" or
similar.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: remove emit_func() and xdi_diff_hunks()</title>
<updated>2012-05-09T21:08:42Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2012-05-09T20:24:34Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=3319e606336c13ba6475d83e700ca53537cedfd9'/>
<id>urn:sha1:3319e606336c13ba6475d83e700ca53537cedfd9</id>
<content type='text'>
The functions are unused now, remove them.

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>add, merge, diff: do not use strcasecmp to compare config variable names</title>
<updated>2011-05-15T01:53:39Z</updated>
<author>
<name>Jonathan Nieder</name>
<email>jrnieder@gmail.com</email>
</author>
<published>2011-05-14T20:19:21Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=8c2be75fe117f5079087a6dfb07c573cc6716143'/>
<id>urn:sha1:8c2be75fe117f5079087a6dfb07c573cc6716143</id>
<content type='text'>
The config machinery already makes section and variable names
lowercase when parsing them, so using strcasecmp for comparison just
feels wasteful.  No noticeable change intended.

Noticed-by: Jay Soffian &lt;jaysoffian@gmail.com&gt;
Signed-off-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rs/maint-diff-fd-leak' into maint</title>
<updated>2010-12-26T19:18:39Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2010-12-26T19:18:39Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=26517dea245cc6332ffb80cf7747f6c211aa2e4d'/>
<id>urn:sha1:26517dea245cc6332ffb80cf7747f6c211aa2e4d</id>
<content type='text'>
* rs/maint-diff-fd-leak:
  close file on error in read_mmfile()
</content>
</entry>
<entry>
<title>close file on error in read_mmfile()</title>
<updated>2010-12-26T19:17:18Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2010-12-25T12:38:46Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=5fd898141ce2a243abf75192c9a55cb0a4e1ba80'/>
<id>urn:sha1:5fd898141ce2a243abf75192c9a55cb0a4e1ba80</id>
<content type='text'>
Reported in http://qa.debian.org/daca/cppcheck/sid/git_1.7.2.3-2.2.html
and in http://thread.gmane.org/gmane.comp.version-control.git/123042.

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff-interface.c: always trim trailing space from xfuncname matches</title>
<updated>2010-09-10T00:18:29Z</updated>
<author>
<name>Brandon Casey</name>
<email>drafnel@gmail.com</email>
</author>
<published>2010-09-09T19:02:46Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=1b6ecbad3511b1aaa65172ef8b520dd3b5141614'/>
<id>urn:sha1:1b6ecbad3511b1aaa65172ef8b520dd3b5141614</id>
<content type='text'>
Generally, trailing space is removed from the string matched by the
xfuncname patterns.  The exception is when the matched string exceeds the
length of the fixed-size buffer that it will be copied in to.  But, a
string that exceeds the buffer can still contain trailing space in the
portion of the string that will be copied into the buffer.  So, simplify
this code slightly, and just perform the trailing space removal always.

Signed-off-by: Brandon Casey &lt;casey@nrlssc.navy.mil&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'maint-1.7.0' into maint</title>
<updated>2010-05-04T22:20:47Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2010-05-04T22:20:47Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=6b6f5d4664c9088636418653a61f600b5e3a9ea4'/>
<id>urn:sha1:6b6f5d4664c9088636418653a61f600b5e3a9ea4</id>
<content type='text'>
* maint-1.7.0:
  remove ecb parameter from xdi_diff_outf()
</content>
</entry>
<entry>
<title>remove ecb parameter from xdi_diff_outf()</title>
<updated>2010-05-04T22:19:14Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2010-05-04T20:41:34Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=dfea79004c54bc96143386d6ac22de500ba4f747'/>
<id>urn:sha1:dfea79004c54bc96143386d6ac22de500ba4f747</id>
<content type='text'>
xdi_diff_outf() overrides the structure members of its last parameter,
ignoring any value that callers pass in.  It's no surprise then that all
callers pass a pointer to an uninitialized structure.  They also don't
read it after the call, so the parameter is neither used for input nor
for output.   Turn it into a local variable of xdi_diff_outf().

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Acked-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refactor duplicated fill_mm() in checkout and merge-recursive</title>
<updated>2010-02-17T23:11:33Z</updated>
<author>
<name>Michael Lukashov</name>
<email>michael.lukashov@gmail.com</email>
</author>
<published>2010-02-16T23:42:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=06b65939b083ba1b71043005bf83b4883e98264e'/>
<id>urn:sha1:06b65939b083ba1b71043005bf83b4883e98264e</id>
<content type='text'>
The following function is duplicated:

  fill_mm

Move it to xdiff-interface.c and rename it 'read_mmblob', as suggested
by Junio C Hamano.

Also, change parameters order for consistency with read_mmfile().

Signed-off-by: Michael Lukashov &lt;michael.lukashov@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>userdiff: add xdiff_clear_find_func()</title>
<updated>2009-07-02T02:16:37Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-07-01T22:01:43Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=8cfe5f1cd5dabc3a21bc792327747deefeff6dff'/>
<id>urn:sha1:8cfe5f1cd5dabc3a21bc792327747deefeff6dff</id>
<content type='text'>
xdiff_set_find_func() is used to set user defined regular expressions
for finding function signatures.  Add xdiff_clear_find_func(), which
frees the memory allocated by the former, making the API complete.

Also, use the new function in diff.c (the only call site of
xdiff_set_find_func()) to clean up after ourselves.

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
