pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: libtirpc+misc patches, 2023-11-15
Posted by Anonymous on Wed 15th Nov 2023 15:37
raw | new post

  1. From 32854f48fa3bd7ffe8c79578fa584796c23b2c94 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Wed, 15 Nov 2023 10:53:51 +0100
  4. Subject: [PATCH 1/4] libtirpc: Implement |wintirpc_syslog()| and reenable
  5.  |syslog()|
  6.  
  7. Implement |wintirpc_syslog()| and reenable |syslog()| in libtirpc
  8. code so we get better diagnostics - and error messages when
  9. C:\etc\netconfig cannot be opened.
  10.  
  11. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  12. ---
  13. libtirpc/src/auth_des.c     | 36 +++++++++++++++++++-----------------
  14.  libtirpc/src/auth_time.c    |  7 ++++---
  15.  libtirpc/src/clnt_generic.c |  4 +++-
  16.  libtirpc/src/clnt_vc.c      |  8 +++++---
  17.  libtirpc/src/getnetpath.c   |  8 +++++---
  18.  libtirpc/src/rpc_generic.c  |  8 +++++---
  19.  libtirpc/src/rpc_soc.c      | 11 ++++++-----
  20.  libtirpc/src/rpcb_clnt.c    |  6 ++++--
  21.  libtirpc/src/wintirpc.c     | 28 +++++++++++++++++++++++++++-
  22.  libtirpc/tirpc/wintirpc.h   | 19 +++++++++++++++++++
  23.  10 files changed, 97 insertions(+), 38 deletions(-)
  24.  
  25. diff --git a/libtirpc/src/auth_des.c b/libtirpc/src/auth_des.c
  26. index b515a0c..76bb9a4 100644
  27. --- a/libtirpc/src/auth_des.c
  28. +++ b/libtirpc/src/auth_des.c
  29. @@ -42,7 +42,9 @@
  30.  //#include <unistd.h>
  31.  //#include <sys/cdefs.h>
  32.  #include <rpc/des_crypt.h>
  33. -//#include <syslog.h>
  34. +#ifndef _WIN32
  35. +#include <syslog.h>
  36. +#endif
  37.  #include <rpc/types.h>
  38.  #include <rpc/auth.h>
  39.  #include <rpc/auth_des.h>
  40. @@ -128,9 +130,9 @@ authdes_seccreate(const char *servername, const u_int win,
  41.         AUTH    *dummy;
  42.  
  43.         if (! getpublickey(servername, (char *) pkey_data)) {
  44. -               //syslog(LOG_ERR,
  45. -               //    "authdes_seccreate: no public key found for %s",
  46. -               //    servername);
  47. +               syslog(LOG_ERR,
  48. +                       "authdes_seccreate: no public key found for %s",
  49. +                       servername);
  50.                 return (NULL);
  51.         }
  52.  
  53. @@ -159,12 +161,12 @@ authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
  54.          */
  55.         auth = ALLOC(AUTH);
  56.         if (auth == NULL) {
  57. -               //syslog(LOG_ERR, "authdes_pk_seccreate: out of memory");
  58. +               syslog(LOG_ERR, "authdes_pk_seccreate: out of memory");
  59.                 return (NULL);
  60.         }
  61.         ad = ALLOC(struct ad_private);
  62.         if (ad == NULL) {
  63. -               //syslog(LOG_ERR, "authdes_pk_seccreate: out of memory");
  64. +               syslog(LOG_ERR, "authdes_pk_seccreate: out of memory");
  65.                 goto failed;
  66.         }
  67.         ad->ad_fullname = ad->ad_servername = NULL; /* Sanity reasons */
  68. @@ -183,13 +185,13 @@ authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
  69.         ad->ad_servername = (char *)mem_alloc(ad->ad_servernamelen + 1);
  70.  
  71.         if (ad->ad_fullname == NULL || ad->ad_servername == NULL) {
  72. -               //syslog(LOG_ERR, "authdes_seccreate: out of memory");
  73. +               syslog(LOG_ERR, "authdes_seccreate: out of memory");
  74.                 goto failed;
  75.         }
  76.         if (timehost != NULL) {
  77.                 ad->ad_timehost = (char *)mem_alloc(strlen(timehost) + 1);
  78.                 if (ad->ad_timehost == NULL) {
  79. -                       //syslog(LOG_ERR, "authdes_seccreate: out of memory");
  80. +                       syslog(LOG_ERR, "authdes_seccreate: out of memory");
  81.                         goto failed;
  82.                 }
  83.                 memcpy(ad->ad_timehost, timehost, strlen(timehost) + 1);
  84. @@ -205,8 +207,8 @@ authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
  85.         ad->ad_window = window;
  86.         if (ckey == NULL) {
  87.                 if (key_gendes(&auth->ah_key) < 0) {
  88. -                       //syslog(LOG_ERR,
  89. -                       //              "authdes_seccreate: keyserv(1m) is unable to generate session key");
  90. +                       syslog(LOG_ERR,
  91. +                               "authdes_seccreate: keyserv(1m) is unable to generate session key");
  92.                         goto failed;
  93.                 }
  94.         } else {
  95. @@ -310,7 +312,7 @@ authdes_marshal(AUTH *auth, XDR *xdrs)
  96.                         DES_ENCRYPT | DES_HW);
  97.         }
  98.         if (DES_FAILED(status)) {
  99. -               //syslog(LOG_ERR, "authdes_marshal: DES encryption failure");
  100. +               syslog(LOG_ERR, "authdes_marshal: DES encryption failure");
  101.                 return (FALSE);
  102.         }
  103.         ad->ad_verf.adv_xtimestamp = cryptbuf[0];
  104. @@ -383,7 +385,7 @@ authdes_validate(AUTH *auth, struct opaque_auth *rverf)
  105.                 (u_int)sizeof (des_block), DES_DECRYPT | DES_HW);
  106.  
  107.         if (DES_FAILED(status)) {
  108. -               //syslog(LOG_ERR, "authdes_validate: DES decryption failure");
  109. +               syslog(LOG_ERR, "authdes_validate: DES decryption failure");
  110.                 return (FALSE);
  111.         }
  112.  
  113. @@ -400,7 +402,7 @@ authdes_validate(AUTH *auth, struct opaque_auth *rverf)
  114.          */
  115.         if (bcmp((char *)&ad->ad_timestamp, (char *)&verf.adv_timestamp,
  116.                  sizeof(struct timeval)) != 0) {
  117. -               //syslog(LOG_DEBUG, "authdes_validate: verifier mismatch");
  118. +               syslog(LOG_DEBUG, "authdes_validate: verifier mismatch");
  119.                 return (FALSE);
  120.         }
  121.  
  122. @@ -438,16 +440,16 @@ authdes_refresh(AUTH *auth, void *dummy)
  123.                          * Hope the clocks are synced!
  124.                          */
  125.                         ad->ad_dosync = 0;
  126. -                       //syslog(LOG_DEBUG,
  127. -                       //    "authdes_refresh: unable to synchronize clock");
  128. +                       syslog(LOG_DEBUG,
  129. +                               "authdes_refresh: unable to synchronize clock");
  130.                  }
  131.         }
  132.         ad->ad_xkey = auth->ah_key;
  133.         pkey.n_bytes = (char *)(ad->ad_pkey);
  134.         pkey.n_len = (u_int)strlen((char *)ad->ad_pkey) + 1;
  135.         if (key_encryptsession_pk(ad->ad_servername, &pkey, &ad->ad_xkey) < 0) {
  136. -               //syslog(LOG_INFO,
  137. -               //    "authdes_refresh: keyserv(1m) is unable to encrypt session key");
  138. +               syslog(LOG_INFO,
  139. +                       "authdes_refresh: keyserv(1m) is unable to encrypt session key");
  140.                 return (FALSE);
  141.         }
  142.         cred->adc_fullname.key = ad->ad_xkey;
  143. diff --git a/libtirpc/src/auth_time.c b/libtirpc/src/auth_time.c
  144. index acf5e0e..99db3f8 100644
  145. --- a/libtirpc/src/auth_time.c
  146. +++ b/libtirpc/src/auth_time.c
  147. @@ -27,7 +27,9 @@
  148.  
  149.  //#include <sys/cdefs.h>
  150.  #include <wintirpc.h>
  151. -//#include <syslog.h>
  152. +#ifndef _WIN32
  153. +#include <syslog.h>
  154. +#endif
  155.  #include <string.h>
  156.  #include <stdlib.h>
  157.  //#include <unistd.h>
  158. @@ -48,8 +50,7 @@
  159.  
  160.  
  161.  #ifdef TESTING
  162. -#define        msg(x)  printf("ERROR: %s\n", x)
  163. -/* #define msg(x) syslog(LOG_ERR, "%s", x) */
  164. +#define msg(x) syslog(LOG_ERR, "%s", x)
  165.  #else
  166.  #define        msg(x)
  167.  #endif
  168. diff --git a/libtirpc/src/clnt_generic.c b/libtirpc/src/clnt_generic.c
  169. index 6473b13..60cf026 100644
  170. --- a/libtirpc/src/clnt_generic.c
  171. +++ b/libtirpc/src/clnt_generic.c
  172. @@ -66,7 +66,9 @@
  173.  #include <string.h>
  174.  #include <stdlib.h>
  175.  //#include <netdb.h>
  176. -//#include <syslog.h>
  177. +#ifndef _WIN32
  178. +#include <syslog.h>
  179. +#endif
  180.  #include <rpc/rpc.h>
  181.  #include <rpc/nettype.h>
  182.  //#include <unistd.h>
  183. diff --git a/libtirpc/src/clnt_vc.c b/libtirpc/src/clnt_vc.c
  184. index bac4212..3adef9c 100644
  185. --- a/libtirpc/src/clnt_vc.c
  186. +++ b/libtirpc/src/clnt_vc.c
  187. @@ -72,7 +72,9 @@
  188.  #include <reentrant.h>
  189.  #include <sys/types.h>
  190.  //#include <sys/poll.h>
  191. -//#include <sys/syslog.h>
  192. +#ifndef _WIN32
  193. +#include <sys/syslog.h>
  194. +#endif
  195.  //#include <sys/un.h>
  196.  //#include <sys/uio.h>
  197.  //#include <sys/socket.h>
  198. @@ -353,8 +355,8 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz, cb_xdr, cb_fn, cb_args)
  199.         cl = (CLIENT *)mem_alloc(sizeof (*cl));
  200.         ct = (struct ct_data *)mem_alloc(sizeof (*ct));
  201.         if ((cl == (CLIENT *)NULL) || (ct == (struct ct_data *)NULL)) {
  202. -//             (void) syslog(LOG_ERR, clnt_vc_errstr,
  203. -//                 clnt_vc_str, __no_mem_str);
  204. +               (void) syslog(LOG_ERR, clnt_vc_errstr,
  205. +                       clnt_vc_str, __no_mem_str);
  206.                 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
  207.                 rpc_createerr.cf_error.re_errno = errno;
  208.                 goto err;
  209. diff --git a/libtirpc/src/getnetpath.c b/libtirpc/src/getnetpath.c
  210. index 1fb6a12..fa11be1 100644
  211. --- a/libtirpc/src/getnetpath.c
  212. +++ b/libtirpc/src/getnetpath.c
  213. @@ -38,7 +38,9 @@
  214.  #include <netconfig.h>
  215.  #include <stdlib.h>
  216.  #include <string.h>
  217. -//#include <syslog.h>
  218. +#ifndef _WIN32
  219. +#include <syslog.h>
  220. +#endif
  221.  
  222.  /*
  223.   * internal structure to keep track of a netpath "session"
  224. @@ -90,7 +92,7 @@ setnetpath()
  225.         return (NULL);
  226.      }
  227.      if ((np_sessionp->nc_handlep = setnetconfig()) == NULL) {
  228. -       //syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
  229. +       syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
  230.         return (NULL);
  231.      }
  232.      np_sessionp->valid = NP_VALID;
  233. @@ -148,7 +150,7 @@ getnetpath(handlep)
  234.             if (np_sessionp->nc_handlep == NULL) {
  235.                         np_sessionp->nc_handlep = setnetconfig();
  236.                         if (np_sessionp->nc_handlep == NULL) {
  237. -                               //syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
  238. +                               syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
  239.                         }
  240.             }
  241.             if ((ncp = getnetconfig(np_sessionp->nc_handlep)) == NULL) {
  242. diff --git a/libtirpc/src/rpc_generic.c b/libtirpc/src/rpc_generic.c
  243. index 8ac2063..de8281a 100644
  244. --- a/libtirpc/src/rpc_generic.c
  245. +++ b/libtirpc/src/rpc_generic.c
  246. @@ -54,7 +54,9 @@
  247.  #include <netconfig.h>
  248.  #include <stdlib.h>
  249.  #include <string.h>
  250. -//#include <syslog.h>
  251. +#ifndef _WIN32
  252. +#include <syslog.h>
  253. +#endif
  254.  #include <rpc/nettype.h>
  255.  #include "rpc_com.h"
  256.  
  257. @@ -262,7 +264,7 @@ __rpc_getconfip(nettype)
  258.                 void *confighandle;
  259.  
  260.                 if (!(confighandle = setnetconfig())) {
  261. -                       //syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
  262. +                       syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
  263.                         return (NULL);
  264.                 }
  265.                 while ((nconf = getnetconfig(confighandle)) != NULL) {
  266. @@ -328,7 +330,7 @@ __rpc_setconf(nettype)
  267.         case _RPC_TCP:
  268.         case _RPC_UDP:
  269.                 if (!(handle->nhandle = setnetconfig())) {
  270. -                       //syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
  271. +                       syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
  272.                         free(handle);
  273.                         return (NULL);
  274.                 }
  275. diff --git a/libtirpc/src/rpc_soc.c b/libtirpc/src/rpc_soc.c
  276. index 0cbb749..d7faf25 100644
  277. --- a/libtirpc/src/rpc_soc.c
  278. +++ b/libtirpc/src/rpc_soc.c
  279. @@ -53,11 +53,12 @@
  280.  #include <rpc/pmap_clnt.h>
  281.  #include <rpc/pmap_prot.h>
  282.  #include <rpc/nettype.h>
  283. -//#include <syslog.h>
  284. +#ifndef _WIN32
  285. +#include <syslog.h>
  286. +#endif
  287.  //#include <netinet/in.h>
  288.  //#include <netdb.h>
  289.  #include <errno.h>
  290. -//#include <syslog.h>
  291.  #include <stdlib.h>
  292.  #include <string.h>
  293.  //#include <unistd.h>
  294. @@ -275,15 +276,15 @@ svc_com_create(fd, sendsize, recvsize, netid)
  295.         struct sockaddr_in sin;
  296.  
  297.         if ((nconf = __rpc_getconfip(netid)) == NULL) {
  298. -               //(void) syslog(LOG_ERR, "Could not get %s transport", netid);
  299. +               (void) syslog(LOG_ERR, "Could not get %s transport", netid);
  300.                 return (NULL);
  301.         }
  302.         if (fd == RPC_ANYSOCK) {
  303.                 fd = __rpc_nconf2fd(nconf);
  304.                 if (fd == -1) {
  305.                         (void) freenetconfigent(nconf);
  306. -                       //(void) syslog(LOG_ERR,
  307. -                       //"svc%s_create: could not open connection", netid);
  308. +                       (void) syslog(LOG_ERR,
  309. +                               "svc%s_create: could not open connection", netid);
  310.                         return (NULL);
  311.                 }
  312.                 madefd = TRUE;
  313. diff --git a/libtirpc/src/rpcb_clnt.c b/libtirpc/src/rpcb_clnt.c
  314. index 61adb78..5fb5daa 100644
  315. --- a/libtirpc/src/rpcb_clnt.c
  316. +++ b/libtirpc/src/rpcb_clnt.c
  317. @@ -56,7 +56,9 @@
  318.  #include <string.h>
  319.  //#include <unistd.h>
  320.  //#include <netdb.h>
  321. -//#include <syslog.h>
  322. +#ifndef _WIN32
  323. +#include <syslog.h>
  324. +#endif
  325.  
  326.  #include "rpc_com.h"
  327.  
  328. @@ -470,7 +472,7 @@ try_nconf:
  329.                 nc_handle = setnetconfig();
  330.                 if (nc_handle == NULL) {
  331.                         /* fails to open netconfig file */
  332. -                       //syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
  333. +                       syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
  334.                         rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
  335.                         mutex_unlock(&loopnconf_lock);
  336.                         return (NULL);
  337. diff --git a/libtirpc/src/wintirpc.c b/libtirpc/src/wintirpc.c
  338. index 4db1bb8..243eb17 100644
  339. --- a/libtirpc/src/wintirpc.c
  340. +++ b/libtirpc/src/wintirpc.c
  341. @@ -247,7 +247,7 @@ int wintirpc_socket(int af, int type, int protocol)
  342.  
  343.         wintirpc_register_osfhandle_fd(s, fd);
  344.  
  345. -       (void)fprintf(stderr, "wintirpc_socket: %s/%d: sock fd=%d\n",
  346. +       (void)syslog(LOG_DEBUG, "wintirpc_socket: %s/%d: sock fd=%d",
  347.                 __FILE__, (int)__LINE__, fd);
  348.  
  349.         return fd;
  350. @@ -314,6 +314,32 @@ int wintirpc_sendto(int s, const char *buf, int len, int flags,
  351.         return(sendto(_get_osfhandle(s), buf, len, flags, to, tolen));
  352.  }
  353.  
  354. +void wintirpc_syslog(int prio, const char *format, ...)
  355. +{
  356. +       const char *prio_s;
  357. +       va_list args;
  358. +       va_start(args, format);
  359. +
  360. +       switch (LOG_PRI(prio)) {
  361. +               case LOG_EMERG:         prio_s = "EMERG";       break;
  362. +               case LOG_ALERT:         prio_s = "ALERT";       break;
  363. +               case LOG_CRIT:          prio_s = "CRIT";        break;
  364. +               case LOG_ERR:           prio_s = "ERR";         break;
  365. +               case LOG_WARNING:       prio_s = "WARNING";     break;
  366. +               case LOG_NOTICE:        prio_s = "NOTICE";      break;
  367. +               case LOG_INFO:          prio_s = "INFO";        break;
  368. +               case LOG_DEBUG:         prio_s = "DEBUG";       break;
  369. +               default:                prio_s = "UNKNOWN_ERROR"; break;
  370. +       }
  371. +
  372. +       (void)fprintf(stderr, "%04x: %s: ", GetCurrentThreadId(), prio_s);
  373. +       (void)vfprintf(stderr, format, args);
  374. +       (void)fputc('\n', stderr);
  375. +       (void)fflush(stderr);
  376. +       va_end(args);
  377. +}
  378. +
  379. +
  380.  void wintirpc_warnx(const char *format, ...)
  381.  {
  382.      va_list args;
  383. diff --git a/libtirpc/tirpc/wintirpc.h b/libtirpc/tirpc/wintirpc.h
  384. index 66a0f48..f5e5a9f 100644
  385. --- a/libtirpc/tirpc/wintirpc.h
  386. +++ b/libtirpc/tirpc/wintirpc.h
  387. @@ -131,6 +131,7 @@ int wintirpc_listen(int in_s, int backlog);
  388.  int wintirpc_accept(int s_fd, struct sockaddr *addr, int *addrlen);
  389.  int wintirpc_send(int s, const char *buf, int len, int flags);
  390.  int wintirpc_sendto(int s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen);
  391. +void wintirpc_syslog(int prio, const char *format, ...);
  392.  void wintirpc_warnx(const char *format, ...);
  393.  void wintirpc_register_osfhandle_fd(SOCKET handle, int fd);
  394.  void wintirpc_unregister_osfhandle(SOCKET handle);
  395. @@ -147,5 +148,23 @@ void wintirpc_debug(char *fmt, ...);
  396.  
  397.  /* Mappings Windows API to |wintirpc_*()|-API */
  398.  #define warnx wintirpc_warnx
  399. +#define syslog wintirpc_syslog
  400. +
  401. +/* syslog */
  402. +#ifndef LOG_EMERG
  403. +#define LOG_EMERG      0
  404. +#define LOG_ALERT      1
  405. +#define LOG_CRIT       2
  406. +#define LOG_ERR                3
  407. +#define LOG_WARNING    4
  408. +#define LOG_NOTICE     5
  409. +#define LOG_INFO       6
  410. +#define LOG_DEBUG      7
  411. +#endif /* !LOG_EMERG */
  412. +
  413. +#define _LOG_PRIMASK     0x07
  414. +
  415. +#define LOG_PRI(p)      ((p) & _LOG_PRIMASK)
  416. +
  417.  
  418.  #endif /* !_TIRPC_WINTIRPC_H */
  419. --
  420. 2.42.1
  421.  
  422. From 4a9b922c95ea583c0cd6d83f2f1a0b7c2f035f29 Mon Sep 17 00:00:00 2001
  423. From: Roland Mainz <roland.mainz@nrubsig.org>
  424. Date: Wed, 15 Nov 2023 11:59:05 +0100
  425. Subject: [PATCH 2/4] libtirpc: Use |close()| for sockets to stop leaking osf
  426.  fds
  427.  
  428. Use |close()| instead of |closesocket()| to stop leaking osf fd.
  429. This also adds a wrapper (|wintirpc_close()|) so we can keep
  430. track the closing of sockets wrapped by osf fds.
  431.  
  432. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  433. ---
  434. libtirpc/src/auth_time.c    |  4 ++--
  435.  libtirpc/src/clnt_bcast.c   |  4 ++--
  436.  libtirpc/src/clnt_dg.c      |  2 +-
  437.  libtirpc/src/clnt_generic.c |  6 +++---
  438.  libtirpc/src/clnt_vc.c      |  5 +++--
  439.  libtirpc/src/rpc_soc.c      |  6 +++---
  440.  libtirpc/src/rpcb_clnt.c    |  8 ++++----
  441.  libtirpc/src/rtime.c        |  2 +-
  442.  libtirpc/src/svc_dg.c       |  2 +-
  443.  libtirpc/src/svc_generic.c  |  2 +-
  444.  libtirpc/src/svc_vc.c       |  2 +-
  445.  libtirpc/src/wintirpc.c     | 28 ++++++++++++++++++++++++++++
  446.  libtirpc/tirpc/wintirpc.h   |  2 ++
  447.  13 files changed, 52 insertions(+), 21 deletions(-)
  448.  
  449. diff --git a/libtirpc/src/auth_time.c b/libtirpc/src/auth_time.c
  450. index 99db3f8..0079f12 100644
  451. --- a/libtirpc/src/auth_time.c
  452. +++ b/libtirpc/src/auth_time.c
  453. @@ -447,7 +447,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid)
  454.                         time_valid = 1;
  455.                 }
  456.                 save = WSAGetLastError();
  457. -               (void)wintirpc_closesocket(s);
  458. +               (void)wintirpc_close(s);
  459.                 errno = save;
  460.                 s = RPC_ANYSOCK;
  461.  
  462. @@ -466,7 +466,7 @@ error:
  463.          */
  464.  
  465.         if (s != RPC_ANYSOCK)
  466. -               (void)wintirpc_closesocket(s);
  467. +               (void)wintirpc_close(s);
  468.  
  469.         if (clnt != NULL)
  470.                 clnt_destroy(clnt);
  471. diff --git a/libtirpc/src/clnt_bcast.c b/libtirpc/src/clnt_bcast.c
  472. index 89b7c7c..6ee6e60 100644
  473. --- a/libtirpc/src/clnt_bcast.c
  474. +++ b/libtirpc/src/clnt_bcast.c
  475. @@ -378,7 +378,7 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
  476.                 if (si.si_af == AF_INET && si.si_proto == IPPROTO_UDP) {
  477.                         udpbufsz = fdlist[fdlistno].dsize;
  478.                         if ((outbuf_pmap = malloc(udpbufsz)) == NULL) {
  479. -                               wintirpc_closesocket(fd);
  480. +                               wintirpc_close(fd);
  481.                                 stat = RPC_SYSTEMERROR;
  482.                                 goto done_broad;
  483.                         }
  484. @@ -676,7 +676,7 @@ done_broad:
  485.                 (void) free(outbuf_pmap);
  486.  #endif                         /* PORTMAP */
  487.         for (i = 0; i < fdlistno; i++) {
  488. -               (void)wintirpc_closesocket(fdlist[i].fd);
  489. +               (void)wintirpc_close(fdlist[i].fd);
  490.                 __rpc_freebroadifs(&fdlist[i].nal);
  491.         }
  492.         AUTH_DESTROY(sys_auth);
  493. diff --git a/libtirpc/src/clnt_dg.c b/libtirpc/src/clnt_dg.c
  494. index 0e7427f..56492ee 100644
  495. --- a/libtirpc/src/clnt_dg.c
  496. +++ b/libtirpc/src/clnt_dg.c
  497. @@ -793,7 +793,7 @@ clnt_dg_destroy(cl)
  498.         while (dg_fd_locks[cu_fd])
  499.                 cond_wait(&dg_cv[cu_fd], &clnt_fd_lock);
  500.         if (cu->cu_closeit)
  501. -               (void)wintirpc_closesocket(cu_fd);
  502. +               (void)wintirpc_close(cu_fd);
  503.         XDR_DESTROY(&(cu->cu_outxdrs));
  504.         mem_free(cu, (sizeof (*cu) + cu->cu_sendsz + cu->cu_recvsz));
  505.         if (cl->cl_netid && cl->cl_netid[0])
  506. diff --git a/libtirpc/src/clnt_generic.c b/libtirpc/src/clnt_generic.c
  507. index 60cf026..2fe0f97 100644
  508. --- a/libtirpc/src/clnt_generic.c
  509. +++ b/libtirpc/src/clnt_generic.c
  510. @@ -437,7 +437,7 @@ err:
  511.         rpc_createerr.cf_stat = RPC_SYSTEMERROR;
  512.         rpc_createerr.cf_error.re_errno = errno;
  513.  err1:  if (madefd)
  514. -               (void)wintirpc_closesocket(fd);
  515. +               (void)wintirpc_close(fd);
  516.         return (NULL);
  517.  }
  518.  
  519. @@ -462,11 +462,11 @@ __rpc_raise_fd(int fd)
  520.                 return (fd);
  521.  
  522.         if (fsync(nfd) == -1) {
  523. -               wintirpc_closesocket(nfd);
  524. +               wintirpc_close(nfd);
  525.                 return (fd);
  526.         }
  527.  
  528. -       if (wintirpc_closesocket(fd) == -1) {
  529. +       if (wintirpc_close(fd) == -1) {
  530.                 /* this is okay, we will syslog an error, then use the new fd */
  531.                 (void) syslog(LOG_ERR,
  532.                         "could not close() fd %d; mem & fd leak", fd);
  533. diff --git a/libtirpc/src/clnt_vc.c b/libtirpc/src/clnt_vc.c
  534. index 3adef9c..64e0d42 100644
  535. --- a/libtirpc/src/clnt_vc.c
  536. +++ b/libtirpc/src/clnt_vc.c
  537. @@ -459,7 +459,7 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz, cb_xdr, cb_fn, cb_args)
  538.             XDR_ENCODE);
  539.         if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
  540.                 if (ct->ct_closeit) {
  541. -                       (void)wintirpc_closesocket(fd);
  542. +                       (void)wintirpc_close(fd);
  543.                 }
  544.                 goto err;
  545.         }
  546. @@ -935,7 +935,8 @@ clnt_vc_destroy(cl)
  547.      }
  548.  
  549.         if (ct->ct_closeit && ct->ct_fd != -1) {
  550. -               (void)wintirpc_closesocket(ct->ct_fd);
  551. +               (void)wintirpc_close(ct->ct_fd);
  552. +               ct->ct_fd = -1;
  553.         }
  554.         XDR_DESTROY(&(ct->ct_xdrs));
  555.         if (ct->ct_addr.buf)
  556. diff --git a/libtirpc/src/rpc_soc.c b/libtirpc/src/rpc_soc.c
  557. index d7faf25..3073dac 100644
  558. --- a/libtirpc/src/rpc_soc.c
  559. +++ b/libtirpc/src/rpc_soc.c
  560. @@ -149,7 +149,7 @@ syserror:
  561.         rpc_createerr.cf_error.re_errno = errno;
  562.  
  563.  err:   if (madefd == TRUE)
  564. -               (void)wintirpc_closesocket(fd);
  565. +               (void)wintirpc_close(fd);
  566.         (void) freenetconfigent(nconf);
  567.         mutex_unlock(&rpcsoc_lock);
  568.         return (NULL);
  569. @@ -298,7 +298,7 @@ svc_com_create(fd, sendsize, recvsize, netid)
  570.         (void) freenetconfigent(nconf);
  571.         if (svc == NULL) {
  572.                 if (madefd)
  573. -                       (void)wintirpc_closesocket(fd);
  574. +                       (void)wintirpc_close(fd);
  575.                 return (NULL);
  576.         }
  577.         port = (((struct sockaddr_in *)svc->xp_ltaddr.buf)->sin_port);
  578. @@ -551,7 +551,7 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz)
  579.                         rpc_createerr.cf_stat = RPC_SYSTEMERROR;
  580.                         rpc_createerr.cf_error.re_errno = errno;
  581.                         if (*sockp != -1)
  582. -                               (void)wintirpc_closesocket(*sockp);
  583. +                               (void)wintirpc_close(*sockp);
  584.                         goto done;
  585.                 }
  586.          }
  587. diff --git a/libtirpc/src/rpcb_clnt.c b/libtirpc/src/rpcb_clnt.c
  588. index 5fb5daa..03b7ef6 100644
  589. --- a/libtirpc/src/rpcb_clnt.c
  590. +++ b/libtirpc/src/rpcb_clnt.c
  591. @@ -458,7 +458,7 @@ local_rpcb()
  592.         }
  593.  
  594.         /* Nobody needs this socket anymore; free the descriptor. */
  595. -       wintirpc_closesocket(sock);
  596. +       wintirpc_close(sock);
  597.  
  598.  try_nconf:
  599.  
  600. @@ -493,7 +493,7 @@ try_nconf:
  601.                                  */
  602.                                 if (fd == SOCKET_ERROR)
  603.                                         continue;
  604. -                               wintirpc_closesocket(fd);
  605. +                               wintirpc_close(fd);
  606.                                 tmpnconf = nconf;
  607.                                 if (!strcmp(nconf->nc_protofmly, NC_INET))
  608.                                         hostname = IN4_LOCALHOST_STRING;
  609. @@ -683,11 +683,11 @@ __rpcbind_is_up()
  610.         strncpy(sun.sun_path, _PATH_RPCBINDSOCK, sizeof(sun.sun_path));
  611.  
  612.         if (connect(_get_osfhandle(sock), (struct sockaddr *)&sun, sizeof(sun)) == SOCKET_ERROR) {
  613. -               wintirpc_closesocket(sock);
  614. +               wintirpc_close(sock);
  615.                 return (FALSE);
  616.         }
  617.  
  618. -       wintirpc_closesocket(sock);
  619. +       wintirpc_close(sock);
  620.         return (TRUE);
  621.  }
  622.  
  623. diff --git a/libtirpc/src/rtime.c b/libtirpc/src/rtime.c
  624. index 1f3b8ab..2203b30 100644
  625. --- a/libtirpc/src/rtime.c
  626. +++ b/libtirpc/src/rtime.c
  627. @@ -150,6 +150,6 @@ do_close(s)
  628.         int save;
  629.  
  630.         save = errno;
  631. -       (void)wintirpc_closesocket(s);
  632. +       (void)wintirpc_close(s);
  633.         errno = save;
  634.  }
  635. diff --git a/libtirpc/src/svc_dg.c b/libtirpc/src/svc_dg.c
  636. index b6bc541..2a49c5e 100644
  637. --- a/libtirpc/src/svc_dg.c
  638. +++ b/libtirpc/src/svc_dg.c
  639. @@ -257,7 +257,7 @@ svc_dg_destroy(xprt)
  640.  
  641.         xprt_unregister(xprt);
  642.         if (xprt->xp_fd != -1)
  643. -               (void)wintirpc_closesocket(xprt->xp_fd);
  644. +               (void)wintirpc_close(xprt->xp_fd);
  645.         XDR_DESTROY(&(su->su_xdrs));
  646.         (void) mem_free(rpc_buffer(xprt), su->su_iosz);
  647.         (void) mem_free(su, sizeof (*su));
  648. diff --git a/libtirpc/src/svc_generic.c b/libtirpc/src/svc_generic.c
  649. index 47a12a3..7ba0bfc 100644
  650. --- a/libtirpc/src/svc_generic.c
  651. +++ b/libtirpc/src/svc_generic.c
  652. @@ -291,7 +291,7 @@ svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz)
  653.  
  654.  freedata:
  655.         if (madefd)
  656. -               (void)wintirpc_closesocket(fd);
  657. +               (void)wintirpc_close(fd);
  658.         if (xprt) {
  659.                 if (!madefd) /* so that svc_destroy doesnt close fd */
  660.                         xprt->xp_fd = RPC_ANYFD;
  661. diff --git a/libtirpc/src/svc_vc.c b/libtirpc/src/svc_vc.c
  662. index 5c57685..23ed338 100644
  663. --- a/libtirpc/src/svc_vc.c
  664. +++ b/libtirpc/src/svc_vc.c
  665. @@ -415,7 +415,7 @@ __svc_vc_dodestroy(xprt)
  666.         cd = (struct cf_conn *)xprt->xp_p1;
  667.  
  668.         if (xprt->xp_fd != RPC_ANYFD)
  669. -               (void)wintirpc_closesocket(xprt->xp_fd);
  670. +               (void)wintirpc_close(xprt->xp_fd);
  671.         if (xprt->xp_port != 0) {
  672.                 /* a rendezvouser socket */
  673.                 r = (struct cf_rendezvous *)xprt->xp_p1;
  674. diff --git a/libtirpc/src/wintirpc.c b/libtirpc/src/wintirpc.c
  675. index 243eb17..cc8266c 100644
  676. --- a/libtirpc/src/wintirpc.c
  677. +++ b/libtirpc/src/wintirpc.c
  678. @@ -186,6 +186,9 @@ void wintirpc_unregister_osfhandle(SOCKET handle)
  679.         assert(handle != 0);
  680.         assert(handle != SOCKET_ERROR);
  681.  
  682. +       if ((handle == 0) || (handle != SOCKET_ERROR))
  683. +               return;
  684. +
  685.         for (i=0 ; i < WINTIRPC_MAX_OSFHANDLE_FD_NHANDLE_VALUE ; i++) {
  686.                 if (handle_fd_map[i].m_s == handle) {
  687.                         handle_fd_map[i].m_s = SOCKET_ERROR;
  688. @@ -196,6 +199,24 @@ void wintirpc_unregister_osfhandle(SOCKET handle)
  689.         (void)fprintf(stderr, "wintirpc_unregister_osfhandle: failed\n");
  690.  }
  691.  
  692. +void wintirpc_unregister_osf_fd(int fd)
  693. +{
  694. +       int i;
  695. +
  696. +       assert(fd >= 0);
  697. +       if (fd < 0)
  698. +               return;
  699. +
  700. +       for (i=0 ; i < WINTIRPC_MAX_OSFHANDLE_FD_NHANDLE_VALUE ; i++) {
  701. +               if (handle_fd_map[i].m_fd == fd) {
  702. +                       handle_fd_map[i].m_s = SOCKET_ERROR;
  703. +                       handle_fd_map[i].m_fd = -1;
  704. +                       return;
  705. +               }
  706. +       }
  707. +       (void)fprintf(stderr, "wintirpc_unregister_osf_fd: failed\n");
  708. +}
  709. +
  710.  int wintirpc_handle2fd(SOCKET handle)
  711.  {
  712.         int i;
  713. @@ -262,6 +283,13 @@ int wintirpc_closesocket(int in_fd)
  714.         return closesocket(s);
  715.  }
  716.  
  717. +int wintirpc_close(int in_fd)
  718. +{
  719. +       wintirpc_unregister_osf_fd(in_fd);
  720. +
  721. +       return _close(in_fd);
  722. +}
  723. +
  724.  int wintirpc_listen(int in_s, int backlog)
  725.  {
  726.         return listen(_get_osfhandle(in_s), backlog);
  727. diff --git a/libtirpc/tirpc/wintirpc.h b/libtirpc/tirpc/wintirpc.h
  728. index f5e5a9f..88027c6 100644
  729. --- a/libtirpc/tirpc/wintirpc.h
  730. +++ b/libtirpc/tirpc/wintirpc.h
  731. @@ -127,6 +127,7 @@ struct sockaddr_un {
  732.  /* Prototypes */
  733.  int wintirpc_socket(int af,int type, int protocol);
  734.  int wintirpc_closesocket(int in_fd);
  735. +int wintirpc_close(int in_fd);
  736.  int wintirpc_listen(int in_s, int backlog);
  737.  int wintirpc_accept(int s_fd, struct sockaddr *addr, int *addrlen);
  738.  int wintirpc_send(int s, const char *buf, int len, int flags);
  739. @@ -135,6 +136,7 @@ void wintirpc_syslog(int prio, const char *format, ...);
  740.  void wintirpc_warnx(const char *format, ...);
  741.  void wintirpc_register_osfhandle_fd(SOCKET handle, int fd);
  742.  void wintirpc_unregister_osfhandle(SOCKET handle);
  743. +void wintirpc_unregister_osf_fd(int fd);
  744.  int wintirpc_handle2fd(SOCKET handle);
  745.  
  746.  /* Debugging function */
  747. --
  748. 2.42.1
  749.  
  750. From 786220e534a83b94c9bf2d312aaf7b5ad7a511d0 Mon Sep 17 00:00:00 2001
  751. From: Roland Mainz <roland.mainz@nrubsig.org>
  752. Date: Wed, 15 Nov 2023 13:33:02 +0100
  753. Subject: [PATCH 3/4] libtirpc: Fix Visual Studio 19 build warnings
  754.  
  755. libtirpc: Fix Visual Studio 19 build warnings caused by missing
  756. casts. This also adds some |assert()| statments where the casts
  757. are not 100% safe.
  758.  
  759. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  760. ---
  761. libtirpc/src/auth_sspi.c     |  3 ++-
  762.  libtirpc/src/rpc_generic.c   |  6 +++++-
  763.  libtirpc/src/rpcb_clnt.c     |  2 +-
  764.  libtirpc/src/svc_auth_unix.c |  2 +-
  765.  libtirpc/src/svc_dg.c        | 15 ++++++++++-----
  766.  libtirpc/src/svc_vc.c        |  2 ++
  767.  libtirpc/src/xdr.c           |  2 +-
  768.  libtirpc/src/xdr_rec.c       | 10 ++++++----
  769.  8 files changed, 28 insertions(+), 14 deletions(-)
  770.  
  771. diff --git a/libtirpc/src/auth_sspi.c b/libtirpc/src/auth_sspi.c
  772. index 3bd558c..b5405c7 100644
  773. --- a/libtirpc/src/auth_sspi.c
  774. +++ b/libtirpc/src/auth_sspi.c
  775. @@ -869,7 +869,8 @@ void print_rpc_gss_sec(struct rpc_sspi_sec *ptr)
  776.         }
  777.         fprintf(fd_out, "     qop: %d\n", ptr->qop);
  778.         fprintf(fd_out, "     service: %d\n", ptr->svc);
  779. -       fprintf(fd_out, "     cred: %p\n", ptr->cred);
  780. +       fprintf(fd_out, "     cred(%p) = { dwLower=%lld, dwUpper=%lld} \n",
  781. +               &ptr->cred, ptr->cred.dwLower, ptr->cred.dwUpper);
  782.  }
  783.  
  784.  void print_negotiated_attrs(PCtxtHandle ctx)
  785. diff --git a/libtirpc/src/rpc_generic.c b/libtirpc/src/rpc_generic.c
  786. index de8281a..5837020 100644
  787. --- a/libtirpc/src/rpc_generic.c
  788. +++ b/libtirpc/src/rpc_generic.c
  789. @@ -923,6 +923,10 @@ __rpc_sockisbound(int fd)
  790.  struct netbuf *
  791.  __rpc_set_netbuf(struct netbuf *nb, const void *ptr, size_t len)
  792.  {
  793. +       /* will it fit into netbuf ? */
  794. +       if (len > INT_MAX)
  795. +               return NULL;
  796. +
  797.         if (nb->len != len) {
  798.                 if (nb->len)
  799.                         mem_free(nb->buf, nb->len);
  800. @@ -930,7 +934,7 @@ __rpc_set_netbuf(struct netbuf *nb, const void *ptr, size_t len)
  801.                 if (nb->buf == NULL)
  802.                         return NULL;
  803.  
  804. -               nb->maxlen = nb->len = len;
  805. +               nb->maxlen = nb->len = (unsigned int)len;
  806.         }
  807.         memcpy(nb->buf, ptr, len);
  808.         return nb;
  809. diff --git a/libtirpc/src/rpcb_clnt.c b/libtirpc/src/rpcb_clnt.c
  810. index 03b7ef6..906db37 100644
  811. --- a/libtirpc/src/rpcb_clnt.c
  812. +++ b/libtirpc/src/rpcb_clnt.c
  813. @@ -365,7 +365,7 @@ getclnthandle(host, nconf, targaddr)
  814.  
  815.         for (tres = res; tres != NULL; tres = tres->ai_next) {
  816.                 taddr.buf = tres->ai_addr;
  817. -               taddr.len = taddr.maxlen = tres->ai_addrlen;
  818. +               taddr.len = taddr.maxlen = (unsigned int)tres->ai_addrlen;
  819.  
  820.  #ifdef ND_DEBUG
  821.                 {
  822. diff --git a/libtirpc/src/svc_auth_unix.c b/libtirpc/src/svc_auth_unix.c
  823. index 551a252..b8e572e 100644
  824. --- a/libtirpc/src/svc_auth_unix.c
  825. +++ b/libtirpc/src/svc_auth_unix.c
  826. @@ -93,7 +93,7 @@ _svcauth_unix(rqst, msg)
  827.                         stat = AUTH_BADCRED;
  828.                         goto done;
  829.                 }
  830. -               aup->aup_len = gid_len;
  831. +               aup->aup_len = (u_int)gid_len;
  832.                 for (i = 0; i < gid_len; i++) {
  833.                         aup->aup_gids[i] = (int)IXDR_GET_INT32(buf);
  834.                 }
  835. diff --git a/libtirpc/src/svc_dg.c b/libtirpc/src/svc_dg.c
  836. index 2a49c5e..34bb7a8 100644
  837. --- a/libtirpc/src/svc_dg.c
  838. +++ b/libtirpc/src/svc_dg.c
  839. @@ -128,7 +128,8 @@ svc_dg_create(fd, sendsize, recvsize)
  840.         su->su_iosz = ((MAX(sendsize, recvsize) + 3) / 4) * 4;
  841.         if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL)
  842.                 goto freedata;
  843. -       xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz,
  844. +       assert(su->su_iosz < UINT_MAX);
  845. +       xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), (u_int)su->su_iosz,
  846.                 XDR_DECODE);
  847.         su->su_cache = NULL;
  848.         xprt->xp_fd = fd;
  849. @@ -177,7 +178,8 @@ svc_dg_recv(xprt, msg)
  850.  
  851.  again:
  852.         alen = sizeof (struct sockaddr_storage);
  853. -       rlen = recvfrom(_get_osfhandle(xprt->xp_fd), rpc_buffer(xprt), su->su_iosz, 0,
  854. +       assert(su->su_iosz < UINT_MAX);
  855. +       rlen = recvfrom(_get_osfhandle(xprt->xp_fd), rpc_buffer(xprt), (u_int)su->su_iosz, 0,
  856.             (struct sockaddr *)(void *)&ss, &alen);
  857.         if (rlen == -1 && errno == EINTR)
  858.                 goto again;
  859. @@ -194,7 +196,8 @@ again:
  860.         su->su_xid = msg->rm_xid;
  861.         if (su->su_cache != NULL) {
  862.                 if (cache_get(xprt, msg, &reply, &replylen)) {
  863. -                       (void)wintirpc_sendto(xprt->xp_fd, reply, replylen, 0,
  864. +                       assert(replylen < INT_MAX);
  865. +                       (void)wintirpc_sendto(xprt->xp_fd, reply, (int)replylen, 0,
  866.                             (struct sockaddr *)(void *)&ss, alen);
  867.                         return (FALSE);
  868.                 }
  869. @@ -217,7 +220,8 @@ svc_dg_reply(xprt, msg)
  870.         msg->rm_xid = su->su_xid;
  871.         if (xdr_replymsg(xdrs, msg)) {
  872.                 slen = XDR_GETPOS(xdrs);
  873. -               if (wintirpc_sendto(xprt->xp_fd, rpc_buffer(xprt), slen, 0,
  874. +               assert(slen < INT_MAX);
  875. +               if (wintirpc_sendto(xprt->xp_fd, rpc_buffer(xprt), (int)slen, 0,
  876.                     (struct sockaddr *)xprt->xp_rtaddr.buf,
  877.                     (socklen_t)xprt->xp_rtaddr.len) == (ssize_t) slen) {
  878.                         stat = TRUE;
  879. @@ -507,8 +511,9 @@ cache_set(xprt, replylen)
  880.         victim->cache_replylen = replylen;
  881.         victim->cache_reply = rpc_buffer(xprt);
  882.         rpc_buffer(xprt) = newbuf;
  883. +       assert(su->su_iosz < UINT_MAX);
  884.         xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt),
  885. -                       su->su_iosz, XDR_ENCODE);
  886. +                       (u_int)su->su_iosz, XDR_ENCODE);
  887.         victim->cache_xid = su->su_xid;
  888.         victim->cache_proc = uc->uc_proc;
  889.         victim->cache_vers = uc->uc_vers;
  890. diff --git a/libtirpc/src/svc_vc.c b/libtirpc/src/svc_vc.c
  891. index 23ed338..5fa8ee4 100644
  892. --- a/libtirpc/src/svc_vc.c
  893. +++ b/libtirpc/src/svc_vc.c
  894. @@ -314,7 +314,9 @@ rendezvous_request(xprt, msg)
  895.         socklen_t len;
  896.         struct __rpc_sockinfo si;
  897.         SVCXPRT *newxprt;
  898. +#ifndef _WIN32 // CVE-2018-14621
  899.         fd_set cleanfds;
  900. +#endif
  901.  
  902.         assert(xprt != NULL);
  903.         assert(msg != NULL);
  904. diff --git a/libtirpc/src/xdr.c b/libtirpc/src/xdr.c
  905. index 38a959d..3c24314 100644
  906. --- a/libtirpc/src/xdr.c
  907. +++ b/libtirpc/src/xdr.c
  908. @@ -699,7 +699,7 @@ xdr_string(xdrs, cpp, maxsize)
  909.         case XDR_ENCODE:
  910.                 if (sp == NULL)
  911.                         return FALSE;
  912. -               size = strlen(sp);
  913. +               size = (u_int)strlen(sp);
  914.                 break;
  915.         case XDR_DECODE:
  916.                 break;
  917. diff --git a/libtirpc/src/xdr_rec.c b/libtirpc/src/xdr_rec.c
  918. index e4c512a..b5c9949 100644
  919. --- a/libtirpc/src/xdr_rec.c
  920. +++ b/libtirpc/src/xdr_rec.c
  921. @@ -320,13 +320,14 @@ xdrrec_getbytes(xdrs, addr, len)
  922.  }
  923.  
  924.  static bool_t
  925. -xdrrec_putbytes(xdrs, addr, len)
  926. +xdrrec_putbytes(xdrs, addr, in_len)
  927.         XDR *xdrs;
  928.         const char *addr;
  929. -       u_int len;
  930. +       u_int in_len;
  931.  {
  932.         RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
  933.         size_t current;
  934. +       size_t len = in_len;
  935.  
  936.         while (len > 0) {
  937.                 current = (size_t)(PtrToUlong(rstrm->out_boundry) -
  938. @@ -729,12 +730,13 @@ fill_input_buf(rstrm)
  939.  }
  940.  
  941.  static bool_t  /* knows nothing about records!  Only about input buffers */
  942. -get_input_bytes(rstrm, addr, len)
  943. +get_input_bytes(rstrm, addr, in_len)
  944.         RECSTREAM *rstrm;
  945.         char *addr;
  946. -       u_int len;
  947. +       u_int in_len;
  948.  {
  949.         size_t current;
  950. +       size_t len = in_len;
  951.  
  952.         if (rstrm->nonblock) {
  953.                 if (len > (u_int)(rstrm->in_boundry - rstrm->in_finger))
  954. --
  955. 2.42.1
  956.  
  957. From 4b465d8884acfa41977a1ce1075aabc5c15c1e37 Mon Sep 17 00:00:00 2001
  958. From: Roland Mainz <roland.mainz@nrubsig.org>
  959. Date: Wed, 15 Nov 2023 15:26:07 +0100
  960. Subject: [PATCH 4/4] daemon: "handle_mount: empty mount root" spam, should be
  961.  debug message
  962.  
  963. daemon: The warning "handle_mount: empty mount root" from
  964. daemon/mount.c is currently triggered very often, it should better be
  965. a debug message.
  966.  
  967. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  968. ---
  969. daemon/mount.c | 2 +-
  970.  1 file changed, 1 insertion(+), 1 deletion(-)
  971.  
  972. diff --git a/daemon/mount.c b/daemon/mount.c
  973. index a7b3a8c..a0cfd7d 100644
  974. --- a/daemon/mount.c
  975. +++ b/daemon/mount.c
  976. @@ -72,7 +72,7 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
  977.      EASSERT(args->hostport != NULL);
  978.  
  979.      if ((args->path == NULL) || (strlen(args->path) == 0)) {
  980. -        eprintf("handle_mount: empty mount root\n");
  981. +        dprintf(1, "handle_mount: empty mount root\n");
  982.          status = ERROR_BAD_NETPATH;
  983.          goto out;
  984.      }
  985. --
  986. 2.42.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