]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: utils: use vasprintf() where available
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 19 Jul 2016 11:45:08 +0000 (13:45 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 19 Jul 2016 12:11:19 +0000 (14:11 +0200)
This allows printing long strings.

tests/utils.c

index 83ec426de8cb23b9e22e90465fe7a04d7a131b80..16649a79da1cc16be565f5149f46402a408bffa0 100644 (file)
@@ -93,13 +93,24 @@ const char *pkcs3_3072 =
 
 void _fail(const char *format, ...)
 {
-       char str[1024];
        va_list arg_ptr;
 
        va_start(arg_ptr, format);
-       vsnprintf(str, sizeof(str), format, arg_ptr);
+#ifdef HAVE_VASPRINTF
+       char *str = NULL;
+       vasprintf(&str, format, arg_ptr);
+
+       if (str)
+               fputs(str, stderr);
+#else
+       {
+               char str[1024];
+
+               vsnprintf(str, sizeof(str), format, arg_ptr);
+               fputs(str, stderr);
+       }
+#endif
        va_end(arg_ptr);
-       fputs(str, stderr);
        error_count++;
        exit(1);
 }