Commit c792dba
fs: Start FD values at 3
The file descriptors with values 0, 1 and 2 are reserved respectively
for the standard input, the standard output, and the error output.
Having the filesystem code allocate FD values starting from 0 was pretty
dangerous; case in point, the PTY driver would open /pty/sl00 and get
the file descriptor 0, and doing so, mapping /pty/sl00 to the standard
input, even though the PTY code did not explicitly set that up.
The simpler fix is just to start the FD values at 3. To avoid changing
behaviour, the PTY driver will now also dup2() the opened PTY file to
the stdin FD.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>1 parent 35d8e02 commit c792dba
2 files changed
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
| 184 | + | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
| |||
0 commit comments