This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]