summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-04-26 14:25:49 -0400
committerIan Moffett <ian@osmora.org>2024-04-26 14:25:49 -0400
commit5bc15a222694d30f62721eecb3d99b7be006f971 (patch)
tree7351970b035eee2b77faf7c1173c90f4c8f14c05
parent28990d31ab8425bdc75d2fec8becc0a993cd2250 (diff)
kernel: filedesc: Ensure write() fd is correct
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/kern/kern_filedesc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/kern_filedesc.c b/sys/kern/kern_filedesc.c
index b95d123..7e65d77 100644
--- a/sys/kern/kern_filedesc.c
+++ b/sys/kern/kern_filedesc.c
@@ -242,6 +242,10 @@ write(int fd, const void *buf, size_t count)
}
desc = fd_from_fdnum(td, fd);
+ if (desc == NULL) {
+ return -EBADF;
+ }
+
if (desc->oflag != O_WRONLY && desc->oflag != O_WRONLY) {
ret = -EACCES;
goto cleanup;