From 86bb54fde6f3ed59050d724a7e98defd7c4f47a9 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 27 Sep 2021 06:51:40 -0400 Subject: [libc][syscalls] 在标准输入输出前加校验,反正在libc初始化之前调用printf出问题 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/dlib/syscall_read.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'components/libc/compilers/dlib/syscall_read.c') diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c index e716d0b024..bdc694b7d8 100644 --- a/components/libc/compilers/dlib/syscall_read.c +++ b/components/libc/compilers/dlib/syscall_read.c @@ -15,6 +15,10 @@ #include #include "libc.h" +#define DBG_TAG "dlib.syscall_read" +#define DBG_LVL DBG_INFO +#include + #pragma module_name = "?__read" size_t __read(int handle, unsigned char *buf, size_t len) { @@ -25,6 +29,11 @@ size_t __read(int handle, unsigned char *buf, size_t len) if (handle == _LLIO_STDIN) { #ifdef RT_USING_POSIX + if (libc_stdio_get_console() < 0) + { + LOG_E("invoke standard input before initializing libc"); + return _LLIO_ERROR; + } return read(STDIN_FILENO, buf, len); #else return _LLIO_ERROR; -- cgit v1.3.1