Browse code

interactive.c: Resolve MSVC C4996 warning

It's about using a standard recommended alias for the wcsdup():

> warning C4996: 'wcsdup': The POSIX name for this item is deprecated.
> Instead, use the ISO C and C++ conformant name: _wcsdup. See online
> help for details.

And the documentation says:

> The Microsoft-implemented POSIX function names strdup and wcsdup are
> deprecated aliases for the _strdup and _wcsdup functions. By default,
> they generate Compiler warning (level 3) C4996. The names are
> deprecated because they don't follow the Standard C rules for
> implementation-specific names. However, the functions are still
> supported.
>
> We recommend you use _strdup and _wcsdup instead. Or, you can continue
> to use these function names, and disable the warning. For more
> information, see Turn off the warning and POSIX function names.

Reference:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strdup-wcs
dup
Signed-off-by: Simon Rozman <simon@rozman.si>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20210321144627.1621-3-simon@rozman.si>
URL: https://www.mail-archive.com/search?l=mid&q=20210321144627.1621-3-simon@rozman.si
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Simon Rozman via Openvpn-devel authored on 2021/03/21 23:46:25
Showing 1 changed files
... ...
@@ -899,7 +899,7 @@ ExecCommand(const WCHAR *argv0, const WCHAR *cmdline, DWORD timeout)
899 899
     si.cb = sizeof(si);
900 900
 
901 901
     /* CreateProcess needs a modifiable cmdline: make a copy */
902
-    cmdline_dup = wcsdup(cmdline);
902
+    cmdline_dup = _wcsdup(cmdline);
903 903
     if (cmdline_dup && CreateProcessW(argv0, cmdline_dup, NULL, NULL, FALSE,
904 904
                                       proc_flags, NULL, NULL, &si, &pi) )
905 905
     {
... ...
@@ -1181,7 +1181,7 @@ SetDNSDomain(const wchar_t *if_name, const char *domain, undo_lists_t *lists)
1181 1181
    /* Add to undo list if domain is non-empty */
1182 1182
    if (err == 0 && wdomain[0] && lists)
1183 1183
    {
1184
-        wchar_t *tmp_name = wcsdup(if_name);
1184
+        wchar_t *tmp_name = _wcsdup(if_name);
1185 1185
         if (!tmp_name || AddListItem(&(*lists)[undo_domain], tmp_name))
1186 1186
         {
1187 1187
             free(tmp_name);
... ...
@@ -1272,7 +1272,7 @@ HandleDNSConfigMessage(const dns_cfg_message_t *msg, undo_lists_t *lists)
1272 1272
 
1273 1273
     if (msg->addr_len > 0)
1274 1274
     {
1275
-        wchar_t *tmp_name = wcsdup(wide_name);
1275
+        wchar_t *tmp_name = _wcsdup(wide_name);
1276 1276
         if (!tmp_name || AddListItem(&(*lists)[undo_type], tmp_name))
1277 1277
         {
1278 1278
             free(tmp_name);