git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Arthur Chan via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org,  Arthur Chan <arthur.chan@adalogics.com>
Subject: Re: [PATCH v2] fuzz: add new oss-fuzz fuzzer for date.c / date.h
Date: Tue, 14 Nov 2023 08:27:47 +0900	[thread overview]
Message-ID: <xmqqzfzh44jw.fsf@gitster.g> (raw)
In-Reply-To: <20231113183509.GA3838361@coredump.intra.peff.net> (Jeff King's message of "Mon, 13 Nov 2023 13:35:09 -0500")

Jeff King <peff@peff.net> writes:

> On Mon, Nov 13, 2023 at 04:22:48PM +0000, Arthur Chan via GitGitGadget wrote:
>
>> +	str = (char *)malloc(size + 1);
>> +	if (!str)
>> +		return 0;
>> +	memcpy(str, data, size);
>> +	str[size] = '\0';
>
> Is it important that we avoid calling die() if the malloc fails here?
>
> The usual way to write this in our code base is just:
>
>   str = xmemdupz(data, size);
>
> It's not entirely a style thing; we sometimes audit the code base
> looking for computations on malloc sizes (for integer overflows) as well
> as sites that should be using xmalloc and are not. Obviously we can
> exclude oss-fuzz/ from such audits, but if there's no reason not to
> prefer our usual style, it's one less thing to worry about.

Good point.  Thanks.

  reply	other threads:[~2023-11-13 23:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-11 17:39 [PATCH] fuzz: add new oss-fuzz fuzzer for date.c / date.h Arthur Chan via GitGitGadget
2023-11-12  5:59 ` Junio C Hamano
2023-11-12 12:39   ` Junio C Hamano
2023-11-13 16:22 ` [PATCH v2] " Arthur Chan via GitGitGadget
2023-11-13 18:35   ` Jeff King
2023-11-13 23:27     ` Junio C Hamano [this message]
2023-11-13 23:27   ` Junio C Hamano
2023-11-14 10:53   ` [PATCH v3] " Arthur Chan via GitGitGadget
2023-11-14 17:03     ` Junio C Hamano
2023-11-17 17:47     ` [PATCH v4] " Arthur Chan via GitGitGadget

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=xmqqzfzh44jw.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=arthur.chan@adalogics.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=peff@peff.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).