<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/git-compat-util.h, branch v2.10.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.10.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.10.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2016-10-28T16:01:18Z</updated>
<entry>
<title>Merge branch 'jk/tighten-alloc' into maint</title>
<updated>2016-10-28T16:01:18Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-10-28T16:01:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=63cf124c2436722d70c28fc12f9337e9938091ef'/>
<id>urn:sha1:63cf124c2436722d70c28fc12f9337e9938091ef</id>
<content type='text'>
Protect our code from over-eager compilers.

* jk/tighten-alloc:
  inline xalloc_flex() into FLEXPTR_ALLOC_MEM
  avoid pointer arithmetic involving NULL in FLEX_ALLOC_MEM
</content>
</entry>
<entry>
<title>inline xalloc_flex() into FLEXPTR_ALLOC_MEM</title>
<updated>2016-10-17T21:42:56Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2016-10-16T10:06:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0ac52a38e8008fa5bb243e150031681420c639fa'/>
<id>urn:sha1:0ac52a38e8008fa5bb243e150031681420c639fa</id>
<content type='text'>
Allocate and copy directly in FLEXPTR_ALLOC_MEM and remove the now
unused helper function xalloc_flex().  The resulting code is shorter
and the offset arithmetic is a bit simpler.

Suggested-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Reviewed-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>avoid pointer arithmetic involving NULL in FLEX_ALLOC_MEM</title>
<updated>2016-10-17T21:42:31Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2016-10-15T16:23:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e9451782cfbe9fc9105bf63228bca3e2265af8f8'/>
<id>urn:sha1:e9451782cfbe9fc9105bf63228bca3e2265af8f8</id>
<content type='text'>
Calculating offsets involving a NULL pointer is undefined.  It works in
practice (for now?), but we should not rely on it.  Allocate first and
then simply refer to the flexible array member by its name instead of
performing pointer arithmetic up front.  The resulting code is slightly
shorter, easier to read and doesn't rely on undefined behaviour.

NB: The cast to a (non-const) void pointer is necessary to keep support
for flexible array members declared as const.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Reviewed-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rs/copy-array' into maint</title>
<updated>2016-10-11T21:18:32Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-10-11T21:18:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a813b19190a75e44b6ebd1ea5317ef5ed914cde0'/>
<id>urn:sha1:a813b19190a75e44b6ebd1ea5317ef5ed914cde0</id>
<content type='text'>
Code cleanup.

* rs/copy-array:
  use COPY_ARRAY
  add COPY_ARRAY
</content>
</entry>
<entry>
<title>Merge branch 'js/regexec-buf' into maint</title>
<updated>2016-09-29T23:49:45Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-09-29T23:49:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=300e95f7df240a0f6efea09d5e21fcc350e5ce83'/>
<id>urn:sha1:300e95f7df240a0f6efea09d5e21fcc350e5ce83</id>
<content type='text'>
Some codepaths in "git diff" used regexec(3) on a buffer that was
mmap(2)ed, which may not have a terminating NUL, leading to a read
beyond the end of the mapped region.  This was fixed by introducing
a regexec_buf() helper that takes a &lt;ptr,len&gt; pair with REG_STARTEND
extension.

* js/regexec-buf:
  regex: use regexec_buf()
  regex: add regexec_buf() that can work on a non NUL-terminated string
  regex: -G&lt;pattern&gt; feeds a non NUL-terminated string to regexec() and fails
</content>
</entry>
<entry>
<title>add COPY_ARRAY</title>
<updated>2016-09-25T23:44:12Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2016-09-25T07:15:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=60566cbb5890abc84fa18c56da70e35ace0b23bf'/>
<id>urn:sha1:60566cbb5890abc84fa18c56da70e35ace0b23bf</id>
<content type='text'>
Add COPY_ARRAY, a safe and convenient helper for copying arrays,
complementing ALLOC_ARRAY and REALLOC_ARRAY.  Users just specify source,
destination and the number of elements; the size of an element is
inferred automatically.

It checks if the multiplication of size and element count overflows.
The inferred size is passed first to st_mult, which allows the division
there to be done at compilation time.

As a basic type safety check it makes sure the sizes of source and
destination elements are the same.  That's evaluated at compilation time
as well.

COPY_ARRAY is safe to use with NULL as source pointer iff 0 elements are
to be copied.  That convention is used in some cases for initializing
arrays.  Raw memcpy(3) does not support it -- compilers are allowed to
assume that only valid pointers are passed to it and can optimize away
NULL checks after such a call.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>regex: add regexec_buf() that can work on a non NUL-terminated string</title>
<updated>2016-09-21T20:56:15Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2016-09-21T18:24:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2f8952250a84313b74f96abb7b035874854cf202'/>
<id>urn:sha1:2f8952250a84313b74f96abb7b035874854cf202</id>
<content type='text'>
We just introduced a test that demonstrates that our sloppy use of
regexec() on a mmap()ed area can result in incorrect results or even
hard crashes.

So what we need to fix this is a function that calls regexec() on a
length-delimited, rather than a NUL-terminated, string.

Happily, there is an extension to regexec() introduced by the NetBSD
project and present in all major regex implementation including
Linux', MacOSX' and the one Git includes in compat/regex/: by using
the (non-POSIX) REG_STARTEND flag, it is possible to tell the
regexec() function that it should only look at the offsets between
pmatch[0].rm_so and pmatch[0].rm_eo.

That is exactly what we need.

Since support for REG_STARTEND is so widespread by now, let's just
introduce a helper function that always uses it, and tell people
on a platform whose regex library does not support it to use the
one from our compat/regex/ directory.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rs/compat-strdup' into maint</title>
<updated>2016-09-19T20:51:42Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-09-19T20:51:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=815a73f7143214510fae6e8a2f2077b2e8694509'/>
<id>urn:sha1:815a73f7143214510fae6e8a2f2077b2e8694509</id>
<content type='text'>
Code cleanup.

* rs/compat-strdup:
  compat: move strdup(3) replacement to its own file
</content>
</entry>
<entry>
<title>Merge branch 'jk/squelch-false-warning-from-gcc-o3' into maint</title>
<updated>2016-09-19T20:51:41Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-09-19T20:51:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3d54b93f405c6881ac477c5bfec10802ea53f73d'/>
<id>urn:sha1:3d54b93f405c6881ac477c5bfec10802ea53f73d</id>
<content type='text'>
Compilation fix.

* jk/squelch-false-warning-from-gcc-o3:
  color_parse_mem: initialize "struct color" temporary
  error_errno: use constant return similar to error()
</content>
</entry>
<entry>
<title>compat: move strdup(3) replacement to its own file</title>
<updated>2016-09-07T17:41:45Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2016-09-03T15:59:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ca2baa3f7532dfe1816b623f39489ed10f3c9a49'/>
<id>urn:sha1:ca2baa3f7532dfe1816b623f39489ed10f3c9a49</id>
<content type='text'>
Move our implementation of strdup(3) out of compat/nedmalloc/ and
allow it to be used independently from USE_NED_ALLOCATOR.  The
original nedmalloc doesn't come with strdup() and doesn't need it.
Only _users_ of nedmalloc need it, which was added when we imported
it to our compat/ hierarchy.

This reduces the difference of our copy of nedmalloc from the
original, making it easier to update, and allows for easier testing
and reusing of our version of strdup().

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
