[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
segfault in stat
From: |
Charles G Waldman |
Subject: |
segfault in stat |
Date: |
Fri, 29 Sep 2000 09:43:34 -0500 (CDT) |
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);
You're passing a bogus pointer to stat, what do you expect? stat does
not allocate memory for the returned status buffer, you are supposed
to pass in a pointer to a valid memory location:
Try this:
struct stat sbuf;
ret = stat(".", &sbuf);