Re: [PATCH 4/7] Fix int overflow

2015-07-08 Thread Ian Lance Taylor
On Mon, Jul 6, 2015 at 12:36 PM, Mikhail Maltsev wrote: > > diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c > index 44a0a9b..befa6b6 100644 > --- a/libiberty/cp-demangle.c > +++ b/libiberty/cp-demangle.c > @@ -103,6 +103,7 @@ > #include "config.h" > #endif > > +#include All exis

Re: [PATCH 4/7] Fix int overflow

2015-07-07 Thread Mikhail Maltsev
On 08.07.2015 1:48, Jeff Law wrote: > I'm not questioning whether or not the test will cause a problem, but > instead questioning if the test does what you expect it to do on a 32bit > host. > > On a host where sizeof (int) == sizeof (long), that len > INT_MAX test > is always going to be false. Y

Re: [PATCH 4/7] Fix int overflow

2015-07-07 Thread Jeff Law
On 07/06/2015 06:04 PM, Mikhail Maltsev wrote: On 07.07.2015 1:55, Jeff Law wrote: len = d_number (di); - if (len <= 0) + if (len <= 0 || len > INT_MAX) return NULL; ret = d_identifier (di, len); di->last_name = ret; Isn't this only helpful if sizeof (long) > sizeof (in

Re: [PATCH 4/7] Fix int overflow

2015-07-06 Thread Mikhail Maltsev
On 07.07.2015 1:55, Jeff Law wrote: >> len = d_number (di); >> - if (len <= 0) >> + if (len <= 0 || len > INT_MAX) >> return NULL; >> ret = d_identifier (di, len); >> di->last_name = ret; > Isn't this only helpful if sizeof (long) > sizeof (int)? Otherwise the > compiler is go

Re: [PATCH 4/7] Fix int overflow

2015-07-06 Thread Jeff Law
On 07/06/2015 01:36 PM, Mikhail Maltsev wrote: --- libiberty/cp-demangle.c | 3 ++- libiberty/testsuite/demangle-expected | 4 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 44a0a9b..befa6b6 100644 --- a

[PATCH 4/7] Fix int overflow

2015-07-06 Thread Mikhail Maltsev
--- libiberty/cp-demangle.c | 3 ++- libiberty/testsuite/demangle-expected | 4 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 44a0a9b..befa6b6 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle