X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=childio.c;h=43818894b552d869d1a674c3b00d7ee34481353d;hb=55d82733a8c6a6e29280bb6413fb2037cbcd381b;hp=7fd3d148135204fe438e111584508700db0f897d;hpb=05bc30b15e31c427ce208495a889e9ff36e6642b;p=xboard.git diff --git a/childio.c b/childio.c index 7fd3d14..4381889 100644 --- a/childio.c +++ b/childio.c @@ -1,9 +1,11 @@ /* - * childio.c -- set up communication with child processes $Id: - * childio.c,v 1.2 1994/11/12 19:31:41 mann Exp mann $ + * childio.c -- set up communication with child processes * - * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. - * Enhancements Copyright 1992-95 Free Software Foundation, Inc. + * Copyright 1991 by Digital Equipment Corporation, Maynard, + * Massachusetts. + * + * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, + * 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. * * The following terms apply to Digital Equipment Corporation's copyright * interest in XBoard: @@ -27,25 +29,25 @@ * SOFTWARE. * ------------------------------------------------------------------------ * - * The following terms apply to the enhanced version of XBoard distributed - * by the Free Software Foundation: + * The following terms apply to the enhanced version of XBoard + * distributed by the Free Software Foundation: * ------------------------------------------------------------------------ - * This program is free software; you can redistribute it and/or modify + * + * GNU XBoard is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU XBoard is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * ------------------------------------------------------------------------ + * along with this program. If not, see http://www.gnu.org/licenses/. * * - * See the file ChangeLog for a revision history. */ + *------------------------------------------------------------------------ + ** See the file ChangeLog for a revision history. */ /* This file splits into two entirely different pieces of code depending on whether USE_PTYS is 1. The whole reason for all @@ -57,6 +59,7 @@ #include "config.h" +#include #include #if HAVE_UNISTD_H # include @@ -64,6 +67,7 @@ #include "common.h" #include "frontend.h" +#include "backend.h" /* for safeStrCpy */ #if !USE_PTYS /* This code is for systems where pipes work properly */ @@ -135,7 +139,7 @@ int PseudoTTY(pty_name) if (grantpt(fd) == -1) return -1; if (unlockpt(fd) == -1) return -1; if (!(ptss = ptsname(fd))) return -1; - strcpy(pty_name, ptss); + safeStrCpy(pty_name, ptss, sizeof(pty_name)/sizeof(pty_name[0])); return fd; } @@ -151,7 +155,7 @@ int PseudoTTY(pty_name) ptyn = _getpty(&fd, O_RDWR, 0600, 0); if (ptyn == NULL) return -1; - strcpy(pty_name, ptyn); + safeStrCpy(pty_name, ptyn, sizeof(pty_name)/sizeof(pty_name[0])); return fd; } @@ -167,7 +171,7 @@ int PseudoTTY(pty_name) fd = getpseudotty(&slave, &master); if (fd < 0) return fd; - strcpy(pty_name, slave); + safeStrCpy(pty_name, slave, sizeof(pty_name)/sizeof(pty_name[0])); return fd; } @@ -206,7 +210,7 @@ int PseudoTTY(pty_name) #ifdef PTY_NAME_SPRINTF PTY_NAME_SPRINTF #else - sprintf (pty_name, "/dev/pty%c%x", c, i); + sprintf (pty_name, "/dev/pty%c%x", c, i); #endif /* no PTY_NAME_SPRINTF */ #ifdef PTY_OPEN @@ -230,7 +234,7 @@ int PseudoTTY(pty_name) #ifdef PTY_TTY_NAME_SPRINTF PTY_TTY_NAME_SPRINTF #else - sprintf (pty_name, "/dev/tty%c%x", c, i); + sprintf (pty_name, "/dev/tty%c%x", c, i); #endif /* no PTY_TTY_NAME_SPRINTF */ #ifndef UNIPLUS if (access (pty_name, 6) != 0)