F-4795 - Guard ClientPublicKeyCheck against short public key blob

pull/1073/head
aidan garske 2026-07-10 12:06:23 -07:00 committed by John Safranek
parent ea22e2962a
commit aa7b268376
1 changed files with 8 additions and 3 deletions

View File

@ -392,11 +392,16 @@ int ClientPublicKeyCheck(const byte* pubKey, word32 pubKeySz, void* ctx)
fp[0] = 0;
/* Get the key type out of the key. */
ato32(pubKey, &sz);
if ((sz > pubKeySz - sizeof(word32))
|| (sz > WOLFSSH_CLIENT_PUBKEYTYPE_SIZE_ESTIMATE - 1)) {
if (pubKeySz < sizeof(word32)) {
ret = -1;
}
else {
ato32(pubKey, &sz);
if ((sz > pubKeySz - sizeof(word32))
|| (sz > WOLFSSH_CLIENT_PUBKEYTYPE_SIZE_ESTIMATE - 1)) {
ret = -1;
}
}
}
if (ret == 0) {