Date: Wed, 10 Dec 1997 21:27:58 -0800 From: John Polstra <jdp@polstra.com> To: Shigio Yamaguchi <shigio@wafu.netgate.net> Cc: hackers@freebsd.org Subject: Re: [RFC] path converting functions. Message-ID: <199712110527.VAA24691@austin.polstra.com> In-Reply-To: Your message of "Wed, 10 Dec 1997 08:34:25 %2B0900." <199712091552.PAA11445@wafu.netgate.net>
next in thread | previous in thread | raw e-mail | index | archive | help
> > Since your functions write into the user-supplied buffer "result", > > you should add an argument that specifies how big it is. See the > > gethostname() and snprintf() interfaces, for example. > > The result argument must refer to a buffer capable of storing at > least MAXPATHLEN characters. This is the way of realpath(3). Well, in my opinion the example set by realpath(3) is bad and it shouldn't be copied in new code. I say again, if a function writes into a caller-supplied buffer then the caller should also specify how large the buffer is. Using a compiled in assumption such as MAXPATHLEN is risky at best. What if you build your program on one machine and then run it on a machine where MAXPATHLEN has a different value? Or, for that matter, on the same machine after some wiz has decided to change the value of MAXPATHLEN? Anyway, that's all the arguing I want to do. You asked for opinions and I gave you mine. :-) John
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712110527.VAA24691>