]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Wrap openvpn_swprintf into Windows define
authorLev Stipakov <lev@openvpn.net>
Tue, 23 Oct 2018 14:51:28 +0000 (17:51 +0300)
committerGert Doering <gert@greenie.muc.de>
Wed, 24 Oct 2018 15:52:55 +0000 (17:52 +0200)
Commit 43a5a4f3b4e411419639c195fee8a76495fdc88e added
vswprintf() call which turned to me missing in OpenBSD 4.9.

Since that call is inside openvpn_swprintf() function which
is only used by Windows, wrap that function info #ifdef _WIN32.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1540306288-23847-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17799.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/buffer.c
src/openvpn/buffer.h

index 8ca189fd4f216f11747cb16f35fa89e4ce90f5f5..27c7527188f54f03e29bd85c5097cc473a390132 100644 (file)
@@ -310,6 +310,13 @@ openvpn_snprintf(char *str, size_t size, const char *format, ...)
     return (len >= 0 && len < size);
 }
 
+/*
+ * openvpn_swprintf() is currently only used by Windows code paths
+ * and when enabled for all platforms it will currently break older 
+ * OpenBSD versions lacking vswprintf(3) support in their libc.
+ */
+
+#ifdef _WIN32
 bool
 openvpn_swprintf(wchar_t *const str, const size_t size, const wchar_t *const format, ...)
 {
@@ -324,6 +331,7 @@ openvpn_swprintf(wchar_t *const str, const size_t size, const wchar_t *const for
     }
     return (len >= 0 && len < size);
 }
+#endif
 
 /*
  * write a string to the end of a buffer that was
index c5b78a03fbad2f44e4dfdb79865ffe52f05b1833..8679ffac03e3df79e9e05f6de7e02e49d1add7c8 100644 (file)
@@ -449,8 +449,12 @@ __attribute__ ((format(__printf__, 3, 4)))
 ;
 
 
+#ifdef _WIN32
 /*
  * Like swprintf but guarantees null termination for size > 0
+ *
+ * This is under #ifdef because only Windows-specific code in tun.c
+ * uses this function and its implementation breaks OpenBSD <= 4.9
  */
 bool
 openvpn_swprintf(wchar_t *const str, const size_t size, const wchar_t *const format, ...);
@@ -458,6 +462,7 @@ openvpn_swprintf(wchar_t *const str, const size_t size, const wchar_t *const for
  * Unlike in openvpn_snprintf, we cannot use format attributes since
  * GCC doesn't support wprintf as archetype.
  */
+#endif
 
 /*
  * remove/add trailing characters