Browse code

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 <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>

Lev Stipakov authored on 2018/10/23 23:51:28
Showing 2 changed files
... ...
@@ -310,6 +310,13 @@ openvpn_snprintf(char *str, size_t size, const char *format, ...)
310 310
     return (len >= 0 && len < size);
311 311
 }
312 312
 
313
+/*
314
+ * openvpn_swprintf() is currently only used by Windows code paths
315
+ * and when enabled for all platforms it will currently break older 
316
+ * OpenBSD versions lacking vswprintf(3) support in their libc.
317
+ */
318
+
319
+#ifdef _WIN32
313 320
 bool
314 321
 openvpn_swprintf(wchar_t *const str, const size_t size, const wchar_t *const format, ...)
315 322
 {
... ...
@@ -324,6 +331,7 @@ openvpn_swprintf(wchar_t *const str, const size_t size, const wchar_t *const for
324 324
     }
325 325
     return (len >= 0 && len < size);
326 326
 }
327
+#endif
327 328
 
328 329
 /*
329 330
  * write a string to the end of a buffer that was
... ...
@@ -449,8 +449,12 @@ __attribute__ ((format(__printf__, 3, 4)))
449 449
 ;
450 450
 
451 451
 
452
+#ifdef _WIN32
452 453
 /*
453 454
  * Like swprintf but guarantees null termination for size > 0
455
+ *
456
+ * This is under #ifdef because only Windows-specific code in tun.c
457
+ * uses this function and its implementation breaks OpenBSD <= 4.9
454 458
  */
455 459
 bool
456 460
 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
458 458
  * Unlike in openvpn_snprintf, we cannot use format attributes since
459 459
  * GCC doesn't support wprintf as archetype.
460 460
  */
461
+#endif
461 462
 
462 463
 /*
463 464
  * remove/add trailing characters