[15579] in bugtraq
Re: ftpd: the advisory version
daemon@ATHENA.MIT.EDU (Juergen P. Meier)
Fri Jun 30 18:04:18 2000
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Message-ID: <20000630094000.A16164@fm.rz.fh-muenchen.de>
Date: Fri, 30 Jun 2000 09:40:00 +0200
Reply-To: jpm@class.de
From: "Juergen P. Meier" <jor@FM.RZ.FH-MUENCHEN.DE>
X-To: Dan Harkless <dan-bugtraq@DILVISH.SPEED.NET>
To: BUGTRAQ@SECURITYFOCUS.COM
In-Reply-To: <200006272242.PAA20500@dilvish.speed.net>
On Tue, Jun 27, 2000 at 03:41:59PM -0700, Dan Harkless wrote:
> Sebastian <scut@NB.IN-BERLIN.DE> writes:
> > So please, use unsigned char pointers, buffers and casts. For example the
> > proper code for the above function would be:
> >
> > void
> > func_proper (unsigned char *domain)
> > {
> > int len = domain[0];
> > unsigned char buff[64];
> >
> >
> > if (len >= 64)
> > return;
> >
> > strncpy (buff, &domain[1], len);
> > buff[63] = '\x00';
> > }
>
> Uh, no, the strncpy() prototype is:
>
> char *strncpy(char *dst, const char *src, size_t n);
>
> len should be a size_t (which is typedef'd to be some kind of unsigned int),
> which would avoid the problem (without having to mess with explicitly
> unsigned chars, which will cause warnings on platforms where chars are
> signed, for one thing).
or where a size_t has different wordlength than an int ;)
this will be one of the biggest problems, to get those int's out of
peoples mind (the code is cleaned quick enough ;)
never ever rely on the size of ordinals.
--
Juergen P. Meier email: jpm@class.de
Class GmbH Firmengruppe phone: +49 172 8379103