From owner-freebsd-hackers Tue Dec 9 07:41:33 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id HAA10875 for hackers-outgoing; Tue, 9 Dec 1997 07:41:33 -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 HAA10859 for ; Tue, 9 Dec 1997 07:41:26 -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 HAA00577; Tue, 9 Dec 1997 07:41:18 -0800 (PST) (envelope-from jdp) Message-Id: <199712091541.HAA00577@austin.polstra.com> To: shigio@wafu.netgate.net Subject: Re: [RFC] path converting functions. In-Reply-To: <199712032230.WAA28837@wafu.netgate.net> References: <199712032230.WAA28837@wafu.netgate.net> Organization: Polstra & Co., Seattle, WA Cc: hackers@freebsd.org Date: Tue, 09 Dec 1997 07:41:18 -0800 From: John Polstra Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In article <199712032230.WAA28837@wafu.netgate.net>, Shigio Yamaguchi wrote: > I've written a set of simple functions to perform conversions between > an absolute path name and a relative path name. > > Thoughts about this? > > o Are there any other functions that will do this? > o Is this useful? > o Is this the correct way to do it? > > ------------------------------------------------------------------------ > > abs2rel - make a relative path name from an absolute path name > > abs2rel(, , ); > > > /usr/src /etc ../usr/src 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. If you don't add a size argument to limit the number of characters written into the buffer, you're creating yet another potential security hole like gets(). An alternative would be to malloc the required amount of space within your new functions, and return a pointer to it. If you do that, be sure to document that the caller is responsible for freeing the space when he is done with it. John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Self-knowledge is always bad news." -- John Barth