Skip to content

Commit fe4e607

Browse files
To1negitster
authored andcommitted
last-modified: fix use of uninitialized memory
git-last-modified(1) uses a scratch bitmap to keep track of paths that have been changed between commits. To avoid reallocating a bitmap on each call of process_parent(), the scratch bitmap is kept and reused. Although, it seems an incorrect length is passed to memset(3). `struct bitmap` uses `eword_t` to for internal storage. This type is typedef'd to uint64_t. To fully zero the memory used by the bitmap, multiply the length (saved in `struct bitmap::word_alloc`) by the size of `eword_t`. Reported-by: Anders Kaseorg <andersk@mit.edu> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Toon Claes <toon@iotcl.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2a04e8c commit fe4e607

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

builtin/last-modified.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static void process_parent(struct last_modified *lm,
327327
if (!(parent->object.flags & PARENT1))
328328
active_paths_free(lm, parent);
329329

330-
memset(lm->scratch->words, 0x0, lm->scratch->word_alloc);
330+
memset(lm->scratch->words, 0x0, lm->scratch->word_alloc * sizeof(eword_t));
331331
diff_queue_clear(&diff_queued_diff);
332332
}
333333

0 commit comments

Comments
 (0)