merge strcpy_truncate branch
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5027 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -122,11 +122,11 @@ void start_login (char *host, int autologin, char *name);
|
||||
void cleanup (int sig);
|
||||
int main (int argc, char **argv);
|
||||
void usage (void);
|
||||
int getterminaltype (char *name);
|
||||
int getterminaltype (char *name, size_t);
|
||||
void _gettermname (void);
|
||||
int terminaltypeok (char *s);
|
||||
void doit (struct sockaddr_in *who);
|
||||
void telnet (int f, int p, char*, int, char*);
|
||||
void my_telnet (int f, int p, char*, int, char*);
|
||||
void interrupt (void);
|
||||
void sendbrk (void);
|
||||
void sendsusp (void);
|
||||
@@ -150,7 +150,7 @@ void putf (char *cp, char *where);
|
||||
void printoption (char *fmt, int option);
|
||||
void printsub (int direction, unsigned char *pointer, int length);
|
||||
void printdata (char *tag, char *ptr, int cnt);
|
||||
|
||||
int login_tty(int t);
|
||||
|
||||
#ifdef ENCRYPTION
|
||||
extern void (*encrypt_output) (unsigned char *, int);
|
||||
|
@@ -360,7 +360,7 @@ char *line = Xline;
|
||||
char myline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
#endif /* CRAY */
|
||||
|
||||
#ifndef HAVE_PTSNAME
|
||||
#if !defined(HAVE_PTSNAME) && defined(STREAMSPTY)
|
||||
static char *ptsname(int fd)
|
||||
{
|
||||
#ifdef HAVE_TTYNAME
|
||||
@@ -388,7 +388,7 @@ int getpty(int *ptynum)
|
||||
p = _getpty(&master, O_RDWR, 0600, 1);
|
||||
if(p == NULL)
|
||||
return -1;
|
||||
strcpy(line, p);
|
||||
strcpy_truncate(line, p, sizeof(Xline));
|
||||
return master;
|
||||
#else
|
||||
|
||||
@@ -420,7 +420,7 @@ int getpty(int *ptynum)
|
||||
#ifdef HAVE_UNLOCKPT
|
||||
unlockpt(p);
|
||||
#endif
|
||||
strcpy(line, ptsname(p));
|
||||
strcpy_truncate(line, ptsname(p), sizeof(Xline));
|
||||
really_stream = 1;
|
||||
return p;
|
||||
}
|
||||
@@ -1087,6 +1087,7 @@ clean_ttyname (char *tty)
|
||||
* Generate a name usable as an `ut_id', typically without `tty'.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_UT_ID
|
||||
static char *
|
||||
make_id (char *tty)
|
||||
{
|
||||
@@ -1098,6 +1099,7 @@ make_id (char *tty)
|
||||
res += 3;
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* startslave(host)
|
||||
@@ -1190,7 +1192,7 @@ init_env(void)
|
||||
char **envp;
|
||||
|
||||
envp = envinit;
|
||||
if (*envp = getenv("TZ"))
|
||||
if ((*envp = getenv("TZ")))
|
||||
*envp++ -= 3;
|
||||
#if defined(_CRAY) || defined(__hpux)
|
||||
else
|
||||
@@ -1392,7 +1394,7 @@ rmut(void)
|
||||
utmpx.ut_type = LOGIN_PROCESS;
|
||||
utxp = getutxline(&utmpx);
|
||||
if (utxp) {
|
||||
strcpy(utxp->ut_user, "");
|
||||
utxp->ut_user[0] = '\0';
|
||||
utxp->ut_type = DEAD_PROCESS;
|
||||
#ifdef HAVE_UT_EXIT
|
||||
#ifdef _STRUCT___EXIT_STATUS
|
||||
|
@@ -275,7 +275,7 @@ int main(int argc, char **argv)
|
||||
#endif /* CRAY */
|
||||
|
||||
case 'S':
|
||||
#ifdef HAS_GETTOS
|
||||
#ifdef HAVE_PARSETOS
|
||||
if ((tos = parsetos(optarg, "tcp")) < 0)
|
||||
fprintf(stderr, "%s%s%s\n",
|
||||
"telnetd: Bad TOS argument '", optarg,
|
||||
@@ -329,7 +329,7 @@ int main(int argc, char **argv)
|
||||
argv += optind;
|
||||
|
||||
if (debug) {
|
||||
int port;
|
||||
int port = 0;
|
||||
struct servent *sp;
|
||||
|
||||
if (argc > 1) {
|
||||
@@ -423,7 +423,7 @@ int main(int argc, char **argv)
|
||||
|
||||
#if defined(IPPROTO_IP) && defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
|
||||
{
|
||||
# ifdef HAS_GETTOS
|
||||
# ifdef HAVE_GETTOSBYNAME
|
||||
struct tosent *tp;
|
||||
if (tos < 0 && (tp = gettosbyname("telnet", "tcp")))
|
||||
tos = tp->t_tos;
|
||||
@@ -440,6 +440,7 @@ int main(int argc, char **argv)
|
||||
net = 0;
|
||||
doit(&from);
|
||||
/* NOTREACHED */
|
||||
return 0;
|
||||
} /* end of main */
|
||||
|
||||
void
|
||||
@@ -463,7 +464,7 @@ usage()
|
||||
fprintf(stderr, " [-r[lowpty]-[highpty]]");
|
||||
#endif
|
||||
fprintf(stderr, "\n\t");
|
||||
#ifdef HAS_GETTOS
|
||||
#ifdef HAVE_GETTOSBYNAME
|
||||
fprintf(stderr, " [-S tos]");
|
||||
#endif
|
||||
#ifdef AUTHENTICATION
|
||||
@@ -485,7 +486,7 @@ static unsigned char ttytype_sbbuf[] = {
|
||||
};
|
||||
|
||||
int
|
||||
getterminaltype(char *name)
|
||||
getterminaltype(char *name, size_t name_sz)
|
||||
{
|
||||
int retval = -1;
|
||||
void _gettermname();
|
||||
@@ -499,7 +500,7 @@ getterminaltype(char *name)
|
||||
while (his_will_wont_is_changing(TELOPT_AUTHENTICATION))
|
||||
ttloop();
|
||||
if (his_state_is_will(TELOPT_AUTHENTICATION)) {
|
||||
retval = auth_wait(name);
|
||||
retval = auth_wait(name, name_sz);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -593,12 +594,12 @@ getterminaltype(char *name)
|
||||
* we have to just go with what we (might) have already gotten.
|
||||
*/
|
||||
if (his_state_is_will(TELOPT_TTYPE) && !terminaltypeok(terminaltype)) {
|
||||
strncpy(first, terminaltype, sizeof(first));
|
||||
strcpy_truncate(first, terminaltype, sizeof(first));
|
||||
for(;;) {
|
||||
/*
|
||||
* Save the unknown name, and request the next name.
|
||||
*/
|
||||
strncpy(last, terminaltype, sizeof(last));
|
||||
strcpy_truncate(last, terminaltype, sizeof(last));
|
||||
_gettermname();
|
||||
if (terminaltypeok(terminaltype))
|
||||
break;
|
||||
@@ -661,7 +662,7 @@ char remote_host_name[MaxHostNameLen];
|
||||
void
|
||||
doit(struct sockaddr_in *who)
|
||||
{
|
||||
char *host;
|
||||
char *host = NULL;
|
||||
struct hostent *hp;
|
||||
int level;
|
||||
int ptynum;
|
||||
@@ -707,8 +708,7 @@ Please contact your net administrator");
|
||||
* We must make a copy because Kerberos is probably going
|
||||
* to also do a gethost* and overwrite the static data...
|
||||
*/
|
||||
strncpy(remote_host_name, host, sizeof(remote_host_name)-1);
|
||||
remote_host_name[sizeof(remote_host_name)-1] = 0;
|
||||
strcpy_truncate(remote_host_name, host, sizeof(remote_host_name));
|
||||
host = remote_host_name;
|
||||
|
||||
/* XXX - should be k_gethostname? */
|
||||
@@ -732,9 +732,9 @@ Please contact your net administrator");
|
||||
* If hostname still doesn't fit utmp, use ipaddr.
|
||||
*/
|
||||
if (strlen(remote_host_name) > abs(utmp_len))
|
||||
strncpy(remote_host_name,
|
||||
strcpy_truncate(remote_host_name,
|
||||
inet_ntoa(who->sin_addr),
|
||||
sizeof(remote_host_name)-1);
|
||||
sizeof(remote_host_name));
|
||||
|
||||
#ifdef AUTHENTICATION
|
||||
auth_encrypt_init(hostname, host, "TELNETD", 1);
|
||||
@@ -745,7 +745,7 @@ Please contact your net administrator");
|
||||
* get terminal type.
|
||||
*/
|
||||
*user_name = 0;
|
||||
level = getterminaltype(user_name);
|
||||
level = getterminaltype(user_name, sizeof(user_name));
|
||||
setenv("TERM", terminaltype ? terminaltype : "network", 1);
|
||||
|
||||
#ifdef _SC_CRAY_SECURE_SYS
|
||||
@@ -757,7 +757,8 @@ Please contact your net administrator");
|
||||
}
|
||||
#endif /* _SC_CRAY_SECURE_SYS */
|
||||
|
||||
telnet(net, ourpty, host, level, user_name); /* begin server processing */
|
||||
/* begin server processing */
|
||||
my_telnet(net, ourpty, host, level, user_name);
|
||||
/*NOTREACHED*/
|
||||
} /* end of doit */
|
||||
|
||||
@@ -784,17 +785,11 @@ show_issue(void)
|
||||
* hand data to telnet receiver finite state machine.
|
||||
*/
|
||||
void
|
||||
telnet(int f, int p, char *host, int level, char *autoname)
|
||||
my_telnet(int f, int p, char *host, int level, char *autoname)
|
||||
{
|
||||
int on = 1;
|
||||
#define TABBUFSIZ 512
|
||||
char defent[TABBUFSIZ];
|
||||
char defstrs[TABBUFSIZ];
|
||||
#undef TABBUFSIZ
|
||||
char *he;
|
||||
char *HN;
|
||||
char *IM;
|
||||
void netflush();
|
||||
int nfd;
|
||||
int startslave_called = 0;
|
||||
time_t timeout;
|
||||
|
@@ -175,6 +175,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBUTIL_H
|
||||
#include <libutil.h>
|
||||
#endif
|
||||
|
||||
#include <roken.h>
|
||||
|
||||
/* Don't use the system login, use our version instead */
|
||||
|
@@ -391,8 +391,8 @@ void edithost(char *pat, char *host)
|
||||
pat++;
|
||||
}
|
||||
if (*host)
|
||||
strncpy(res, host,
|
||||
sizeof editedhost - (res - editedhost) -1);
|
||||
strcpy_truncate (res, host,
|
||||
sizeof editedhost - (res - editedhost));
|
||||
else
|
||||
*res = '\0';
|
||||
editedhost[sizeof editedhost - 1] = '\0';
|
||||
@@ -527,7 +527,7 @@ printsub(int direction, unsigned char *pointer, int length)
|
||||
/* where suboption data sits */
|
||||
/* length of suboption data */
|
||||
{
|
||||
int i;
|
||||
int i = 0;
|
||||
unsigned char buf[512];
|
||||
|
||||
if (!(diagnostic & TD_OPTIONS))
|
||||
|
Reference in New Issue
Block a user