identification: Fix printing of empty RDNs on FreeBSD
authorTobias Brunner <tobias@strongswan.org>
Mon, 27 Jan 2014 12:50:28 +0000 (13:50 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 12 Feb 2014 12:45:42 +0000 (13:45 +0100)
On FreeBSD (null) is printed for NULL even if the precision is 0.

src/libstrongswan/utils/identification.c

index 9c43ad5..e7eb63b 100644 (file)
@@ -332,8 +332,13 @@ static void dntoa(chunk_t dn, char *buf, size_t len)
                buf += written;
                len -= written;
 
+               written = 0;
                chunk_printable(data, &printable, '?');
-               written = snprintf(buf, len, "%.*s", (int)printable.len, printable.ptr);
+               if (printable.ptr)
+               {
+                       written = snprintf(buf, len, "%.*s", (int)printable.len,
+                                                          printable.ptr);
+               }
                chunk_free(&printable);
                if (written < 0 || written >= len)
                {