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?threads / discuss / 4581
wrong check condition in patch-delta.c?
Subject: wrong check condition in patch-delta.c?
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
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