fix sys_getcwd (#8852)

This commit is contained in:
xiao-mang 2024-04-25 18:28:53 +08:00 committed by GitHub
parent be97a8ef25
commit 75f41723cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 3 deletions

View File

@ -4718,9 +4718,10 @@ __exit:
} }
#endif #endif
char *sys_getcwd(char *buf, size_t size) long sys_getcwd(char *buf, size_t size)
{ {
char *tmp, *ret = RT_NULL; char *tmp = RT_NULL;
long ret = -1;
if (!lwp_user_accessable((void *)buf, size)) if (!lwp_user_accessable((void *)buf, size))
{ {
@ -4737,7 +4738,10 @@ char *sys_getcwd(char *buf, size_t size)
{ {
if (lwp_put_to_user(buf, tmp, size) > 0) if (lwp_put_to_user(buf, tmp, size) > 0)
{ {
ret = buf; if (buf != RT_NULL)
ret = strlen(buf);
else
ret = -EFAULT;
} }
} }