On Thursday 13 November 2003 06:54, Gene Buckle wrote:
> On Wed, 12 Nov 2003, Cameron Moore wrote:
> > * [EMAIL PROTECTED] (Gene Buckle) [2003.11.12 10:35]:
> > > static const char *
> > > getDateString ()
> > > {
> > >   static char buf[64];          // FIXME
> > >   struct tm * t = globals->get_time_params()->getGmt();
> > >   sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
> > >           t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
> > >           t->tm_hour, t->tm_min, t->tm_sec);
> > >   return buf;
> > > }

> > We should at least be using snprintf() here.

> So what makes snprintf() a better choice than sprintf()?

With snprintf, you can make sure buf will never overflow. Though I guess 
it's impossible to overflow buf with the format-string that's used now.

--Ivo


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to