aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-07-08 13:14:58 -0700
committerJunio C Hamano <gitster@pobox.com>2021-07-08 13:14:59 -0700
commit1d38852b115983a3bd83b2ae61398826f86b5948 (patch)
tree2d0c55a86c66e3d10e971967fada4a4c987e85b3
parent7e242013652525e6d8e0ee73bfb85ecaeab700ea (diff)
parent4dbc55e87da408e746888d0e65064a87bf8eb8b5 (diff)
downloadgit-1d38852b115983a3bd83b2ae61398826f86b5948.tar.gz
Merge branch 'ah/uninitialized-reads-fix'
Make the codebase MSAN clean. * ah/uninitialized-reads-fix: builtin/checkout--worker: zero-initialise struct to avoid MSAN complaints split-index: use oideq instead of memcmp to compare object_id's bulk-checkin: make buffer reuse more obvious and safer
-rw-r--r--builtin/checkout--worker.c2
-rw-r--r--bulk-checkin.c3
-rw-r--r--split-index.c3
3 files changed, 4 insertions, 4 deletions
diff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c
index 289a9b8f89..fb9fd13b73 100644
--- a/builtin/checkout--worker.c
+++ b/builtin/checkout--worker.c
@@ -53,7 +53,7 @@ static void packet_to_pc_item(const char *buffer, int len,
static void report_result(struct parallel_checkout_item *pc_item)
{
- struct pc_item_result res;
+ struct pc_item_result res = { 0 };
size_t size;
res.id = pc_item->id;
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 127312acd1..b023d9959a 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -100,6 +100,7 @@ static int stream_to_pack(struct bulk_checkin_state *state,
const char *path, unsigned flags)
{
git_zstream s;
+ unsigned char ibuf[16384];
unsigned char obuf[16384];
unsigned hdrlen;
int status = Z_OK;
@@ -113,8 +114,6 @@ static int stream_to_pack(struct bulk_checkin_state *state,
s.avail_out = sizeof(obuf) - hdrlen;
while (status != Z_STREAM_END) {
- unsigned char ibuf[16384];
-
if (size && !s.avail_in) {
ssize_t rsize = size < sizeof(ibuf) ? size : sizeof(ibuf);
ssize_t read_result = read_in_full(fd, ibuf, rsize);
diff --git a/split-index.c b/split-index.c
index 4d6e52d46f..8e52e891c3 100644
--- a/split-index.c
+++ b/split-index.c
@@ -207,7 +207,8 @@ static int compare_ce_content(struct cache_entry *a, struct cache_entry *b)
b->ce_flags &= ondisk_flags;
ret = memcmp(&a->ce_stat_data, &b->ce_stat_data,
offsetof(struct cache_entry, name) -
- offsetof(struct cache_entry, ce_stat_data));
+ offsetof(struct cache_entry, oid)) ||
+ !oideq(&a->oid, &b->oid);
a->ce_flags = ce_flags;
b->ce_flags = base_flags;