Skip to content

Commit 848af18

Browse files
authored
Merge pull request #142 from rizlik/sz_check
add size checking for AesCbc request
2 parents 3de3c55 + 712e494 commit 848af18

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/wh_server_crypto.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,12 @@ static int _HandleAesCbc(whServerContext* ctx, uint16_t magic, const void* crypt
12821282
uint32_t enc = req.enc;
12831283
uint32_t key_len = req.keyLen;
12841284
uint32_t len = req.sz;
1285+
uint64_t needed_size = sizeof(whMessageCrypto_AesCbcResponse) + len +
1286+
key_len + AES_BLOCK_SIZE;
1287+
if (needed_size > inSize) {
1288+
return WH_ERROR_BADARGS;
1289+
}
1290+
12851291
whKeyId key_id =
12861292
WH_MAKE_KEYID(WH_KEYTYPE_CRYPTO, ctx->comm->client_id, req.keyId);
12871293

0 commit comments

Comments
 (0)