summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2002-12-01 21:57:38 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2002-12-01 21:57:38 +0000
commit10092f86f822a4e446811ba8f8a9f516f45c677f (patch)
tree69b09cd6123b2f67775afcb144cd2d6790fbaf36
parent9c5879eecb11a9da1d7f97bd3bbef23486a067f2 (diff)
downloadgnutls-10092f86f822a4e446811ba8f8a9f516f45c677f.tar.gz
more fixes in gnutls_x509_extract_certificate_dn_string()
-rw-r--r--lib/gnutls_x509.c21
1 files changed, 11 insertions, 10 deletions
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);