[patch] bfd/som.c: fix local buffer overrun (was: gas (binutils) 2.10: SIGSEGV on hppa1.1-hp-hpux10.20)

Marco Franzen marcof@thyron.com
Tue Sep 12 08:00:00 GMT 2000


Correcting a mistake in my previous posting:

> >   > (Especially when you do an alloca in a nested scope, leave it and
> >   > enter another nested scope (as happens here): When re-using the stack space
> >   > of the old scope, whether the automatic space of the new scope (if larger)
> >   > might overlap with the alloca-ted area.)

That's what I meant (although expressed awkwardly). But my later example
wasn't:

> int f ()
> {
>   char *dynbuf = alloca (64);
>   {
>     char buf[1024];
>     dynbuf = alloca (8192);
>   }
>   {
>     char smallbuf[25];

Make this 
      char bigbuf[4096];
or there is no chance at all of colliding with dynbuf, no matter how alloca
and the compiler interact.

>     assert (smallbuf+24 < dynbuf || dynbuf+8191 < smallbuf); 

Change this accordingly to
      assert (bigbuf+ sizeof bigbuf <= dynbuf || dynbuf + 8192 <= bigbuf);

>   }
> }

Sorry about the confusion.
-----------------------------------------------------------------
This email is confidential and intended solely for the use of the
individual to whom it is addressed.
Any views or opinions presented are solely those of the author
and do not necessarily represent those of Thyron Limited.
If you are not the intended recipient then please be advised
that you have received this email in error and that any use,
dissemination, forwarding, printing or copying of this email
is strictly prohibited.
If you have received this email in error, please notify the
Thyron IT Administrator on +44 (0)1923 236 050 or
send an email to mail-admin@thyron.com.
Thank You


More information about the Binutils mailing list