]> git.tue.mpg.de Git - paraslash.git/commitdiff
client: Check buffer size returned by apc_priv_decrypt().
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 7 May 2023 14:40:26 +0000 (16:40 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 16 May 2024 23:36:54 +0000 (01:36 +0200)
The decoded challenge buffer contains the challenge and the two session
keys but nothing else. So we know its size up-front and should fail
the handshake if the size of the rsa-decrypted buffer differs.

client_common.c

index fe8234f98fe90f6ce74ea5e22699fbfc0059a042..32a94492968dadae99f3b50ab1505449849ad293 100644 (file)
@@ -342,6 +342,10 @@ static int client_post_monitor(struct sched *s, void *context)
                free(sbb.iov.iov_base);
                if (ret < 0)
                        goto out;
+               if (ret != APC_CHALLENGE_SIZE + 2 * SESSION_KEY_LEN) {
+                       ret = -E_DECRYPT;
+                       goto out;
+               }
                ct->challenge_hash = alloc(HASH2_SIZE);
                if (has_feature("sha256", ct)) {
                        hash2_function((char *)crypt_buf, APC_CHALLENGE_SIZE,