diff options
author | Anton Kling <anton@kling.gg> | 2024-04-17 23:15:36 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-04-17 23:15:36 +0200 |
commit | e8deee43bc0a8a9bf7664485bb0ce3b886189dae (patch) | |
tree | d6e2c2da813d2ca549cf512604d6560579dac2f4 /kernel | |
parent | b913a159103bedec035207fe4d84c9ad9c313517 (diff) |
VFS/LibC: Fix small bugs
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/fs/vfs.c | 6 | ||||
-rw-r--r-- | kernel/random.c | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/kernel/fs/vfs.c b/kernel/fs/vfs.c index 8ae2b1f..bcc0ce5 100644 --- a/kernel/fs/vfs.c +++ b/kernel/fs/vfs.c @@ -9,6 +9,10 @@ vfs_mounts_t mounts[10]; int num_mounts = 0; vfs_fd_t *get_vfs_fd(int fd, process_t *p) { + if (fd < 0) { + return NULL; + } + if (!p) { p = current_task; } @@ -265,7 +269,7 @@ int vfs_open(const char *file, int flags, int mode) { vfs_resolve_path(file, resolved_path); vfs_inode_t *inode = vfs_internal_open(resolved_path); if (0 == inode) { - if (mode & O_CREAT) { + if (flags & O_CREAT) { if (vfs_create_file(resolved_path)) { klog("VFS: File created", LOG_NOTE); return vfs_open(file, flags, mode); diff --git a/kernel/random.c b/kernel/random.c index bb28606..38924ce 100644 --- a/kernel/random.c +++ b/kernel/random.c @@ -1,4 +1,5 @@ // FIXME: This is mostlikely incredibly inefficent and insecure. +#include <assert.h> #include <crypto/ChaCha20/chacha20.h> #include <crypto/SHA1/sha1.h> #include <crypto/xoshiro256plusplus/xoshiro256plusplus.h> |