Fixes #18768
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18777)
loopargs_t *tempargs = *(loopargs_t **) args;
EVP_PKEY_CTX *ffdh_ctx = tempargs->ffdh_ctx[testnum];
unsigned char *derived_secret = tempargs->secret_ff_a;
- size_t outlen = MAX_FFDH_SIZE;
int count;
- for (count = 0; COND(ffdh_c[testnum][0]); count++)
+ for (count = 0; COND(ffdh_c[testnum][0]); count++) {
+ /* outlen can be overwritten with a too small value (no padding used) */
+ size_t outlen = MAX_FFDH_SIZE;
+
EVP_PKEY_derive(ffdh_ctx, derived_secret, &outlen);
+ }
return count;
}
#endif /* OPENSSL_NO_DH */