From: Johannes Schindelin Date: Thu, 12 Jan 2023 00:05:02 +0000 (+0100) Subject: attr: adjust a mismatched data type X-Git-Tag: v2.39.2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=37537d6472d87098d455b6a0c36885997ea81a85;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- diff --git a/attr.c b/attr.c index b43e93ee96..9922529b58 100644 --- a/attr.c +++ b/attr.c @@ -752,7 +752,7 @@ static struct attr_stack *read_attr_from_index(struct index_state *istate, struct attr_stack *res; char *buf, *sp; int lineno = 0; - size_t size; + unsigned long size; if (!istate) return NULL;