* [PATCH] Add overflow check to get_delta_hdr_size
@ 2017-08-12 7:27 Martin Koegler
2017-08-14 16:55 ` Junio C Hamano
2017-08-14 16:56 ` Junio C Hamano
0 siblings, 2 replies; 3+ messages in thread
From: Martin Koegler @ 2017-08-12 7:27 UTC (permalink / raw
To: git, gitster, Johannes.Schindelin; +Cc: Martin Koegler
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.
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;
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Add overflow check to get_delta_hdr_size
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
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2017-08-14 16:55 UTC (permalink / raw
To: Martin Koegler; +Cc: git, Johannes.Schindelin
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;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add overflow check to get_delta_hdr_size
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
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2017-08-14 16:56 UTC (permalink / raw
To: Martin Koegler; +Cc: git, Johannes.Schindelin
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;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-14 16:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).