You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2020/12/15 22:54:07 UTC
[incubator-nuttx] branch master updated: fs: Skip call fs_checkfd
if fd < 3 in fs_fdopen
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 29c6f11 fs: Skip call fs_checkfd if fd < 3 in fs_fdopen
29c6f11 is described below
commit 29c6f112395cf45cdb5ca4b43d3f16fb8936ae5d
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Dec 15 15:46:40 2020 +0800
fs: Skip call fs_checkfd if fd < 3 in fs_fdopen
since the stdin, stdout and stderr may initialize later
in userspace if CONFIG_DEV_CONSOLE isn't enabled.
Note: it isn't bigger issue here to skip the check because
vfs will check the validation again in read and write syscall
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
fs/vfs/fs_fdopen.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/vfs/fs_fdopen.c b/fs/vfs/fs_fdopen.c
index cace0ca..4498379 100644
--- a/fs/vfs/fs_fdopen.c
+++ b/fs/vfs/fs_fdopen.c
@@ -115,7 +115,7 @@ int fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb,
{
FAR struct streamlist *slist;
FAR FILE *stream;
- int ret;
+ int ret = OK;
/* Check input parameters */
@@ -164,7 +164,7 @@ int fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb,
* more checks.
*/
- else
+ else if (fd >= 3)
{
ret = fs_checkfd(tcb, fd, oflags);
}