Skip to content

Commit 20263be

Browse files
authored
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 <[email protected]>
1 parent ddf42ba commit 20263be

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

components/lwp/lwp_syscall.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5767,6 +5767,7 @@ sysret_t sys_mount(char *source, char *target,
57675767
size_t len_filesystemtype, copy_len_filesystemtype;
57685768
char *tmp = NULL;
57695769
int ret = 0;
5770+
struct stat buf = {0};
57705771

57715772
len_source = lwp_user_strlen(source);
57725773
if (len_source <= 0)
@@ -5805,8 +5806,6 @@ sysret_t sys_mount(char *source, char *target,
58055806
copy_source = NULL;
58065807
}
58075808

5808-
struct stat buf;
5809-
58105809
if (copy_source && stat(copy_source, &buf) && S_ISBLK(buf.st_mode))
58115810
{
58125811
char *dev_fullpath = dfs_normalize_path(RT_NULL, copy_source);

0 commit comments

Comments
 (0)