Skip to content

Commit 62a86b8

Browse files
PhilipOakleydscho
authored andcommitted
write_object_file_literally(): use size_t
The previous commit adds a test that demonstrates a problem in the `hash-object --literally` command, manifesting in an unnecessary file size limit on systems using the LLP64 data model (which includes Windows). Walking the affected code path is `cmd_hash_object()` >> `hash_fd()` >> `hash_literally()` >> `hash_object_file_literally()`. The function `hash_object_file_literally()` is the first with a file length parameter (via a mem buffer). This commit changes the type of that parameter to the LLP64 compatible `size_t` type. There are no other uses of the function. The `strbuf` type is already `size_t` compatible. Note: The hash-object test does not yet pass. Subsequent commits will continue to walk the call tree's lower level functions to identify further fixes. Signed-off-by: Philip Oakley <philipoakley@iee.email> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 24571ca commit 62a86b8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

object-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ static void write_object_file_prepare(const struct git_hash_algo *algo,
19771977
}
19781978

19791979
static void write_object_file_prepare_literally(const struct git_hash_algo *algo,
1980-
const void *buf, unsigned long len,
1980+
const void *buf, size_t len,
19811981
const char *type, struct object_id *oid,
19821982
char *hdr, int *hdrlen)
19831983
{
@@ -2531,7 +2531,7 @@ int write_object_file_flags(const void *buf, unsigned long len,
25312531
return 0;
25322532
}
25332533

2534-
int write_object_file_literally(const void *buf, unsigned long len,
2534+
int write_object_file_literally(const void *buf, size_t len,
25352535
const char *type, struct object_id *oid,
25362536
unsigned flags)
25372537
{

object-store-ll.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static inline int write_object_file(const void *buf, unsigned long len,
282282
return write_object_file_flags(buf, len, type, oid, NULL, 0);
283283
}
284284

285-
int write_object_file_literally(const void *buf, unsigned long len,
285+
int write_object_file_literally(const void *buf, size_t len,
286286
const char *type, struct object_id *oid,
287287
unsigned flags);
288288
int stream_loose_object(struct input_stream *in_stream, size_t len,

0 commit comments

Comments
 (0)