Skip to content

Commit

Permalink
OSSL_PARAM_BLD and BIGNUM; ensure at least one byte is allocated
Browse files Browse the repository at this point in the history
A zero BIGNUM contains zero bytes, while OSSL_PARAMs with an INTEGER (or
UNSIGNED INTEGER) data type are expected to have at least one data byte
allocated, containing a zero.  This wasn't handled correctly.

Fixes #20011

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #20013)

(cherry picked from commit c455f87)
  • Loading branch information
levitte committed Jan 11, 2023
1 parent fcc224a commit e33c37a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crypto/param_build.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
}
if (BN_get_flags(bn, BN_FLG_SECURE) == BN_FLG_SECURE)
secure = 1;

/* The BIGNUM is zero, we must transfer at least one byte */
if (sz == 0)
sz++;
}
pd = param_push(bld, key, sz, sz, OSSL_PARAM_UNSIGNED_INTEGER, secure);
if (pd == NULL)
Expand Down

0 comments on commit e33c37a

Please sign in to comment.