[Openvpn-devel,v1] openvpnserv: don't use registry default as format string

Message ID 20261103200234.17639-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] openvpnserv: don't use registry default as format string |

Commit Message

Gert Doering Nov. 3, 2026, 8:02 p.m. UTC
  From: Razvan Cojocaru <razvanc@mailbox.org>

GetRegString() passed default_value, which is built from the install
path, as the swprintf() format, so a '%' in the path was interpreted
as a conversion. Print it with "%ls" and treat only a negative
return as failure.

Format string use introduced in b1263b06 ("Ensure strings read from
registry are null-terminated").

Change-Id: Ib53e82554712d881b1e24f6f3a2f8fbb702951bd
Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Heiko Hund <heiko@openvpn.net>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2110
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2110
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Heiko Hund <heiko@openvpn.net>
  

Patch

diff --git a/src/openvpnserv/common.c b/src/openvpnserv/common.c
index 7a23d41..671ddde 100644
--- a/src/openvpnserv/common.c
+++ b/src/openvpnserv/common.c
@@ -38,7 +38,7 @@ 
     if (status == ERROR_FILE_NOT_FOUND && default_value)
     {
         size_t len = size / sizeof(data[0]);
-        if (swprintf(data, len, default_value))
+        if (swprintf(data, len, L"%ls", default_value) >= 0)
         {
             status = ERROR_SUCCESS;
         }