[PATCH 1/2] Cygwin: stat(): Fix "Bad address" error on stat() for /dev/tty.

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Jul 7 09:46:15 GMT 2023


Hi Takashi,

On Jul  7 12:34, Takashi Yano wrote:
> diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
> index 18e0f3097..2aae2fd65 100644
> --- a/winsup/cygwin/dtable.cc
> +++ b/winsup/cygwin/dtable.cc
> @@ -600,7 +600,13 @@ fh_alloc (path_conv& pc)
>  	case FH_TTY:
>  	  if (!pc.isopen ())
>  	    {
> -	      fhraw = cnew_no_ctor (fhandler_console, -1);
> +	      if (CTTY_IS_VALID (myself->ctty))
> +		{
> +		  if (iscons_dev (myself->ctty))
> +		    fhraw = cnew_no_ctor (fhandler_console, -1);
> +		  else
> +		    fhraw = cnew_no_ctor (fhandler_pty_slave, -1);
> +		}

What happens if CTTY_IS_VALID fails at this point?  There's no
`else' catching that situation?

>  	      debug_printf ("not called from open for /dev/tty");
>  	    }
>  	  else if (!CTTY_IS_VALID (myself->ctty) && last_tty_dev


Thanks,
Corinna


More information about the Cygwin-patches mailing list