[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: segfault in stat
From: |
Andries . Brouwer |
Subject: |
Re: segfault in stat |
Date: |
Sat, 30 Sep 2000 00:29:01 +0200 (MET DST) |
On Fri, Sep 29, 2000 at 04:45:56PM -0500, Nathan Straz wrote:
> On Fri, Sep 29, 2000 at 11:07:23PM +0200, address@hidden wrote:
> > >>>>> Nathan Straz writes:
> >
> > > I was doing some negative testing of stat(2) on Linux with glibc
> > 2.1.3
> > > and I was able to provoke a segfault. Here is the code:
>
> Okay, it seems that everyone seemed to miss the point that is was doing
> "negative testing." That means I MEANT to send a bad pointer to see
> that the results are correct.
You evoke undefined behaviour.
So *any* result you find would be correct, including reformatting your disk
drive.
Prescribed error returns:
---------------------------------------------------------------------------
The stat( ) function shall fail if:
[EACCES] Search permission is denied for a component of the path prefix.
[EIO] An error occurred while reading from the file system.
[ELOOP] A loop exists in symbolic links encountered during resolution
of the path argument.
[ENAMETOOLONG] The length of the path argument exceeds PATH_MAX or a path name
component is longer than NAME_MAX.
[ENOENT] A component of path does not name an existing file or path is
an empty string.
[ENOTDIR] A component of the path prefix is not a directory.
[EOVERFLOW] The file size in bytes or the number of blocks allocated to
the file or the file serial number cannot be represented
correctly in the structure pointed to by buf.
---------------------------------------------------------------------------
Allowed error returns:
---------------------------------------------------------------------------
The stat( ) function may fail if:
[ELOOP] More than SYMLOOP_MAX symbolic links were encountered during
resolution of the path argument.
[ENAMETOOLONG] As a result of encountering a symbolic link in resolution
of the path argument, the length of the substituted path name
string exceeded PATH_MAX.
[EOVERFLOW] A value to be stored would overflow one of the members
of the stat structure.
---------------------------------------------------------------------------
General errors include:
[EFAULT] Bad address. The system detected an invalid address
in attempting to use an argument of a call. The reliable
detection of this error cannot be guaranteed, and when not
detected may result in the generation of a signal, indicating
an address violation, which is sent to the process.
Andries