Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Oct 1997 19:41:57 -0400 (EDT)
From:      Thomas David Rivers <rivers@dignus.com>
To:        freebsd-hackers@freefall.FreeBSD.org, joerg_wunsch@uriah.heep.sax.de
Subject:   Re: Possible SERIOUS bug in open()?
Message-ID:  <199710222341.TAA05037@lakes.dignus.com>

next in thread | raw e-mail | index | archive | help

J"org writes:

> As Jamil J. Weatherbee wrote:
> 
> > > > This was sent to me recently...  It seems to be a pretty serious hole
> > > > in open() and permissions...
> > > 
> > > Fixed.
> > 
> > How exactly did you fix it, this is related to what I was saying about
> > opening a file as RD_ONLY and WR_ONLY, ...
> 
> Yep, this was in the same boat.  The way the fix works, only one of
> O_RDONLY, O_WRONLY, or O_RDWR should be possible now, and anything
> else should be rejected as EINVAL.
> 
> -- 
> cheers, J"org

 Umm... I don't know the answer to this; it's just a thought I had.
Couldn't you do something like:

  f = open("name", 0);
  if(f>0) {
	/* file exists... */
  } else {
	/* file doesn't exist. */
  }

to see if the file exists?  (You should use stat(), or access, but I'm
just devil's advocate here...) Or, are the semantics for that simply not 
defined?     What do other operating systems do in this case?

	- Dave Rivers -




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