summaryrefslogtreecommitdiff
path: root/firmware/common
diff options
context:
space:
mode:
authorHeikki Hannikainen <hessuh@rockbox.org>2002-08-24 09:47:54 +0000
committerHeikki Hannikainen <hessuh@rockbox.org>2002-08-24 09:47:54 +0000
commitadbe4eddf918b7b617eb5bd4dda1435d5402b2c4 (patch)
tree7b59619e1a6b1a98525088f710ea777c3b614f05 /firmware/common
parentbd510c2d2be5096f83e8ee80745fe528053ac2ec (diff)
Make close() check for a valid fd and set errno accordingly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1965 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common')
-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;
}