[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: segfault in stat
From: |
Andreas Jaeger |
Subject: |
Re: segfault in stat |
Date: |
29 Sep 2000 16:44:38 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Channel Islands) |
>>>>> 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:
> $ cat stat.c
> #include <sys/stat.h>
> #include <unistd.h>
> #include <string.h>
> #include <errno.h>
> int main()
> {
> int ret;
> void *ptr = (void*) -1L;
> ret = stat(".",(struct stat *)ptr);
> if (ret==-1)
> perror("stat()");
> }
[...]
You have to give a valid pointer.
> It appears to me that when vers != _STAT_VER_KERNEL in __xstat() that
> 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 definately says otherwise.
The authoritative source for glibc is the info documentation, if the
man pages are wrong, please tell Andries (CC'ed).
Andreas
> Please let me know what the proper behaviour is so I can adjust the test
> case accordingly.
> Thanks,
--
Andreas Jaeger
SuSE Labs address@hidden
private address@hidden
http://www.suse.de/~aj