mirror of
https://github.com/Dasharo/zephyr.git
synced 2026-03-06 14:57:20 -08:00
lib: libc: newlib: Fix userspace write() and read() mishap
The commit 4344e27c26 changed the syscall
function invocation in the `write()` and `read()` functions to the
direct syscall implementation function invocation by mistake.
The newlib `write()` and `read()` functions must call the
`z_zephyr_write_stdout()` and `z_zephyr_read_stdin()` syscall functions
in order to function properly in a user mode context.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
committed by
Christopher Friedt
parent
30db452aec
commit
eab7ae922a
@@ -178,7 +178,7 @@ void __stdin_hook_install(unsigned char (*hook)(void))
|
||||
_stdin_hook = hook;
|
||||
}
|
||||
|
||||
int z_impl_zephyr_read_stdin(char *buf, int nbytes)
|
||||
int z_impl_z_zephyr_read_stdin(char *buf, int nbytes)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -196,12 +196,12 @@ int z_impl_zephyr_read_stdin(char *buf, int nbytes)
|
||||
static inline int z_vrfy_z_zephyr_read_stdin(char *buf, int nbytes)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(buf, nbytes));
|
||||
return z_impl_zephyr_read_stdin((char *)buf, nbytes);
|
||||
return z_impl_z_zephyr_read_stdin((char *)buf, nbytes);
|
||||
}
|
||||
#include <syscalls/z_zephyr_read_stdin_mrsh.c>
|
||||
#endif
|
||||
|
||||
int z_impl_zephyr_write_stdout(const void *buffer, int nbytes)
|
||||
int z_impl_z_zephyr_write_stdout(const void *buffer, int nbytes)
|
||||
{
|
||||
const char *buf = buffer;
|
||||
int i;
|
||||
@@ -219,7 +219,7 @@ int z_impl_zephyr_write_stdout(const void *buffer, int nbytes)
|
||||
static inline int z_vrfy_z_zephyr_write_stdout(const void *buf, int nbytes)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_READ(buf, nbytes));
|
||||
return z_impl_zephyr_write_stdout((const void *)buf, nbytes);
|
||||
return z_impl_z_zephyr_write_stdout((const void *)buf, nbytes);
|
||||
}
|
||||
#include <syscalls/z_zephyr_write_stdout_mrsh.c>
|
||||
#endif
|
||||
@@ -229,7 +229,7 @@ int _read(int fd, char *buf, int nbytes)
|
||||
{
|
||||
ARG_UNUSED(fd);
|
||||
|
||||
return z_impl_zephyr_read_stdin(buf, nbytes);
|
||||
return z_zephyr_read_stdin(buf, nbytes);
|
||||
}
|
||||
__weak FUNC_ALIAS(_read, read, int);
|
||||
|
||||
@@ -237,7 +237,7 @@ int _write(int fd, const void *buf, int nbytes)
|
||||
{
|
||||
ARG_UNUSED(fd);
|
||||
|
||||
return z_impl_zephyr_write_stdout(buf, nbytes);
|
||||
return z_zephyr_write_stdout(buf, nbytes);
|
||||
}
|
||||
__weak FUNC_ALIAS(_write, write, int);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user