pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for mount paths with Japanese characters, nfs_mount nfs://-URL shell-safe encoding, cleanup+misc, 2024-11-26
Posted by Anonymous on Tue 26th Nov 2024 13:26
raw | new post

  1. From 454b7c01fd24bea247087c4cf1e270d779efe553 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 26 Nov 2024 10:56:33 +0100
  4. Subject: [PATCH 1/6] mount: Listing shares prints %ff for all Japanese
  5.  characters in nfs://-URL
  6.  
  7. Listing shares prints %ff for all Japanese characters in nfs://-URL
  8.  
  9. Reported-by: Takeshi Nishimura <takeshi.nishimura.linux@gmail.com>
  10. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  11. ---
  12. mount/enum.c | 4 ++--
  13.  1 file changed, 2 insertions(+), 2 deletions(-)
  14.  
  15. diff --git a/mount/enum.c b/mount/enum.c
  16. index df377a8..b31d019 100644
  17. --- a/mount/enum.c
  18. +++ b/mount/enum.c
  19. @@ -122,7 +122,7 @@ void PrintMountLine(
  20.      utf8unc_p += 2;
  21.  
  22.      for ( ; *utf8unc_p != '\0' ; ) {
  23. -        char uc = *utf8unc_p++;
  24. +        unsigned char uc = *utf8unc_p++;
  25.  
  26.          if (uc == '/')
  27.              slash_counter++;
  28. @@ -166,7 +166,7 @@ void PrintMountLine(
  29.       * in this context it is safe to use
  30.       */
  31.  #pragma warning (disable : 4996)
  32. -            (void)sprintf(us, "%%%2.2x", uc);
  33. +            (void)sprintf(us, "%%%2.2x", (int)uc);
  34.  #pragma warning( pop )
  35.              us+=3;
  36.          }
  37. --
  38. 2.45.1
  39.  
  40. From c51947e5caea5d5fc167193d11aae26135d131b5 Mon Sep 17 00:00:00 2001
  41. From: Roland Mainz <roland.mainz@nrubsig.org>
  42. Date: Tue, 26 Nov 2024 11:01:51 +0100
  43. Subject: [PATCH 2/6] mount: Always encode '+' in nfs://-URLs
  44.  
  45. mount: Always encode '+' in nfs://-URLs, because plain '+' characters
  46. are decoded into a <space>.
  47.  
  48. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  49. ---
  50. mount/enum.c | 6 ++++--
  51.  1 file changed, 4 insertions(+), 2 deletions(-)
  52.  
  53. diff --git a/mount/enum.c b/mount/enum.c
  54. index b31d019..2033c9c 100644
  55. --- a/mount/enum.c
  56. +++ b/mount/enum.c
  57. @@ -89,7 +89,9 @@ void PrintMountLine(
  58.   * characters which must be encoded because they have a special meaning:
  59.   * ";", "/", "?", ":", "@", "=" and "&"
  60.   * Only alphanumerics, "$-_.+!*'()," and reserved characters
  61. - * ("/" for nfs://-URLS) are allowed
  62. + * ("/" for nfs://-URLS) are allowed.
  63. + * Note that '+' must always be encoded because urldecoding
  64. + * turns it into a <space>.
  65.   */
  66.  #define ISVALIDURLCHAR(c) \
  67.         ( \
  68. @@ -97,7 +99,7 @@ void PrintMountLine(
  69.             ((c) >= 'a' && (c) <= 'z') || \
  70.             ((c) >= 'A' && (c) <= 'Z') || \
  71.              ((c) == '$') || ((c) == '-') || ((c) == '_') || ((c) == '.') || \
  72. -            ((c) == '+') || ((c) == '!') || ((c) == '*') || ((c) == '\'') || \
  73. +            ((c) == '!') || ((c) == '*') || ((c) == '\'') || \
  74.              ((c) == '(') || ((c) == ')') || ((c) == ',') || ((c) == '/') \
  75.          )
  76.  
  77. --
  78. 2.45.1
  79.  
  80. From 7be55feda09f6e251c879411cfb4259172e59ffd Mon Sep 17 00:00:00 2001
  81. From: Roland Mainz <roland.mainz@nrubsig.org>
  82. Date: Tue, 26 Nov 2024 11:09:06 +0100
  83. Subject: [PATCH 3/6] mount: Encode POSIX/bash/ksh93 special characters in
  84.  nfs://-URLs to make them "safe" for shells
  85.  
  86. Encode POSIX/bash/ksh93 special characters in nfs://-URLs to make
  87. them "safe" for shells to use without quotes, e.g. no globbing ('*'),
  88. no subshell ('(', ')'), no history ('!') characters etc.
  89.  
  90. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  91. ---
  92. mount/enum.c | 17 +++++++++++++++++
  93.  1 file changed, 17 insertions(+)
  94.  
  95. diff --git a/mount/enum.c b/mount/enum.c
  96. index 2033c9c..176f135 100644
  97. --- a/mount/enum.c
  98. +++ b/mount/enum.c
  99. @@ -93,6 +93,22 @@ void PrintMountLine(
  100.   * Note that '+' must always be encoded because urldecoding
  101.   * turns it into a <space>.
  102.   */
  103. +/*
  104. + * SHELL_SAFE_URLS - urlencode characters which are special words
  105. + * in POSIX shells, e.g. '!', '(', ')', '*', "'", "$".
  106. + * Fixme: This should be a command-line option
  107. + */
  108. +#define SHELL_SAFE_URLS 1
  109. +#ifdef SHELL_SAFE_URLS
  110. +#define ISVALIDURLCHAR(c) \
  111. +       ( \
  112. +            ((c) >= '0' && (c) <= '9') || \
  113. +           ((c) >= 'a' && (c) <= 'z') || \
  114. +           ((c) >= 'A' && (c) <= 'Z') || \
  115. +            ((c) == '-') || ((c) == '_') || ((c) == '.') || \
  116. +            ((c) == '/') \
  117. +        )
  118. +#else
  119.  #define ISVALIDURLCHAR(c) \
  120.         ( \
  121.              ((c) >= '0' && (c) <= '9') || \
  122. @@ -102,6 +118,7 @@ void PrintMountLine(
  123.              ((c) == '!') || ((c) == '*') || ((c) == '\'') || \
  124.              ((c) == '(') || ((c) == ')') || ((c) == ',') || ((c) == '/') \
  125.          )
  126. +#endif /* SHELL_SAFE_URLS */
  127.  
  128.      unsigned int slash_counter = 0;
  129.      char *utf8unc = wcs2utf8str(cygwin_unc_buffer);
  130. --
  131. 2.45.1
  132.  
  133. From ef92495d1fae0227dc656dc9c3e2f43f0899825f Mon Sep 17 00:00:00 2001
  134. From: Roland Mainz <roland.mainz@nrubsig.org>
  135. Date: Tue, 26 Nov 2024 12:52:19 +0100
  136. Subject: [PATCH 4/6] mount: Fix Japanese character output in UNC path field
  137.  
  138. Fix Japanese character output in UNC path field
  139.  
  140. Reported-by: Takeshi Nishimura <takeshi.nishimura.linux@gmail.com>
  141. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  142. ---
  143. mount/mount.c | 9 ++++++++-
  144.  1 file changed, 8 insertions(+), 1 deletion(-)
  145.  
  146. diff --git a/mount/mount.c b/mount/mount.c
  147. index 8c6b008..717f46c 100644
  148. --- a/mount/mount.c
  149. +++ b/mount/mount.c
  150. @@ -31,6 +31,9 @@
  151.  #include <stdlib.h>
  152.  #include <stdbool.h>
  153.  #include <stdio.h>
  154. +#include <locale.h>
  155. +#include <io.h>
  156. +#include <fcntl.h>
  157.  
  158.  #include "nfs41_build_features.h"
  159.  #include "nfs41_driver.h" /* |NFS41_PROVIDER_NAME_U| */
  160. @@ -562,8 +565,12 @@ int list_nfs_mounts_main(int argc, wchar_t *argv[])
  161.  int __cdecl wmain(int argc, wchar_t *argv[])
  162.  {
  163.      DWORD result = NO_ERROR;
  164. -
  165.      int crtsetdbgflags = 0;
  166. +
  167. +    (void)setlocale(LC_ALL, "");
  168. +    (void)_setmode(_fileno(stdout), _O_WTEXT);
  169. +    (void)_setmode(_fileno(stderr), _O_WTEXT);
  170. +
  171.      crtsetdbgflags |= _CRTDBG_ALLOC_MEM_DF;  /* use debug heap */
  172.      crtsetdbgflags |= _CRTDBG_LEAK_CHECK_DF; /* report leaks on exit */
  173.      crtsetdbgflags |= _CRTDBG_DELAY_FREE_MEM_DF;
  174. --
  175. 2.45.1
  176.  
  177. From 34eb11090d2d34e15be59520095894d15a7c0304 Mon Sep 17 00:00:00 2001
  178. From: Roland Mainz <roland.mainz@nrubsig.org>
  179. Date: Tue, 26 Nov 2024 13:12:49 +0100
  180. Subject: [PATCH 5/6] daemon,dll,mount: Fix |GetLastError()| handing
  181.  
  182. Fix |GetLastError()| handing: Callers should always call |GetLastError()|
  183. first BEFORE calling debug printf or similar functinos, or
  184. save the lasterror code and restore it after the debug code.
  185.  
  186. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  187. ---
  188. daemon/daemon_debug.c | 11 +++++++----
  189.  daemon/nfs41_daemon.c |  5 +++--
  190.  dll/nfs41_np.c        | 16 ++++++++++++----
  191.  mount/mount.c         |  4 ++--
  192.  4 files changed, 24 insertions(+), 12 deletions(-)
  193.  
  194. diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
  195. index 15a3855..21b29e6 100644
  196. --- a/daemon/daemon_debug.c
  197. +++ b/daemon/daemon_debug.c
  198. @@ -47,20 +47,23 @@ void open_log_files()
  199.      const char dfile[] = "nfsddbg.log";
  200.      const char efile[] = "nfsderr.log";
  201.      const char mode[] = "w";
  202. +    DWORD lasterr;
  203.  
  204.      (void)remove(efile);
  205.      (void)remove(dfile);
  206.  
  207.      elog_file = fopen(efile, mode);
  208.      if (elog_file == NULL) {
  209. -        ReportStatusToSCMgr(SERVICE_STOPPED, GetLastError(), 0);
  210. -        exit (GetLastError());
  211. +        lasterr = GetLastError();
  212. +        ReportStatusToSCMgr(SERVICE_STOPPED, lasterr, 0);
  213. +        exit(lasterr);
  214.      }
  215.  
  216.      dlog_file = fopen(dfile, mode);
  217.      if (dlog_file == NULL) {
  218. -        ReportStatusToSCMgr(SERVICE_STOPPED, GetLastError(), 0);
  219. -        exit (GetLastError());
  220. +        lasterr = GetLastError();
  221. +        ReportStatusToSCMgr(SERVICE_STOPPED, lasterr, 0);
  222. +        exit(lasterr);
  223.      }
  224.  }
  225.  
  226. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  227. index e9fec3a..d442fd2 100644
  228. --- a/daemon/nfs41_daemon.c
  229. +++ b/daemon/nfs41_daemon.c
  230. @@ -154,8 +154,9 @@ static unsigned int nfsd_worker_thread_main(void *args)
  231.          0, NULL);
  232.      if (pipe == INVALID_HANDLE_VALUE)
  233.      {
  234. -        eprintf("Unable to open upcall pipe %d\n", GetLastError());
  235. -        return GetLastError();
  236. +        DWORD lasterr = GetLastError();
  237. +        eprintf("Unable to open upcall pipe %d\n", (int)lasterr);
  238. +        return lasterr;
  239.      }
  240.  
  241.      while(1) {
  242. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  243. index 07f2984..5bce2cd 100644
  244. --- a/dll/nfs41_np.c
  245. +++ b/dll/nfs41_np.c
  246. @@ -61,11 +61,14 @@ static DWORD is_unc_path_mounted(__in LPWSTR lpRemoteName);
  247.  
  248.  ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  249.  {
  250. +    DWORD saved_lasterr;
  251.      ULONG rc = 0;
  252.  #define SZBUFFER_SIZE 1024
  253.      wchar_t szbuffer[SZBUFFER_SIZE+1];
  254.      wchar_t *szbp = szbuffer;
  255.  
  256. +    saved_lasterr = GetLastError();
  257. +
  258.      va_list marker;
  259.      va_start(marker, fmt);
  260.  
  261. @@ -81,6 +84,8 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  262.  
  263.      va_end(marker);
  264.  
  265. +    SetLastError(saved_lasterr);
  266. +
  267.      return rc;
  268.  }
  269.  
  270. @@ -695,13 +700,16 @@ NPAddConnection3(
  271.          }
  272.      }
  273.      else {
  274. +        DWORD lasterr;
  275. +
  276.          wszScratch[0] = L'\0';
  277.          Status = QueryDosDevice(LocalName, wszScratch, 1024);
  278. +        lasterr = GetLastError();
  279.          DbgP((L"QueryDosDevice(lpDeviceName='%s',lpTargetPath='%s') "
  280.              L"returned %d/GetLastError()=%d\n",
  281. -            LocalName, wszScratch, Status, (int)GetLastError()));
  282. +            LocalName, wszScratch, Status, (int)lasterr));
  283.  
  284. -        if (Status || (GetLastError() != ERROR_FILE_NOT_FOUND)) {
  285. +        if (Status || (lasterr != ERROR_FILE_NOT_FOUND)) {
  286.              Status = WN_ALREADY_CONNECTED;
  287.              goto out;
  288.          }
  289. @@ -887,9 +895,9 @@ NPCancelConnection(
  290.                          DDD_RAW_TARGET_PATH | DDD_EXACT_MATCH_ON_REMOVE,
  291.                      lpName,
  292.                      pNetResource->ConnectionName) == FALSE) {
  293. -                    DbgP((L"DefineDosDevice error: %d\n",
  294. -                        GetLastError()));
  295.                      Status = GetLastError();
  296. +                    DbgP((L"DefineDosDevice error: %d\n",
  297. +                        (int)Status));
  298.                  }
  299.                  else {
  300.                      pNetResource->InUse = FALSE;
  301. diff --git a/mount/mount.c b/mount/mount.c
  302. index 717f46c..1ad62a6 100644
  303. --- a/mount/mount.c
  304. +++ b/mount/mount.c
  305. @@ -710,10 +710,10 @@ static DWORD ParseRemoteName(
  306.           */
  307.          premotename_utf8 = wcs2utf8str(premotename);
  308.          if (!premotename_utf8) {
  309. +            result = GetLastError();
  310.              (void)fwprintf(stderr,
  311.                  L"wcs2utf8str() failed, lasterr=%d\n.",
  312. -                (int)GetLastError());
  313. -            result = GetLastError();
  314. +                (int)result);
  315.              goto out;
  316.          }
  317.  
  318. --
  319. 2.45.1
  320.  
  321. From ec322d3e60a13a050730013c316cec3c53baa6c9 Mon Sep 17 00:00:00 2001
  322. From: Roland Mainz <roland.mainz@nrubsig.org>
  323. Date: Tue, 26 Nov 2024 13:58:52 +0100
  324. Subject: [PATCH 6/6] dll,mount: Explicitly use the |*W()| (widechar) APIs
  325.  instead of the TCHAR ones
  326.  
  327. Cleanup: Explicitly use the |*W()| (widechar) APIs instead of the TCHAR ones
  328.  
  329. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  330. ---
  331. dll/nfs41_np.c  | 34 +++++++++++++++++-----------------
  332.  mount/enum.c    |  8 ++++----
  333.  mount/mount.c   | 32 ++++++++++++++++----------------
  334.  mount/options.c | 12 ++++++------
  335.  mount/options.h |  9 +++++----
  336.  5 files changed, 48 insertions(+), 47 deletions(-)
  337.  
  338. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  339. index 5bce2cd..fb25f5c 100644
  340. --- a/dll/nfs41_np.c
  341. +++ b/dll/nfs41_np.c
  342. @@ -59,7 +59,7 @@ const LUID SystemLuid = SYSTEM_LUID;
  343.  static DWORD is_unc_path_mounted(__in LPWSTR lpRemoteName);
  344.  
  345.  
  346. -ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  347. +ULONG _cdecl NFS41DbgPrint(__in LPWSTR fmt, ...)
  348.  {
  349.      DWORD saved_lasterr;
  350.      ULONG rc = 0;
  351. @@ -80,7 +80,7 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  352.          fmt, marker);
  353.      szbuffer[SZBUFFER_SIZE-1] = L'\0';
  354.  
  355. -    OutputDebugString(szbuffer);
  356. +    OutputDebugStringW(szbuffer);
  357.  
  358.      va_end(marker);
  359.  
  360. @@ -326,13 +326,13 @@ static DWORD StoreConnectionInfo(
  361.          (USHORT)(wcslen(lpNetResource->lpRemoteName)+1)*sizeof(WCHAR);
  362.      pNfs41NetResource->ConnectionNameLength = ConnectionNameLength;
  363.  
  364. -    (void)StringCchCopy(pNfs41NetResource->LocalName,
  365. +    (void)StringCchCopyW(pNfs41NetResource->LocalName,
  366.          pNfs41NetResource->LocalNameLength,
  367.          LocalName);
  368. -    (void)StringCchCopy(pNfs41NetResource->RemoteName,
  369. +    (void)StringCchCopyW(pNfs41NetResource->RemoteName,
  370.          pNfs41NetResource->RemoteNameLength,
  371.          lpNetResource->lpRemoteName);
  372. -    (void)StringCchCopy(pNfs41NetResource->ConnectionName,
  373. +    (void)StringCchCopyW(pNfs41NetResource->ConnectionName,
  374.          pNfs41NetResource->ConnectionNameLength,
  375.          ConnectionName);
  376.  
  377. @@ -555,7 +555,7 @@ NPAddConnection3(
  378.      //  \device\miniredirector\;<DriveLetter>:\Server\Share
  379.  
  380.      // local name, must start with "X:"
  381. -    if (lstrlen(lpLocalName) < 2 ||
  382. +    if (wcslen(lpLocalName) < 2 ||
  383.          lpLocalName[1] != L':') {
  384.          DbgP((L"lpLocalName(='%s') "
  385.              "is not a device letter\n",
  386. @@ -676,7 +676,7 @@ NPAddConnection3(
  387.      DbgP((L"Full Connect Name: '%s'\n", ConnectionName));
  388.      DbgP((L"Full Connect Name Length: %d %d\n",
  389.          (wcslen(ConnectionName) + 1) * sizeof(WCHAR),
  390. -        (lstrlen(ConnectionName) + 1) * sizeof(WCHAR)));
  391. +        (wcslen(ConnectionName) + 1) * sizeof(WCHAR)));
  392.  
  393.      if (lpNetResource->lpLocalName == NULL) {
  394.          DWORD gc_status;
  395. @@ -703,9 +703,9 @@ NPAddConnection3(
  396.          DWORD lasterr;
  397.  
  398.          wszScratch[0] = L'\0';
  399. -        Status = QueryDosDevice(LocalName, wszScratch, 1024);
  400. +        Status = QueryDosDeviceW(LocalName, wszScratch, 1024);
  401.          lasterr = GetLastError();
  402. -        DbgP((L"QueryDosDevice(lpDeviceName='%s',lpTargetPath='%s') "
  403. +        DbgP((L"QueryDosDeviceW(lpDeviceName='%s',lpTargetPath='%s') "
  404.              L"returned %d/GetLastError()=%d\n",
  405.              LocalName, wszScratch, Status, (int)lasterr));
  406.  
  407. @@ -726,15 +726,15 @@ NPAddConnection3(
  408.      }
  409.  
  410.      if (lpNetResource->lpLocalName != NULL) {
  411. -        DbgP((L"DefineDosDevice(lpLocalName='%s', "
  412. +        DbgP((L"DefineDosDeviceW(lpLocalName='%s', "
  413.              L"ConnectionName='%s')\n",
  414.              lpLocalName, ConnectionName));
  415. -        if (!DefineDosDevice(DDD_RAW_TARGET_PATH |
  416. +        if (!DefineDosDeviceW(DDD_RAW_TARGET_PATH |
  417.              DDD_NO_BROADCAST_SYSTEM,
  418.              lpLocalName,
  419.              ConnectionName)) {
  420.              Status = GetLastError();
  421. -            DbgP((L"DefineDosDevice(lpLocalName='%s',"
  422. +            DbgP((L"DefineDosDeviceW(lpLocalName='%s',"
  423.                  L"ConnectionName='%s') failed with %d\n",
  424.                  lpLocalName, ConnectionName, Status));
  425.              goto out_delconn;
  426. @@ -756,7 +756,7 @@ out:
  427.      return Status;
  428.  out_undefine:
  429.      if (lpNetResource->lpLocalName != NULL) {
  430. -        (void)DefineDosDevice(DDD_REMOVE_DEFINITION |
  431. +        (void)DefineDosDeviceW(DDD_REMOVE_DEFINITION |
  432.              DDD_RAW_TARGET_PATH |
  433.              DDD_EXACT_MATCH_ON_REMOVE,
  434.              LocalName, ConnectionName);
  435. @@ -891,12 +891,12 @@ NPCancelConnection(
  436.                      break;
  437.                  }
  438.  
  439. -                if (DefineDosDevice(DDD_REMOVE_DEFINITION |
  440. +                if (DefineDosDeviceW(DDD_REMOVE_DEFINITION |
  441.                          DDD_RAW_TARGET_PATH | DDD_EXACT_MATCH_ON_REMOVE,
  442.                      lpName,
  443.                      pNetResource->ConnectionName) == FALSE) {
  444.                      Status = GetLastError();
  445. -                    DbgP((L"DefineDosDevice error: %d\n",
  446. +                    DbgP((L"DefineDosDeviceW error: %d\n",
  447.                          (int)Status));
  448.                  }
  449.                  else {
  450. @@ -1244,13 +1244,13 @@ NPEnumResource(
  451.                  SpaceNeeded -= sizeof(NETRESOURCE);
  452.                  StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded);
  453.                  // copy local name
  454. -                (void)StringCchCopy(StringZone,
  455. +                (void)StringCchCopyW(StringZone,
  456.                      pNfsNetResource->LocalNameLength,
  457.                      pNfsNetResource->LocalName);
  458.                  pNetResource->lpLocalName = StringZone;
  459.                  StringZone += pNfsNetResource->LocalNameLength/sizeof(WCHAR);
  460.                  // copy remote name
  461. -                (void)StringCchCopy(StringZone,
  462. +                (void)StringCchCopyW(StringZone,
  463.                      pNfsNetResource->RemoteNameLength,
  464.                      pNfsNetResource->RemoteName);
  465.                  pNetResource->lpRemoteName = StringZone;
  466. diff --git a/mount/enum.c b/mount/enum.c
  467. index 176f135..00f2b34 100644
  468. --- a/mount/enum.c
  469. +++ b/mount/enum.c
  470. @@ -219,21 +219,21 @@ void PrintMountLine(
  471.  #define ENUM_RESOURCE_BUFFER_SIZE (16*1024)
  472.  
  473.  DWORD EnumMounts(
  474. -    IN LPNETRESOURCE pContainer)
  475. +    IN LPNETRESOURCEW pContainer)
  476.  {
  477.      DWORD result = NO_ERROR;
  478. -    LPNETRESOURCE pResources;
  479. +    LPNETRESOURCEW pResources;
  480.      DWORD i, dwCount, dwTotal = 0;
  481.      DWORD dwBufferSize = ENUM_RESOURCE_BUFFER_SIZE;
  482.      HANDLE hEnum;
  483.  
  484. -    pResources = (LPNETRESOURCE)GlobalAlloc(0, ENUM_RESOURCE_BUFFER_SIZE);
  485. +    pResources = (LPNETRESOURCEW)GlobalAlloc(0, ENUM_RESOURCE_BUFFER_SIZE);
  486.      if (pResources == NULL) {
  487.          result = WN_OUT_OF_MEMORY;
  488.          goto out;
  489.      }
  490.  
  491. -    result = WNetOpenEnum(RESOURCE_CONNECTED,
  492. +    result = WNetOpenEnumW(RESOURCE_CONNECTED,
  493.          RESOURCETYPE_DISK, 0, pContainer, &hEnum);
  494.      if (result)
  495.          goto out_free;
  496. diff --git a/mount/mount.c b/mount/mount.c
  497. index 1ad62a6..7c8b0db 100644
  498. --- a/mount/mount.c
  499. +++ b/mount/mount.c
  500. @@ -51,7 +51,7 @@
  501.  #define MOUNT_CONFIG_NFS_PORT_DEFAULT   2049
  502.  
  503.  DWORD EnumMounts(
  504. -    IN LPNETRESOURCE pContainer);
  505. +    IN LPNETRESOURCEW pContainer);
  506.  
  507.  static DWORD ParseRemoteName(
  508.      IN bool use_nfspubfh,
  509. @@ -72,7 +72,7 @@ static DWORD DoUnmount(
  510.      IN BOOL bForce);
  511.  static BOOL ParseDriveLetter(
  512.      IN LPWSTR pArg,
  513. -    OUT PTCH pDriveLetter);
  514. +    OUT PWCH pDriveLetter);
  515.  void PrintErrorMessage(
  516.      IN DWORD dwError);
  517.  
  518. @@ -687,7 +687,7 @@ static DWORD ParseRemoteName(
  519.      wchar_t srvname[SRVNAME_LEN];
  520.      url_parser_context *uctx = NULL;
  521.  
  522. -    result = StringCchCopy(premotename, NFS41_SYS_MAX_PATH_LEN, pRemoteName);
  523. +    result = StringCchCopyW(premotename, NFS41_SYS_MAX_PATH_LEN, pRemoteName);
  524.  
  525.      /*
  526.       * Support nfs://-URLS per RFC 2224 ("NFS URL
  527. @@ -962,22 +962,22 @@ static DWORD ParseRemoteName(
  528.          goto out;
  529.      }
  530.  
  531. -    result = StringCchCopy(pConnectionName, cchConnectionLen, L"\\\\");
  532. +    result = StringCchCopyW(pConnectionName, cchConnectionLen, L"\\\\");
  533.      if (FAILED(result))
  534.          goto out;
  535. -    result = StringCbCat(pConnectionName, cchConnectionLen, srvname);
  536. +    result = StringCbCatW(pConnectionName, cchConnectionLen, srvname);
  537.      if (FAILED(result))
  538.          goto out;
  539.  #ifdef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
  540. -    result = StringCbCat(pConnectionName, cchConnectionLen,
  541. +    result = StringCbCatW(pConnectionName, cchConnectionLen,
  542.          (use_nfspubfh?(L"\\pubnfs4"):(L"\\nfs4")));
  543.      if (FAILED(result))
  544.          goto out;
  545.  #endif /* NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX */
  546.      if (*pEnd)
  547. -        result = StringCchCat(pConnectionName, cchConnectionLen, pEnd);
  548. +        result = StringCchCatW(pConnectionName, cchConnectionLen, pEnd);
  549.  
  550. -    result = StringCchCopy(pParsedRemoteName, cchConnectionLen, srvname);
  551. +    result = StringCchCopyW(pParsedRemoteName, cchConnectionLen, srvname);
  552.  
  553.  #ifdef DEBUG_MOUNT
  554.      (void)fwprintf(stderr,
  555. @@ -1007,7 +1007,7 @@ static DWORD DoMount(
  556.      DWORD result = NO_ERROR;
  557.      wchar_t szExisting[NFS41_SYS_MAX_PATH_LEN];
  558.      DWORD dwLength;
  559. -    NETRESOURCE NetResource;
  560. +    NETRESOURCEW NetResource;
  561.  
  562.      if (pOptions->Buffer->Length) {
  563.          if (pOptions->Current)
  564. @@ -1027,7 +1027,7 @@ static DWORD DoMount(
  565.      if (pLocalName) {
  566.          /* fail if the connection already exists */
  567.          dwLength = NFS41_SYS_MAX_PATH_LEN;
  568. -        result = WNetGetConnection(pLocalName, (LPWSTR)szExisting, &dwLength);
  569. +        result = WNetGetConnectionW(pLocalName, (LPWSTR)szExisting, &dwLength);
  570.          if (result == NO_ERROR) {
  571.              result = ERROR_ALREADY_ASSIGNED;
  572.              (void)fwprintf(stderr, L"Mount failed, drive '%s' is "
  573. @@ -1042,7 +1042,7 @@ static DWORD DoMount(
  574.      DWORD ConnectResult;
  575.      DWORD Flags = 0;
  576.  
  577. -    (void)memset(&NetResource, 0, sizeof(NETRESOURCE));
  578. +    (void)memset(&NetResource, 0, sizeof(NETRESOURCEW));
  579.      NetResource.dwType = RESOURCETYPE_DISK;
  580.      if (pLocalName) {
  581.          /* drive letter is chosen automatically if lpLocalName == "*" */
  582. @@ -1062,7 +1062,7 @@ static DWORD DoMount(
  583.      if (bPersistent)
  584.          Flags |= CONNECT_UPDATE_PROFILE;
  585.  
  586. -    result = WNetUseConnection(NULL,
  587. +    result = WNetUseConnectionW(NULL,
  588.          &NetResource, NULL, NULL, Flags,
  589.          szConnection, &ConnectSize, &ConnectResult);
  590.  
  591. @@ -1071,7 +1071,7 @@ static DWORD DoMount(
  592.              pParsedRemoteName, szConnection);
  593.      }
  594.      else {
  595. -        (void)fwprintf(stderr, L"WNetUseConnection('%s', '%s') "
  596. +        (void)fwprintf(stderr, L"WNetUseConnectionW('%s', '%s') "
  597.              L"failed with error code %u.\n",
  598.              pLocalName, pRemoteName, result);
  599.      }
  600. @@ -1086,7 +1086,7 @@ static DWORD DoUnmount(
  601.      DWORD result;
  602.  
  603.      /* disconnect the specified local drive */
  604. -    result = WNetCancelConnection2(pLocalName, CONNECT_UPDATE_PROFILE, bForce);
  605. +    result = WNetCancelConnection2W(pLocalName, CONNECT_UPDATE_PROFILE, bForce);
  606.      /* TODO: verify that this connection uses the nfs41 provider -cbodley */
  607.      switch (result)
  608.      {
  609. @@ -1099,7 +1099,7 @@ static DWORD DoUnmount(
  610.              L"connected.\n", pLocalName);
  611.          break;
  612.      default:
  613. -        (void)fwprintf(stderr, L"WNetCancelConnection2('%s') failed "
  614. +        (void)fwprintf(stderr, L"WNetCancelConnection2W('%s') failed "
  615.              L"with error code %u.\n", pLocalName, result);
  616.          break;
  617.      }
  618. @@ -1139,7 +1139,7 @@ void PrintErrorMessage(
  619.      IN DWORD dwError)
  620.  {
  621.      LPWSTR lpMsgBuf = NULL;
  622. -    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
  623. +    FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
  624.          NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  625.          (LPWSTR)&lpMsgBuf, 0, NULL);
  626.      (void)fputws(lpMsgBuf, stderr);
  627. diff --git a/mount/options.c b/mount/options.c
  628. index 9f20bae..af48428 100644
  629. --- a/mount/options.c
  630. +++ b/mount/options.c
  631. @@ -66,7 +66,7 @@ BOOL FindOptionByName(
  632.      for (;;)
  633.      {
  634.          if ((Current->EaNameLength == NameLength) &&
  635. -            (!wcscmp((LPTSTR)Current->EaName, Name))) {
  636. +            (!wcscmp((LPWSTR)Current->EaName, Name))) {
  637.              *ppOption = Current;
  638.              return TRUE;
  639.          }
  640. @@ -147,12 +147,12 @@ BOOL InsertOption(
  641.  
  642.      Current->EaNameLength = NameLen;
  643.      if (NameLen) /* copy attribute name */
  644. -        StringCbCopy((LPTSTR)Current->EaName,
  645. +        StringCbCopyW((LPWSTR)Current->EaName,
  646.              NameLen + sizeof(wchar_t), Name);
  647.  
  648.      Current->EaValueLength = ValueLen;
  649.      if (ValueLen) /* copy attribute value */
  650. -        StringCbCopy((LPTSTR)(Current->EaName + NameLen + sizeof(wchar_t)),
  651. +        StringCbCopyW((LPWSTR)(Current->EaName + NameLen + sizeof(wchar_t)),
  652.              ValueLen + sizeof(wchar_t), Value);
  653.  
  654.      Current->Flags = 0;
  655. @@ -182,8 +182,8 @@ void RecursivePrintEaInformation(
  656.          EA->Flags,
  657.          EA->EaNameLength,
  658.          EA->EaValueLength,
  659. -        (LPTSTR)EA->EaName,
  660. -        (LPTSTR)(EA->EaName + EA->EaNameLength + sizeof(wchar_t)));
  661. +        (LPWSTR)EA->EaName,
  662. +        (LPWSTR)(EA->EaName + EA->EaNameLength + sizeof(wchar_t)));
  663.  
  664.      if (EA->NextEntryOffset)
  665.          RecursivePrintEaInformation((PFILE_FULL_EA_INFORMATION)
  666. @@ -194,7 +194,7 @@ static const wchar_t COMMA_T = L',';
  667.  static const wchar_t EQUAL_T = L'=';
  668.  
  669.  BOOL ParseMountOptions(
  670. -    IN LPTSTR Arg,
  671. +    IN LPWSTR Arg,
  672.      IN OUT PMOUNT_OPTION_LIST Options)
  673.  {
  674.      PTCH pos, comma, equals;
  675. diff --git a/mount/options.h b/mount/options.h
  676. index 408a82b..9af2c1c 100644
  677. --- a/mount/options.h
  678. +++ b/mount/options.h
  679. @@ -3,6 +3,7 @@
  680.   *
  681.   * Olga Kornievskaia <aglo@umich.edu>
  682.   * Casey Bodley <cbodley@umich.edu>
  683. + * Roland Mainz <roland.mainz@nrubsig.org>
  684.   *
  685.   * This library is free software; you can redistribute it and/or modify it
  686.   * under the terms of the GNU Lesser General Public License as published by
  687. @@ -76,17 +77,17 @@ void FreeMountOptions(
  688.      IN OUT PMOUNT_OPTION_LIST Options);
  689.  
  690.  BOOL FindOptionByName(
  691. -    IN LPCTSTR Name,
  692. +    IN LPCWSTR Name,
  693.      IN PMOUNT_OPTION_LIST Options,
  694.      OUT PFILE_FULL_EA_INFORMATION* ppOption);
  695.  
  696.  BOOL ParseMountOptions(
  697. -    IN LPTSTR Arg,
  698. +    IN LPWSTR Arg,
  699.      IN OUT PMOUNT_OPTION_LIST Options);
  700.  
  701.  BOOL InsertOption(
  702. -    IN LPCTSTR Name,
  703. -    IN LPCTSTR Value,
  704. +    IN LPCWSTR Name,
  705. +    IN LPCWSTR Value,
  706.      IN OUT PMOUNT_OPTION_LIST Options);
  707.  
  708.  void RecursivePrintEaInformation(
  709. --
  710. 2.45.1

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at