From 20263be18001586a928477ae46388c3cdfadf230 Mon Sep 17 00:00:00 2001 From: Shell Date: Tue, 12 Nov 2024 21:11:50 +0800 Subject: [PATCH] fixup: smart: uninitialized buffer on mount(2) (#9636) The `struct stat` object used inside mount(2) is uninitialized, which can lead to undefined behavior during running Changes: - Set zero to buffer before calling to stat() Signed-off-by: Shell --- components/lwp/lwp_syscall.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 6e99abe8a7..0bfaff62ad 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -5767,6 +5767,7 @@ sysret_t sys_mount(char *source, char *target, size_t len_filesystemtype, copy_len_filesystemtype; char *tmp = NULL; int ret = 0; + struct stat buf = {0}; len_source = lwp_user_strlen(source); if (len_source <= 0) @@ -5805,8 +5806,6 @@ sysret_t sys_mount(char *source, char *target, copy_source = NULL; } - struct stat buf; - if (copy_source && stat(copy_source, &buf) && S_ISBLK(buf.st_mode)) { char *dev_fullpath = dfs_normalize_path(RT_NULL, copy_source);