diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-02-20 13:49:55 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-02-21 08:51:18 +0100 |
commit | 56453bb2c8dc45aa592385f586d4f9e190e1d83d (patch) | |
tree | 58eabd3fe33eb5f759aa230231f90efc9d75fde9 | |
parent | 4512cfde33b721b8b452fcc77710b50348f0793e (diff) | |
download | gnutls-56453bb2c8dc45aa592385f586d4f9e190e1d83d.tar.gz |
make_printable_string: allow operation with null input
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r-- | lib/x509/common.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/x509/common.c b/lib/x509/common.c index b260784a6c..12fc7c7e56 100644 --- a/lib/x509/common.c +++ b/lib/x509/common.c @@ -285,6 +285,15 @@ make_printable_string(unsigned etype, const gnutls_datum_t * input, int printable = 0; int ret; + /* empty input strings result to a null string */ + if (input->data == NULL || input->size == 0) { + out->data = gnutls_calloc(1, 1); + if (out->data == NULL) + return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR); + out->size = 0; + return 0; + } + if (etype == ASN1_ETYPE_BMP_STRING) { ret = _gnutls_ucs2_to_utf8(input->data, input->size, out, 1); if (ret < 0) { @@ -399,6 +408,8 @@ decode_complex_string(const struct oid_to_string *oentry, void *value, /* _gnutls_x509_read_value always null terminates */ } + assert(out->data != NULL); + /* Refuse to deal with strings containing NULs. */ if (strlen((void *) out->data) != (size_t) out->size) { _gnutls_free_datum(out); |