!456 fix: nanosleep 接口的rmtp参数被错误清零

Merge pull request !456 from zhushengle/nanosleep
This commit is contained in:
openharmony_ci 2021-07-23 06:24:31 +00:00 committed by Gitee
commit a531bcf389
1 changed files with 6 additions and 1 deletions

View File

@ -356,13 +356,18 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
{
int ret;
struct timespec srqtp;
struct timespec srmtp = { 0 };
struct timespec srmtp;
if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) {
errno = EFAULT;
return -EFAULT;
}
if (rmtp && LOS_ArchCopyFromUser(&srmtp, rmtp, sizeof(struct timespec))) {
errno = EFAULT;
return -EFAULT;
}
ret = nanosleep(&srqtp, rmtp ? &srmtp : NULL);
if (ret < 0) {
return -get_errno();