* exceptions.cc: Add stdlib.h include for alloca declaration.
* poll.cc: Ditto. * termios.cc: Ditto. * syscalls.cc (_write): Only allow zero length when fd is valid.
This commit is contained in:
@@ -355,12 +355,6 @@ _read (int fd, void *ptr, size_t len)
|
||||
extern "C" ssize_t
|
||||
_write (int fd, const void *ptr, size_t len)
|
||||
{
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
if (__check_invalid_read_ptr_errno (ptr, len))
|
||||
return -1;
|
||||
|
||||
int res = -1;
|
||||
|
||||
sigframe thisframe (mainthread);
|
||||
@@ -368,6 +362,16 @@ _write (int fd, const void *ptr, size_t len)
|
||||
if (cfd < 0)
|
||||
goto done;
|
||||
|
||||
/* No further action required for len == 0 */
|
||||
if (len == 0)
|
||||
{
|
||||
res = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (len && __check_invalid_read_ptr_errno (ptr, len))
|
||||
goto done;
|
||||
|
||||
/* Could block, so let user know we at least got here. */
|
||||
if (fd == 1 || fd == 2)
|
||||
paranoid_printf ("write (%d, %p, %d)", fd, ptr, len);
|
||||
|
Reference in New Issue
Block a user