diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2022-07-18 15:38:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-18 15:38:13 +0200 |
commit | 5ca5381f2c8d910e32cac078529e6a35cc40c136 (patch) | |
tree | b6729671dfe327ccc6b058e6f7e9a643e8298128 /thirdparty/mbedtls/library/asn1write.c | |
parent | 4e9d3130f509472cde6eeaacaa0062d841cbebef (diff) | |
parent | 9403a68853784e542bbff51a84e6dc5c89241d2b (diff) |
Merge pull request #63146 from Faless/mbedtls/2.18.1
Diffstat (limited to 'thirdparty/mbedtls/library/asn1write.c')
-rw-r--r-- | thirdparty/mbedtls/library/asn1write.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/thirdparty/mbedtls/library/asn1write.c b/thirdparty/mbedtls/library/asn1write.c index 3811ef27a3..afa26a6be9 100644 --- a/thirdparty/mbedtls/library/asn1write.c +++ b/thirdparty/mbedtls/library/asn1write.c @@ -133,6 +133,11 @@ int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start, const mbedt // len = mbedtls_mpi_size( X ); + /* DER represents 0 with a sign bit (0=nonnegative) and 7 value bits, not + * as 0 digits. We need to end up with 020100, not with 0200. */ + if( len == 0 ) + len = 1; + if( *p < start || (size_t)( *p - start ) < len ) return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); @@ -472,7 +477,7 @@ mbedtls_asn1_named_data *mbedtls_asn1_store_named_data( cur->val.len = val_len; } - if( val != NULL ) + if( val != NULL && val_len != 0 ) memcpy( cur->val.p, val, val_len ); return( cur ); |