]> git.ozlabs.org Git - ppp.git/commitdiff
fix a bug reported by Morgan Nelson.
authorAlexandr D. Kanevskiy <kad@blackcatlinux.com>
Tue, 23 Sep 2003 15:11:58 +0000 (15:11 +0000)
committerAlexandr D. Kanevskiy <kad@blackcatlinux.com>
Tue, 23 Sep 2003 15:11:58 +0000 (15:11 +0000)
Confirmed on RedHat/ASPLinux 9

pppd/main.c

index 640782ad6f35d03b02f08d583733669734943acd..4171accd7204b1dc1c64c2f12829d7042857c1c5 100644 (file)
@@ -40,7 +40,7 @@
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#define RCSID  "$Id: main.c,v 1.128 2003/06/11 23:56:26 paulus Exp $"
+#define RCSID  "$Id: main.c,v 1.129 2003/09/23 15:11:58 kad Exp $"
 
 #include <stdio.h>
 #include <ctype.h>
 
 #include <stdio.h>
 #include <ctype.h>
@@ -1503,6 +1503,7 @@ device_script(program, in, out, dont_wait)
     int pid;
     int status = -1;
     int errfd;
     int pid;
     int status = -1;
     int errfd;
+    int fd;
 
     ++conn_running;
     pid = safe_fork();
 
     ++conn_running;
     pid = safe_fork();
@@ -1530,6 +1531,14 @@ device_script(program, in, out, dont_wait)
 
     /* here we are executing in the child */
 
 
     /* here we are executing in the child */
 
+    /* make sure fds 0, 1, 2 are occupied */
+    while ((fd = dup(in)) >= 0) {
+        if (fd > 2) {
+           close(fd);
+           break;
+       }
+    }
+
     /* dup in and out to fds > 2 */
     {
        int fd1 = in, fd2 = out, fd3 = log_to_fd;
     /* dup in and out to fds > 2 */
     {
        int fd1 = in, fd2 = out, fd3 = log_to_fd;