pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: urlparser update+ReactOS/clang fixes, 2024-12-03
Posted by Anonymous on Tue 3rd Dec 2024 16:52
raw | new post

  1. From e8aa89be8d85c1d3da7f55a305a40bed85d240e5 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 3 Dec 2024 14:41:38 +0100
  4. Subject: [PATCH 1/2] mount: Update urlparser to newer upstream version
  5.  
  6. Update URL parser to newer upstream version
  7. (http://svn.nrubsig.org/svn/people/gisburn/code/urlparser1/ revision 458).
  8.  
  9. Fixes:
  10. - Fix accidental license plate change. License shoud be MIT
  11. - Fix non-empty parameter array for empty parameter string
  12. - Fix clang, gcc 15 and Visual Studio 2022 warnings
  13. - Add support for using wide-char APIs in debug output
  14. - Fix cstyle
  15.  
  16. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  17. ---
  18. mount/urlparser1.c | 115 ++++++++++++++++++++++++++++++---------------
  19.  mount/urlparser1.h |  31 ++++++------
  20.  2 files changed, 94 insertions(+), 52 deletions(-)
  21.  
  22. diff --git a/mount/urlparser1.c b/mount/urlparser1.c
  23. index 66303a1..2b09541 100644
  24. --- a/mount/urlparser1.c
  25. +++ b/mount/urlparser1.c
  26. @@ -1,22 +1,25 @@
  27.  /*
  28. - * NFSv4.1 client for Windows
  29. - * Copyright (c) 2024 Roland Mainz <roland.mainz@nrubsig.org>
  30. + * MIT License
  31.   *
  32. - * Roland Mainz <roland.mainz@nrubsig.org>
  33. + * Copyright (c) 2024 Roland Mainz <roland.mainz@nrubsig.org>
  34.   *
  35. - * This library is free software; you can redistribute it and/or modify it
  36. - * under the terms of the GNU Lesser General Public License as published by
  37. - * the Free Software Foundation; either version 2.1 of the License, or (at
  38. - * your option) any later version.
  39. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  40. + * of this software and associated documentation files (the "Software"), to deal
  41. + * in the Software without restriction, including without limitation the rights
  42. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  43. + * copies of the Software, and to permit persons to whom the Software is
  44. + * furnished to do so, subject to the following conditions:
  45.   *
  46. - * This library is distributed in the hope that it will be useful, but
  47. - * without any warranty; without even the implied warranty of merchantability
  48. - * or fitness for a particular purpose.  See the GNU Lesser General Public
  49. - * License for more details.
  50. + * The above copyright notice and this permission notice shall be included in all
  51. + * copies or substantial portions of the Software.
  52.   *
  53. - * You should have received a copy of the GNU Lesser General Public License
  54. - * along with this library; if not, write to the Free Software Foundation,
  55. - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  56. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  57. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  59. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  60. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  61. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  62. + * SOFTWARE.
  63.   */
  64.  
  65.  /* urlparser1.c - simple URL parser */
  66. @@ -25,6 +28,15 @@
  67.  #error Code requires ISO C17
  68.  #endif
  69.  
  70. +/*
  71. + * Build config:
  72. + * - Test paser
  73. + * #define TEST_URLPARSER 1
  74. + * - Use wide-char API, e.g. for Visual Studio if |stdout|/|stderr|
  75. + *   are in |_O_WTEXT| mode
  76. + * #define DBG_USE_WIDECHAR 1
  77. + */
  78. +
  79.  #ifdef _MSC_VER
  80.  #ifndef _CRT_STDIO_ISO_WIDE_SPECIFIERS
  81.  #error Code requires ISO wide-char behaviour
  82. @@ -37,7 +49,12 @@
  83.  #include <ctype.h>
  84.  #include <stdio.h>
  85.  
  86. -// #define TEST_URLPARSER 1
  87. +#ifdef DBG_USE_WIDECHAR
  88. +#include <wchar.h>
  89. +#include <locale.h>
  90. +#include <io.h>
  91. +#include <fcntl.h>
  92. +#endif /* DBG_USE_WIDECHAR */
  93.  
  94.  #include "urlparser1.h"
  95.  
  96. @@ -93,6 +110,20 @@ typedef struct _url_parser_context_private {
  97.  #define D(x)
  98.  #endif
  99.  
  100. +#ifdef DBG_USE_WIDECHAR
  101. +/*
  102. + * Use wide-char APIs on WIN32, otherwise we cannot output
  103. + * Japanese/Chinese/etc correctly
  104. + */
  105. +#define DBG_PUTS(str, fp)              fputws(L"" str, (fp))
  106. +#define DBG_PUTC(c, fp)                        fputwc(btowc(c), (fp))
  107. +#define DBG_PRINTF(fp, fmt, ...)       fwprintf((fp), L"" fmt, __VA_ARGS__)
  108. +#else
  109. +#define DBG_PUTS(str, fp)              fputs((str), (fp))
  110. +#define DBG_PUTC(c, fp)                        fputc((c), (fp))
  111. +#define DBG_PRINTF(fp, fmt, ...)       fprintf((fp), fmt, __VA_ARGS__)
  112. +#endif /* DBG_USE_WIDECHAR */
  113. +
  114.  static
  115.  void urldecodestr(char *outbuff, const char *buffer, size_t len)
  116.  {
  117. @@ -175,7 +206,7 @@ int url_parser_parse(url_parser_context *ctx)
  118.  {
  119.         url_parser_context_private *uctx = (url_parser_context_private *)ctx;
  120.  
  121. -       D((void)fprintf(stderr, "## parser in_url='%s'\n", uctx->c.in_url));
  122. +       D((void)DBG_PRINTF(stderr, "## parser in_url='%s'\n", uctx->c.in_url));
  123.  
  124.         char *s;
  125.         const char *urlstr = uctx->c.in_url;
  126. @@ -183,7 +214,7 @@ int url_parser_parse(url_parser_context *ctx)
  127.  
  128.         s = strstr(urlstr, "://");
  129.         if (!s) {
  130. -               D((void)fprintf(stderr, "url_parser: Not an URL\n"));
  131. +               D((void)DBG_PUTS("url_parser: Not an URL\n", stderr));
  132.                 return -1;
  133.         }
  134.  
  135. @@ -192,7 +223,7 @@ int url_parser_parse(url_parser_context *ctx)
  136.         uctx->c.scheme[slen] = '\0';
  137.         urlstr += slen + 3;
  138.  
  139. -       D((void)fprintf(stdout, "scheme='%s', rest='%s'\n", uctx->c.scheme, urlstr));
  140. +       D((void)DBG_PRINTF(stdout, "scheme='%s', rest='%s'\n", uctx->c.scheme, urlstr));
  141.  
  142.         s = strstr(urlstr, "@");
  143.         if (s) {
  144. @@ -207,8 +238,7 @@ int url_parser_parse(url_parser_context *ctx)
  145.                         uctx->c.login.passwd = s+1;
  146.                         *s = '\0';
  147.                 }
  148. -               else
  149. -               {
  150. +               else {
  151.                         uctx->c.login.passwd = NULL;
  152.                 }
  153.  
  154. @@ -216,13 +246,12 @@ int url_parser_parse(url_parser_context *ctx)
  155.                 if (uctx->c.login.username[0] == '\0')
  156.                         uctx->c.login.username = NULL;
  157.         }
  158. -       else
  159. -       {
  160. +       else {
  161.                 uctx->c.login.username = NULL;
  162.                 uctx->c.login.passwd = NULL;
  163.         }
  164.  
  165. -       D((void)fprintf(stdout, "login='%s', passwd='%s', rest='%s'\n",
  166. +       D((void)DBG_PRINTF(stdout, "login='%s', passwd='%s', rest='%s'\n",
  167.                 DBGNULLSTR(uctx->c.login.username),
  168.                 DBGNULLSTR(uctx->c.login.passwd),
  169.                 DBGNULLSTR(urlstr)));
  170. @@ -231,9 +260,10 @@ int url_parser_parse(url_parser_context *ctx)
  171.  
  172.         uctx->c.num_parameters = 0;
  173.         raw_parameters = strstr(urlstr, "?");
  174. -       if (raw_parameters) {
  175. +       /* Do we have a non-empty parameter string ? */
  176. +       if (raw_parameters && (raw_parameters[1] != '\0')) {
  177.                 *raw_parameters++ = '\0';
  178. -               D((void)fprintf(stdout, "raw parameters = '%s'\n", raw_parameters));
  179. +               D((void)DBG_PRINTF(stdout, "raw parameters = '%s'\n", raw_parameters));
  180.  
  181.                 char *ps = raw_parameters;
  182.                 char *pv; /* parameter value */
  183. @@ -306,7 +336,7 @@ int url_parser_parse(url_parser_context *ctx)
  184.                         s = strstr(s, "]");
  185.  
  186.                 if (s == NULL) {
  187. -                       D((void)fprintf(stderr, "url_parser: Unmatched '[' in hostname\n"));
  188. +                       D((void)DBG_PUTS("url_parser: Unmatched '[' in hostname\n", stderr));
  189.                         return -1;
  190.                 }
  191.  
  192. @@ -317,23 +347,27 @@ int url_parser_parse(url_parser_context *ctx)
  193.                         *s = '\0';
  194.                 }
  195.         }
  196. -       else
  197. -       {
  198. +       else {
  199.                 (void)strcpy(uctx->c.hostport.hostname, urlstr);
  200.                 uctx->c.path = NULL;
  201.                 urlstr = NULL;
  202.         }
  203.  
  204. -       D((void)fprintf(stdout, "hostport='%s', port=%d, rest='%s', num_parameters=%d\n",
  205. -               DBGNULLSTR(uctx->c.hostport.hostname),
  206. -               uctx->c.hostport.port,
  207. -               DBGNULLSTR(urlstr),
  208. -               (int)uctx->c.num_parameters));
  209. +       D(
  210. +               (void)DBG_PRINTF(stdout,
  211. +                       "hostport='%s', port=%d, rest='%s', num_parameters=%d\n",
  212. +                       DBGNULLSTR(uctx->c.hostport.hostname),
  213. +                       uctx->c.hostport.port,
  214. +                       DBGNULLSTR(urlstr),
  215. +                       (int)uctx->c.num_parameters);
  216. +       );
  217. +
  218.  
  219.         D(
  220.                 ssize_t dpi;
  221.                 for (dpi = 0 ; dpi < uctx->c.num_parameters ; dpi++) {
  222. -                       (void)fprintf(stdout, "param[%d]: name='%s'/value='%s'\n",
  223. +                       (void)DBG_PRINTF(stdout,
  224. +                               "param[%d]: name='%s'/value='%s'\n",
  225.                                 (int)dpi,
  226.                                 uctx->c.parameters[dpi].name,
  227.                                 DBGNULLSTR(uctx->c.parameters[dpi].value));
  228. @@ -345,7 +379,7 @@ int url_parser_parse(url_parser_context *ctx)
  229.         }
  230.  
  231.         urldecodestr(uctx->c.path, urlstr, strlen(urlstr));
  232. -       D((void)fprintf(stdout, "path='%s'\n", uctx->c.path));
  233. +       D((void)DBG_PRINTF(stdout, "path='%s'\n", uctx->c.path));
  234.  
  235.  done:
  236.         return 0;
  237. @@ -366,14 +400,18 @@ void test_url_parser(const char *instr)
  238.  
  239.         (void)url_parser_parse(c);
  240.  
  241. -       (void)fputc('\n', stdout);
  242. +       DBG_PUTC('\n', stdout);
  243.  
  244.         url_parser_free_context(c);
  245.  }
  246.  
  247. +
  248.  int main(int ac, char *av[])
  249.  {
  250. -       (void)puts("#start");
  251. +       (void)ac; /* not used */
  252. +       (void)av; /* not used */
  253. +
  254. +       (void)DBG_PUTS("#start\n", stdout);
  255.  
  256.         (void)setvbuf(stdout, NULL, _IONBF, 0);
  257.         (void)setvbuf(stderr, NULL, _IONBF, 0);
  258. @@ -404,12 +442,13 @@ int main(int ac, char *av[])
  259.         (void)test_url_parser("foo://hostbar:93//path/path2?param1&param2=p2");
  260.         (void)test_url_parser("foo://hostbar:93?pname1=pvalue1&%E2%82%AC=u+n2&n3=v3");
  261.         (void)test_url_parser("foo://hostbar:93?pname1=pvalue1&%E2%82%AC=%E2%82%AC&n3=v3");
  262. +       (void)test_url_parser("foo://hostbar:93?");
  263.  
  264.         (void)test_url_parser("foo://");
  265.         (void)test_url_parser("typo:/hostbar");
  266.         (void)test_url_parser("wrong");
  267.  
  268. -       (void)puts("#done");
  269. +       (void)DBG_PUTS("#done\n", stdout);
  270.  
  271.         return EXIT_SUCCESS;
  272.  }
  273. diff --git a/mount/urlparser1.h b/mount/urlparser1.h
  274. index 4526f1c..451f28c 100644
  275. --- a/mount/urlparser1.h
  276. +++ b/mount/urlparser1.h
  277. @@ -1,22 +1,25 @@
  278.  /*
  279. - * NFSv4.1 client for Windows
  280. - * Copyright (c) 2024 Roland Mainz <roland.mainz@nrubsig.org>
  281. + * MIT License
  282.   *
  283. - * Roland Mainz <roland.mainz@nrubsig.org>
  284. + * Copyright (c) 2024 Roland Mainz <roland.mainz@nrubsig.org>
  285.   *
  286. - * This library is free software; you can redistribute it and/or modify it
  287. - * under the terms of the GNU Lesser General Public License as published by
  288. - * the Free Software Foundation; either version 2.1 of the License, or (at
  289. - * your option) any later version.
  290. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  291. + * of this software and associated documentation files (the "Software"), to deal
  292. + * in the Software without restriction, including without limitation the rights
  293. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  294. + * copies of the Software, and to permit persons to whom the Software is
  295. + * furnished to do so, subject to the following conditions:
  296.   *
  297. - * This library is distributed in the hope that it will be useful, but
  298. - * without any warranty; without even the implied warranty of merchantability
  299. - * or fitness for a particular purpose.  See the GNU Lesser General Public
  300. - * License for more details.
  301. + * The above copyright notice and this permission notice shall be included in all
  302. + * copies or substantial portions of the Software.
  303.   *
  304. - * You should have received a copy of the GNU Lesser General Public License
  305. - * along with this library; if not, write to the Free Software Foundation,
  306. - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  307. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  308. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  309. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  310. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  311. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  312. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  313. + * SOFTWARE.
  314.   */
  315.  
  316.  /* urlparser1.h - header for simple URL parser */
  317. --
  318. 2.45.1
  319.  
  320. From 78bf851619ab72fc2efc80ec756edc518a38e5bb Mon Sep 17 00:00:00 2001
  321. From: Dan Shelton <dan.f.shelton@gmail.com>
  322. Date: Tue, 3 Dec 2024 15:25:41 +0100
  323. Subject: [PATCH 2/2] daemon,dll,libtirpc: Fix ReactOS/clang compiler warnings
  324.  
  325. Fix ReactOS/clang compiler warnings
  326.  
  327. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  328. ---
  329. daemon/nfs41_daemon.c  | 6 ++++--
  330.  dll/nfs41_np.c         | 2 +-
  331.  libtirpc/src/clnt_vc.c | 7 ++++---
  332.  libtirpc/src/svc_vc.c  | 8 +++++---
  333.  4 files changed, 14 insertions(+), 9 deletions(-)
  334.  
  335. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  336. index e359f6f..6530144 100644
  337. --- a/daemon/nfs41_daemon.c
  338. +++ b/daemon/nfs41_daemon.c
  339. @@ -552,8 +552,10 @@ static
  340.  void nfsd_crt_debug_init(void)
  341.  {
  342.  #ifdef _DEBUG
  343. -    /* dump memory leaks to stderr on exit; this requires the debug heap,
  344. -    /* available only when built in debug mode under visual studio -cbodley */
  345. +    /*
  346. +     * dump memory leaks to stderr on exit; this requires the debug heap,
  347. +     * available only when built in debug mode under visual studio -cbodley
  348. +     */
  349.  
  350.      int crtsetdbgflags = nfs41_dg.crtdbgmem_flags;
  351.  
  352. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  353. index 5e81099..1e8a712 100644
  354. --- a/dll/nfs41_np.c
  355. +++ b/dll/nfs41_np.c
  356. @@ -1038,7 +1038,7 @@ DWORD APIENTRY
  357.  NPGetConnection3(
  358.      __in LPCWSTR                        lpLocalName,
  359.      __in DWORD                          dwLevel,
  360. -    __out_bcount(*lpBufferSize) LPWSTR  lpRemoteName,
  361. +    __out_bcount(*lpBufferSize) LPVOID  lpRemoteName,
  362.      __inout LPDWORD                     lpBufferSize)
  363.  {
  364.      DWORD Status = 0;
  365. diff --git a/libtirpc/src/clnt_vc.c b/libtirpc/src/clnt_vc.c
  366. index dbbc42b..2151d33 100644
  367. --- a/libtirpc/src/clnt_vc.c
  368. +++ b/libtirpc/src/clnt_vc.c
  369. @@ -132,7 +132,7 @@ static void clnt_vc_destroy(CLIENT *);
  370.  static struct clnt_ops *clnt_vc_ops(void);
  371.  static bool_t time_not_ok(struct timeval *);
  372.  static int read_vc(void *, void *, int);
  373. -static int write_vc(void *, char *, int);
  374. +static int write_vc(void *, void *, int);
  375.  
  376.  struct ct_data {
  377.         int             ct_fd;          /* connection's fd */
  378. @@ -1075,11 +1075,12 @@ read_vc(ctp, buf, len)
  379.  }
  380.  
  381.  static int
  382. -write_vc(ctp, buf, len)
  383. +write_vc(ctp, bufp, len)
  384.         void *ctp;
  385. -       char *buf;
  386. +       void *bufp;
  387.         int len;
  388.  {
  389. +       char *buf = bufp;
  390.         struct ct_data *ct = (struct ct_data *)ctp;
  391.         int i = 0, cnt;
  392.  
  393. diff --git a/libtirpc/src/svc_vc.c b/libtirpc/src/svc_vc.c
  394. index 6ce2748..8b8a7dd 100644
  395. --- a/libtirpc/src/svc_vc.c
  396. +++ b/libtirpc/src/svc_vc.c
  397. @@ -75,7 +75,7 @@ static enum xprt_stat rendezvous_stat(SVCXPRT *);
  398.  static void svc_vc_destroy(SVCXPRT *);
  399.  static void __svc_vc_dodestroy (SVCXPRT *);
  400.  static int read_vc(void *, void *, int);
  401. -static int write_vc(void *, char *, int);
  402. +static int write_vc(void *, void *, int);
  403.  static enum xprt_stat svc_vc_stat(SVCXPRT *);
  404.  static bool_t svc_vc_recv(SVCXPRT *, struct rpc_msg *);
  405.  static bool_t svc_vc_getargs(SVCXPRT *, xdrproc_t, void *);
  406. @@ -567,18 +567,20 @@ fatal_err:
  407.   * Any error is fatal and the connection is closed.
  408.   */
  409.  static int
  410. -write_vc(xprtp, buf, len)
  411. +write_vc(xprtp, bufp, len)
  412.         void *xprtp;
  413. -       char *buf;
  414. +       void *bufp;
  415.         int len;
  416.  {
  417.         SVCXPRT *xprt;
  418. +       char *buf;
  419.         int i, cnt;
  420.         struct cf_conn *cd;
  421.         struct timeval tv0 = { 0 }, tv1;
  422.  
  423.         xprt = (SVCXPRT *)xprtp;
  424.         assert(xprt != NULL);
  425. +       buf = bufp;
  426.  
  427.         cd = (struct cf_conn *)xprt->xp_p1;
  428.  
  429. --
  430. 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