Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Jun 2011 13:00:17 -0400
From:      Mark Johnston <markjdb@gmail.com>
To:        "Klaus T. Aehlig" <aehlig@linta.de>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: fdopendir prototype on 7.3-RELEASE amd64
Message-ID:  <20110601170017.GB1830@oddish.mark-home>
In-Reply-To: <20110601152713.GB51073@kta1c10.sesnet.soton.ac.uk>
References:  <20110601152713.GB51073@kta1c10.sesnet.soton.ac.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jun 01, 2011 at 04:27:13PM +0100, Klaus T. Aehlig wrote:
> 
> [Please CC me, as I'm not subscribed to this list]
> 
> Hallo,
> 
> while dealing with PR ports/157274 [1], I found that the following
> program cause a segmentation fault on 7.3-RELEASE amd64, even though 
> my understanding of the man page of fdopendir(3) says it should not.
> 
> #include <fcntl.h>
> #include <sys/types.h>
> #include <dirent.h>
> 
> int main(int argc, char **argv) {
>   DIR *dirp;
>   int fd;
> 
>   fd = open(".", O_RDONLY);
>   dirp = fdopendir(fd);
>   (void) readdir(dirp);
> 
> }
> 
> Compiling gives the warning "assignment makes pointer from integer without a cast"
> refering to the line with the fdopendir call. Indeed, adding the prototype
> 
> extern DIR *fdopendir(int);
> 
> right after the #include lines solves this problem. Is my understanding of the 
> man page that the above #include lines should suffice incorrect? Is this
> problem known---or even fixed already?
> 
> I have reports that indicate that this problem also seems to exist on 7.3-RELEASE-p4 amd64
> and 8.1-RELEASE i386. The above program does not segfault on my 8.2-STABLE amd64.
> 
> Any hints on the status of this observation are very welcome.
> 
> Best regards,
> Klaus
> 
> 
> [1] http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/157274
> 

This has been fixed (in include/dirent.h) with r205265 on RELENG_7, but
I can't see how you'd run into the problem on 8.1. The problem was that
the fdopendir prototype was missing from dirent.h, so the code was
compiled using the incorrect prototype "int fdopendir()".

-Mark



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110601170017.GB1830>