[BACK]Return to pty.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/Attic/pty.c between version 1.8 and 1.9

version 1.8, 1999/11/24 19:53:48 version 1.9, 1999/12/06 12:10:12
Line 36 
Line 36 
  */   */
   
 int  int
 pty_allocate(int *ptyfd, int *ttyfd, char *namebuf)  pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
 {  {
 #ifdef HAVE_OPENPTY  #if defined(HAVE_OPENPTY) || defined(BSD4_4)
         /* openpty(3) exists in OSF/1 and some other os'es */          /* openpty(3) exists in OSF/1 and some other os'es */
           char buf[64];
         int i;          int i;
   
         i = openpty(ptyfd, ttyfd, namebuf, NULL, NULL);          i = openpty(ptyfd, ttyfd, buf, NULL, NULL);
         if (i < 0) {          if (i < 0) {
                 error("openpty: %.100s", strerror(errno));                  error("openpty: %.100s", strerror(errno));
                 return 0;                  return 0;
         }          }
           strlcpy(namebuf, buf, namebuflen);      /* possible truncation */
         return 1;          return 1;
 #else /* HAVE_OPENPTY */  #else /* HAVE_OPENPTY */
 #ifdef HAVE__GETPTY  #ifdef HAVE__GETPTY
Line 61 
Line 63 
                 error("_getpty: %.100s", strerror(errno));                  error("_getpty: %.100s", strerror(errno));
                 return 0;                  return 0;
         }          }
         strcpy(namebuf, slave);          strlcpy(namebuf, slave, namebuflen);
         /* Open the slave side. */          /* Open the slave side. */
         *ttyfd = open(namebuf, O_RDWR | O_NOCTTY);          *ttyfd = open(namebuf, O_RDWR | O_NOCTTY);
         if (*ttyfd < 0) {          if (*ttyfd < 0) {
Line 95 
Line 97 
         pts = ptsname(ptm);          pts = ptsname(ptm);
         if (pts == NULL)          if (pts == NULL)
                 error("Slave pty side name could not be obtained.");                  error("Slave pty side name could not be obtained.");
         strcpy(namebuf, pts);          strlcpy(namebuf, pts, namebuflen);
         *ptyfd = ptm;          *ptyfd = ptm;
   
         /* Open the slave side. */          /* Open the slave side. */
Line 126 
Line 128 
         name = ttyname(*ptyfd);          name = ttyname(*ptyfd);
         if (!name)          if (!name)
                 fatal("Open of /dev/ptc returns device for which ttyname fails.");                  fatal("Open of /dev/ptc returns device for which ttyname fails.");
         strcpy(namebuf, name);          strlcpy(namebuf, name, namebuflen);
         *ttyfd = open(name, O_RDWR | O_NOCTTY);          *ttyfd = open(name, O_RDWR | O_NOCTTY);
         if (*ttyfd < 0) {          if (*ttyfd < 0) {
                 error("Could not open pty slave side %.100s: %.100s",                  error("Could not open pty slave side %.100s: %.100s",
Line 150 
Line 152 
                 *ptyfd = open(buf, O_RDWR | O_NOCTTY);                  *ptyfd = open(buf, O_RDWR | O_NOCTTY);
                 if (*ptyfd < 0)                  if (*ptyfd < 0)
                         continue;                          continue;
                 snprintf(namebuf, sizeof buf, "/dev/tty%c%c", ptymajors[i / num_minors],                  snprintf(namebuf, sizeof namebuflen, "/dev/tty%c%c",
                          ptyminors[i % num_minors]);                      ptymajors[i / num_minors], ptyminors[i % num_minors]);
   
                 /* Open the slave side. */                  /* Open the slave side. */
                 *ttyfd = open(namebuf, O_RDWR | O_NOCTTY);                  *ttyfd = open(namebuf, O_RDWR | O_NOCTTY);

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9