git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* wrong check condition in patch-delta.c?
@ 2006-06-20  6:32 Nguyễn Thái Ngọc Duy
  2006-06-20  7:21 ` Marco Roeland
  2006-06-20 12:28 ` Nicolas Pitre
  0 siblings, 2 replies; 3+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2006-06-20  6:32 UTC (permalink / raw)
  To: git

Hi,
While inspecting patch-delta.c, I encounter this:
                       if (cp_off + cp_size < cp_size ||
                           cp_off + cp_size > src_size ||
                           cp_size > size)
                               goto bad;
"cp_off + cp_size < cp_size" doesn't make sense to me. Is it on purpose?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: wrong check condition in patch-delta.c?
  2006-06-20  6:32 wrong check condition in patch-delta.c? Nguyễn Thái Ngọc Duy
@ 2006-06-20  7:21 ` Marco Roeland
  2006-06-20 12:28 ` Nicolas Pitre
  1 sibling, 0 replies; 3+ messages in thread
From: Marco Roeland @ 2006-06-20  7:21 UTC (permalink / raw)
  To: Nguy???n Thái Ng???c Duy; +Cc: git

On Tuesday June 20th 2006 Nguy???n Thái Ng???c Duy wrote:

> While inspecting patch-delta.c, I encounter this:
>                       if (cp_off + cp_size < cp_size ||
>                           cp_off + cp_size > src_size ||
>                           cp_size > size)
>                               goto bad;
> "cp_off + cp_size < cp_size" doesn't make sense to me. Is it on purpose?

It protects against possible overflow. Adding fixed length integers is
"wraparound" after all and discards the "carry" bit.
-- 
Marco Roeland

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: wrong check condition in patch-delta.c?
  2006-06-20  6:32 wrong check condition in patch-delta.c? Nguyễn Thái Ngọc Duy
  2006-06-20  7:21 ` Marco Roeland
@ 2006-06-20 12:28 ` Nicolas Pitre
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Pitre @ 2006-06-20 12:28 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git

[-- Attachment #1: Type: TEXT/PLAIN, Size: 418 bytes --]

On Tue, 20 Jun 2006, Nguyn Thái Ngc Duy wrote:

> Hi,
> While inspecting patch-delta.c, I encounter this:
>                       if (cp_off + cp_size < cp_size ||
>                           cp_off + cp_size > src_size ||
>                           cp_size > size)
>                               goto bad;
> "cp_off + cp_size < cp_size" doesn't make sense to me. Is it on purpose?

Yes, it absolutely is.


Nicolas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-06-20 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-20  6:32 wrong check condition in patch-delta.c? Nguyễn Thái Ngọc Duy
2006-06-20  7:21 ` Marco Roeland
2006-06-20 12:28 ` Nicolas Pitre

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).