Fix possible NULL-pointer dereference in _stat

When given NULL pointers as buffers to _stat, return EFAULT, just as
Linux and FreeBSD. Fixes #101.
This commit is contained in:
Julian Stecklina 2012-02-08 22:57:57 +01:00 committed by Norman Feske
parent 97b978c6c8
commit a6bac95fbd
1 changed files with 5 additions and 0 deletions

View File

@ -96,6 +96,11 @@ static void _sysio_to_stat_struct(Noux::Sysio const *sysio, struct stat *buf)
static int _stat(const char *path, struct stat *buf, bool lstat = false)
{
if ((path == NULL) or (buf == NULL)) {
errno = EFAULT;
return -1;
}
Genode::strncpy(sysio()->stat_in.path, path, sizeof(sysio()->stat_in.path));
if (!noux()->syscall(Noux::Session::SYSCALL_STAT)) {