diff options
-rw-r--r-- | lib/x509/common.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/lib/x509/common.c b/lib/x509/common.c index 495c649b7e..e890987ab2 100644 --- a/lib/x509/common.c +++ b/lib/x509/common.c @@ -325,6 +325,7 @@ _gnutls_x509_data2hex (const opaque * data, size_t data_size, { char *res; char escaped[MAX_STRING_LEN]; + unsigned int size; if (2 * data_size + 1 > MAX_STRING_LEN) { @@ -333,29 +334,24 @@ _gnutls_x509_data2hex (const opaque * data, size_t data_size, } res = _gnutls_bin2hex (data, data_size, escaped, sizeof (escaped)); - - if (res) + if (!res) { - unsigned int size = strlen (res) + 1; - if (size + 1 > *sizeof_out) - { - *sizeof_out = size; - return GNUTLS_E_SHORT_MEMORY_BUFFER; - } - *sizeof_out = size; /* -1 for the null +1 for the '#' */ - - if (out) - { - strcpy (out, "#"); - strcat (out, res); - } + gnutls_assert (); + return GNUTLS_E_INTERNAL_ERROR; + } - return 0; + size = strlen (res) + 1; + if (size + 1 > *sizeof_out) + { + *sizeof_out = size; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } - else + *sizeof_out = size; /* -1 for the null +1 for the '#' */ + + if (out) { - gnutls_assert (); - return GNUTLS_E_INTERNAL_ERROR; + strcpy (out, "#"); + strcat (out, res); } return 0; |