This is the mail archive of the
libc-hacker@cygnus.com
mailing list for the glibc project.
Re: libio backward compat bug? involving setmntent()
- To: Zack Weinberg <zack@rabi.columbia.edu>
- Subject: Re: libio backward compat bug? involving setmntent()
- From: Ulrich Drepper <drepper@cygnus.com>
- Date: 02 May 1999 18:35:12 -0700
- Cc: libc-hacker@cygnus.com
- References: <199904131333.JAA26316@blastula.phys.columbia.edu>
- Reply-To: drepper@cygnus.com (Ulrich Drepper)
Zack Weinberg <zack@rabi.columbia.edu> writes:
> The appended slightly-out-of-spec code segfaults when compiled on a
> libc 2.0 system and run on a libc 2.1 system. The problem is that
> setmntent() returns a new FILE*, but fclose is bound to the old
> fclose.
>
> Do we want to support this, and if so, how? (Have old fclose
> recognize when it's handed a new FILE* and call _IO_new_fclose?)
There is no libc problem (at least, not really). The program is
wrong:
> fp = setmntent("/etc/mtab", "r");
> while((me = getmntent(fp)) != 0)
> printf("%s on %s\ttype %s opts %s freq %d pass %d\n",
> me->mnt_fsname, me->mnt_dir, me->mnt_type,
> me->mnt_opts, me->mnt_freq, me->mnt_passno);
>
> fclose(fp);
This must be
endmntent (fp);
> return 0;
> }
--
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------