[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: CVE-2016-8685 in potrace



Hi

I do not have a strong preference for wheezy. Long term I agree with you.

/ Ola

Sent from a phone

Den 4 apr 2017 11:33 skrev "Hugo Lefeuvre" <hle@debian.org>:
Hi Ben, Ola,

> This seems to be a correct optimisation.  Overflow/underflow on signed
> arithmetic has undefined behaviour, therefore standard C code will not
> allow it to happen and the compiler may rely on that.  If the code does
> actually cause an overflow, literally anything can result.
>
> Thankfully gcc does have an option to support code that relies on
> two's-complement wrapping behaviour on signed arithmetic, which is
> -fwrapv.  See also the -fno-strict-overflow option.

You're right ! Compiling with -fwrapv fixes the problem.

Alternatively we could use the attached patch that also seems to fix the
problem.

This patch should be sufficient because in this case an integer overflow can
only occur if there is a x with

 * x < bm->w

and

 * x + BM_WORDBITS > INT_MAX

thus only if bm->w > INT_MAX - BM_WORDBITS.

I don't know which solution is the best, but the second solution is probably
better for future maintainance.

Cheers,
 Hugo

--
             Hugo Lefeuvre (hle)    |    www.owl.eu.com
4096/ ACB7 B67F 197F 9B32 1533 431C AC90 AC3E C524 065E

Reply to: