patch-src_rpcb_svc_com_c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. --- rpcbind-0.2.3.orig/src/rpcb_svc_com.c 2015-04-27 16:07:43.000000000 +0200
  2. +++ rpcbind-0.2.3/src/rpcb_svc_com.c 2016-10-08 18:20:08.000000000 +0200
  3. @@ -42,8 +42,6 @@
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <sys/param.h>
  7. -#include <sys/poll.h>
  8. -#include <bits/poll.h>
  9. #include <sys/socket.h>
  10. #include <rpc/rpc.h>
  11. #include <rpc/rpcb_prot.h>
  12. @@ -54,6 +52,7 @@
  13. #include <unistd.h>
  14. #include <stdio.h>
  15. #include <time.h>
  16. +#include <poll.h>
  17. #ifdef PORTMAP
  18. #include <netinet/in.h>
  19. #include <rpc/pmap_prot.h>
  20. @@ -100,29 +99,29 @@ struct finfo {
  21. static struct finfo FINFO[NFORWARD];
  22. -static bool_t xdr_encap_parms __P((XDR *, struct encap_parms *));
  23. -static bool_t xdr_rmtcall_args __P((XDR *, struct r_rmtcall_args *));
  24. -static bool_t xdr_rmtcall_result __P((XDR *, struct r_rmtcall_args *));
  25. -static bool_t xdr_opaque_parms __P((XDR *, struct r_rmtcall_args *));
  26. -static int find_rmtcallfd_by_netid __P((char *));
  27. -static SVCXPRT *find_rmtcallxprt_by_fd __P((int));
  28. -static int forward_register __P((u_int32_t, struct netbuf *, int, char *,
  29. - rpcproc_t, rpcvers_t, u_int32_t *));
  30. -static struct finfo *forward_find __P((u_int32_t));
  31. -static int free_slot_by_xid __P((u_int32_t));
  32. -static int free_slot_by_index __P((int));
  33. -static int netbufcmp __P((struct netbuf *, struct netbuf *));
  34. -static struct netbuf *netbufdup __P((struct netbuf *));
  35. -static void netbuffree __P((struct netbuf *));
  36. -static int check_rmtcalls __P((struct pollfd *, int));
  37. -static void xprt_set_caller __P((SVCXPRT *, struct finfo *));
  38. -static void send_svcsyserr __P((SVCXPRT *, struct finfo *));
  39. -static void handle_reply __P((int, SVCXPRT *));
  40. -static void find_versions __P((rpcprog_t, char *, rpcvers_t *, rpcvers_t *));
  41. -static rpcblist_ptr find_service __P((rpcprog_t, rpcvers_t, char *));
  42. -static char *getowner __P((SVCXPRT *, char *, size_t));
  43. -static int add_pmaplist __P((RPCB *));
  44. -static int del_pmaplist __P((RPCB *));
  45. +static bool_t xdr_encap_parms (XDR *, struct encap_parms *);
  46. +static bool_t xdr_rmtcall_args (XDR *, struct r_rmtcall_args *);
  47. +static bool_t xdr_rmtcall_result (XDR *, struct r_rmtcall_args *);
  48. +static bool_t xdr_opaque_parms (XDR *, struct r_rmtcall_args *);
  49. +static int find_rmtcallfd_by_netid (char *);
  50. +static SVCXPRT *find_rmtcallxprt_by_fd (int);
  51. +static int forward_register (u_int32_t, struct netbuf *, int, char *,
  52. + rpcproc_t, rpcvers_t, u_int32_t *);
  53. +static struct finfo *forward_find (u_int32_t);
  54. +static int free_slot_by_xid (u_int32_t);
  55. +static int free_slot_by_index (int);
  56. +static int netbufcmp (struct netbuf *, struct netbuf *);
  57. +static struct netbuf *netbufdup (struct netbuf *);
  58. +static void netbuffree (struct netbuf *);
  59. +static int check_rmtcalls (struct pollfd *, int);
  60. +static void xprt_set_caller (SVCXPRT *, struct finfo *);
  61. +static void send_svcsyserr (SVCXPRT *, struct finfo *);
  62. +static void handle_reply (int, SVCXPRT *);
  63. +static void find_versions (rpcprog_t, char *, rpcvers_t *, rpcvers_t *);
  64. +static rpcblist_ptr find_service (rpcprog_t, rpcvers_t, char *);
  65. +static char *getowner (SVCXPRT *, char *, size_t);
  66. +static int add_pmaplist (RPCB *);
  67. +static int del_pmaplist (RPCB *);
  68. /*
  69. * Set a mapping of program, version, netid
  70. @@ -1183,12 +1182,33 @@ check_rmtcalls(struct pollfd *pfds, int
  71. return (ncallbacks_found);
  72. }
  73. +/*
  74. + * This is really a helper function defined in libtirpc, but unfortunately, it hasn't
  75. + * been exported yet.
  76. + */
  77. +static struct netbuf *
  78. +__rpc_set_netbuf(struct netbuf *nb, const void *ptr, size_t len)
  79. +{
  80. + if (nb->len != len) {
  81. + if (nb->len)
  82. + mem_free(nb->buf, nb->len);
  83. + nb->buf = mem_alloc(len);
  84. + if (nb->buf == NULL)
  85. + return NULL;
  86. +
  87. + nb->maxlen = nb->len = len;
  88. + }
  89. + memcpy(nb->buf, ptr, len);
  90. + return nb;
  91. +}
  92. +
  93. static void
  94. xprt_set_caller(SVCXPRT *xprt, struct finfo *fi)
  95. {
  96. + const struct netbuf *caller = fi->caller_addr;
  97. u_int32_t *xidp;
  98. - *(svc_getrpccaller(xprt)) = *(fi->caller_addr);
  99. + __rpc_set_netbuf(svc_getrpccaller(xprt), caller->buf, caller->len);
  100. xidp = __rpcb_get_dg_xidp(xprt);
  101. *xidp = fi->caller_xid;
  102. }
  103. @@ -1274,10 +1294,17 @@ handle_reply(int fd, SVCXPRT *xprt)
  104. a.rmt_localvers = fi->versnum;
  105. xprt_set_caller(xprt, fi);
  106. +#if defined(SVC_XP_AUTH)
  107. + SVC_XP_AUTH(xprt) = svc_auth_none;
  108. +#else
  109. xprt->xp_auth = &svc_auth_none;
  110. +#endif
  111. svc_sendreply(xprt, (xdrproc_t) xdr_rmtcall_result, (char *) &a);
  112. +#if !defined(SVC_XP_AUTH)
  113. SVCAUTH_DESTROY(xprt->xp_auth);
  114. xprt->xp_auth = NULL;
  115. +#endif
  116. +
  117. done:
  118. if (buffer)
  119. free(buffer);