From: Nikos Mavrogiannopoulos Date: Sun, 1 Dec 2002 21:57:38 +0000 (+0000) Subject: more fixes in gnutls_x509_extract_certificate_dn_string() X-Git-Tag: gnutls_0_6_0~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=10092f86f822a4e446811ba8f8a9f516f45c677f;p=thirdparty%2Fgnutls.git more fixes in gnutls_x509_extract_certificate_dn_string() --- diff --git a/lib/gnutls_x509.c b/lib/gnutls_x509.c index 754dd21af8..534a084d86 100644 --- a/lib/gnutls_x509.c +++ b/lib/gnutls_x509.c @@ -2880,7 +2880,7 @@ int gnutls_x509_extract_certificate_dn_string(char *buf, unsigned int sizeof_buf { gnutls_x509_dn dn; gnutls_string str; - int ret; + int ret, i; char str_buffer[256]; if (buf == NULL || sizeof_buf == 0) { @@ -2896,9 +2896,9 @@ int gnutls_x509_extract_certificate_dn_string(char *buf, unsigned int sizeof_buf gnutls_assert(); \ return GNUTLS_E_MEMORY_ERROR; \ } -#define PRINTX( x, y, i) \ +#define PRINTX( x, y) \ if (y[0]!=0) { \ - if (i!=0) STR_APPEND( ","); \ + if (i==0) i=1; else { STR_APPEND( ","); } \ STR_APPEND( x); \ STR_APPEND( "="); \ STR_APPEND( str_escape(y, str_buffer, sizeof(str_buffer))); \ @@ -2911,13 +2911,14 @@ int gnutls_x509_extract_certificate_dn_string(char *buf, unsigned int sizeof_buf if (ret < 0) return ret; - PRINTX( "CN", dn.common_name, 0); - PRINTX( "E", dn.email, 1); - PRINTX( "OU", dn.organizational_unit_name, 1); - PRINTX( "O", dn.organization, 1); - PRINTX( "L", dn.locality_name, 1); - PRINTX( "ST", dn.state_or_province_name, 1); - PRINTX( "C", dn.country, 1); + i = 0; + PRINTX( "CN", dn.common_name); + PRINTX( "E", dn.email); + PRINTX( "OU", dn.organizational_unit_name); + PRINTX( "O", dn.organization); + PRINTX( "L", dn.locality_name); + PRINTX( "ST", dn.state_or_province_name); + PRINTX( "C", dn.country); if (str.length >= sizeof_buf) { _gnutls_string_clear( &str);