Skip to content

Commit 331f20d

Browse files
committed
Merge branch 'ew/hash-with-openssl-evp'
Fix-up new-ish code to support OpenSSL EVP API. * ew/hash-with-openssl-evp: treewide: fix various bugs w/ OpenSSL 3+ EVP API
2 parents c52a02a + e0b8c84 commit 331f20d

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

builtin/fast-import.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
11021102
|| (pack_size + PACK_SIZE_THRESHOLD + len) < pack_size)
11031103
cycle_packfile();
11041104

1105+
the_hash_algo->init_fn(&checkpoint.ctx);
11051106
hashfile_checkpoint(pack_file, &checkpoint);
11061107
offset = checkpoint.offset;
11071108

builtin/index-pack.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ static void parse_pack_objects(unsigned char *hash)
11661166
struct ofs_delta_entry *ofs_delta = ofs_deltas;
11671167
struct object_id ref_delta_oid;
11681168
struct stat st;
1169+
git_hash_ctx tmp_ctx;
11691170

11701171
if (verbose)
11711172
progress = start_progress(
@@ -1202,7 +1203,9 @@ static void parse_pack_objects(unsigned char *hash)
12021203

12031204
/* Check pack integrity */
12041205
flush();
1205-
the_hash_algo->final_fn(hash, &input_ctx);
1206+
the_hash_algo->init_fn(&tmp_ctx);
1207+
the_hash_algo->clone_fn(&tmp_ctx, &input_ctx);
1208+
the_hash_algo->final_fn(hash, &tmp_ctx);
12061209
if (!hasheq(fill(the_hash_algo->rawsz), hash))
12071210
die(_("pack is corrupted (SHA1 mismatch)"));
12081211
use(the_hash_algo->rawsz);

builtin/unpack-objects.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix UNUSED)
609609
{
610610
int i;
611611
struct object_id oid;
612+
git_hash_ctx tmp_ctx;
612613

613614
disable_replace_refs();
614615

@@ -669,7 +670,9 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix UNUSED)
669670
the_hash_algo->init_fn(&ctx);
670671
unpack_all();
671672
the_hash_algo->update_fn(&ctx, buffer, offset);
672-
the_hash_algo->final_oid_fn(&oid, &ctx);
673+
the_hash_algo->init_fn(&tmp_ctx);
674+
the_hash_algo->clone_fn(&tmp_ctx, &ctx);
675+
the_hash_algo->final_oid_fn(&oid, &tmp_ctx);
673676
if (strict) {
674677
write_rest();
675678
if (fsck_finish(&fsck_options))

bulk-checkin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ static int deflate_to_pack(struct bulk_checkin_packfile *state,
268268
type, size);
269269
the_hash_algo->init_fn(&ctx);
270270
the_hash_algo->update_fn(&ctx, obuf, header_len);
271+
the_hash_algo->init_fn(&checkpoint.ctx);
271272

272273
/* Note: idx is non-NULL when we are writing */
273274
if ((flags & HASH_WRITE_OBJECT) != 0)

csum-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ int hashfile_truncate(struct hashfile *f, struct hashfile_checkpoint *checkpoint
207207
lseek(f->fd, offset, SEEK_SET) != offset)
208208
return -1;
209209
f->total = offset;
210-
f->ctx = checkpoint->ctx;
210+
the_hash_algo->clone_fn(&f->ctx, &checkpoint->ctx);
211211
f->offset = 0; /* hashflush() was called in checkpoint */
212212
return 0;
213213
}

0 commit comments

Comments
 (0)