Skip to content

Commit d9e3a76

Browse files
committed
fix_fds(): check that input FDs are okay
If the file descriptor numbers were bad, a dup2() could clobber a file descriptor that gets used later.
1 parent 652b8f5 commit d9e3a76

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

libqrexec/exec.c

+5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ void exec_qubes_rpc_if_requested(const char *prog, char *const envp[]) {
8181

8282
void fix_fds(int fdin, int fdout, int fderr)
8383
{
84+
if (fdin < 0 || fdout < 1 || fderr < 2) {
85+
LOG(ERROR, "fix_fds: bad FD numbers: fdin %d, fdout %d, fderr %d",
86+
fdin, fdout, fderr);
87+
_exit(125);
88+
}
8489
int i;
8590
for (i = 3; i < 256; i++)
8691
if (i != fdin && i != fdout && i != fderr)

0 commit comments

Comments
 (0)