diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-10-02 07:46:27 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-10-02 07:46:27 -0700 |
| commit | ead0a050e2eddf8c67ee3404e165bffd42c6fd42 (patch) | |
| tree | 0d2d1c33bec3d1be1c99d67dec0edfc39dc861e6 /pack-write.c | |
| parent | Merge branch 'jk/http-leakfixes' (diff) | |
| parent | csum-file.c: use unsafe SHA-1 implementation when available (diff) | |
| download | git-ead0a050e2eddf8c67ee3404e165bffd42c6fd42.tar.gz git-ead0a050e2eddf8c67ee3404e165bffd42c6fd42.zip | |
Merge branch 'tb/weak-sha1-for-tail-sum'
The checksum at the tail of files are now computed without
collision detection protection. This is safe as the consumer of
the information to protect itself from replay attacks checks for
hash collisions independently.
* tb/weak-sha1-for-tail-sum:
csum-file.c: use unsafe SHA-1 implementation when available
Makefile: allow specifying a SHA-1 for non-cryptographic uses
hash.h: scaffolding for _unsafe hashing variants
sha1: do not redefine `platform_SHA_CTX` and friends
pack-objects: use finalize_object_file() to rename pack/idx/etc
finalize_object_file(): implement collision check
finalize_object_file(): refactor unlink_or_warn() placement
finalize_object_file(): check for name collision before renaming
Diffstat (limited to 'pack-write.c')
| -rw-r--r-- | pack-write.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/pack-write.c b/pack-write.c index 27965672f1..f415604c15 100644 --- a/pack-write.c +++ b/pack-write.c @@ -8,6 +8,7 @@ #include "csum-file.h" #include "remote.h" #include "chunk-format.h" +#include "object-file.h" #include "pack-mtimes.h" #include "pack-objects.h" #include "pack-revindex.h" @@ -528,9 +529,9 @@ static void rename_tmp_packfile(struct strbuf *name_prefix, const char *source, size_t name_prefix_len = name_prefix->len; strbuf_addstr(name_prefix, ext); - if (rename(source, name_prefix->buf)) - die_errno("unable to rename temporary file to '%s'", - name_prefix->buf); + if (finalize_object_file(source, name_prefix->buf)) + die("unable to rename temporary file to '%s'", + name_prefix->buf); strbuf_setlen(name_prefix, name_prefix_len); } |
