[5454] in bugtraq
Re: Possible SERIOUS bug in open()?
daemon@ATHENA.MIT.EDU (Mark E. Mallett)
Sat Oct 25 16:25:50 1997
Date: Sat, 25 Oct 1997 15:45:21 -0400
Reply-To: "Mark E. Mallett" <mem@MV.MV.COM>
From: "Mark E. Mallett" <mem@MV.MV.COM>
X-To: Tim Newsham <newsham@aloha.net>
To: BUGTRAQ@NETSPACE.ORG
In-Reply-To: <199710251926.JAA07524@haleakala.aloha.net> from "Tim Newsham" at
Oct 25, 97 09:26:12 am
> What about the higher flag bits? (O_APPEND, O_CREAT, ...)
ah, right.
> this would be much more clear and much less error-prone if
> this was done explicitely instead of with a clever hack that
> obfuscates the operation.
Agreed. Heck, for clarity I even prefer a style of if (flags == 0)
over if (!flags) but I'm probably the only one.
> Implementing it in this way
> makes it clear what to do:
>
> switch(uap->flags & O_ACCMODE) {
> case O_RDONLY:
> lowbits = FREAD;
> break;
> case O_WRONLY:
> lowbits = FWRITE;
> break;
> case O_RDWR:
> lowbits = FREAD | FWRITE;
> break;
> default:
> return EINVAL;
> }
> flags = (uap->flags & ~O_ACCMODE) | lowbits;
Would probably want to move this above the opening falloc() also.
mm