|
From: John R. <jr...@Bi...> - 2003-12-27 15:29:09
|
> It would be nice if valgrind reported any fd > 2 when: system(),
> popen(), or exec() was called. This is almost always a security
> problem.
gdb 5.3 uses two fds when creating a process. The program below outputs
3 4 5 6 7 8 9 10 11 12
when run from a usual login shell, but it prints
5 6 7 8 9 10 11 12 13 14
when run from gdb. So "almost always a security problem"
might not apply in this case, and the documentation/FAQ
probably should mention it. Also, there is a coding paradigm which
uses fd 3 as "cmdin" ["command in", for interactive/supervisory
input when stdin already has a data-stream input].
cmdin is to stdin as stderr is to stdout, sort of.
===== fd_next.c
#include <unistd.h>
#include <stdio.h>
main()
{
int j;
int fd[10];
pipe(&fd[0]);
pipe(&fd[2]);
pipe(&fd[4]);
pipe(&fd[6]);
pipe(&fd[8]);
for (j=0; j<10; ++j) {
printf(" %d", fd[j]);
}
printf("\n");
return 0;
}
=====
|