- From e8aa89be8d85c1d3da7f55a305a40bed85d240e5 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 3 Dec 2024 14:41:38 +0100
- Subject: [PATCH 1/2] mount: Update urlparser to newer upstream version
- Update URL parser to newer upstream version
- (http://svn.nrubsig.org/svn/people/gisburn/code/urlparser1/ revision 458).
- Fixes:
- - Fix accidental license plate change. License shoud be MIT
- - Fix non-empty parameter array for empty parameter string
- - Fix clang, gcc 15 and Visual Studio 2022 warnings
- - Add support for using wide-char APIs in debug output
- - Fix cstyle
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/urlparser1.c | 115 ++++++++++++++++++++++++++++++---------------
- mount/urlparser1.h | 31 ++++++------
- 2 files changed, 94 insertions(+), 52 deletions(-)
- diff --git a/mount/urlparser1.c b/mount/urlparser1.c
- index 66303a1..2b09541 100644
- --- a/mount/urlparser1.c
- +++ b/mount/urlparser1.c
- @@ -1,22 +1,25 @@
- /*
- - * NFSv4.1 client for Windows
- - * Copyright (c) 2024 Roland Mainz <roland.mainz@nrubsig.org>
- + * MIT License
- *
- - * Roland Mainz <roland.mainz@nrubsig.org>
- + * Copyright (c) 2024 Roland Mainz <roland.mainz@nrubsig.org>
- *
- - * This library is free software; you can redistribute it and/or modify it
- - * under the terms of the GNU Lesser General Public License as published by
- - * the Free Software Foundation; either version 2.1 of the License, or (at
- - * your option) any later version.
- + * Permission is hereby granted, free of charge, to any person obtaining a copy
- + * of this software and associated documentation files (the "Software"), to deal
- + * in the Software without restriction, including without limitation the rights
- + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- + * copies of the Software, and to permit persons to whom the Software is
- + * furnished to do so, subject to the following conditions:
- *
- - * This library is distributed in the hope that it will be useful, but
- - * without any warranty; without even the implied warranty of merchantability
- - * or fitness for a particular purpose. See the GNU Lesser General Public
- - * License for more details.
- + * The above copyright notice and this permission notice shall be included in all
- + * copies or substantial portions of the Software.
- *
- - * You should have received a copy of the GNU Lesser General Public License
- - * along with this library; if not, write to the Free Software Foundation,
- - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- + * SOFTWARE.
- */
- /* urlparser1.c - simple URL parser */
- @@ -25,6 +28,15 @@
- #error Code requires ISO C17
- #endif
- +/*
- + * Build config:
- + * - Test paser
- + * #define TEST_URLPARSER 1
- + * - Use wide-char API, e.g. for Visual Studio if |stdout|/|stderr|
- + * are in |_O_WTEXT| mode
- + * #define DBG_USE_WIDECHAR 1
- + */
- +
- #ifdef _MSC_VER
- #ifndef _CRT_STDIO_ISO_WIDE_SPECIFIERS
- #error Code requires ISO wide-char behaviour
- @@ -37,7 +49,12 @@
- #include <ctype.h>
- #include <stdio.h>
- -// #define TEST_URLPARSER 1
- +#ifdef DBG_USE_WIDECHAR
- +#include <wchar.h>
- +#include <locale.h>
- +#include <io.h>
- +#include <fcntl.h>
- +#endif /* DBG_USE_WIDECHAR */
- #include "urlparser1.h"
- @@ -93,6 +110,20 @@ typedef struct _url_parser_context_private {
- #define D(x)
- #endif
- +#ifdef DBG_USE_WIDECHAR
- +/*
- + * Use wide-char APIs on WIN32, otherwise we cannot output
- + * Japanese/Chinese/etc correctly
- + */
- +#define DBG_PUTS(str, fp) fputws(L"" str, (fp))
- +#define DBG_PUTC(c, fp) fputwc(btowc(c), (fp))
- +#define DBG_PRINTF(fp, fmt, ...) fwprintf((fp), L"" fmt, __VA_ARGS__)
- +#else
- +#define DBG_PUTS(str, fp) fputs((str), (fp))
- +#define DBG_PUTC(c, fp) fputc((c), (fp))
- +#define DBG_PRINTF(fp, fmt, ...) fprintf((fp), fmt, __VA_ARGS__)
- +#endif /* DBG_USE_WIDECHAR */
- +
- static
- void urldecodestr(char *outbuff, const char *buffer, size_t len)
- {
- @@ -175,7 +206,7 @@ int url_parser_parse(url_parser_context *ctx)
- {
- url_parser_context_private *uctx = (url_parser_context_private *)ctx;
- - D((void)fprintf(stderr, "## parser in_url='%s'\n", uctx->c.in_url));
- + D((void)DBG_PRINTF(stderr, "## parser in_url='%s'\n", uctx->c.in_url));
- char *s;
- const char *urlstr = uctx->c.in_url;
- @@ -183,7 +214,7 @@ int url_parser_parse(url_parser_context *ctx)
- s = strstr(urlstr, "://");
- if (!s) {
- - D((void)fprintf(stderr, "url_parser: Not an URL\n"));
- + D((void)DBG_PUTS("url_parser: Not an URL\n", stderr));
- return -1;
- }
- @@ -192,7 +223,7 @@ int url_parser_parse(url_parser_context *ctx)
- uctx->c.scheme[slen] = '\0';
- urlstr += slen + 3;
- - D((void)fprintf(stdout, "scheme='%s', rest='%s'\n", uctx->c.scheme, urlstr));
- + D((void)DBG_PRINTF(stdout, "scheme='%s', rest='%s'\n", uctx->c.scheme, urlstr));
- s = strstr(urlstr, "@");
- if (s) {
- @@ -207,8 +238,7 @@ int url_parser_parse(url_parser_context *ctx)
- uctx->c.login.passwd = s+1;
- *s = '\0';
- }
- - else
- - {
- + else {
- uctx->c.login.passwd = NULL;
- }
- @@ -216,13 +246,12 @@ int url_parser_parse(url_parser_context *ctx)
- if (uctx->c.login.username[0] == '\0')
- uctx->c.login.username = NULL;
- }
- - else
- - {
- + else {
- uctx->c.login.username = NULL;
- uctx->c.login.passwd = NULL;
- }
- - D((void)fprintf(stdout, "login='%s', passwd='%s', rest='%s'\n",
- + D((void)DBG_PRINTF(stdout, "login='%s', passwd='%s', rest='%s'\n",
- DBGNULLSTR(uctx->c.login.username),
- DBGNULLSTR(uctx->c.login.passwd),
- DBGNULLSTR(urlstr)));
- @@ -231,9 +260,10 @@ int url_parser_parse(url_parser_context *ctx)
- uctx->c.num_parameters = 0;
- raw_parameters = strstr(urlstr, "?");
- - if (raw_parameters) {
- + /* Do we have a non-empty parameter string ? */
- + if (raw_parameters && (raw_parameters[1] != '\0')) {
- *raw_parameters++ = '\0';
- - D((void)fprintf(stdout, "raw parameters = '%s'\n", raw_parameters));
- + D((void)DBG_PRINTF(stdout, "raw parameters = '%s'\n", raw_parameters));
- char *ps = raw_parameters;
- char *pv; /* parameter value */
- @@ -306,7 +336,7 @@ int url_parser_parse(url_parser_context *ctx)
- s = strstr(s, "]");
- if (s == NULL) {
- - D((void)fprintf(stderr, "url_parser: Unmatched '[' in hostname\n"));
- + D((void)DBG_PUTS("url_parser: Unmatched '[' in hostname\n", stderr));
- return -1;
- }
- @@ -317,23 +347,27 @@ int url_parser_parse(url_parser_context *ctx)
- *s = '\0';
- }
- }
- - else
- - {
- + else {
- (void)strcpy(uctx->c.hostport.hostname, urlstr);
- uctx->c.path = NULL;
- urlstr = NULL;
- }
- - D((void)fprintf(stdout, "hostport='%s', port=%d, rest='%s', num_parameters=%d\n",
- - DBGNULLSTR(uctx->c.hostport.hostname),
- - uctx->c.hostport.port,
- - DBGNULLSTR(urlstr),
- - (int)uctx->c.num_parameters));
- + D(
- + (void)DBG_PRINTF(stdout,
- + "hostport='%s', port=%d, rest='%s', num_parameters=%d\n",
- + DBGNULLSTR(uctx->c.hostport.hostname),
- + uctx->c.hostport.port,
- + DBGNULLSTR(urlstr),
- + (int)uctx->c.num_parameters);
- + );
- +
- D(
- ssize_t dpi;
- for (dpi = 0 ; dpi < uctx->c.num_parameters ; dpi++) {
- - (void)fprintf(stdout, "param[%d]: name='%s'/value='%s'\n",
- + (void)DBG_PRINTF(stdout,
- + "param[%d]: name='%s'/value='%s'\n",
- (int)dpi,
- uctx->c.parameters[dpi].name,
- DBGNULLSTR(uctx->c.parameters[dpi].value));
- @@ -345,7 +379,7 @@ int url_parser_parse(url_parser_context *ctx)
- }
- urldecodestr(uctx->c.path, urlstr, strlen(urlstr));
- - D((void)fprintf(stdout, "path='%s'\n", uctx->c.path));
- + D((void)DBG_PRINTF(stdout, "path='%s'\n", uctx->c.path));
- done:
- return 0;
- @@ -366,14 +400,18 @@ void test_url_parser(const char *instr)
- (void)url_parser_parse(c);
- - (void)fputc('\n', stdout);
- + DBG_PUTC('\n', stdout);
- url_parser_free_context(c);
- }
- +
- int main(int ac, char *av[])
- {
- - (void)puts("#start");
- + (void)ac; /* not used */
- + (void)av; /* not used */
- +
- + (void)DBG_PUTS("#start\n", stdout);
- (void)setvbuf(stdout, NULL, _IONBF, 0);
- (void)setvbuf(stderr, NULL, _IONBF, 0);
- @@ -404,12 +442,13 @@ int main(int ac, char *av[])
- (void)test_url_parser("foo://hostbar:93//path/path2?param1¶m2=p2");
- (void)test_url_parser("foo://hostbar:93?pname1=pvalue1&%E2%82%AC=u+n2&n3=v3");
- (void)test_url_parser("foo://hostbar:93?pname1=pvalue1&%E2%82%AC=%E2%82%AC&n3=v3");
- + (void)test_url_parser("foo://hostbar:93?");
- (void)test_url_parser("foo://");
- (void)test_url_parser("typo:/hostbar");
- (void)test_url_parser("wrong");
- - (void)puts("#done");
- + (void)DBG_PUTS("#done\n", stdout);
- return EXIT_SUCCESS;
- }
- diff --git a/mount/urlparser1.h b/mount/urlparser1.h
- index 4526f1c..451f28c 100644
- --- a/mount/urlparser1.h
- +++ b/mount/urlparser1.h
- @@ -1,22 +1,25 @@
- /*
- - * NFSv4.1 client for Windows
- - * Copyright (c) 2024 Roland Mainz <roland.mainz@nrubsig.org>
- + * MIT License
- *
- - * Roland Mainz <roland.mainz@nrubsig.org>
- + * Copyright (c) 2024 Roland Mainz <roland.mainz@nrubsig.org>
- *
- - * This library is free software; you can redistribute it and/or modify it
- - * under the terms of the GNU Lesser General Public License as published by
- - * the Free Software Foundation; either version 2.1 of the License, or (at
- - * your option) any later version.
- + * Permission is hereby granted, free of charge, to any person obtaining a copy
- + * of this software and associated documentation files (the "Software"), to deal
- + * in the Software without restriction, including without limitation the rights
- + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- + * copies of the Software, and to permit persons to whom the Software is
- + * furnished to do so, subject to the following conditions:
- *
- - * This library is distributed in the hope that it will be useful, but
- - * without any warranty; without even the implied warranty of merchantability
- - * or fitness for a particular purpose. See the GNU Lesser General Public
- - * License for more details.
- + * The above copyright notice and this permission notice shall be included in all
- + * copies or substantial portions of the Software.
- *
- - * You should have received a copy of the GNU Lesser General Public License
- - * along with this library; if not, write to the Free Software Foundation,
- - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- + * SOFTWARE.
- */
- /* urlparser1.h - header for simple URL parser */
- --
- 2.45.1
- From 78bf851619ab72fc2efc80ec756edc518a38e5bb Mon Sep 17 00:00:00 2001
- From: Dan Shelton <dan.f.shelton@gmail.com>
- Date: Tue, 3 Dec 2024 15:25:41 +0100
- Subject: [PATCH 2/2] daemon,dll,libtirpc: Fix ReactOS/clang compiler warnings
- Fix ReactOS/clang compiler warnings
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_daemon.c | 6 ++++--
- dll/nfs41_np.c | 2 +-
- libtirpc/src/clnt_vc.c | 7 ++++---
- libtirpc/src/svc_vc.c | 8 +++++---
- 4 files changed, 14 insertions(+), 9 deletions(-)
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index e359f6f..6530144 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -552,8 +552,10 @@ static
- void nfsd_crt_debug_init(void)
- {
- #ifdef _DEBUG
- - /* dump memory leaks to stderr on exit; this requires the debug heap,
- - /* available only when built in debug mode under visual studio -cbodley */
- + /*
- + * dump memory leaks to stderr on exit; this requires the debug heap,
- + * available only when built in debug mode under visual studio -cbodley
- + */
- int crtsetdbgflags = nfs41_dg.crtdbgmem_flags;
- diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
- index 5e81099..1e8a712 100644
- --- a/dll/nfs41_np.c
- +++ b/dll/nfs41_np.c
- @@ -1038,7 +1038,7 @@ DWORD APIENTRY
- NPGetConnection3(
- __in LPCWSTR lpLocalName,
- __in DWORD dwLevel,
- - __out_bcount(*lpBufferSize) LPWSTR lpRemoteName,
- + __out_bcount(*lpBufferSize) LPVOID lpRemoteName,
- __inout LPDWORD lpBufferSize)
- {
- DWORD Status = 0;
- diff --git a/libtirpc/src/clnt_vc.c b/libtirpc/src/clnt_vc.c
- index dbbc42b..2151d33 100644
- --- a/libtirpc/src/clnt_vc.c
- +++ b/libtirpc/src/clnt_vc.c
- @@ -132,7 +132,7 @@ static void clnt_vc_destroy(CLIENT *);
- static struct clnt_ops *clnt_vc_ops(void);
- static bool_t time_not_ok(struct timeval *);
- static int read_vc(void *, void *, int);
- -static int write_vc(void *, char *, int);
- +static int write_vc(void *, void *, int);
- struct ct_data {
- int ct_fd; /* connection's fd */
- @@ -1075,11 +1075,12 @@ read_vc(ctp, buf, len)
- }
- static int
- -write_vc(ctp, buf, len)
- +write_vc(ctp, bufp, len)
- void *ctp;
- - char *buf;
- + void *bufp;
- int len;
- {
- + char *buf = bufp;
- struct ct_data *ct = (struct ct_data *)ctp;
- int i = 0, cnt;
- diff --git a/libtirpc/src/svc_vc.c b/libtirpc/src/svc_vc.c
- index 6ce2748..8b8a7dd 100644
- --- a/libtirpc/src/svc_vc.c
- +++ b/libtirpc/src/svc_vc.c
- @@ -75,7 +75,7 @@ static enum xprt_stat rendezvous_stat(SVCXPRT *);
- static void svc_vc_destroy(SVCXPRT *);
- static void __svc_vc_dodestroy (SVCXPRT *);
- static int read_vc(void *, void *, int);
- -static int write_vc(void *, char *, int);
- +static int write_vc(void *, void *, int);
- static enum xprt_stat svc_vc_stat(SVCXPRT *);
- static bool_t svc_vc_recv(SVCXPRT *, struct rpc_msg *);
- static bool_t svc_vc_getargs(SVCXPRT *, xdrproc_t, void *);
- @@ -567,18 +567,20 @@ fatal_err:
- * Any error is fatal and the connection is closed.
- */
- static int
- -write_vc(xprtp, buf, len)
- +write_vc(xprtp, bufp, len)
- void *xprtp;
- - char *buf;
- + void *bufp;
- int len;
- {
- SVCXPRT *xprt;
- + char *buf;
- int i, cnt;
- struct cf_conn *cd;
- struct timeval tv0 = { 0 }, tv1;
- xprt = (SVCXPRT *)xprtp;
- assert(xprt != NULL);
- + buf = bufp;
- cd = (struct cf_conn *)xprt->xp_p1;
- --
- 2.45.1
msnfs41client: urlparser update+ReactOS/clang fixes, 2024-12-03
Posted by Anonymous on Tue 3rd Dec 2024 16:52
raw | new post
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.