@@ -1426,6 +1426,14 @@ static int GetInputText(WOLFSSH* ssh, byte** pEol)
14261426 eol = WSTRNSTR ((const char * )ssh -> inputBuffer .buffer , "\r\n" ,
14271427 ssh -> inputBuffer .length );
14281428
1429+ /* section 4.2 in RFC 4253 states that can be lenient on the CR for
1430+ * interop with older or undocumented versions of SSH */
1431+ if (!eol ) {
1432+ WLOG (WS_LOG_DEBUG , "Checking for old version of protocol exchange" );
1433+ eol = WSTRNSTR ((const char * )ssh -> inputBuffer .buffer , "\n" ,
1434+ ssh -> inputBuffer .length );
1435+ }
1436+
14291437 if (eol )
14301438 gotLine = 1 ;
14311439
@@ -2254,6 +2262,8 @@ static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
22542262 }
22552263
22562264 if (ret == WS_SUCCESS ) {
2265+ byte SSH_PROTO_EOL_SZ = 2 ;
2266+
22572267 strSz = (word32 )WSTRLEN (sshProtoIdStr ) - SSH_PROTO_EOL_SZ ;
22582268 c32toa (strSz , scratchLen );
22592269 ret = wc_HashUpdate (& ssh -> handshake -> hash , enmhashId ,
@@ -5339,6 +5349,7 @@ int DoProtoId(WOLFSSH* ssh)
53395349 int ret ;
53405350 word32 idSz ;
53415351 byte * eol ;
5352+ byte SSH_PROTO_EOL_SZ = 1 ;
53425353
53435354 if ( (ret = GetInputText (ssh , & eol )) < 0 ) {
53445355 WLOG (WS_LOG_DEBUG , "get input text failed" );
@@ -5367,6 +5378,9 @@ int DoProtoId(WOLFSSH* ssh)
53675378 ssh -> clientOpenSSH = 1 ;
53685379 }
53695380
5381+ if (* eol == '\r' ) {
5382+ SSH_PROTO_EOL_SZ ++ ;
5383+ }
53705384 * eol = 0 ;
53715385
53725386 idSz = (word32 )WSTRLEN ((char * )ssh -> inputBuffer .buffer );
0 commit comments