This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: gdb-patches Digest 26 May 2005 03:14:52 -0000 Issue 2677
- From: David Anderson <davea at quasar dot engr dot sgi dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 25 May 2005 20:25:34 -0700 (PDT)
- Subject: Re: gdb-patches Digest 26 May 2005 03:14:52 -0000 Issue 2677
>1. Won't introduce overflow. And one can easily see this from the
>context. To name an example in function remote_thread_alive:
>
> int tid = PIDGET (ptid);
> char buf[16];
>
> if (tid < 0)
> sprintf (buf, "T-%08x", -tid);
> else
> sprintf (buf, "T%08x", tid);
>
>In this context, there is no possibility that buf get overflowed.
If int enough larger than 64 bits then it will overflow the buffer.
I don't know of such a machine yet, but lets write safe code.
Better a useless value in the buffer than a buffer overflow.
David Anderson