aboutsummaryrefslogtreecommitdiff
path: root/src/appl/telnet/telnetd/telnetd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/appl/telnet/telnetd/telnetd.c')
-rw-r--r--src/appl/telnet/telnetd/telnetd.c74
1 files changed, 27 insertions, 47 deletions
diff --git a/src/appl/telnet/telnetd/telnetd.c b/src/appl/telnet/telnetd/telnetd.c
index 7267469..5588d1a 100644
--- a/src/appl/telnet/telnetd/telnetd.c
+++ b/src/appl/telnet/telnetd/telnetd.c
@@ -153,7 +153,7 @@ extern void usage P((void));
*/
char valid_opts[] = {
'd', ':', 'h', 'k', 'L', ':', 'n', 'S', ':', 'U',
- 'w',
+ 'w', ':',
#ifdef AUTHENTICATION
'a', ':', 'X', ':',
#endif
@@ -522,7 +522,7 @@ main(argc, argv)
}
(void) setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
(char *)&on, sizeof(on));
- if (bind(s, (struct sockaddr *)&sin, sizeof sin) < 0) {
+ if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
perror("bind");
exit(1);
}
@@ -530,7 +530,7 @@ main(argc, argv)
perror("listen");
exit(1);
}
- foo = sizeof sin;
+ foo = sizeof(sin);
ns = accept(s, (struct sockaddr *)&sin, &foo);
if (ns < 0) {
perror("accept");
@@ -693,7 +693,7 @@ static void encrypt_failure()
char *error_message =
"Encryption was not successfully negotiated. Goodbye.\r\n\r\n";
- writenet(error_message, strlen(error_message));
+ netputs(error_message);
netflush();
exit(1);
}
@@ -780,36 +780,26 @@ getterminaltype(name)
if (his_state_is_will(TELOPT_TSPEED)) {
static unsigned char sb[] =
{ IAC, SB, TELOPT_TSPEED, TELQUAL_SEND, IAC, SE };
-
- memcpy(nfrontp, sb, sizeof sb);
- nfrontp += sizeof sb;
+ netwrite(sb, sizeof(sb));
}
if (his_state_is_will(TELOPT_XDISPLOC)) {
static unsigned char sb[] =
{ IAC, SB, TELOPT_XDISPLOC, TELQUAL_SEND, IAC, SE };
-
- memcpy(nfrontp, sb, sizeof sb);
- nfrontp += sizeof sb;
+ netwrite(sb, sizeof(sb));
}
if (his_state_is_will(TELOPT_NEW_ENVIRON)) {
static unsigned char sb[] =
{ IAC, SB, TELOPT_NEW_ENVIRON, TELQUAL_SEND, IAC, SE };
-
- memcpy(nfrontp, sb, sizeof sb);
- nfrontp += sizeof sb;
+ netwrite(sb, sizeof(sb));
}
else if (his_state_is_will(TELOPT_OLD_ENVIRON)) {
static unsigned char sb[] =
{ IAC, SB, TELOPT_OLD_ENVIRON, TELQUAL_SEND, IAC, SE };
-
- memcpy(nfrontp, sb, sizeof sb);
- nfrontp += sizeof sb;
+ netwrite(sb, sizeof(sb));
}
- if (his_state_is_will(TELOPT_TTYPE)) {
+ if (his_state_is_will(TELOPT_TTYPE))
+ netwrite(ttytype_sbbuf, sizeof(ttytype_sbbuf));
- memcpy(nfrontp, ttytype_sbbuf, sizeof ttytype_sbbuf);
- nfrontp += sizeof ttytype_sbbuf;
- }
if (his_state_is_will(TELOPT_TSPEED)) {
while (sequenceIs(tspeedsubopt, baseline))
ttloop();
@@ -886,8 +876,7 @@ _gettermname()
if (his_state_is_wont(TELOPT_TTYPE))
return;
settimer(baseline);
- memcpy(nfrontp, ttytype_sbbuf, sizeof ttytype_sbbuf);
- nfrontp += sizeof ttytype_sbbuf;
+ netwrite(ttytype_sbbuf, sizeof(ttytype_sbbuf));
while (sequenceIs(ttypesubopt, baseline))
ttloop();
}
@@ -1009,7 +998,7 @@ pty_init();
setenv("TERM", *terminaltype ? terminaltype : "network", 1);
#if defined (AUTHENTICATION)
- if (user_name[0] == '\0') {
+ if (level < 0 && auth_level > 0) {
fatal (net, "No authentication provided");
exit (-1);
}
@@ -1159,9 +1148,7 @@ telnet(f, p, host)
* mode, which we do not want.
*/
if (his_want_state_is_will(TELOPT_ECHO)) {
- DIAG(TD_OPTIONS,
- {sprintf(nfrontp, "td: simulating recv\r\n");
- nfrontp += strlen(nfrontp);});
+ DIAG(TD_OPTIONS, netputs("td: simulating recv\r\n"));
willoption(TELOPT_ECHO);
}
@@ -1205,7 +1192,7 @@ telnet(f, p, host)
#if defined(SO_OOBINLINE)
(void) setsockopt(net, SOL_SOCKET, SO_OOBINLINE,
- (char *)&on, sizeof on);
+ (char *)&on, sizeof(on));
#endif /* defined(SO_OOBINLINE) */
#ifdef SIGTSTP
@@ -1266,7 +1253,8 @@ telnet(f, p, host)
HN = getstr("hn", &cp);
IM = getstr("im", &cp);
if (HN && *HN)
- (void) strcpy(host_name, HN);
+ (void) strncpy(host_name, HN, sizeof(host_name) - 1);
+ host_name[sizeof(host_name) - 1] = '\0';
if (IM == 0)
IM = "";
} else {
@@ -1289,9 +1277,7 @@ telnet(f, p, host)
localstat();
#endif /* LINEMODE */
- DIAG(TD_REPORT,
- {sprintf(nfrontp, "td: Entering processing loop\r\n");
- nfrontp += strlen(nfrontp);});
+ DIAG(TD_REPORT, netputs("td: Entering processing loop\r\n"));
#ifdef convex
startslave(host);
@@ -1416,8 +1402,7 @@ telnet(f, p, host)
netip = netibuf;
}
DIAG((TD_REPORT | TD_NETDATA),
- {sprintf(nfrontp, "td: netread %d chars\r\n", ncc);
- nfrontp += strlen(nfrontp);});
+ netprintf("td: netread %d chars\r\n", ncc));
DIAG(TD_NETDATA, printdata("nd", netip, ncc));
}
@@ -1464,9 +1449,7 @@ telnet(f, p, host)
* royally if we send them urgent
* mode data.
*/
- *nfrontp++ = IAC;
- *nfrontp++ = DM;
- neturg = nfrontp-1; /* off by one XXX */
+ netprintf_urg("%c%c", IAC, DM);
#endif
}
if (his_state_is_will(TELOPT_LFLOW) &&
@@ -1476,13 +1459,11 @@ telnet(f, p, host)
ptyibuf[0] & TIOCPKT_DOSTOP ? 1 : 0;
if (newflow != flowmode) {
flowmode = newflow;
- (void) sprintf(nfrontp,
- "%c%c%c%c%c%c",
+ netprintf("%c%c%c%c%c%c",
IAC, SB, TELOPT_LFLOW,
flowmode ? LFLOW_ON
: LFLOW_OFF,
IAC, SE);
- nfrontp += 6;
}
}
pcc--;
@@ -1505,19 +1486,19 @@ telnet(f, p, host)
break;
c = *ptyip++ & 0377, pcc--;
if (c == IAC)
- *nfrontp++ = c;
+ netprintf("%c", c);
#if defined(CRAY2) && defined(UNICOS5)
else if (c == '\n' &&
my_state_is_wont(TELOPT_BINARY) && newmap)
- *nfrontp++ = '\r';
+ netputs("\r");
#endif /* defined(CRAY2) && defined(UNICOS5) */
- *nfrontp++ = c;
+ netprintf("%c", c);
if ((c == '\r') && (my_state_is_wont(TELOPT_BINARY))) {
if (pcc > 0 && ((*ptyip & 0377) == '\n')) {
- *nfrontp++ = *ptyip++ & 0377;
+ netprintf("%c", *ptyip++ & 0377);
pcc--;
} else
- *nfrontp++ = '\0';
+ netprintf("%c", '\0');
}
}
#if defined(CRAY2) && defined(UNICOS5)
@@ -1679,7 +1660,7 @@ sendsusp()
* When we get an AYT, if ^T is enabled, use that. Otherwise,
* just send back "[Yes]".
*/
- void
+void
recv_ayt()
{
#if defined(SIGINFO) && defined(TCSIG)
@@ -1688,8 +1669,7 @@ recv_ayt()
return;
}
#endif
- (void) strcpy(nfrontp, "\r\n[Yes]\r\n");
- nfrontp += 9;
+ netputs("\r\n[Yes]\r\n");
}
void