gdb-patches Digest 26 May 2005 03:14:52 -0000 Issue 2677

David Anderson davea@quasar.engr.sgi.com
Thu May 26 03:44:00 GMT 2005


>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



More information about the Gdb-patches mailing list