diff --git a/INSTALL b/INSTALL index 8b641e3..f812f5a 120000 --- a/INSTALL +++ b/INSTALL @@ -1 +1 @@ -/usr/share/automake-1.13/INSTALL \ No newline at end of file +/usr/share/automake-1.14/INSTALL \ No newline at end of file diff --git a/configure.ac b/configure.ac index bcbe911..10d17ea 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(libtirpc, 0.2.5) +AC_INIT(libtirpc, 0.2.4) AM_INIT_AUTOMAKE([silent-rules]) AM_SILENT_RULES([yes]) AC_CONFIG_SRCDIR([src/auth_des.c]) diff --git a/libtirpc.pc.in b/libtirpc.pc.in index ec4cf75..38034c5 100644 --- a/libtirpc.pc.in +++ b/libtirpc.pc.in @@ -8,4 +8,5 @@ Description: Transport Independent RPC Library Requires: Version: @PACKAGE_VERSION@ Libs: -L@libdir@ -ltirpc +Libs.private: -lpthread Cflags: -I@includedir@/tirpc diff --git a/src/clnt_bcast.c b/src/clnt_bcast.c index 373d8a5..ddcb694 100644 --- a/src/clnt_bcast.c +++ b/src/clnt_bcast.c @@ -142,7 +142,8 @@ __rpc_getbroadifs(int af, int proto, int socktype, broadlist_t *list) return 0; for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) { - if (ifap->ifa_addr->sa_family != af || + if (ifap->ifa_addr == NULL || /* happens for eg tuntap devices */ + ifap->ifa_addr->sa_family != af || !(ifap->ifa_flags & IFF_UP)) continue; bip = (struct broadif *)malloc(sizeof *bip); @@ -588,9 +589,11 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, LIBTIRPC_DEBUG(3, ("rpc_broadcast_exp: uaddr %s\n", uaddrp)); np = uaddr2taddr( fdlist[i].nconf, uaddrp); - done = (*eachresult)(resultsp, - np, fdlist[i].nconf); - free(np); + if (np != NULL) { + done = (*eachresult)(resultsp, + np, fdlist[i].nconf); + free(np); + } #ifdef PORTMAP } #endif /* PORTMAP */ diff --git a/src/debug.h b/src/debug.h index afc8d57..c971ac3 100644 --- a/src/debug.h +++ b/src/debug.h @@ -21,6 +21,8 @@ #ifndef _DEBUG_H #define _DEBUG_H + +#include #include extern int libtirpc_debug_level; diff --git a/src/rpc_generic.c b/src/rpc_generic.c index a43906c..764a25c 100644 --- a/src/rpc_generic.c +++ b/src/rpc_generic.c @@ -608,6 +608,7 @@ __rpc_taddr2uaddr_af(int af, const struct netbuf *nbuf) struct sockaddr_in6 *sin6; char namebuf6[INET6_ADDRSTRLEN]; #endif + int path_len; u_int16_t port; if (nbuf->len <= 0) @@ -638,13 +639,12 @@ __rpc_taddr2uaddr_af(int af, const struct netbuf *nbuf) #endif case AF_LOCAL: sun = nbuf->buf; - /* if (asprintf(&ret, "%.*s", (int)(sun->sun_len - - offsetof(struct sockaddr_un, sun_path)), - sun->sun_path) < 0)*/ - if (asprintf(&ret, "%.*s", (int)(sizeof(*sun) - - offsetof(struct sockaddr_un, sun_path)), - sun->sun_path) < 0) + path_len = nbuf->len - offsetof(struct sockaddr_un, sun_path); + if (path_len < 0) + return NULL; + + if (asprintf(&ret, "%.*s", path_len, sun->sun_path) < 0) return (NULL); break; default: diff --git a/src/rpc_soc.c b/src/rpc_soc.c index 338edbb..e146ed4 100644 --- a/src/rpc_soc.c +++ b/src/rpc_soc.c @@ -564,16 +564,12 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) u_int sendsz; u_int recvsz; { - struct netbuf *svcaddr; - CLIENT *cl; + struct netbuf svcaddr = {0, 0, NULL}; + CLIENT *cl = NULL; int len; - cl = NULL; - svcaddr = NULL; - if (((svcaddr = malloc(sizeof(struct netbuf))) == NULL ) || - ((svcaddr->buf = malloc(sizeof(struct sockaddr_un))) == NULL)) { - if (svcaddr != NULL) - free(svcaddr); + memset(&svcaddr, 0, sizeof(svcaddr)); + if (__rpc_set_netbuf(&svcaddr, raddr, sizeof(*raddr)) == NULL) { rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; return(cl); @@ -590,14 +586,10 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) goto done; } } - svcaddr->buf = raddr; - svcaddr->len = sizeof(raddr); - svcaddr->maxlen = sizeof (struct sockaddr_un); - cl = clnt_vc_create(*sockp, svcaddr, prog, + cl = clnt_vc_create(*sockp, &svcaddr, prog, vers, sendsz, recvsz); done: - free(svcaddr->buf); - free(svcaddr); + free(svcaddr.buf); return(cl); } diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c index a796593..f1c71a2 100644 --- a/src/rpcb_clnt.c +++ b/src/rpcb_clnt.c @@ -401,6 +401,44 @@ out_err: return (client); } +/* + * Create a PMAP client handle. + */ +static CLIENT * +getpmaphandle(nconf, hostname, tgtaddr) + const struct netconfig *nconf; + const char *hostname; + char **tgtaddr; +{ + CLIENT *client = NULL; + rpcvers_t pmapvers = 2; + + /* + * Try UDP only - there are some portmappers out + * there that use UDP only. + */ + if (nconf == NULL || strcmp(nconf->nc_proto, NC_TCP) == 0) { + struct netconfig *newnconf; + + if ((newnconf = getnetconfigent("udp")) == NULL) { + rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; + return NULL; + } + client = getclnthandle(hostname, newnconf, tgtaddr); + freenetconfigent(newnconf); + } else if (strcmp(nconf->nc_proto, NC_UDP) == 0) { + if (strcmp(nconf->nc_protofmly, NC_INET) != 0) + return NULL; + client = getclnthandle(hostname, nconf, tgtaddr); + } + + /* Set version */ + if (client != NULL) + CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers); + + return client; +} + /* XXX */ #define IN4_LOCALHOST_STRING "127.0.0.1" #define IN6_LOCALHOST_STRING "::1" @@ -733,34 +771,20 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) if (strcmp(nconf->nc_protofmly, NC_INET) == 0) { u_short port = 0; struct netbuf remote; - rpcvers_t pmapvers = 2; struct pmap pmapparms; - /* - * Try UDP only - there are some portmappers out - * there that use UDP only. - */ - if (strcmp(nconf->nc_proto, NC_TCP) == 0) { - struct netconfig *newnconf; - - if ((newnconf = getnetconfigent("udp")) == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (NULL); - } - client = getclnthandle(host, newnconf, &parms.r_addr); - freenetconfigent(newnconf); - } else if (strcmp(nconf->nc_proto, NC_UDP) == 0) - client = getclnthandle(host, nconf, &parms.r_addr); - else + if (strcmp(nconf->nc_proto, NC_UDP) != 0 + && strcmp(nconf->nc_proto, NC_TCP) != 0) goto try_rpcbind; + + client = getpmaphandle(nconf, host, &parms.r_addr); if (client == NULL) return (NULL); /* - * Set version and retry timeout. + * Set retry timeout. */ CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime); - CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers); pmapparms.pm_prog = program; pmapparms.pm_vers = version; diff --git a/src/svc_vc.c b/src/svc_vc.c index 4c70de8..4d3ea51 100644 --- a/src/svc_vc.c +++ b/src/svc_vc.c @@ -559,20 +559,19 @@ write_vc(xprtp, buf, len) cd->strm_stat = XPRT_DIED; return (-1); } - if (cd->nonblock && i != cnt) { - /* - * For non-blocking connections, do not - * take more than 2 seconds writing the - * data out. - * - * XXX 2 is an arbitrary amount. - */ - gettimeofday(&tv1, NULL); - if (tv1.tv_sec - tv0.tv_sec >= 2) { - cd->strm_stat = XPRT_DIED; - return (-1); - } + /* + * For non-blocking connections, do not + * take more than 2 seconds writing the + * data out. + * + * XXX 2 is an arbitrary amount. + */ + gettimeofday(&tv1, NULL); + if (tv1.tv_sec - tv0.tv_sec >= 2) { + cd->strm_stat = XPRT_DIED; + return (-1); } + i = 0; /* Don't change buf and cnt */ } }