On Sat, 2013-01-26 at 22:57:59 +0400, Игорь Пашев wrote:
> The patch fo screen.cc [1] introduces the function CheckTtyname():
> 
>  int
>  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.

Regards,
Guillem


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20130126193939.ga10...@gaara.hadrons.org

Reply via email to