mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Replace use of stat() with fstat()
For better security.
This commit is contained in:
parent
68c78222e1
commit
0e9dbcbc77
1 changed files with 7 additions and 7 deletions
14
src/tty.c
14
src/tty.c
|
|
@ -1332,7 +1332,13 @@ static bool is_serial_device(const char *format, ...)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (stat(filename, &st) != 0)
|
||||
fd = open(filename, O_RDONLY | O_NONBLOCK | O_NOCTTY);
|
||||
if (fd == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fstat(fd, &st) == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1343,12 +1349,6 @@ static bool is_serial_device(const char *format, ...)
|
|||
return false;
|
||||
}
|
||||
|
||||
fd = open(filename, O_RDONLY | O_NONBLOCK | O_NOCTTY);
|
||||
if (fd == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure it is a tty
|
||||
status = isatty(fd);
|
||||
if (status == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue