threads / discuss / 4581

wrong check condition in patch-delta.c?

Subject: wrong check condition in patch-delta.c?

## tl;dr

3 messages between Jun 20, 2006 and Jun 20, 2006.

replies: 2people: 3as markdown or json

Nguyễn Thái Ngọc Duy· Jun 20, 2006, 06:32 UTC · lore
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?
Marco Roeland· Jun 20, 2006, 07:21 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: wrong check condition in patch-delta.c?

On Tuesday June 20th 2006 Nguy???n Thái Ng???c Duy wrote:
Show 6 quoted lines
> 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
Nicolas Pitre· Jun 20, 2006, 12:28 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: wrong check condition in patch-delta.c?

On Tue, 20 Jun 2006, Nguyn Thái Ngc Duy wrote:
Show 7 quoted lines
> 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

← back to recent threads