summaryrefslogtreecommitdiffstats
path: root/crypto/params.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2023-01-10 12:22:39 +0100
committerRichard Levitte <levitte@openssl.org>2023-01-11 23:38:13 +0100
commitc2ae89148343750e420b72ef1b709ebbc16e47b8 (patch)
tree8fad08a8bd7d71d5a635a1765cc2bbf24efbed71 /crypto/params.c
parentb49cf273883c8d3f47542941fe5cc6cb51aec9c9 (diff)
In OSSL_PARAM_set_BN(), make sure that the data_size field is at least 1
This way, we guarantee that a zero is represented with one byte of data that's set to zero. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20013)
Diffstat (limited to 'crypto/params.c')
-rw-r--r--crypto/params.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/params.c b/crypto/params.c
index 4c5a6f5334..f75cfe69cf 100644
--- a/crypto/params.c
+++ b/crypto/params.c
@@ -1068,6 +1068,9 @@ int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val)
/* We add 1 byte for signed numbers, to make space for a sign extension */
if (p->data_type == OSSL_PARAM_INTEGER)
bytes++;
+ /* We make sure that at least one byte is used, so zero is properly set */
+ if (bytes == 0)
+ bytes++;
p->return_size = bytes;
if (p->data == NULL)