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_ktrace.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_ktrace.c')
-rw-r--r-- | sys/kern/kern_ktrace.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 22f04e0..14cc719 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -253,7 +253,7 @@ ktrace(curp, uap) int ops = KTROP(uap->ops); int descend = uap->ops & KTRFLAG_DESCEND; int ret = 0; - int error = 0; + int flags, error = 0; struct nameidata nd; curp->p_traceflag |= KTRFAC_ACTIVE; @@ -262,7 +262,8 @@ ktrace(curp, uap) * an operation which requires a file argument. */ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->fname, curp); - error = vn_open(&nd, FREAD|FWRITE|O_NOFOLLOW, 0); + flags = FREAD | FWRITE | O_NOFOLLOW; + error = vn_open(&nd, &flags, 0); if (error) { curp->p_traceflag &= ~KTRFAC_ACTIVE; return (error); |