All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Toon Claes <toon@iotcl.com>,
	 git@vger.kernel.org,  Karthik Nayak <karthik.188@gmail.com>,
	 Anders Kaseorg <andersk@mit.edu>
Subject: Re: [PATCH] last-modified: fix bug caused by inproper initialized memory
Date: Tue, 09 Dec 2025 07:42:56 +0900	[thread overview]
Message-ID: <xmqq5xaglhn3.fsf@gitster.g> (raw)
In-Reply-To: <20251208201501.GA216526@coredump.intra.peff.net> (Jeff King's message of "Mon, 8 Dec 2025 15:15:01 -0500")

Jeff King <peff@peff.net> writes:

>   git grep 'memset(.*0,.*\* \?sizeof'
>
> that's looking for memsets of "0" that also multiply by sizeof. Looks
> like there are a few:
>
>   add-patch.c:    memset(hunk + 1, 0, (splittable_into - 1) * sizeof(*hunk));
>   builtin/last-modified.c:        memset(lm->scratch->words, 0x0, lm->scratch->word_alloc * sizeof(eword_t));
>   compat/simple-ipc/ipc-win32.c:  memset(ea, 0, NR_EA * sizeof(EXPLICIT_ACCESS));
>   diff-delta.c:   memset(hash, 0, hsize * sizeof(*hash));
>   hashmap.c:      memset(map->table, 0, map->tablesize * sizeof(struct hashmap_entry *));
>   pack-revindex.c:                memset(pos, 0, BUCKETS * sizeof(*pos));
>
> The first one is an oddball, but the other five could use it. So if we
> were to do a patch adding MEMZERO_ARRAY(), it would probably make sense
> to convert those spots. I'd be OK either way.

Thanks for making an excellent suggestion while I was away from the
keyboard ;-)

Between MEMZERO_ARRAY() and CLEAR_ARRAY(), I am on the fence.

  reply	other threads:[~2025-12-08 22:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-28 16:37 [PATCH] last-modified: fix bug caused by inproper initialized memory Toon Claes
2025-11-28 20:55 ` Jeff King
2025-11-28 22:20   ` Anders Kaseorg
2025-11-29 10:50     ` Jeff King
2025-12-08 11:47   ` Toon Claes
2025-12-08 20:15     ` Jeff King
2025-12-08 22:42       ` Junio C Hamano [this message]
2025-11-29  2:01 ` Junio C Hamano
2025-11-29  2:11   ` Junio C Hamano
2025-11-29  9:38     ` Toon Claes
2025-12-08 11:46 ` [PATCH v2] last-modified: fix use of uninitialized memory Toon Claes
2025-12-08 13:26   ` Junio C Hamano
2025-12-09  8:43     ` Toon Claes
2025-12-09 12:18       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq5xaglhn3.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=andersk@mit.edu \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    --cc=peff@peff.net \
    --cc=toon@iotcl.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.