From owner-freebsd-hackers Wed Dec 10 21:33:39 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id VAA04050 for hackers-outgoing; Wed, 10 Dec 1997 21:33:39 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from austin.polstra.com (austin.polstra.com [206.213.73.10]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id VAA03789 for ; Wed, 10 Dec 1997 21:28:05 -0800 (PST) (envelope-from jdp@austin.polstra.com) Received: from austin.polstra.com (jdp@localhost) by austin.polstra.com (8.8.8/8.8.7) with ESMTP id VAA24691; Wed, 10 Dec 1997 21:27:58 -0800 (PST) (envelope-from jdp) Message-Id: <199712110527.VAA24691@austin.polstra.com> To: Shigio Yamaguchi cc: hackers@freebsd.org Subject: Re: [RFC] path converting functions. In-reply-to: Your message of "Wed, 10 Dec 1997 08:34:25 +0900." <199712091552.PAA11445@wafu.netgate.net> Date: Wed, 10 Dec 1997 21:27:58 -0800 From: John Polstra Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > 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