aboutsummaryrefslogtreecommitdiff
path: root/security/krb5-17/files/patch-appl::telnet::telnetd::telnetd.c
blob: 9eef1709beebc4169640fff37a0959b11b783ebe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
--- appl/telnet/telnetd/telnetd.c.orig	Wed Feb 28 14:06:51 2001
+++ appl/telnet/telnetd/telnetd.c	Mon Jul 23 17:27:05 2001
@@ -693,7 +693,7 @@
     char *error_message =
 	"Encryption was not successfully negotiated.  Goodbye.\r\n\r\n";
 
-    writenet(error_message, strlen(error_message));
+    output_datalen(error_message, strlen(error_message));
     netflush();
     exit(1);
 }
@@ -782,9 +782,7 @@
 			{ IAC, SB, TELOPT_TSPEED, TELQUAL_SEND, IAC, SE };
 
 	if(nfrontp - netobuf + sizeof(sb) < sizeof(netobuf)) {
-	    memcpy(nfrontp, sb, sizeof(sb));
-	    nfrontp += sizeof(sb);
-	    *nfrontp = '\0';
+		output_datalen(sb, sizeof sb);
 	}
     }
     if (his_state_is_will(TELOPT_XDISPLOC)) {
@@ -792,9 +790,7 @@
 			{ IAC, SB, TELOPT_XDISPLOC, TELQUAL_SEND, IAC, SE };
 
 	if(nfrontp - netobuf + sizeof(sb) < sizeof(netobuf)) {
-	    memcpy(nfrontp, sb, sizeof(sb));
-	    nfrontp += sizeof(sb);
-	    *nfrontp = '\0';
+		output_datalen(sb, sizeof sb);
 	}
     }
     if (his_state_is_will(TELOPT_NEW_ENVIRON)) {
@@ -802,9 +798,7 @@
 			{ IAC, SB, TELOPT_NEW_ENVIRON, TELQUAL_SEND, IAC, SE };
 
 	if(nfrontp - netobuf + sizeof(sb) < sizeof(netobuf)) {
-	    memcpy(nfrontp, sb, sizeof(sb));
-	    nfrontp += sizeof(sb);
-	    *nfrontp = '\0';
+		output_datalen(sb, sizeof sb);
 	}
     }
     else if (his_state_is_will(TELOPT_OLD_ENVIRON)) {
@@ -812,17 +806,13 @@
 			{ IAC, SB, TELOPT_OLD_ENVIRON, TELQUAL_SEND, IAC, SE };
 
 	if(nfrontp - netobuf + sizeof(sb) < sizeof(netobuf)) {
-	    memcpy(nfrontp, sb, sizeof(sb));
-	    nfrontp += sizeof(sb);
-	    *nfrontp = '\0';
+		output_datalen(sb, sizeof sb);
 	}
     }
     if (his_state_is_will(TELOPT_TTYPE)) {
 
 	if(nfrontp - netobuf + sizeof(ttytype_sbbuf) < sizeof(netobuf)) {
-	    memcpy(nfrontp, ttytype_sbbuf, sizeof(ttytype_sbbuf));
-	    nfrontp += sizeof(ttytype_sbbuf);
-	    *nfrontp = '\0';
+		output_datalen(ttytype_sbbuf, sizeof ttytype_sbbuf);
 	}
     }
     if (his_state_is_will(TELOPT_TSPEED)) {
@@ -902,9 +892,7 @@
 	return;
     settimer(baseline);
     if(nfrontp - netobuf + sizeof(ttytype_sbbuf)) {
-    	memcpy(nfrontp, ttytype_sbbuf, sizeof(ttytype_sbbuf));
-    	nfrontp += sizeof(ttytype_sbbuf);
-	*nfrontp = '\0';
+	output_datalen(ttytype_sbbuf, sizeof ttytype_sbbuf);
     }
     while (sequenceIs(ttypesubopt, baseline))
 	ttloop();
@@ -1177,9 +1165,7 @@
 	 * 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, output_data("td: simulating recv\r\n"));
 		willoption(TELOPT_ECHO);
 	}
 
@@ -1308,9 +1294,7 @@
 	localstat();
 #endif	/* LINEMODE */
 
-	DIAG(TD_REPORT,
-		{sprintf(nfrontp, "td: Entering processing loop\r\n");
-		 nfrontp += strlen(nfrontp);});
+	DIAG(TD_REPORT, output_data("td: Entering processing loop\r\n"));
 
 #ifdef	convex
 	startslave(host);
@@ -1435,8 +1419,7 @@
 			netip = netibuf;
 		    }
 		    DIAG((TD_REPORT | TD_NETDATA),
-			    {sprintf(nfrontp, "td: netread %d chars\r\n", ncc);
-			     nfrontp += strlen(nfrontp);});
+			output_data("td: netread %d chars\r\n", ncc));
 		    DIAG(TD_NETDATA, printdata("nd", netip, ncc));
 		}
 
@@ -1483,8 +1466,7 @@
 					 * royally if we send them urgent
 					 * mode data.
 					 */
-					*nfrontp++ = IAC;
-					*nfrontp++ = DM;
+					output_data("%c%c", IAC, DM);
 					neturg = nfrontp-1; /* off by one XXX */
 #endif
 				}
@@ -1495,13 +1477,11 @@
 					    ptyibuf[0] & TIOCPKT_DOSTOP ? 1 : 0;
 					if (newflow != flowmode) {
 						flowmode = newflow;
-						(void) sprintf(nfrontp,
-							"%c%c%c%c%c%c",
+						output_data("%c%c%c%c%c%c",
 							IAC, SB, TELOPT_LFLOW,
 							flowmode ? LFLOW_ON
 								 : LFLOW_OFF,
 							IAC, SE);
-						nfrontp += 6;
 					}
 				}
 				pcc--;
@@ -1524,19 +1504,19 @@
 				break;
 			c = *ptyip++ & 0377, pcc--;
 			if (c == IAC)
-				*nfrontp++ = c;
+				output_data("%c", c);
 #if	defined(CRAY2) && defined(UNICOS5)
 			else if (c == '\n' &&
 				     my_state_is_wont(TELOPT_BINARY) && newmap)
-				*nfrontp++ = '\r';
+				output_data("\r");
 #endif	/* defined(CRAY2) && defined(UNICOS5) */
-			*nfrontp++ = c;
+			output_data("%c", c);
 			if ((c == '\r') && (my_state_is_wont(TELOPT_BINARY))) {
 				if (pcc > 0 && ((*ptyip & 0377) == '\n')) {
-					*nfrontp++ = *ptyip++ & 0377;
+					output_data("%c", *ptyip++ & 0377);
 					pcc--;
 				} else
-					*nfrontp++ = '\0';
+					output_data("%c", '\0');
 			}
 		}
 #if	defined(CRAY2) && defined(UNICOS5)
@@ -1707,10 +1687,7 @@
 		return;
 	}
 #endif
-	(void) strncpy(nfrontp, "\r\n[Yes]\r\n",
-		       sizeof(netobuf) - 1 - (nfrontp - netobuf));
-	nfrontp += 9;
-	*nfrontp = '\0';
+	output_data("\r\n[Yes]\r\n");
 }
 
 	void