blob: 6d40d3cce8d08081981d9ec4d772fdaceee29c44 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001Patch from Fedora https://src.fedoraproject.org/rpms/libtirpc/raw/master/f/libtirpc-1.0.4-rc1.patch
2
3Upstream-Status: Backport
4Signed-off-by: Khem Raj <raj.khem@gmail.com>
5
6diff --git a/src/clnt_generic.c b/src/clnt_generic.c
7index e5a314f..3f3dabf 100644
8--- a/src/clnt_generic.c
9+++ b/src/clnt_generic.c
10@@ -47,7 +47,6 @@
11
12 extern bool_t __rpc_is_local_host(const char *);
13 int __rpc_raise_fd(int);
14-extern int __binddynport(int fd);
15
16 #ifndef NETIDLEN
17 #define NETIDLEN 32
18@@ -341,8 +340,7 @@ clnt_tli_create(int fd, const struct netconfig *nconf,
19 servtype = nconf->nc_semantics;
20 if (!__rpc_fd2sockinfo(fd, &si))
21 goto err;
22- if (__binddynport(fd) == -1)
23- goto err;
24+ bindresvport(fd, NULL);
25 } else {
26 if (!__rpc_fd2sockinfo(fd, &si))
27 goto err;
28diff --git a/src/rpc_soc.c b/src/rpc_soc.c
29index af6c482..5a6eeb7 100644
30--- a/src/rpc_soc.c
31+++ b/src/rpc_soc.c
32@@ -67,8 +67,6 @@
33
34 extern mutex_t rpcsoc_lock;
35
36-extern int __binddynport(int fd);
37-
38 static CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t,
39 int *, u_int, u_int, char *, int);
40 static SVCXPRT *svc_com_create(int, u_int, u_int, char *);
41@@ -147,8 +145,7 @@ clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp, flags)
42 bindaddr.maxlen = bindaddr.len = sizeof (struct sockaddr_in);
43 bindaddr.buf = raddr;
44
45- if (__binddynport(fd) == -1)
46- goto err;
47+ bindresvport(fd, NULL);
48 cl = clnt_tli_create(fd, nconf, &bindaddr, prog, vers,
49 sendsz, recvsz);
50 if (cl) {
51diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c
52index a94fc73..4b44364 100644
53--- a/src/rpcb_clnt.c
54+++ b/src/rpcb_clnt.c
55@@ -752,7 +752,7 @@ __try_protocol_version_2(program, version, nconf, host, tp)
56
57 client = getpmaphandle(nconf, host, &parms.r_addr);
58 if (client == NULL)
59- return (NULL);
60+ goto error;
61
62 /*
63 * Set retry timeout.
64@@ -771,11 +771,11 @@ __try_protocol_version_2(program, version, nconf, host, tp)
65 if (clnt_st != RPC_SUCCESS) {
66 rpc_createerr.cf_stat = RPC_PMAPFAILURE;
67 clnt_geterr(client, &rpc_createerr.cf_error);
68- return (NULL);
69+ goto error;
70 } else if (port == 0) {
71 pmapaddress = NULL;
72 rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
73- return (NULL);
74+ goto error;
75 }
76 port = htons(port);
77 CLNT_CONTROL(client, CLGET_SVC_ADDR, (char *)&remote);
78@@ -789,14 +789,24 @@ __try_protocol_version_2(program, version, nconf, host, tp)
79 free(pmapaddress);
80 pmapaddress = NULL;
81 }
82- return (NULL);
83+ goto error;
84 }
85 memcpy(pmapaddress->buf, remote.buf, remote.len);
86 memcpy(&((char *)pmapaddress->buf)[sizeof (short)],
87 (char *)(void *)&port, sizeof (short));
88 pmapaddress->len = pmapaddress->maxlen = remote.len;
89
90+ CLNT_DESTROY(client);
91 return pmapaddress;
92+
93+error:
94+ if (client) {
95+ CLNT_DESTROY(client);
96+ client = NULL;
97+
98+ }
99+ return (NULL);
100+
101 }
102 #endif
103