All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Martin Koegler <martin.koegler@chello.at>
Cc: git@vger.kernel.org, Johannes.Schindelin@gmx.de
Subject: Re: [PATCH] Add overflow check to get_delta_hdr_size
Date: Mon, 14 Aug 2017 09:56:00 -0700	[thread overview]
Message-ID: <xmqqk226w0kf.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1502522838-12581-1-git-send-email-martin@mail.zuhause> (Martin Koegler's message of "Sat, 12 Aug 2017 09:27:18 +0200")

Martin Koegler <martin.koegler@chello.at> writes:

> From: Martin Koegler <martin.koegler@chello.at>
>
> Signed-off-by: Martin Koegler <martin.koegler@chello.at>
> ---
> Applies on top of my size_t series
>
> I'm not sure, if die or error is better.

As there is no fallback when we hit it, die would be sufficient; the
only thing the callers of this helper, or their callers, could do is
as a reaction to an error return from here would be to die themselves,
I would think.




>  delta.h | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/delta.h b/delta.h
> index 2df0f55..18a4983 100644
> --- a/delta.h
> +++ b/delta.h
> @@ -96,6 +96,11 @@ static inline size_t get_delta_hdr_size(const unsigned char **datap,
>  		cmd = *data++;
>  		size |= (cmd & 0x7f) << i;
>  		i += 7;
> +		if (bitsizeof(size_t) <= i) {
> +			error("too large object size");
> +			size = 0;
> +			break;
> +		}
>  	} while (cmd & 0x80 && data < top);
>  	*datap = data;
>  	return size;

      parent reply	other threads:[~2017-08-14 16:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-12  7:27 [PATCH] Add overflow check to get_delta_hdr_size Martin Koegler
2017-08-14 16:55 ` Junio C Hamano
2017-08-14 16:56 ` Junio C Hamano [this message]

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=xmqqk226w0kf.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=martin.koegler@chello.at \
    /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.