0005-rpcbproc_callit_com-Stop-freeing-a-static-pointer.patch 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. From 4e201b75928ff7d4894cd30ab0f5f67b9cd95f5c Mon Sep 17 00:00:00 2001
  2. From: Steve Dickson <steved@redhat.com>
  3. Date: Thu, 18 Jan 2018 17:33:56 +0000
  4. Subject: [PATCH] rpcbproc_callit_com: Stop freeing a static pointer
  5. commit 7ea36ee introduced a svc_freeargs() call
  6. that ended up freeing static pointer.
  7. It turns out the allocations for the rmt_args
  8. is not necessary . The xdr routines (xdr_bytes) will
  9. handle the memory management and the largest
  10. possible message size is UDPMSGSIZE (due to UDP only)
  11. which is smaller than RPC_BUF_MAX
  12. Signed-off-by: Steve Dickson <steved@redhat.com>
  13. (cherry picked from commit 7c7590ad536c0e24bef790cb1e65702fc54db566)
  14. Signed-off-by: Ed Blake <ed.blake@sondrel.com>
  15. ---
  16. src/rpcb_svc_com.c | 39 ++++++---------------------------------
  17. 1 file changed, 6 insertions(+), 33 deletions(-)
  18. diff --git a/src/rpcb_svc_com.c b/src/rpcb_svc_com.c
  19. index 0432b6f..64f1104 100644
  20. --- a/src/rpcb_svc_com.c
  21. +++ b/src/rpcb_svc_com.c
  22. @@ -616,9 +616,9 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
  23. struct netconfig *nconf;
  24. struct netbuf *caller;
  25. struct r_rmtcall_args a;
  26. - char *buf_alloc = NULL, *outbufp;
  27. + char *outbufp;
  28. char *outbuf_alloc = NULL;
  29. - char buf[RPC_BUF_MAX], outbuf[RPC_BUF_MAX];
  30. + char outbuf[RPC_BUF_MAX];
  31. struct netbuf *na = (struct netbuf *) NULL;
  32. struct rpc_msg call_msg;
  33. int outlen;
  34. @@ -639,36 +639,10 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
  35. }
  36. if (si.si_socktype != SOCK_DGRAM)
  37. return; /* Only datagram type accepted */
  38. - sendsz = __rpc_get_t_size(si.si_af, si.si_proto, UDPMSGSIZE);
  39. - if (sendsz == 0) { /* data transfer not supported */
  40. - if (reply_type == RPCBPROC_INDIRECT)
  41. - svcerr_systemerr(transp);
  42. - return;
  43. - }
  44. - /*
  45. - * Should be multiple of 4 for XDR.
  46. - */
  47. - sendsz = ((sendsz + 3) / 4) * 4;
  48. - if (sendsz > RPC_BUF_MAX) {
  49. -#ifdef notyet
  50. - buf_alloc = alloca(sendsz); /* not in IDR2? */
  51. -#else
  52. - buf_alloc = malloc(sendsz);
  53. -#endif /* notyet */
  54. - if (buf_alloc == NULL) {
  55. - if (debugging)
  56. - xlog(LOG_DEBUG,
  57. - "rpcbproc_callit_com: No Memory!\n");
  58. - if (reply_type == RPCBPROC_INDIRECT)
  59. - svcerr_systemerr(transp);
  60. - return;
  61. - }
  62. - a.rmt_args.args = buf_alloc;
  63. - } else {
  64. - a.rmt_args.args = buf;
  65. - }
  66. + sendsz = UDPMSGSIZE;
  67. call_msg.rm_xid = 0; /* For error checking purposes */
  68. + memset(&a, 0, sizeof(a)); /* Zero out the input buffer */
  69. if (!svc_getargs(transp, (xdrproc_t) xdr_rmtcall_args, (char *) &a)) {
  70. if (reply_type == RPCBPROC_INDIRECT)
  71. svcerr_decode(transp);
  72. @@ -708,7 +682,8 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
  73. if (rbl == (rpcblist_ptr)NULL) {
  74. #ifdef RPCBIND_DEBUG
  75. if (debugging)
  76. - xlog(LOG_DEBUG, "not found\n");
  77. + xlog(LOG_DEBUG, "prog %lu vers %lu: not found\n",
  78. + a.rmt_prog, a.rmt_vers);
  79. #endif
  80. if (reply_type == RPCBPROC_INDIRECT)
  81. svcerr_noprog(transp);
  82. @@ -941,8 +916,6 @@ out:
  83. }
  84. if (local_uaddr)
  85. free(local_uaddr);
  86. - if (buf_alloc)
  87. - free(buf_alloc);
  88. if (outbuf_alloc)
  89. free(outbuf_alloc);
  90. if (na) {
  91. --
  92. 2.11.0