summaryrefslogtreecommitdiffstats
path: root/sys/kern/link_elf_obj.c
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2000-07-04 03:34:11 +0000
committermckusick <mckusick@FreeBSD.org>2000-07-04 03:34:11 +0000
commit040e64cd9770955113ddffda73fff7b62dd5959b (patch)
tree4d2f06b02c643384c981cf2399da8d136ee8a568 /sys/kern/link_elf_obj.c
parent806786489f486969418422381048f277d86e0a20 (diff)
downloadFreeBSD-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_obj.c')
-rw-r--r--sys/kern/link_elf_obj.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
index 833f12e..18e32b2 100644
--- a/sys/kern/link_elf_obj.c
+++ b/sys/kern/link_elf_obj.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);
OpenPOWER on IntegriCloud