OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Subject: Re: WuFTPD: Providing *remote* root since at least1994
From: Mikael Olsson (mikael.olssonENTERNET.SE)
Date: Mon Jun 26 2000 - 14:51:28 CDT


der Mouse wrote:
>
> > Not to mention that could still be overflowable. snprintf() doesn't
> > null terminate.
>
> Then IMO it's broken - what's your reference for thinking it doesn't?
> The only snprintf manpage I have at hand (NetBSD's) says

There was quite a bit of discussion about the behavior of snprintf()
a while ago; can't quite remember on which list it was though.

The consensus was that "(default libs of) different OSes behave
completely differently", so if you want to be cross-platform
(or cross-major-version), you can't assume that snprintf() terminates.
You need to do a mystring[sizeof(mystring)-1]='\0' after the call
to be on the safe side.

And, no, this wasn't just "lame OS" standard behaviour; it differs
between different unix dialects.

I also _think_ I remember posts saying that ANSI C doesn't require
snprintf() to null terminate. (Don't quote me on that though)

$.02

/Mike

--
Mikael Olsson, EnterNet Sweden AB, Box 393, S-891 28 ÖRNSKÖLDSVIK
Phone: +46 (0)660 29 92 00         Direct: +46 (0)660 29 92 05
Mobile: +46 (0)70 66 77 636        Fax: +46 (0)660 122 50
WWW: http://www.enternet.se/       E-mail: mikael.olssonenternet.se