Don't add VAPPEND if the file is not being opened for writing. Note that this

only affects cases where open(2) is being used improperly - i.e. when the user
specifies O_APPEND without O_WRONLY or O_RDWR.

Reviewed by:	rwatson
This commit is contained in:
Edward Tomasz Napierala 2009-12-08 20:47:10 +00:00
parent 259100de20
commit 9d7031a6d6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=200273
2 changed files with 2 additions and 2 deletions

View File

@ -4426,7 +4426,7 @@ fhopen(td, uap)
}
if (fmode & FREAD)
accmode |= VREAD;
if (fmode & O_APPEND)
if ((fmode & O_APPEND) && (fmode & FWRITE))
accmode |= VAPPEND;
#ifdef MAC
error = mac_vnode_check_open(td->td_ucred, vp, accmode);

View File

@ -212,7 +212,7 @@ vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags,
accmode |= VREAD;
if (fmode & FEXEC)
accmode |= VEXEC;
if (fmode & O_APPEND)
if ((fmode & O_APPEND) && (fmode & FWRITE))
accmode |= VAPPEND;
#ifdef MAC
error = mac_vnode_check_open(cred, vp, accmode);