Skip to content

Commit 2c60365

Browse files
account for proto size difference
1 parent 0b88193 commit 2c60365

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/internal.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,7 +2235,12 @@ static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
22352235
}
22362236

22372237
if (ret == WS_SUCCESS) {
2238+
byte SSH_PROTO_EOL_SZ = 1;
2239+
22382240
strSz = (word32)WSTRLEN(sshProtoIdStr) - SSH_PROTO_EOL_SZ;
2241+
if (strSz > 1 && sshProtoIdStr[strSz - 1] == '\r') {
2242+
strSz--; /* subtract 1 more for CR */
2243+
}
22392244
c32toa(strSz, scratchLen);
22402245
ret = wc_HashUpdate(&ssh->handshake->hash, enmhashId,
22412246
scratchLen, LENGTH_SZ);
@@ -5216,6 +5221,7 @@ int DoProtoId(WOLFSSH* ssh)
52165221
int ret;
52175222
word32 idSz;
52185223
byte* eol;
5224+
byte SSH_PROTO_EOL_SZ = 1;
52195225

52205226
if ( (ret = GetInputText(ssh, &eol)) < 0) {
52215227
WLOG(WS_LOG_DEBUG, "get input text failed");
@@ -5244,6 +5250,9 @@ int DoProtoId(WOLFSSH* ssh)
52445250
ssh->clientOpenSSH = 1;
52455251
}
52465252

5253+
if (*eol == '\r') {
5254+
SSH_PROTO_EOL_SZ++;
5255+
}
52475256
*eol = 0;
52485257

52495258
idSz = (word32)WSTRLEN((char*)ssh->inputBuffer.buffer);

wolfssh/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ enum {
123123
#define SHA1_96_SZ 12
124124
#define UINT32_SZ 4
125125
#define SSH_PROTO_SZ 7 /* "SSH-2.0" */
126-
#define SSH_PROTO_EOL_SZ 2 /* Just the CRLF */
127126
#define AEAD_IMP_IV_SZ 4
128127
#define AEAD_EXP_IV_SZ 8
129128
#define AEAD_NONCE_SZ (AEAD_IMP_IV_SZ+AEAD_EXP_IV_SZ)

0 commit comments

Comments
 (0)