security fix: replaced strcpy with safeStrCpy from backend.c
[xboard.git] / childio.c
index 6a47d2d..e0de2b6 100644 (file)
--- a/childio.c
+++ b/childio.c
@@ -2,9 +2,10 @@
  * childio.c -- set up communication with child processes 
  *
  * Copyright 1991 by Digital Equipment Corporation, Maynard,
- * Massachusetts.  Enhancements Copyright
- * 1992-2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software
- * Foundation, Inc.
+ * Massachusetts. 
+ *
+ * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
+ * 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
  *
  * The following terms apply to Digital Equipment Corporation's copyright
  * interest in XBoard:
@@ -65,6 +66,7 @@
 
 #include "common.h"
 #include "frontend.h"
+#include "backend.h" /* for safeStrCpy */
 
 #if !USE_PTYS
 /* This code is for systems where pipes work properly */
@@ -136,7 +138,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;
 }
 
@@ -152,7 +154,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;
 }
 
@@ -168,7 +170,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;
 }