]> git.ipfire.org Git - thirdparty/git.git/commit
attr: adjust a mismatched data type
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Thu, 12 Jan 2023 00:05:02 +0000 (01:05 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Jan 2023 14:58:20 +0000 (06:58 -0800)
commit37537d6472d87098d455b6a0c36885997ea81a85
tree8f3139cd98939af69666994df230d5bb505c3583
parentc6ab91335a16ea889134c74f1b9a2aaa7ff236a7
attr: adjust a mismatched data type

On platforms where `size_t` does not have the same width as `unsigned
long`, passing a pointer to the former when a pointer to the latter is
expected can lead to problems.

Windows and 32-bit Linux are among the affected platforms.

In this instance, we want to store the size of the blob that was read in
that variable. However, `read_blob_data_from_index()` passes that
pointer to `read_object_file()` which expects an `unsigned long *`.
Which means that on affected platforms, the variable is not fully
populated and part of its value is left uninitialized. (On Big-Endian
platforms, this problem would be even worse.)

The consequence is that depending on the uninitialized memory's
contents, we may erroneously reject perfectly fine attributes.

Let's address this by passing a pointer to a variable of the expected
data type.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
attr.c