write: Validate file handle in write system call before accessing the writable attribute. --- firmware/common/file.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/firmware/common/file.c b/firmware/common/file.c index 9096587..5ef00ea 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -680,7 +680,9 @@ static int readwrite(int fd, void* buf, long count, bool write) ssize_t write(int fd, const void* buf, size_t count) { - if (!openfiles[fd].write) { + if (openfiles[fd].busy && !openfiles[fd].write) /* other cases handled by + readwrite() */ + { errno = EACCES; return -1; } -- 1.7.1