diff options
author | Ken Raeburn <raeburn@mit.edu> | 2000-06-30 00:16:21 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2000-06-30 00:16:21 +0000 |
commit | 5115426fe6ca5bd63cf8e3997fbaf8277792c024 (patch) | |
tree | 65d8c302c3ba8080437850651370eadad1632e22 /src/appl/telnet/telnetd/telnetd.c | |
parent | 8165626f1caaaa60fcfd04472a07e8362f2447b8 (diff) | |
download | krb5-5115426fe6ca5bd63cf8e3997fbaf8277792c024.tar.gz krb5-5115426fe6ca5bd63cf8e3997fbaf8277792c024.tar.xz krb5-5115426fe6ca5bd63cf8e3997fbaf8277792c024.zip |
1.2-beta4 pullup
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12470 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/appl/telnet/telnetd/telnetd.c')
-rw-r--r-- | src/appl/telnet/telnetd/telnetd.c | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/src/appl/telnet/telnetd/telnetd.c b/src/appl/telnet/telnetd/telnetd.c index 726746967..f103488cb 100644 --- a/src/appl/telnet/telnetd/telnetd.c +++ b/src/appl/telnet/telnetd/telnetd.c @@ -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"); @@ -781,34 +781,49 @@ getterminaltype(name) static unsigned char sb[] = { IAC, SB, TELOPT_TSPEED, TELQUAL_SEND, IAC, SE }; - memcpy(nfrontp, sb, sizeof sb); - nfrontp += sizeof sb; + if(nfrontp - netobuf + sizeof(sb) < sizeof(netobuf)) { + memcpy(nfrontp, sb, sizeof(sb)); + nfrontp += sizeof(sb); + *nfrontp = '\0'; + } } 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; + if(nfrontp - netobuf + sizeof(sb) < sizeof(netobuf)) { + memcpy(nfrontp, sb, sizeof(sb)); + nfrontp += sizeof(sb); + *nfrontp = '\0'; + } } 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; + if(nfrontp - netobuf + sizeof(sb) < sizeof(netobuf)) { + memcpy(nfrontp, sb, sizeof(sb)); + nfrontp += sizeof(sb); + *nfrontp = '\0'; + } } 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; + if(nfrontp - netobuf + sizeof(sb) < sizeof(netobuf)) { + memcpy(nfrontp, sb, sizeof(sb)); + nfrontp += sizeof(sb); + *nfrontp = '\0'; + } } if (his_state_is_will(TELOPT_TTYPE)) { - memcpy(nfrontp, ttytype_sbbuf, sizeof ttytype_sbbuf); - nfrontp += sizeof ttytype_sbbuf; + if(nfrontp - netobuf + sizeof(ttytype_sbbuf) < sizeof(netobuf)) { + memcpy(nfrontp, ttytype_sbbuf, sizeof(ttytype_sbbuf)); + nfrontp += sizeof(ttytype_sbbuf); + *nfrontp = '\0'; + } } if (his_state_is_will(TELOPT_TSPEED)) { while (sequenceIs(tspeedsubopt, baseline)) @@ -886,8 +901,11 @@ _gettermname() if (his_state_is_wont(TELOPT_TTYPE)) return; settimer(baseline); - memcpy(nfrontp, ttytype_sbbuf, sizeof ttytype_sbbuf); - nfrontp += sizeof ttytype_sbbuf; + if(nfrontp - netobuf + sizeof(ttytype_sbbuf)) { + memcpy(nfrontp, ttytype_sbbuf, sizeof(ttytype_sbbuf)); + nfrontp += sizeof(ttytype_sbbuf); + *nfrontp = '\0'; + } while (sequenceIs(ttypesubopt, baseline)) ttloop(); } @@ -1009,7 +1027,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); } @@ -1205,7 +1223,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 +1284,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 { @@ -1688,8 +1707,10 @@ recv_ayt() return; } #endif - (void) strcpy(nfrontp, "\r\n[Yes]\r\n"); + (void) strncpy(nfrontp, "\r\n[Yes]\r\n", + sizeof(netobuf) - 1 - (nfrontp - netobuf)); nfrontp += 9; + *nfrontp = '\0'; } void |