From: Simon Josefsson Date: Mon, 2 Feb 2009 14:12:51 +0000 (+0100) Subject: Simplify keyid printing to avoid allocation and asserts. X-Git-Tag: gnutls_2_7_5~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=199f770ea37f975045351801c08697d7c8e2b714;p=thirdparty%2Fgnutls.git Simplify keyid printing to avoid allocation and asserts. --- diff --git a/lib/x509/output.c b/lib/x509/output.c index 83c4cb7644..d503dc9a76 100644 --- a/lib/x509/output.c +++ b/lib/x509/output.c @@ -1139,36 +1139,19 @@ static void print_keyid (gnutls_string * str, gnutls_x509_crt_t cert) { int err; - size_t size = 0; - char *buffer = NULL; - - err = gnutls_x509_crt_get_key_id (cert, 0, buffer, &size); - if (err != GNUTLS_E_SHORT_MEMORY_BUFFER) - { - addf (str, "error: get_key_id: %s\n", gnutls_strerror (err)); - return; - } - - buffer = gnutls_malloc (size); - if (!buffer) - { - addf (str, "error: malloc: %s\n", gnutls_strerror (err)); - return; - } + char buffer[20]; + size_t size = 20; err = gnutls_x509_crt_get_key_id (cert, 0, buffer, &size); if (err < 0) { - gnutls_free (buffer); - addf (str, "error: get_key_id2: %s\n", gnutls_strerror (err)); + addf (str, "error: get_key_id: %s\n", gnutls_strerror (err)); return; } addf (str, _("\tPublic Key Id:\n\t\t")); hexprint (str, buffer, size); adds (str, "\n"); - - gnutls_free (buffer); } static void