W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2002

Problems in Linux readdir_r() affecting libwww...

From: GIRALT,JOSEP (HP-Spain,ex2) <josep_giralt@hp.com>
Date: Wed, 6 Feb 2002 08:14:07 -0500 (EST)
Message-ID: <635E5D5D3362D411886D00D0B77FBB8906185EA8@dali.bpo.hp.com>
To: "'www-lib@w3.org'" <www-lib@w3.org>

Hi all,

I've recently found a problem using the libwww library under linux (RedHat
6.2 and 7.2). The usage of the readdir_r() in the files HTFile.c and
HTMulti.c are correct in most of the systems but cause a core dump under
Linux. The reason is that the glibc implementation of that call does return
0 at the end-of-directory and sets the "dirbuf" pointer to NULL (

This is consistent with the GNU documentation


but not consistent with the POSIX documentation that says it should return
an error.

This causes a core dump because the 

	while (readdir_r(dp, &result, &dirbuf) == 0)
	   if (!dirbuf->d_ino ......

loop does not end at the end of directory.

I just did a fix  by 

	while (readdir_r(dp, &result, &dirbuf) == 0)
	   if (dirbuf == (struct direct *)NULL) break;
	   if (!dirbuf->d_ino ......

which covers all the different Unix versions HPUX, Linux and Solaries I've
been able to test  so far. But still I don't know how you want to address
this issue in the future because the same issue seems to re-appear for each
Linux versions. 

Thanks a lot in advance and let me know what you think.

Josep Giralt
Software Architect.
Hewlett-Packard InkJet Commercial Division. Barcelona. Spain.

Received on Wednesday, 6 February 2002 08:20:38 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:55 UTC