Merge pull request #213 from JacobBarthelmeh/testing

be more lenient on CR with protocol exchange
pull/255/head
John Safranek 2020-03-18 09:35:32 -07:00 committed by GitHub
commit 80760b5fc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -1426,6 +1426,14 @@ static int GetInputText(WOLFSSH* ssh, byte** pEol)
eol = WSTRNSTR((const char*)ssh->inputBuffer.buffer, "\r\n",
ssh->inputBuffer.length);
/* section 4.2 in RFC 4253 states that can be lenient on the CR for
* interop with older or undocumented versions of SSH */
if (!eol) {
WLOG(WS_LOG_DEBUG, "Checking for old version of protocol exchange");
eol = WSTRNSTR((const char*)ssh->inputBuffer.buffer, "\n",
ssh->inputBuffer.length);
}
if (eol)
gotLine = 1;
@ -2254,6 +2262,8 @@ static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
}
if (ret == WS_SUCCESS) {
byte SSH_PROTO_EOL_SZ = 2;
strSz = (word32)WSTRLEN(sshProtoIdStr) - SSH_PROTO_EOL_SZ;
c32toa(strSz, scratchLen);
ret = wc_HashUpdate(&ssh->handshake->hash, enmhashId,
@ -5339,6 +5349,7 @@ int DoProtoId(WOLFSSH* ssh)
int ret;
word32 idSz;
byte* eol;
byte SSH_PROTO_EOL_SZ = 1;
if ( (ret = GetInputText(ssh, &eol)) < 0) {
WLOG(WS_LOG_DEBUG, "get input text failed");
@ -5367,6 +5378,9 @@ int DoProtoId(WOLFSSH* ssh)
ssh->clientOpenSSH = 1;
}
if (*eol == '\r') {
SSH_PROTO_EOL_SZ++;
}
*eol = 0;
idSz = (word32)WSTRLEN((char*)ssh->inputBuffer.buffer);

View File

@ -123,7 +123,6 @@ enum {
#define SHA1_96_SZ 12
#define UINT32_SZ 4
#define SSH_PROTO_SZ 7 /* "SSH-2.0" */
#define SSH_PROTO_EOL_SZ 2 /* Just the CRLF */
#define AEAD_IMP_IV_SZ 4
#define AEAD_EXP_IV_SZ 8
#define AEAD_NONCE_SZ (AEAD_IMP_IV_SZ+AEAD_EXP_IV_SZ)