Skip to content

Commit c0048ed

Browse files
committed
DoProtoId: case-sensitive match on SSH- prefix
Per RFC 4253 4.2. Also updated unit test. Issue: F-2865
1 parent 3cd5eef commit c0048ed

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/internal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10875,7 +10875,7 @@ int DoProtoId(WOLFSSH* ssh)
1087510875
}
1087610876

1087710877
if (ssh->inputBuffer.length >= 4
10878-
&& WSTRNCASECMP((char*)ssh->inputBuffer.buffer, "SSH-", 4) == 0)
10878+
&& WSTRNCMP((char*)ssh->inputBuffer.buffer, "SSH-", 4) == 0)
1087910879
break;
1088010880

1088110881
if (!allowBanner) {
@@ -10904,8 +10904,8 @@ int DoProtoId(WOLFSSH* ssh)
1090410904
eolSz = (*eol == '\r') ? 2 : 1;
1090510905

1090610906
if (ssh->inputBuffer.length >= SSH_PROTO_SZ
10907-
&& WSTRNCASECMP((char*)ssh->inputBuffer.buffer,
10908-
ssh->ctx->sshProtoIdStr, SSH_PROTO_SZ) == 0) {
10907+
&& WSTRNCMP((char*)ssh->inputBuffer.buffer,
10908+
ssh->ctx->sshProtoIdStr, SSH_PROTO_SZ) == 0) {
1090910909

1091010910
if (ssh->ctx->side == WOLFSSH_ENDPOINT_SERVER)
1091110911
ssh->clientState = CLIENT_VERSION_DONE;

tests/unit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ static const ProtoIdTestVector protoIdTestVectors[] = {
8787
"SSH-2.0-wolfSSHv" LIBWOLFSSH_VERSION_STRING "\n",
8888
0, WS_SUCCESS, WOLFSSH_ENDPOINT_CLIENT },
8989

90-
/* Case-insensitive match. DoProtoId uses WSTRNCASECMP. */
90+
/* Case rejection. DoProtoId uses WSTRNCMP. */
9191
{ "lowercase ssh prefix",
9292
"ssh-2.0-wolfSSHv" LIBWOLFSSH_VERSION_STRING "\r\n",
93-
0, WS_SUCCESS, WOLFSSH_ENDPOINT_CLIENT },
93+
0, WS_SOCKET_ERROR_E, WOLFSSH_ENDPOINT_CLIENT },
9494
{ "mixed case SSH prefix",
9595
"Ssh-2.0-wolfSSHv" LIBWOLFSSH_VERSION_STRING "\r\n",
96-
0, WS_SUCCESS, WOLFSSH_ENDPOINT_CLIENT },
96+
0, WS_SOCKET_ERROR_E, WOLFSSH_ENDPOINT_CLIENT },
9797

9898
/* OpenSSH peer identification. */
9999
{ "OpenSSH version string",

0 commit comments

Comments
 (0)