]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
iservice: fix buffer size in call to FormatMessage
authorHeiko Hund <heiko@ist.eigentlich.net>
Sat, 22 Nov 2025 15:55:00 +0000 (16:55 +0100)
committerGert Doering <gert@greenie.muc.de>
Sat, 22 Nov 2025 17:39:35 +0000 (18:39 +0100)
The buffer size is to be given in # of TCHARs according to the docs. In
this case that is the number of WCHARs in the buffer.

While here, remove the unused FORMAT_MESSAGE_ARGUMENT_ARRAY flag. Just
to make things a bit shorter.

Reported-by: stephan@srlabs.de
Change-Id: I4c3e5aed23d2e4c543066bb8032ad8808dcd27a8
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1387
Message-Id: <20251122155506.8901-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34583.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpnserv/interactive.c

index 33282c635e779f5f2dc328dcd56658ce7ed1d636..f64c24725b7f7feb5c97141487d6c1238397b8a6 100644 (file)
@@ -734,9 +734,8 @@ BlockDNSErrHandler(DWORD err, const char *msg)
 
     err_str = L"Unknown Win32 Error";
 
-    if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM
-                          | FORMAT_MESSAGE_ARGUMENT_ARRAY,
-                      NULL, err, 0, buf, sizeof(buf), NULL))
+    if (FormatMessageW(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
+                       NULL, err, 0, buf, _countof(buf), NULL))
     {
         err_str = buf;
     }