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/link_elf.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/link_elf.c')
-rw-r--r-- | sys/kern/link_elf.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index 833f12e..18e32b2 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -504,7 +504,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu Elf_Addr base_vaddr; Elf_Addr base_vlimit; int error = 0; - int resid; + int resid, flags; elf_file_t ef; linker_file_t lf; Elf_Shdr *shdr; @@ -517,7 +517,8 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu lf = NULL; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, p); - error = vn_open(&nd, FREAD, 0); + flags = FREAD; + error = vn_open(&nd, &flags, 0); if (error) return error; NDFREE(&nd, NDF_ONLY_PNBUF); |