This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix for PR70498 in Libiberty Demangler
- From: Bernd Schmidt <bschmidt at redhat dot com>
- To: Marcel BÃhme <boehme dot marcel at gmail dot com>
- Cc: Pedro Alves <palves at redhat dot com>, gcc-patches at gcc dot gnu dot org, Jason Merrill <jason at redhat dot com>
- Date: Fri, 15 Apr 2016 13:38:32 +0200
- Subject: Re: Fix for PR70498 in Libiberty Demangler
- Authentication-results: sourceware.org; auth=none
- References: <9B8E7D06-93A5-40C6-A1F8-599482DD9056 at gmail dot com> <56FEB2AD dot 3030304 at redhat dot com> <56FEB36F dot 3070906 at redhat dot com> <5C58DC48-8E92-4581-A1DC-1491A3DC7CEB at gmail dot com> <5707CA63 dot 6030206 at redhat dot com> <8ADE62F0-5D21-452D-8740-8B62CDDB93A9 at gmail dot com>
On 04/13/2016 03:04 PM, Marcel Böhme wrote:
Hi Bernd,
Shouldn't we check for overflows before performing the +1 addition
(i.e. 0 <= num < INT_MAX)? Ideally we'd also have a way to signal
from d_number if we had an overflow while parsing that number.
Without an overflow signal, d_number will already be prone to return
a negative number for supposedly non-negative numbers (those not
preceded with ’n’). In that case an overflow check would be
unnecessary in d_compact_number which is supposed to always return a
positive number or a negative one (-1). If you decide in favour of an
overflow signal, it must be handled by the call-sites. Not sure what
the “default behaviour” should be then. Otherwise, we can simply
assume that the call sites for d_number can handle negative numbers.
Shouldn't we look into fixing d_number eventually so it can signal error?
index = d_compact_number (di) + 1; if (index == 0) return NULL;
which probably ought to have the same kind of check (I'll note that
at this point we've accumulated two "+1"s, I'll assume that's what
we want).
Yes. There should be an overflow check here.
Could you update the patch for that?
Bernd