From 1b634307589808ae238d0aaa0529ccad62216e6d Mon Sep 17 00:00:00 2001 From: Steve Dickson Date: Thu, 8 Nov 2018 14:09:07 -0500 Subject: [PATCH] Updated to latest upstream RC release: libtirpc-1-1-5-rc2 Signed-off-by: Steve Dickson --- libtirpc-1.0.4-rc2.patch | 274 ------------------ ....1.5-rc1.patch => libtirpc-1.1.5-rc2.patch | 132 ++++++++- libtirpc.spec | 9 +- 3 files changed, 135 insertions(+), 280 deletions(-) delete mode 100644 libtirpc-1.0.4-rc2.patch rename libtirpc-1.1.5-rc1.patch => libtirpc-1.1.5-rc2.patch (54%) diff --git a/libtirpc-1.0.4-rc2.patch b/libtirpc-1.0.4-rc2.patch deleted file mode 100644 index 35b38cf..0000000 --- a/libtirpc-1.0.4-rc2.patch +++ /dev/null @@ -1,274 +0,0 @@ -diff --git a/src/clnt_dg.c b/src/clnt_dg.c -index 04a2aba..eb5467f 100644 ---- a/src/clnt_dg.c -+++ b/src/clnt_dg.c -@@ -160,15 +160,22 @@ clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz) - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - if (dg_fd_locks == (int *) NULL) { -- int cv_allocsz; -- size_t fd_allocsz; -- int dtbsize = __rpc_dtbsize(); -+ size_t cv_allocsz, fd_allocsz; -+ unsigned int dtbsize = __rpc_dtbsize(); -+ -+ if ( (size_t) dtbsize > SIZE_MAX/sizeof(cond_t)) { -+ mutex_unlock(&clnt_fd_lock); -+ thr_sigsetmask(SIG_SETMASK, &(mask), NULL); -+ errno = EOVERFLOW; -+ goto err1; -+ } - - fd_allocsz = dtbsize * sizeof (int); - dg_fd_locks = (int *) mem_alloc(fd_allocsz); - if (dg_fd_locks == (int *) NULL) { - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); -+ errno = ENOMEM; - goto err1; - } else - memset(dg_fd_locks, '\0', fd_allocsz); -@@ -180,6 +187,7 @@ clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz) - dg_fd_locks = (int *) NULL; - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); -+ errno = ENOMEM; - goto err1; - } else { - int i; -diff --git a/src/clnt_generic.c b/src/clnt_generic.c -index e5a314f..3f3dabf 100644 ---- a/src/clnt_generic.c -+++ b/src/clnt_generic.c -@@ -47,7 +47,6 @@ - - extern bool_t __rpc_is_local_host(const char *); - int __rpc_raise_fd(int); --extern int __binddynport(int fd); - - #ifndef NETIDLEN - #define NETIDLEN 32 -@@ -341,8 +340,7 @@ clnt_tli_create(int fd, const struct netconfig *nconf, - servtype = nconf->nc_semantics; - if (!__rpc_fd2sockinfo(fd, &si)) - goto err; -- if (__binddynport(fd) == -1) -- goto err; -+ bindresvport(fd, NULL); - } else { - if (!__rpc_fd2sockinfo(fd, &si)) - goto err; -diff --git a/src/clnt_vc.c b/src/clnt_vc.c -index 6098c3a..3d775c7 100644 ---- a/src/clnt_vc.c -+++ b/src/clnt_vc.c -@@ -63,6 +63,7 @@ - #include - #include - #include -+#include - - #include - #include "rpc_com.h" -@@ -201,14 +202,25 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz) - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - if (vc_fd_locks == (int *) NULL) { -- int cv_allocsz, fd_allocsz; -- int dtbsize = __rpc_dtbsize(); -+ size_t cv_allocsz, fd_allocsz; -+ unsigned int dtbsize = __rpc_dtbsize(); -+ struct rpc_createerr *ce = &get_rpc_createerr(); -+ -+ if ( (size_t) dtbsize > SIZE_MAX/sizeof(cond_t)) { -+ mutex_unlock(&clnt_fd_lock); -+ thr_sigsetmask(SIG_SETMASK, &(mask), NULL); -+ ce->cf_stat = RPC_SYSTEMERROR; -+ ce->cf_error.re_errno = EOVERFLOW; -+ goto err; -+ } - - fd_allocsz = dtbsize * sizeof (int); - vc_fd_locks = (int *) mem_alloc(fd_allocsz); - if (vc_fd_locks == (int *) NULL) { - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); -+ ce->cf_stat = RPC_SYSTEMERROR; -+ ce->cf_error.re_errno = ENOMEM; - goto err; - } else - memset(vc_fd_locks, '\0', fd_allocsz); -@@ -221,6 +233,8 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz) - vc_fd_locks = (int *) NULL; - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); -+ ce->cf_stat = RPC_SYSTEMERROR; -+ ce->cf_error.re_errno = ENOMEM; - goto err; - } else { - int i; -diff --git a/src/rpc_soc.c b/src/rpc_soc.c -index af6c482..5a6eeb7 100644 ---- a/src/rpc_soc.c -+++ b/src/rpc_soc.c -@@ -67,8 +67,6 @@ - - extern mutex_t rpcsoc_lock; - --extern int __binddynport(int fd); -- - static CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t, - int *, u_int, u_int, char *, int); - static SVCXPRT *svc_com_create(int, u_int, u_int, char *); -@@ -147,8 +145,7 @@ clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp, flags) - bindaddr.maxlen = bindaddr.len = sizeof (struct sockaddr_in); - bindaddr.buf = raddr; - -- if (__binddynport(fd) == -1) -- goto err; -+ bindresvport(fd, NULL); - cl = clnt_tli_create(fd, nconf, &bindaddr, prog, vers, - sendsz, recvsz); - if (cl) { -diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c -index a94fc73..e45736a 100644 ---- a/src/rpcb_clnt.c -+++ b/src/rpcb_clnt.c -@@ -752,7 +752,7 @@ __try_protocol_version_2(program, version, nconf, host, tp) - - client = getpmaphandle(nconf, host, &parms.r_addr); - if (client == NULL) -- return (NULL); -+ goto error; - - /* - * Set retry timeout. -@@ -771,11 +771,11 @@ __try_protocol_version_2(program, version, nconf, host, tp) - if (clnt_st != RPC_SUCCESS) { - rpc_createerr.cf_stat = RPC_PMAPFAILURE; - clnt_geterr(client, &rpc_createerr.cf_error); -- return (NULL); -+ goto error; - } else if (port == 0) { - pmapaddress = NULL; - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; -- return (NULL); -+ goto error; - } - port = htons(port); - CLNT_CONTROL(client, CLGET_SVC_ADDR, (char *)&remote); -@@ -789,14 +789,24 @@ __try_protocol_version_2(program, version, nconf, host, tp) - free(pmapaddress); - pmapaddress = NULL; - } -- return (NULL); -+ goto error; - } - memcpy(pmapaddress->buf, remote.buf, remote.len); - memcpy(&((char *)pmapaddress->buf)[sizeof (short)], - (char *)(void *)&port, sizeof (short)); - pmapaddress->len = pmapaddress->maxlen = remote.len; - -+ CLNT_DESTROY(client); - return pmapaddress; -+ -+error: -+ if (client) { -+ CLNT_DESTROY(client); -+ client = NULL; -+ -+ } -+ return (NULL); -+ - } - #endif - -@@ -836,6 +846,7 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) - struct netbuf *address = NULL; - rpcvers_t start_vers = RPCBVERS4; - struct netbuf servaddr; -+ struct rpc_err rpcerr; - - /* parameter checking */ - if (nconf == NULL) { -@@ -892,7 +903,8 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) - clnt_st = CLNT_CALL(client, (rpcproc_t)RPCBPROC_GETADDR, - (xdrproc_t) xdr_rpcb, (char *)(void *)&parms, - (xdrproc_t) xdr_wrapstring, (char *)(void *) &ua, *tp); -- if (clnt_st == RPC_SUCCESS) { -+ switch (clnt_st) { -+ case RPC_SUCCESS: - if ((ua == NULL) || (ua[0] == 0)) { - /* address unknown */ - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; -@@ -914,12 +926,15 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) - (char *)(void *)&servaddr); - __rpc_fixup_addr(address, &servaddr); - goto done; -- } else if (clnt_st == RPC_PROGVERSMISMATCH) { -- struct rpc_err rpcerr; -+ case RPC_PROGVERSMISMATCH: - clnt_geterr(client, &rpcerr); - if (rpcerr.re_vers.low > RPCBVERS4) - goto error; /* a new version, can't handle */ -- } else if (clnt_st != RPC_PROGUNAVAIL) { -+ /* Try the next lower version */ -+ case RPC_PROGUNAVAIL: -+ case RPC_CANTDECODEARGS: -+ break; -+ default: - /* Cant handle this error */ - rpc_createerr.cf_stat = clnt_st; - clnt_geterr(client, &rpc_createerr.cf_error); -@@ -929,7 +944,7 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) - - #ifdef PORTMAP /* Try version 2 for TCP or UDP */ - if (strcmp(nconf->nc_protofmly, NC_INET) == 0) { -- address = __try_protocol_version_2(program, 2, nconf, host, tp); -+ address = __try_protocol_version_2(program, version, nconf, host, tp); - if (address == NULL) - goto error; - } -diff --git a/src/xdr_stdio.c b/src/xdr_stdio.c -index 4410262..846c7bf 100644 ---- a/src/xdr_stdio.c -+++ b/src/xdr_stdio.c -@@ -38,6 +38,7 @@ - */ - - #include -+#include - - #include - #include -@@ -103,10 +104,12 @@ xdrstdio_getlong(xdrs, lp) - XDR *xdrs; - long *lp; - { -+ int32_t mycopy; - -- if (fread(lp, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1) -+ if (fread(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1) - return (FALSE); -- *lp = (long)ntohl((u_int32_t)*lp); -+ -+ *lp = (long)ntohl(mycopy); - return (TRUE); - } - -@@ -115,8 +118,14 @@ xdrstdio_putlong(xdrs, lp) - XDR *xdrs; - const long *lp; - { -- long mycopy = (long)htonl((u_int32_t)*lp); -+ int32_t mycopy; -+ -+#if defined(_LP64) -+ if ((*lp > UINT32_MAX) || (*lp < INT32_MIN)) -+ return (FALSE); -+#endif - -+ mycopy = (int32_t)htonl((int32_t)*lp); - if (fwrite(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1) - return (FALSE); - return (TRUE); diff --git a/libtirpc-1.1.5-rc1.patch b/libtirpc-1.1.5-rc2.patch similarity index 54% rename from libtirpc-1.1.5-rc1.patch rename to libtirpc-1.1.5-rc2.patch index 63484ab..6b4c9c0 100644 --- a/libtirpc-1.1.5-rc1.patch +++ b/libtirpc-1.1.5-rc2.patch @@ -32,18 +32,48 @@ index 98cf061..2ad6c89 100644 } while ((nconf = __rpc_getconf(handle)) != NULL) { diff --git a/src/getnetconfig.c b/src/getnetconfig.c -index 92e7c43..d67d97d 100644 +index 92e7c43..cfd33c2 100644 --- a/src/getnetconfig.c +++ b/src/getnetconfig.c -@@ -709,6 +709,8 @@ struct netconfig *ncp; +@@ -681,6 +681,7 @@ struct netconfig *ncp; + { + struct netconfig *p; + char *tmp; ++ char *t; + u_int i; + + if ((tmp=malloc(MAXNETCONFIGLINE)) == NULL) +@@ -700,20 +701,21 @@ struct netconfig *ncp; + */ + *p = *ncp; + p->nc_netid = (char *)strcpy(tmp,ncp->nc_netid); +- tmp = strchr(tmp, 0) + 1; +- p->nc_protofmly = (char *)strcpy(tmp,ncp->nc_protofmly); +- tmp = strchr(tmp, 0) + 1; +- p->nc_proto = (char *)strcpy(tmp,ncp->nc_proto); +- tmp = strchr(tmp, 0) + 1; +- p->nc_device = (char *)strcpy(tmp,ncp->nc_device); ++ t = strchr(tmp, 0) + 1; ++ p->nc_protofmly = (char *)strcpy(t,ncp->nc_protofmly); ++ t = strchr(t, 0) + 1; ++ p->nc_proto = (char *)strcpy(t,ncp->nc_proto); ++ t = strchr(t, 0) + 1; ++ p->nc_device = (char *)strcpy(t,ncp->nc_device); p->nc_lookups = (char **)malloc((size_t)(p->nc_nlookups+1) * sizeof(char *)); if (p->nc_lookups == NULL) { - free(p->nc_netid); +- free(p->nc_netid); + free(p); + free(tmp); return(NULL); } for (i=0; i < p->nc_nlookups; i++) { +- tmp = strchr(tmp, 0) + 1; +- p->nc_lookups[i] = (char *)strcpy(tmp,ncp->nc_lookups[i]); ++ t = strchr(t, 0) + 1; ++ p->nc_lookups[i] = (char *)strcpy(t,ncp->nc_lookups[i]); + } + return(p); + } diff --git a/src/getnetpath.c b/src/getnetpath.c index 7c19932..ea1a18c 100644 --- a/src/getnetpath.c @@ -56,6 +86,32 @@ index 7c19932..ea1a18c 100644 return (NULL); } np_sessionp->valid = NP_VALID; +diff --git a/src/getpublickey.c b/src/getpublickey.c +index 8cf4dc2..be37a24 100644 +--- a/src/getpublickey.c ++++ b/src/getpublickey.c +@@ -74,7 +74,7 @@ __getpublickey_real(netname, publickey) + return (0); + } + *p = '\0'; +- (void) strncpy(publickey, lookup, HEXKEYBYTES); ++ memcpy(publickey, lookup, HEXKEYBYTES); + publickey[HEXKEYBYTES] = '\0'; + return (1); + } +diff --git a/src/getrpcent.c b/src/getrpcent.c +index cba4cd8..e49dc05 100644 +--- a/src/getrpcent.c ++++ b/src/getrpcent.c +@@ -100,7 +100,7 @@ _rpcdata() + return (d); + } + +-#if !HAVE_GETRPCBYNYMBER ++#if !HAVE_GETRPCBYNUMBER + struct rpcent * + getrpcbynumber(number) + int number; diff --git a/src/rpc_generic.c b/src/rpc_generic.c index 589cbd5..51f36ac 100644 --- a/src/rpc_generic.c @@ -149,3 +205,73 @@ index cb58002..c32fe0a 100644 break; } madenow = TRUE; +diff --git a/src/svc_vc.c b/src/svc_vc.c +index 97a76a3..c23cd36 100644 +--- a/src/svc_vc.c ++++ b/src/svc_vc.c +@@ -502,9 +502,14 @@ read_vc(xprtp, buf, len) + cfp = (struct cf_conn *)xprt->xp_p1; + + if (cfp->nonblock) { ++ /* Since len == 0 is returned on zero length ++ * read or EOF errno needs to be reset before ++ * the read ++ */ ++ errno = 0; + len = read(sock, buf, (size_t)len); + if (len < 0) { +- if (errno == EAGAIN) ++ if (errno == EAGAIN || errno == EWOULDBLOCK) + len = 0; + else + goto fatal_err; +diff --git a/src/xdr_rec.c b/src/xdr_rec.c +index 7d535cf..676cc82 100644 +--- a/src/xdr_rec.c ++++ b/src/xdr_rec.c +@@ -61,6 +61,7 @@ + #include + #include + #include ++#include + #include "rpc_com.h" + static bool_t xdrrec_getlong(XDR *, long *); + static bool_t xdrrec_putlong(XDR *, const long *); +@@ -537,7 +538,13 @@ __xdrrec_getrec(xdrs, statp, expectdata) + n = rstrm->readit(rstrm->tcp_handle, rstrm->in_hdrp, + (int)sizeof (rstrm->in_header) - rstrm->in_hdrlen); + if (n == 0) { +- *statp = expectdata ? XPRT_DIED : XPRT_IDLE; ++ /* EAGAIN or EWOULDBLOCK means a zero length ++ * read not an EOF. ++ */ ++ if (errno == EAGAIN || errno == EWOULDBLOCK) ++ *statp = XPRT_IDLE; ++ else ++ *statp = expectdata ? XPRT_DIED : XPRT_IDLE; + return FALSE; + } + if (n < 0) { +@@ -564,6 +571,7 @@ __xdrrec_getrec(xdrs, statp, expectdata) + rstrm->in_header &= ~LAST_FRAG; + rstrm->last_frag = TRUE; + } ++ rstrm->in_haveheader = 1; + } + + n = rstrm->readit(rstrm->tcp_handle, +@@ -576,7 +584,13 @@ __xdrrec_getrec(xdrs, statp, expectdata) + } + + if (n == 0) { +- *statp = expectdata ? XPRT_DIED : XPRT_IDLE; ++ /* EAGAIN or EWOULDBLOCK means a zero length ++ * read not an EOF. ++ */ ++ if (errno == EAGAIN || errno == EWOULDBLOCK) ++ *statp = XPRT_IDLE; ++ else ++ *statp = expectdata ? XPRT_DIED : XPRT_IDLE; + return FALSE; + } + diff --git a/libtirpc.spec b/libtirpc.spec index 836fadf..f25a052 100644 --- a/libtirpc.spec +++ b/libtirpc.spec @@ -2,14 +2,14 @@ Name: libtirpc Version: 1.1.4 -Release: 2.rc1%{?dist} +Release: 2.rc2%{?dist} Summary: Transport Independent RPC Library Group: System Environment/Libraries License: SISSL and BSD URL: http://git.linux-nfs.org/?p=steved/libtirpc.git;a=summary Source0: http://downloads.sourceforge.net/libtirpc/libtirpc-%{version}.tar.bz2 -Patch001: libtirpc-1.1.5-rc1.patch +Patch001: libtirpc-1.1.5-rc2.patch BuildRequires: automake, autoconf, libtool, pkgconfig BuildRequires: krb5-devel @@ -124,7 +124,10 @@ mv %{buildroot}%{_mandir}/man3 %{buildroot}%{_mandir}/man3t %{_mandir}/*/* %changelog -* Tue Nov 6 2018 Steve Dickson 1.0.4-2.rc2 +* Thu Nov 8 2018 Steve Dickson 1.0.4-2.rc2 +- Updated to latest upstream RC release: libtirpc-1-1-5-rc2 + +* Tue Nov 6 2018 Steve Dickson 1.0.4-2.rc1 - Remove ldconfig scriptlet (bz 1644103) * Thu Sep 13 2018 Steve Dickson 1.1.4-1.rc1