Re: screen says "Bad tty" if /dev/console is a symlink
On Sat, 2013-01-26 at 22:57:59 +0400, Игорь Пашев wrote:
> The patch fo screen.cc  introduces the function CheckTtyname():
> CheckTtyname (tty)
> char *tty;
> struct stat st;
> if (lstat(tty, &st) || !S_ISCHR(st.st_mode) ||
> (st.st_nlink > 1 && strncmp(tty, "/dev/", 5)))
> return -1;
> return 0;
> Does it make sense to replace lstat() with stat()?
Yes, that makes sense, but reading into the intention of the function
that would defeat the check on the actual name, so for that latter
check to also make sense you'd have to dereference the path before
doing the strncmp(), at which point using lstat() on the dereferenced
path would be fine again.