On Mar 2, 2016, at 12:33 AM, Marcel Böhme <boehme.mar...@gmail.com> wrote:
> Please find attached the proposed patch for Bug 69687: 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69687
> 
> * Limiting the length of the mangled string to 264k characters.

No.  This isn’t in the spirit of GNU software.

> * Limiting the loop iterations to 256 (max. of C++ function parameters).

No.

Instead, find the bit of the code that is wrong and fix that.  From the PR:

> The function string_need (cplus-dem.c:4751) checks whether sufficient memory 
> is available to append size-of-arg more characters. If not, xrealloc decl 
> with n=2*(length of decl + length of arg) characters. Since n is a signed 
> int, n wraps over at some iteration.

So, check for overflow, or better use unsigned values that are large enough to 
never overflow.  With no possibility for overflow, you can then retest the bug 
and see if there are any other failure modes and fix those.

Reply via email to