Skip to content

Commit 8bd3286

Browse files
committed
fixup! Guard against data loss checking out a huge file
This commit tries to validate the `size` value before it is read. Let's redo it. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d1130fa commit 8bd3286

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

entry.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,7 @@ static int create_file(const char *path, unsigned int mode)
8585
void *read_blob_entry(const struct cache_entry *ce, size_t *size)
8686
{
8787
enum object_type type;
88-
void *blob_data;
89-
unsigned long trunc_size = (unsigned long)*size;
90-
91-
/*
92-
* On 64-bit Windows, unsigned long holds less than size_t. It should be very,
93-
* very rare that a file larger than 2^32 bytes ends up in a repository, but in
94-
* case it does, this dies rather than write corrupt data to the workdir.
95-
*/
96-
if (trunc_size != *size)
97-
die_errno("object too large to read on this platform");
98-
99-
blob_data = read_object_file(&ce->oid, &type, (unsigned long *)size);
88+
void *blob_data = read_object_file(&ce->oid, &type, (unsigned long *)size);
10089

10190
if (blob_data) {
10291
if (type == OBJ_BLOB)

0 commit comments

Comments
 (0)