Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Aug 2006 18:40:36 +1000
From:      Peter Jeremy <peterjeremy@optushome.com.au>
To:        Micah <micahjon@ywave.com>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: struct dirent question
Message-ID:  <20060817084036.GC845@turion.vk2pj.dyndns.org>
In-Reply-To: <44E3A221.1070905@ywave.com>
References:  <44E29055.3080205@centtech.com> <20060816054925.GA11651@droopy.unibe.ch> <44E3484D.8090905@centtech.com> <44E39DEC.1050204@uts.edu.au> <44E3A221.1070905@ywave.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--6zdv2QT/q3FMhpsV
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, 2006-Aug-16 15:54:25 -0700, Micah wrote:
>I think you could fake it as follows:
>
>struct dirent {
>        __uint32_t d_fileno;            /* file number of entry */
>        __uint16_t d_reclen;            /* length of this record */
>        __uint8_t  d_type;              /* file type, see below */
>        __uint8_t  d_namlen;            /* length of string in d_name */
>#define MAXNAMLEN 255
>        char    d_name[MAXNAMLEN + 1];  /* name must be no longer than=20
>this */
>#if !__BSD_VISIBLE
>#undef MAXNAMLEN
>#endif
>};

Macro definitions don't nest so this isn't safe.  Consider some code that
does:

#define	MAXNAMLEN	1024
=2E..
#include <sys/dirent.h>
=2E..
char	mybuffer[MAXNAMLEN];

--=20
Peter Jeremy

--6zdv2QT/q3FMhpsV
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFE5CuE/opHv/APuIcRAmVJAKCq8Fww4zhaASi+MUa5yHob4m8eYwCfT/Yq
NKjcZ4AQMoGPOJ+Rgdcarp8=
=7TgC
-----END PGP SIGNATURE-----

--6zdv2QT/q3FMhpsV--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060817084036.GC845>