#44 isatty() crashes when passed a socket fd

closed
None
5
2008-04-28
2007-08-14
No

I found out the isatty() function crashes badly when passed a socket file descriptor.

Here is the fix I came up with:

int
isatty(int file_descriptor)
{
...
if(FLAG_IS_SET(fd->fd_Flags,FDF_IS_SOCKET))
{
__set_errno(ENOTTY);
goto out;
}

result = 1;

if(FLAG_IS_CLEAR(fd->fd_Flags,FDF_IS_INTERACTIVE))
{
BPTR file;

file = __resolve_fd_file(fd);
if(file == ZERO || NOT IsInteractive(file))
result = 0;
}

out:

__fd_unlock(fd);

__stdio_unlock();

RETURN(result);
return(result);
}

Discussion

  • Olaf Barthel

    Olaf Barthel - 2007-09-12
    • assigned_to: nobody --> obarthel
     
  • Olaf Barthel

    Olaf Barthel - 2008-04-28
    • status: open --> closed
     

Log in to post a comment.