From xemacs-m  Thu Sep 25 03:03:21 1997
Received: from server.sensei.co.uk (server.sensei.co.uk [193.132.124.5])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id DAA16257;
	Thu, 25 Sep 1997 03:03:20 -0500 (CDT)
Received: from cerise.sensei.co.uk (glynn@muvies.demon.co.uk [158.152.66.14]) by server.sensei.co.uk (8.8.5/8.8.2) with ESMTP id JAA29096; Thu, 25 Sep 1997 09:03:16 +0100
Received: (from glynn@localhost) by cerise.sensei.co.uk (8.8.5/8.8.2) id IAA04442; Thu, 25 Sep 1997 08:48:22 +0100
Date: Thu, 25 Sep 1997 08:48:22 +0100
Message-Id: <199709250748.IAA04442@cerise.sensei.co.uk>
From: Glynn Clements <glynn@sensei.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: SL Baur <steve@xemacs.org>
Cc: xemacs-beta@xemacs.org
Subject: Re: Fatal serious (security) flaw in XEmacs 19.16/20.3
In-Reply-To: <m2zpp22ae9.fsf@altair.xemacs.org>
References: <m2zpp22ae9.fsf@altair.xemacs.org>
X-Mailer: VM 6.34 under 20.3 "Sarajevo" XEmacs  Lucid (beta23)


SL Baur wrote:

> What is the correct POSIX way to get max file name length?

According to Stevens[1], the POSIX way is to:

1. Check whether PATH_MAX is defined in <limits.h>. If it is, then
that's the maximum value.

2. Otherwise, call `pathconf("/", _PC_PATH_MAX)'. If it returns -1
without changing errno, then there is no upper limit on the length of
a pathname. If it returns a positive value, then the upper limit is
one more than the return value (not including a terminating NUL).

In general, `pathconf(path, _PC_PATH_MAX)' returns the maximum length
of a filename relative to `path', which depends upon the type of the
filesystem containing `path', and of any filesystems mounted beneath
it.

Of course, there's no guarantee that such a procedure will yield the
correct results.

On Linux-2.0.30, libc 5.4.23, limits.h #define's PATH_MAX to 1024,
while `pathconf("/", _PC_PATH_MAX)' returns 4095, yet I could create a
directory such that `/bin/pwd | wc -c' prints 5688. (deleting the
directory was somewhat more complex than creating it).

-- 
Glynn Clements <glynn@sensei.co.uk>

[1]
Advanced Programming in the Unix(R) Environment
W Richard Stevens
Addison-Wesley

