* dir.cc (dirfd): Per POSIX, return EINVAL on invalid directory stream.

(telldir): Per POSIX, return -1 and set errno to EBADF, rather than
	just returning 0, on invalid directory stream.
	* signal.cc (sigwaitinfo): Return -1, not EFAULT, when SEGV was catched.
This commit is contained in:
Corinna Vinschen 2014-08-19 19:25:54 +00:00
parent 59c3d5a1a4
commit 905a851912
3 changed files with 13 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2014-08-19 Corinna Vinschen <corinna@vinschen.de>
* dir.cc (dirfd): Per POSIX, return EINVAL on invalid directory stream.
(telldir): Per POSIX, return -1 and set errno to EBADF, rather than
just returning 0, on invalid directory stream.
* signal.cc (sigwaitinfo): Return -1, not EFAULT, when SEGV was catched.
2014-08-19 Corinna Vinschen <corinna@vinschen.de> 2014-08-19 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (enum conn_state): Add "connect_credxchg" state. * fhandler.h (enum conn_state): Add "connect_credxchg" state.

View File

@ -33,7 +33,7 @@ dirfd (DIR *dir)
return -1; return -1;
if (dir->__d_cookie != __DIRENT_COOKIE) if (dir->__d_cookie != __DIRENT_COOKIE)
{ {
set_errno (EBADF); set_errno (EINVAL);
syscall_printf ("-1 = dirfd (%p)", dir); syscall_printf ("-1 = dirfd (%p)", dir);
return -1; return -1;
} }
@ -205,7 +205,10 @@ telldir (DIR *dir)
return -1; return -1;
if (dir->__d_cookie != __DIRENT_COOKIE) if (dir->__d_cookie != __DIRENT_COOKIE)
return 0; {
set_errno (EBADF);
return -1;
}
return ((fhandler_base *) dir->__fh)->telldir (dir); return ((fhandler_base *) dir->__fh)->telldir (dir);
} }

View File

@ -564,7 +564,7 @@ sigwaitinfo (const sigset_t *set, siginfo_t *info)
myfault efault; myfault efault;
if (efault.faulted (EFAULT)) if (efault.faulted (EFAULT))
return EFAULT; return -1;
set_signal_mask (_my_tls.sigwait_mask, *set); set_signal_mask (_my_tls.sigwait_mask, *set);
sig_dispatch_pending (true); sig_dispatch_pending (true);