From: Lev Stipakov Date: Tue, 23 Oct 2018 14:51:28 +0000 (+0300) Subject: Wrap openvpn_swprintf into Windows define X-Git-Tag: v2.5_beta1~393 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ce1a9b6b3ae0be32a3d999c5bc93731c64d7bbb;p=thirdparty%2Fopenvpn.git Wrap openvpn_swprintf into Windows define 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 Acked-by: Antonio Quartulli Acked-by: Selva Nair 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 --- diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 8ca189fd4..27c752718 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -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 diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index c5b78a03f..8679ffac0 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -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