The open() system call in f8 really broken...

Jakub Jelinek jakub at redhat.com
Thu Aug 16 20:38:15 UTC 2007


On Thu, Aug 16, 2007 at 04:21:38PM -0400, Dave Jones wrote:
> On Thu, Aug 16, 2007 at 05:08:15PM +0200, Oliver Falk wrote:
> 
>  > If you compile the whole Fedora tree, how many warnings will you see?
>  
> So I grepped across a make prep'd tree of devel (all 63 gig of it).
> Here's the fallout..
> 
> openmpi/openmpi-1.2.3/orte/runtime/orte_abort.c         fd = open(abort_file, O_CREAT);
> jython/jython-svn-Release_2_2beta1/CPythonLib/test/test_unicode_file.py:f = os.open(TESTFN_ENCODED, os.O_CREAT)
> perl/perl-5.8.8/t/op/taint.t:   eval { sysopen(my $cr, $evil, &O_CREAT) };
> proftpd/proftpd-1.3.0a/contrib/mod_rewrite.c:    if ((fifo_lockfd = open(fifo_lockname, O_CREAT)) < 0)
> pwlib/pwlib-1.10.7/configure:sem_t *s = sem_open("test", O_CREAT)
> pwlib/pwlib-1.10.7/configure.ac:                 [sem_t *s = sem_open("test", O_CREAT)],
> python/Python-2.5.1/Lib/test/test_unicode_file.py:        f = os.open(filename, os.O_CREAT)
> python-docs/Python-2.5.1/Lib/test/test_unicode_file.py:        f = os.open(filename, os.O_CREAT)
> xca/xca-0.6.3/_tmp_root/usr/lib/python2.5/test/test_unicode_file.py:        f = os.open(filename, os.O_CREAT)
> 
> Not too bad considering.

You grepped only for O_CREAT and no other bits in flags?  Otherwise
the list is way too short IMHO.

fd = open(abort_file, O_CREAT);
is broken not just for one reason, but for 2...
1) POSIX says:
   Applications shall specify exactly one of the first three values (file
   access modes) below in the value of oflag:
   O_RDONLY, O_WRONLY, O_RDWR
   Any combination of the following may be used:
   ... many ...

   Eventhough Linux defines O_RDONLY to 0, so O_CREAT alone is actually
   O_CREAT | O_RDONLY, e.g. on the Hurd O_RDONLY is 1, O_WRONLY 2
   and O_RDWR 3, so not giving any of those is a serious error there
   and just a portability issue on Linux.
2) missing mode for O_CREAT

Anyway, cases where open has compile time constant oflag argument
will be handled by the compile time error if mode is missing and O_CREAT
is present, so no need to worry about it - the mass rebuild will find
them all.  The case steved was moaning about is when oflag is not
__builtin_constant_p.  We can check even those cases after the mass rebuild,
simply check what programs or shared libraries use
__open{,at}{,64}_2@@GLIBC_2.7 symbols and check all those manually.

	Jakub




More information about the Fedora-maintainers mailing list