static void session_identification() { /* max length of 255 chars */ char linebuf[256]; int len = 0; char done = 0; /* write our version string, this blocks */ if (atomicio(write, ses.sock, LOCAL_IDENT "\r\n", strlen(LOCAL_IDENT "\r\n")) == DROPBEAR_FAILURE) { dropbear_exit("Error writing ident string"); } len = ident_readln(ses.sock, linebuf, 256); if (len >= 4 && memcmp(linebuf, "SSH-", 4) == 0) { /* start of line matches */ done = 1; } if (!done) { dropbear_exit("Failed to get client version"); } else { /* linebuf is already null terminated */ ses.remoteident = m_malloc(len); memcpy(ses.remoteident, linebuf, len); } TRACE(("remoteident: %s", ses.remoteident)); }
static void session_identification() { /* max length of 255 chars */ char linebuf[256]; int len = 0; int i; char done = 0; /* write our version string, this blocks */ if (atomicio(write, ses.sock, LOCAL_IDENT "\r\n", strlen(LOCAL_IDENT "\r\n")) == DROPBEAR_FAILURE) { dropbear_exit("Error writing ident string"); } /* Now read the client version string, there are allowed to be other lines * before the "SSH-*" line. We allow a max of 9 lines before it, just for * sanity */ for (i = 0; i < 10; i++) { len = ident_readln(ses.sock, linebuf, 256); if (len < 0) { break; } if (len >= 4 && memcmp(linebuf, "SSH-", 4) == 0) { /* start of line matches */ done = 1; break; } } if (!done) { dropbear_exit("Failed to get remote ident"); } else { /* linebuf is already null terminated */ ses.remoteident = m_malloc(len); memcpy(ses.remoteident, linebuf, len); } TRACE(("remoteident: %s", ses.remoteident)); }