<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/reftable/basics.c, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2025-10-07T16:22:57Z</updated>
<entry>
<title>reftable: check for trailing newline in 'tables.list'</title>
<updated>2025-10-07T16:22:57Z</updated>
<author>
<name>Karthik Nayak</name>
<email>karthik.188@gmail.com</email>
</author>
<published>2025-10-07T12:11:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f6442063775b68d9eeaeb9088379fba3298c80ac'/>
<id>urn:sha1:f6442063775b68d9eeaeb9088379fba3298c80ac</id>
<content type='text'>
In the reftable format, the 'tables.list' file contains a
newline separated list of tables. While we parse this file, we do not
check or care about the last newline. Tighten the parser in
`parse_names()` to return an appropriate error if the last newline is
missing.

This requires modification to `parse_names()` to now return the error
while accepting the output as a third argument.

Signed-off-by: Karthik Nayak &lt;karthik.188@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>reftable: fix formatting of the license header</title>
<updated>2025-04-07T21:53:09Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-04-07T13:16:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6dcc05ffc3ead0745d19decd0e8ecd65edc9d414'/>
<id>urn:sha1:6dcc05ffc3ead0745d19decd0e8ecd65edc9d414</id>
<content type='text'>
The license headers used across the reftable library doesn't follow our
typical coding style for multi-line comments. Fix it.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>reftable/basics: provide wrappers for big endian conversion</title>
<updated>2025-02-18T18:55:37Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-02-18T09:20:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e676694298c4a8d9f6fdf3844cbfb03bbee552cc'/>
<id>urn:sha1:e676694298c4a8d9f6fdf3844cbfb03bbee552cc</id>
<content type='text'>
We're using a mixture of big endian conversion functions provided by
both the reftable library, but also by the Git codebase. Refactor the
code so that we exclusively use reftable-provided wrappers in order to
untangle us from the Git codebase.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>reftable/basics: adjust `hash_size()` to return `uint32_t`</title>
<updated>2025-01-21T22:20:29Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-01-20T16:17:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=57adf71b93efa9f9b4db5147e9fa1235f0a1d5ba'/>
<id>urn:sha1:57adf71b93efa9f9b4db5147e9fa1235f0a1d5ba</id>
<content type='text'>
The `hash_size()` function returns the number of bytes used by the hash
function. Weirdly enough though, it returns a signed integer for its
size even though the size obviously cannot ever be negative. The only
case where it could be negative is if the function returned an error
when asked for an unknown hash, but we assert(3p) instead.

Adjust the type of `hash_size()` to be `uint32_t` and adapt all places
that use signed integers for the hash size to follow suit. This also
allows us to get rid of a couple asserts that we had which verified that
the size was indeed positive, which further stresses the point that this
refactoring makes sense.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>reftable/basics: adjust `common_prefix_size()` to return `size_t`</title>
<updated>2025-01-21T22:20:29Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-01-20T16:17:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5ac65f0d6b867ff031fda03779c2f2613f022b10'/>
<id>urn:sha1:5ac65f0d6b867ff031fda03779c2f2613f022b10</id>
<content type='text'>
The `common_prefix_size()` function computes the length of the common
prefix between two buffers. As such its return value will always be an
unsigned integer, as the length cannot be negative. Regardless of that,
the function returns a signed integer, which is nonsensical and causes a
couple of -Wsign-compare warnings all over the place.

Adjust the function to return a `size_t` instead.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>reftable: handle realloc error in parse_names()</title>
<updated>2024-12-28T16:00:44Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-12-28T09:48:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e4981ed1e72d3f25da901b9415d2c4805bed0dbc'/>
<id>urn:sha1:e4981ed1e72d3f25da901b9415d2c4805bed0dbc</id>
<content type='text'>
Check the final reallocation for adding the terminating NULL and handle
it just like those in the loop.  Simply use REFTABLE_ALLOC_GROW instead
of keeping the REFTABLE_REALLOC_ARRAY call and adding code to preserve
the original pointer value around it.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>reftable: fix allocation count on realloc error</title>
<updated>2024-12-28T16:00:44Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-12-28T09:48:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2cca185e85171c462166839cfd6ee57c09573160'/>
<id>urn:sha1:2cca185e85171c462166839cfd6ee57c09573160</id>
<content type='text'>
When realloc(3) fails, it returns NULL and keeps the original allocation
intact.  REFTABLE_ALLOC_GROW overwrites both the original pointer and
the allocation count variable in that case, simultaneously leaking the
original allocation and misrepresenting the number of storable items.

parse_names() avoids the leak by keeping the original pointer if
reallocation fails, but still increase the allocation count in such a
case as if it succeeded.  That's OK, because the error handling code
just frees everything and doesn't look at names_cap anymore.

reftable_buf_add() does the same, but here it is a problem as it leaves
the reftable_buf in a broken state, with -&gt;alloc being roughly twice as
big as the actually allocated memory, allowing out-of-bounds writes in
subsequent calls.

Reimplement REFTABLE_ALLOC_GROW to avoid leaks, keep allocation counts
in sync and still signal failures to callers while avoiding code
duplication in callers.  Make it an expression that evaluates to 0 if no
reallocation is needed or it succeeded and 1 on failure while keeping
the original pointer and allocation counter values.

Adjust REFTABLE_ALLOC_GROW_OR_NULL to the new calling convention for
REFTABLE_ALLOC_GROW, but keep its support for non-size_t alloc variables
for now.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ps/reftable-alloc-failures-zalloc-fix'</title>
<updated>2024-12-23T17:32:06Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-12-23T17:32:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3151e6a1214b583552ca39c57d429a8eaa8923e8'/>
<id>urn:sha1:3151e6a1214b583552ca39c57d429a8eaa8923e8</id>
<content type='text'>
Recent reftable updates mistook a NULL return from a request for
0-byte allocation as OOM and died unnecessarily, which has been
corrected.

* ps/reftable-alloc-failures-zalloc-fix:
  reftable/basics: return NULL on zero-sized allocations
  reftable/stack: fix zero-sized allocation when there are no readers
  reftable/merged: fix zero-sized allocation when there are no readers
  reftable/stack: don't perform auto-compaction with less than two tables
</content>
</entry>
<entry>
<title>reftable/basics: return NULL on zero-sized allocations</title>
<updated>2024-12-22T08:58:23Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-22T07:24:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d7282891f542b58410a209230009182b9057af79'/>
<id>urn:sha1:d7282891f542b58410a209230009182b9057af79</id>
<content type='text'>
In the preceding commits we have fixed a couple of issues when
allocating zero-sized objects. These issues were masked by
implementation-defined behaviour. Quoting malloc(3p):

  If size is 0, either:

    * A null pointer shall be returned and errno may be set to an
      implementation-defined value, or

    * A pointer to the allocated space shall be returned. The
      application shall ensure that the pointer is not used to access an
      object.

So it is perfectly valid that implementations of this function may or
may not return a NULL pointer in such a case.

Adapt both `reftable_malloc()` and `reftable_realloc()` so that they
return NULL pointers on zero-sized allocations. This should remove any
implementation-defined behaviour in our allocators and thus allows us to
detect such platform-specific issues more easily going forward.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>reftable/system: stop depending on "hash.h"</title>
<updated>2024-11-19T03:23:10Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-11-18T15:33:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c2f08236ed786a48e50af33ecc5c0f951c14761b'/>
<id>urn:sha1:c2f08236ed786a48e50af33ecc5c0f951c14761b</id>
<content type='text'>
We include "hash.h" in "reftable/system.h" such that we can use hash
format IDs as well as the raw size of SHA1 and SHA256. As we are in the
process of converting the reftable library to become standalone we of
course cannot rely on those constants anymore.

Introduce a new `enum reftable_hash` to replace internal uses of the
hash format IDs and new constants that replace internal uses of the hash
size. Adapt the reftable backend to set up the correct hash function.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
