comparison common-session.c @ 302:973fccb59ea4 ucc-axis-hack

propagate from branch 'au.asn.ucc.matt.dropbear' (head 11034278bd1917bebcbdc69cf53b1891ce9db121) to branch 'au.asn.ucc.matt.dropbear.ucc-axis-hack' (head 10a1f614fec73d0820c3f61160d9db409b9beb46)
author Matt Johnston <matt@ucc.asn.au>
date Sat, 25 Mar 2006 12:59:58 +0000
parents 7f9adaf85fca
children bf29e6659fb9
comparison
equal deleted inserted replaced
299:740e782679be 302:973fccb59ea4
230 if (atomicio(write, ses.sock, LOCAL_IDENT "\r\n", 230 if (atomicio(write, ses.sock, LOCAL_IDENT "\r\n",
231 strlen(LOCAL_IDENT "\r\n")) == DROPBEAR_FAILURE) { 231 strlen(LOCAL_IDENT "\r\n")) == DROPBEAR_FAILURE) {
232 dropbear_exit("Error writing ident string"); 232 dropbear_exit("Error writing ident string");
233 } 233 }
234 234
235 /* We allow up to 9 lines before the actual version string, to 235 /* If they send more than 50 lines, something is wrong */
236 * account for wrappers/cruft etc. According to the spec only the client 236 for (i = 0; i < 50; i++) {
237 * needs to handle this, but no harm in letting the server handle it too */
238 for (i = 0; i < 10; i++) {
239 len = ident_readln(ses.sock, linebuf, sizeof(linebuf)); 237 len = ident_readln(ses.sock, linebuf, sizeof(linebuf));
240 238
241 if (len < 0 && errno != EINTR) { 239 if (len < 0 && errno != EINTR) {
242 /* It failed */ 240 /* It failed */
243 break; 241 break;
256 } else { 254 } else {
257 /* linebuf is already null terminated */ 255 /* linebuf is already null terminated */
258 ses.remoteident = m_malloc(len); 256 ses.remoteident = m_malloc(len);
259 memcpy(ses.remoteident, linebuf, len); 257 memcpy(ses.remoteident, linebuf, len);
260 } 258 }
259
260 /* Shall assume that 2.x will be backwards compatible. */
261 if (strncmp(ses.remoteident, "SSH-2.", 6) != 0
262 && strncmp(ses.remoteident, "SSH-1.99-", 9) != 0) {
263 dropbear_exit("Incompatible remote version '%s'", ses.remoteident);
264 }
261 265
262 TRACE(("remoteident: %s", ses.remoteident)) 266 TRACE(("remoteident: %s", ses.remoteident))
263 267
264 } 268 }
265 269