bug-glibc
[Top][All Lists]
Advanced

[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: Fri, 29 Sep 2000 23:07:23 +0200 (MET DST)

    >>>>> 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:

     >   void *ptr = (void*) -1L;
     >   ret = stat(".",(struct stat *)ptr);

That code is broken. If now your computer explodes, you cannot complain.

     > It appears to me that when vers != _STAT_VER_KERNEL in __xstat() that

_STAT_VER_KERNEL?
__xstat?

Seems like you are looking at the internals of one particular implementation.

     > buf is not checked to be valid before xstat_conv uses it.  I realize
     > this is probably nit-picky, but I thought I would bring it up anyway.  I
     > would expect a -1 return with errno set to EFAULT as the man page
     > states, but the info file definitely says otherwise.

Andreas Jaeger writes:

    The authoritative source for glibc is the info documentation, if the
    man pages are wrong, please tell Andries (CC'ed).

Roughly speaking I agree with Andreas, but my detailed point of view
is different. Glibc comes with an info file that describes what it does.
But this info file does not describe all glibc versions, often only the
current one. The man pages have as goal to describe what the standards
say, with notes describing deviations and variations seen in the various
libc and glibc versions. Since __xstat is part of the internals of some
implementation, the man pages will not say anything about it.

Remains the question of whether EFAULT should be returned,
and the answer is no. And the man pages do not say that this
value must be returned either, only that if it is returned
it means "Bad address".

So, maybe nothing is wrong here, not with glibc, not with stat(2).

Andries



reply via email to

[Prev in Thread] Current Thread [Next in Thread]