From 5d799d27f91908d93f249e86e874b69aebb355fd Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 18 Oct 2018 14:41:47 -0700 Subject: [PATCH] Fix null test and write test issues about the stat parameter This issue may cause SegFault if pass null to state, and miss the validation by test_user_memory(...) if not null. --- LibOS/shim/src/sys/shim_stat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LibOS/shim/src/sys/shim_stat.c b/LibOS/shim/src/sys/shim_stat.c index 094a883d..8430f37d 100644 --- a/LibOS/shim/src/sys/shim_stat.c +++ b/LibOS/shim/src/sys/shim_stat.c @@ -39,7 +39,7 @@ int shim_do_stat (const char * file, struct stat * stat) if (!file || test_user_string(file)) return -EFAULT; - if (!stat && test_user_memory(stat, sizeof(*stat), true)) + if (!stat || test_user_memory(stat, sizeof(*stat), true)) return -EFAULT; int ret; @@ -67,7 +67,7 @@ int shim_do_lstat (const char * file, struct stat * stat) if (!file || test_user_string(file)) return -EFAULT; - if (!stat && test_user_memory(stat, sizeof(*stat), true)) + if (!stat || test_user_memory(stat, sizeof(*stat), true)) return -EFAULT; int ret;