mirror of https://github.com/wolfSSL/wolfssh.git
internal: reject '-' in proto ID softwareversion
RFC 4253 Section 4.2 bars the minus sign from softwareversion. ValidateProtoId now scans the body up to the first space and rejects a '-' there; the comments after the space may still carry one. - document the rule on wolfSSH_CTX_SetSshProtoIdStr() in ssh.h - unit vectors for a dash in softwareversion and in the comments Issue: F-16082pull/1352/head
parent
ad187fb7c4
commit
d2530b33aa
|
|
@ -15537,6 +15537,17 @@ int ValidateProtoId(const char* protoIdStr, word32 len)
|
|||
}
|
||||
}
|
||||
|
||||
/* softwareversion runs to the first space and must not contain a '-'
|
||||
* (RFC 4253 section 4.2); the comments may. */
|
||||
for (i = SSH_PROTO_SZ;
|
||||
i < len - SSH_PROTO_EOL_SZ && protoIdStr[i] != ' '; i++) {
|
||||
if (protoIdStr[i] == '-') {
|
||||
WLOG(WS_LOG_ERROR, "Proto Id was invalid: softwareversion "
|
||||
"must not contain '-'");
|
||||
return WS_BAD_ARGUMENT;
|
||||
}
|
||||
}
|
||||
|
||||
return WS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -663,6 +663,9 @@ static int test_DoProtoId(void)
|
|||
* 0x7e must both be accepted. */
|
||||
{ "body w/ SP comments", "SSH-2.0-app comment\r\n", 1 },
|
||||
{ "body w/ tilde", "SSH-2.0-app~1\r\n", 1 },
|
||||
/* RFC 4253 section 4.2 bars '-' only from softwareversion. */
|
||||
{ "comments w/ minus", "SSH-2.0-app my-comment\r\n", 1 },
|
||||
{ "comments are minus", "SSH-2.0-app -\r\n", 1 },
|
||||
/* Failing Tests */
|
||||
{ "wrong version prefix", "SSH-2-this_is_my_app\r\n", 0 },
|
||||
{ "bad casing prefix", "sSH-2.0-this_is_my_app\r\n", 0 },
|
||||
|
|
@ -675,7 +678,10 @@ static int test_DoProtoId(void)
|
|||
{ "Body End in CR", "SSH-2.0-s\r\r\n", 0 },
|
||||
{ "Body End in TAB", "SSH-2.0-s\t\r\n", 0 },
|
||||
{ "body starts w/ space", "SSH-2.0-\x20-a-b\r\n", 0 },
|
||||
{ "body has embedded TAB", "SSH-2.0-\x7e-a\t\r\n", 0 },
|
||||
{ "body has embedded TAB", "SSH-2.0-\x7e" "a\t\r\n", 0 },
|
||||
{ "swversion w/ minus", "SSH-2.0-my-app\r\n", 0 },
|
||||
{ "swversion is minus", "SSH-2.0--\r\n", 0 },
|
||||
{ "minus before comments", "SSH-2.0-app- comment\r\n", 0 },
|
||||
{ "too long id", tooLongProtoId, 0 },
|
||||
{ "null pointer", NULL, 0 },
|
||||
};
|
||||
|
|
|
|||
|
|
@ -832,6 +832,8 @@ WOLFSSH_API int wolfSSH_CTX_SetBanner(WOLFSSH_CTX* ctx, const char* newBanner);
|
|||
* body as softwareversion [SP comments], so a leading space would
|
||||
* make softwareversion empty. A space later in the body is accepted
|
||||
* and starts the optional comments field.
|
||||
* MUST NOT carry a '-' in softwareversion, the body up to the first
|
||||
* space (RFC 4253 section 4.2). The comments may carry one.
|
||||
* If these are not adhered to the function will return WS_BAD_ARGUMENT
|
||||
* and not load the ProtoId into the WOLFSSH_CTX struct.
|
||||
* ProtoIdStr is stored by reference and is not copied, so it must remain
|
||||
|
|
|
|||
Loading…
Reference in New Issue