--- /dev/null
+# Sanitize.in for Kerberos V5
+
+# Each directory to survive it's way into a release will need a file
+# like this one called "./.Sanitize". All keyword lines must exist,
+# and must exist in the order specified by this file. Each directory
+# in the tree will be processed, top down, in the following order.
+
+# Hash started lines like this one are comments and will be deleted
+# before anything else is done. Blank lines will also be squashed
+# out.
+
+# The lines between the "Do-first:" line and the "Things-to-keep:"
+# line are executed as a /bin/sh shell script before anything else is
+# done in this
+
+Do-first:
+
+# All files listed between the "Things-to-keep:" line and the
+# "Files-to-sed:" line will be kept. All other files will be removed.
+# Directories listed in this section will have their own Sanitize
+# called. Directories not listed will be removed in their entirety
+# with rm -rf.
+
+Things-to-keep:
+
+.cvsignore
+ChangeLog
+Makefile.in
+configure.in
+cleanup.c
+getpty.c
+initialize_slave.c
+libpty.h
+logwtmp.c
+open_ctty.c
+open_slave.c
+pty-int.h
+pty_err.et
+update_utmp.c
+update_wtmp.c
+vhangup.c
+void_assoc.c
+
+Things-to-lose:
+
+Do-last:
+
+# End of file.
+
+Tue Aug 1 08:20:06 1995 Sam Hartman <hartmans@tertius.mit.edu>
+
+ * cleanup.c (pty_cleanup): Allow pid to be zero (unknown).
+
+ * pty-int.h: Define VHANG_FIRST and VHANG_LAST based on presence
+ of vhangup.
+
+ * pty_err.et: Define PTY_GETPTY_SLAVE_TOOLONG
+
+ * getpty.c (pty_getpty): Close slave side if we call openpty.
+
+ (pty_getpty): Take length parameter; return error if it isn't big enough.
+
+
+
Tue Aug 1 12:06:14 1995 Ezra Peisach <epeisach@kangaroo.mit.edu>
* open_ctty.c (pty_open_ctty): Fixed typo TIOCSTTY to TIOCSCTTY.
long pty_cleanup (slave, pid, update_utmp)
char *slave;
- pid_t pid;
+ pid_t pid; /* May be zero for unknown.*/
int update_utmp;
{
struct utmp ut;
#include "libpty.h"
#include "pty-int.h"
-long pty_getpty (fd, slave)
-int *fd; char *slave;
+long pty_getpty (fd, slave, slavelength)
+ int slavelength;
+ int *fd; char *slave;
{
char c;
char *p;
int i,ptynum;
struct stat stb;
+char slavebuf[1024];
+
#ifdef HAVE_OPENPTY
int slavefd;
if(openpty(fd, &slavefd, slave, (struct termios *) 0,
(struct winsize *) 0)) return 1;
+close(slavefd);
return 0;
#else
#endif
#endif
if (p) {
+ if ( strlen(p) < slavelength)
+ {
+ close (*fd);
+ *fd = -1;
+ return PTY_GETPTY_SLAVE_TOOLONG;
+ }
+
strcpy(slave, p);
return 0;
}
return PTY_GETPTY_FSTAT;
}
ptynum = (int)(stb.st_rdev&0xFF);
- sprintf(slave, "/dev/ttyp%x", ptynum);
+ sprintf(slavebuf, "/dev/ttyp%x", ptynum);
+ if ( strlen(slavebuf) < slavelength) {
+ close(*fd);
+ *fd = -1;
+ return PTY_GETPTY_SLAVE_TOOLONG;
+ }
+ strncpy ( slave, slavebuf, slavelength);
return 0;
} else {
for (c = 'p'; c <= 's'; c++) {
- sprintf(slave,"/dev/ptyXX");
- slave[strlen("/dev/pty")] = c;
- slave[strlen("/dev/ptyp")] = '0';
- if (stat(slave, &stb) < 0)
+ sprintf(slavebuf,"/dev/ptyXX");
+ slavebuf[strlen("/dev/pty")] = c;
+ slavebuf[strlen("/dev/ptyp")] = '0';
+ if (stat(slavebuf, &stb) < 0)
break;
for (i = 0; i < 16; i++) {
- slave[sizeof("/dev/ptyp") - 1] = "0123456789abcdef"[i];
- *fd = open(slave, O_RDWR);
+ slavebuf[sizeof("/dev/ptyp") - 1] = "0123456789abcdef"[i];
+ *fd = open(slavebuf, O_RDWR);
if (*fd < 0) continue;
/* got pty */
- slave[strlen("/dev/")] = 't';
+ slavebuf[strlen("/dev/")] = 't';
+ if ( strlen(slavebuf) < slavelength ) {
+ close ( *fd);
+ *fd = -1;
+return PTY_GETPTY_SLAVE_TOOLONG;
+ }
+ strncpy ( slave, slavebuf, slavelength);
+
return 0;
}
}
#ifdef __STDC__ /* use prototypes */
-long pty_getpty ( int *fd, char *slave);
+long pty_getpty ( int *fd, char *slave, int slavelength);
long pty_open_slave (const char *slave, int *fd);
long pty_open_ctty (const char *slave, int *fd);
#endif
#endif
+#if defined(HAVE_VHANGUP)
+#define VHANG_first /* may not work under Ultrix*/
+#define VHANG_LAST
+#endif
+
/* Internal functions */
#ifdef __STDC__
long ptyint_void_association(void);
error_code PTY_GETPTY_NOPTY, "All terminal ports in use"
+error_code PTY_GETPTY_SLAVE_TOOLONG, "buffer to hold slave pty name is too short"
+
error_code PTY_OPEN_SLAVE_OPENFAIL, "Failed to open slave side of pty"
error_code PTY_OPEN_SLAVE_CHMODFAIL, "Failed to chmod slave side of pty"