From fdca30279f2ac4e63d8f49ff7af6a37ebcdbba42 Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Wed, 2 Aug 1995 17:20:59 +0000 Subject: [PATCH] * Fix tests for length of slave buffer. * Add pty_init to initialize error tables. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6379 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/pty/.Sanitize | 1 + src/util/pty/ChangeLog | 5 +++++ src/util/pty/Makefile.in | 7 ++++--- src/util/pty/getpty.c | 4 ++-- src/util/pty/init.c | 29 +++++++++++++++++++++++++++++ src/util/pty/libpty.h | 2 ++ src/util/pty/pty-int.h | 5 ++++- 7 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 src/util/pty/init.c diff --git a/src/util/pty/.Sanitize b/src/util/pty/.Sanitize index b50536221..d988ede18 100644 --- a/src/util/pty/.Sanitize +++ b/src/util/pty/.Sanitize @@ -31,6 +31,7 @@ cleanup.c getpty.c initialize_slave.c libpty.h +init.c logwtmp.c open_ctty.c open_slave.c diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog index 190e05ca4..0a4c2cf9f 100644 --- a/src/util/pty/ChangeLog +++ b/src/util/pty/ChangeLog @@ -1,3 +1,8 @@ +Wed Aug 2 11:59:19 1995 Sam Hartman + + * init.c (pty_init): New file to handle initialization--currently only error tables. + + * getpty.c (pty_getpty): Reverse sense of logic tests so they work. Tue Aug 1 08:20:06 1995 Sam Hartman diff --git a/src/util/pty/Makefile.in b/src/util/pty/Makefile.in index 1e6545888..d80a81579 100644 --- a/src/util/pty/Makefile.in +++ b/src/util/pty/Makefile.in @@ -6,7 +6,8 @@ SED = sed $(CC) $(CFLAGS) -c $(srcdir)/$*.c -LIBOBJS= cleanup.o getpty.o initialize_slave.o open_ctty.o open_slave.o update_utmp.o update_wtmp.o vhangup.o void_assoc.o pty_err.o logwtmp.o +LIBOBJS= cleanup.o getpty.o initialize_slave.o open_ctty.o open_slave.o \ + update_utmp.o update_wtmp.o vhangup.o void_assoc.o pty_err.o logwtmp.o init.o LIBDONE=DONE LIB_SUBDIRS=. @@ -16,10 +17,10 @@ INSTALLFILE = cp LOCALINCLUDE=-I. -I$(srcdir) FILES= Makefile cleanup.c getpty.c initialize_slave.c open_ctty.c open_slave.c update_utmp.c update_wtmp.c vhangup.c void_assoc.c pty_err.h pty_err.c\ -logwtmp.c +logwtmp.c init.c CFILES=cleanup.c getpty.c initialize_slave.c open_ctty.c open_slave.c\ -update_utmp.c update_wtmp.c vhangup.c void_assoc.c pty_err.c logwtmp.c +update_utmp.c update_wtmp.c vhangup.c void_assoc.c pty_err.c logwtmp.c init.c SRCS=pty_err.h $(CFILES) diff --git a/src/util/pty/getpty.c b/src/util/pty/getpty.c index 7968e4256..b0eb602a7 100644 --- a/src/util/pty/getpty.c +++ b/src/util/pty/getpty.c @@ -63,7 +63,7 @@ close(slavefd); #endif #endif if (p) { - if ( strlen(p) < slavelength) + if ( strlen(p) > slavelength) { close (*fd); *fd = -1; @@ -80,7 +80,7 @@ close(slavefd); } ptynum = (int)(stb.st_rdev&0xFF); sprintf(slavebuf, "/dev/ttyp%x", ptynum); - if ( strlen(slavebuf) < slavelength) { + if ( strlen(slavebuf) > slavelength) { close(*fd); *fd = -1; return PTY_GETPTY_SLAVE_TOOLONG; diff --git a/src/util/pty/init.c b/src/util/pty/init.c new file mode 100644 index 000000000..40cf2396b --- /dev/null +++ b/src/util/pty/init.c @@ -0,0 +1,29 @@ +/* + * pty_init: Initialize internal state of pty. + * Currently initializes error tables. + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * + *Permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + */ + +#include "mit-copyright.h" +#include +#include "libpty.h" +#include "pty-int.h" + +long pty_init() +{ + initialize_pty_error_table(); + return 0; +} diff --git a/src/util/pty/libpty.h b/src/util/pty/libpty.h index b8e9a5aa4..685ce61bd 100644 --- a/src/util/pty/libpty.h +++ b/src/util/pty/libpty.h @@ -24,6 +24,7 @@ #ifdef __STDC__ /* use prototypes */ +long pty_init(void); long pty_getpty ( int *fd, char *slave, int slavelength); long pty_open_slave (const char *slave, int *fd); @@ -37,6 +38,7 @@ long pty_logwtmp (char *tty, char * user, char *host); long pty_cleanup(char *slave, int pid, int update_utmp); #else /*__STDC__*/ +long pty_init(); long pty_getpty(); long pty_open_slave(); diff --git a/src/util/pty/pty-int.h b/src/util/pty/pty-int.h index 95d5dd220..675079259 100644 --- a/src/util/pty/pty-int.h +++ b/src/util/pty/pty-int.h @@ -1,6 +1,7 @@ /* Includes needed by libpty*/ #ifndef __PTY_INT_H__ #include +#include #ifdef HAVE_UNISTD_H #include #endif @@ -12,7 +13,7 @@ #endif #include -#include + #include #include #include @@ -83,6 +84,7 @@ /* Internal functions */ #ifdef __STDC__ +void initialize_pty_error_table(void); long ptyint_void_association(void); long ptyint_open_ctty (char *slave, int *fd); void ptyint_vhangup(void); @@ -90,6 +92,7 @@ void ptyint_vhangup(void); long ptyint_void_association(); void ptyint_vhangup(); +void initialize_pty_error_table(); #endif /* __STDC__*/ #define __PTY_INT_H__ -- 2.26.2