diff options
author | mckusick <mckusick@FreeBSD.org> | 2000-07-04 03:34:11 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2000-07-04 03:34:11 +0000 |
commit | 040e64cd9770955113ddffda73fff7b62dd5959b (patch) | |
tree | 4d2f06b02c643384c981cf2399da8d136ee8a568 /sys/kern/kern_sig.c | |
parent | 806786489f486969418422381048f277d86e0a20 (diff) | |
download | FreeBSD-src-040e64cd9770955113ddffda73fff7b62dd5959b.zip FreeBSD-src-040e64cd9770955113ddffda73fff7b62dd5959b.tar.gz |
Move the truncation code out of vn_open and into the open system call
after the acquisition of any advisory locks. This fix corrects a case
in which a process tries to open a file with a non-blocking exclusive
lock. Even if it fails to get the lock it would still truncate the
file even though its open failed. With this change, the truncation
is done only after the lock is successfully acquired.
Obtained from: BSD/OS
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r-- | sys/kern/kern_sig.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 7702aba..e96f471 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1598,7 +1598,7 @@ coredump(p) register struct ucred *cred = p->p_ucred; struct nameidata nd; struct vattr vattr; - int error, error1; + int error, error1, flags; char *name; /* name of corefile */ off_t limit; @@ -1621,7 +1621,8 @@ coredump(p) name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid); NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p); - error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR); + flags = O_CREAT | FWRITE | O_NOFOLLOW; + error = vn_open(&nd, &flags, S_IRUSR | S_IWUSR); free(name, M_TEMP); if (error) return (error); |