summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/common/file.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c
index c5f4cd5f5e..2c00c3e3f6 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -122,6 +122,14 @@ int open(char* pathname, int flags)
int close(int fd)
{
+ if (fd < 0 || fd > MAX_OPEN_FILES-1) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (!openfiles[fd].busy) {
+ errno = EBADF;
+ return -1;
+ }
openfiles[fd].busy = false;
return 0;
}