# wrong check condition in patch-delta.c?

3 messages from 2006-06-20 to 2006-06-20. Participants: Nguyễn Thái Ngọc Duy, Marco Roeland, Nicolas Pitre.
Thread: https://gitlist.dev/t/4581

## Nguyễn Thái Ngọc Duy, 2006-06-20 06:32

Subject: wrong check condition in patch-delta.c?
Message-ID: <fcaeb9bf0606192332j5b2ee4b9ycf2c63c7b1820204@mail.gmail.com>
URL: https://gitlist.dev/e/fcaeb9bf0606192332j5b2ee4b9ycf2c63c7b1820204%40mail.gmail.com

```
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, 2006-06-20 07:21

Subject: Re: wrong check condition in patch-delta.c?
Message-ID: <20060620072150.GB26656@fiberbit.xs4all.nl>
URL: https://gitlist.dev/e/20060620072150.GB26656%40fiberbit.xs4all.nl
In-Reply-To: <fcaeb9bf0606192332j5b2ee4b9ycf2c63c7b1820204@mail.gmail.com>

```
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

```

## Nicolas Pitre, 2006-06-20 12:28

Subject: Re: wrong check condition in patch-delta.c?
Message-ID: <Pine.LNX.4.64.0606200827120.3377@localhost.localdomain>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0606200827120.3377%40localhost.localdomain
In-Reply-To: <fcaeb9bf0606192332j5b2ee4b9ycf2c63c7b1820204@mail.gmail.com>

```
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

```
