Date: Tue, 18 Nov 2008 09:20:03 GMT From: Andrey Chernov <ache@nagual.pp.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/128933: realpath(3) does not follow SUS specification for a NULL/empty path Message-ID: <200811180920.mAI9K3Ms016126@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/128933; it has been noted by GNATS. From: Andrey Chernov <ache@nagual.pp.ru> To: James Vega <vega.james@gmail.com> Cc: freebsd-gnats-submit@freebsd.org Subject: Re: kern/128933: realpath(3) does not follow SUS specification for a NULL/empty path Date: Tue, 18 Nov 2008 12:06:12 +0300 On Mon, Nov 17, 2008 at 02:04:59AM +0000, James Vega wrote: > According to the Single Unix Specification[0], the realpath stdlib function should return NULL (to indicate an error) when the first argument to realpath is either NULL or an empty string and set errno to EINVAL/ENOENT respectively. > > For the empty string case, FreeBSD is currently populating resolved with the current working directory and returning the pointer to that. > > For the NULL case, I see no check whether path is NULL or not. Instead, the first use of it is dereferencing the pointer > > if (path[0] == '/' > > [0] - http://www.opengroup.org/onlinepubs/009695399/functions/realpath.html The situation is even worse. realpath(3) breaks those SUS rules ("shall fail if") too: [ENOENT] A component of file_name does not name an existing file [ENOTDIR] A component of the path prefix is not a directory i.e. realpath(3) does not detect fictional file name (last component) with ENOENT and does not detect intermediate non-directories components with ENOTDIR. See following examples with realpath(1): # realpath /non_existent /non_existent (should be "No such file or directory") # realpath /bin/non_existent/cp realpath: /bin/non_existent/cp: No such file or directory (should be: "Not a directory", as early as non_existent checked) -- http://ache.pp.ru/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811180920.mAI9K3Ms016126>