|
|
9cd3a2 |
diff -up libtirpc-0.2.4/src/rpcb_prot.c.orig libtirpc-0.2.4/src/rpcb_prot.c
|
|
|
9cd3a2 |
--- libtirpc-0.2.4/src/rpcb_prot.c.orig 2013-12-09 15:59:51.000000000 -0500
|
|
|
9cd3a2 |
+++ libtirpc-0.2.4/src/rpcb_prot.c 2017-05-17 13:05:47.562168877 -0400
|
|
|
9cd3a2 |
@@ -41,6 +41,7 @@
|
|
|
9cd3a2 |
#include <rpc/types.h>
|
|
|
9cd3a2 |
#include <rpc/xdr.h>
|
|
|
9cd3a2 |
#include <rpc/rpcb_prot.h>
|
|
|
9cd3a2 |
+#include "rpc_com.h"
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
bool_t
|
|
|
9cd3a2 |
xdr_rpcb(xdrs, objp)
|
|
|
9cd3a2 |
@@ -53,13 +54,13 @@ xdr_rpcb(xdrs, objp)
|
|
|
9cd3a2 |
if (!xdr_u_int32_t(xdrs, &objp->r_vers)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->r_netid, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->r_netid, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->r_addr, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->r_addr, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->r_owner, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->r_owner, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
return (TRUE);
|
|
|
9cd3a2 |
@@ -159,19 +160,19 @@ xdr_rpcb_entry(xdrs, objp)
|
|
|
9cd3a2 |
XDR *xdrs;
|
|
|
9cd3a2 |
rpcb_entry *objp;
|
|
|
9cd3a2 |
{
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->r_maddr, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->r_maddr, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->r_nc_netid, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->r_nc_netid, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
if (!xdr_u_int32_t(xdrs, &objp->r_nc_semantics)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->r_nc_protofmly, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->r_nc_protofmly, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->r_nc_proto, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->r_nc_proto, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
return (TRUE);
|
|
|
9cd3a2 |
@@ -292,7 +293,7 @@ xdr_rpcb_rmtcallres(xdrs, p)
|
|
|
9cd3a2 |
bool_t dummy;
|
|
|
9cd3a2 |
struct r_rpcb_rmtcallres *objp = (struct r_rpcb_rmtcallres *)(void *)p;
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->addr, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->addr, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
if (!xdr_u_int(xdrs, &objp->results.results_len)) {
|
|
|
9cd3a2 |
@@ -312,6 +313,11 @@ xdr_netbuf(xdrs, objp)
|
|
|
9cd3a2 |
if (!xdr_u_int32_t(xdrs, (u_int32_t *) &objp->maxlen)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
+
|
|
|
9cd3a2 |
+ if (objp->maxlen > RPC_MAXDATASIZE) {
|
|
|
9cd3a2 |
+ return (FALSE);
|
|
|
9cd3a2 |
+ }
|
|
|
9cd3a2 |
+
|
|
|
9cd3a2 |
dummy = xdr_bytes(xdrs, (char **)&(objp->buf),
|
|
|
9cd3a2 |
(u_int *)&(objp->len), objp->maxlen);
|
|
|
9cd3a2 |
return (dummy);
|
|
|
9cd3a2 |
diff -up libtirpc-0.2.4/src/rpcb_st_xdr.c.orig libtirpc-0.2.4/src/rpcb_st_xdr.c
|
|
|
9cd3a2 |
--- libtirpc-0.2.4/src/rpcb_st_xdr.c.orig 2013-12-09 15:59:51.000000000 -0500
|
|
|
9cd3a2 |
+++ libtirpc-0.2.4/src/rpcb_st_xdr.c 2017-05-17 13:05:47.562168877 -0400
|
|
|
9cd3a2 |
@@ -38,6 +38,7 @@
|
|
|
9cd3a2 |
#include <sys/cdefs.h>
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
#include <rpc/rpc.h>
|
|
|
9cd3a2 |
+#include "rpc_com.h"
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
/* Link list of all the stats about getport and getaddr */
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
@@ -59,7 +60,7 @@ xdr_rpcbs_addrlist(xdrs, objp)
|
|
|
9cd3a2 |
if (!xdr_int(xdrs, &objp->failure)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
@@ -110,7 +111,7 @@ xdr_rpcbs_rmtcalllist(xdrs, objp)
|
|
|
9cd3a2 |
IXDR_PUT_INT32(buf, objp->failure);
|
|
|
9cd3a2 |
IXDR_PUT_INT32(buf, objp->indirect);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
if (!xdr_pointer(xdrs, (char **)&objp->next,
|
|
|
9cd3a2 |
@@ -148,7 +149,7 @@ xdr_rpcbs_rmtcalllist(xdrs, objp)
|
|
|
9cd3a2 |
objp->failure = (int)IXDR_GET_INT32(buf);
|
|
|
9cd3a2 |
objp->indirect = (int)IXDR_GET_INT32(buf);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
if (!xdr_pointer(xdrs, (char **)&objp->next,
|
|
|
9cd3a2 |
@@ -176,7 +177,7 @@ xdr_rpcbs_rmtcalllist(xdrs, objp)
|
|
|
9cd3a2 |
if (!xdr_int(xdrs, &objp->indirect)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
- if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
|
|
|
9cd3a2 |
+ if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) {
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
if (!xdr_pointer(xdrs, (char **)&objp->next,
|
|
|
9cd3a2 |
diff -up libtirpc-0.2.4/src/rpc_generic.c.orig libtirpc-0.2.4/src/rpc_generic.c
|
|
|
9cd3a2 |
--- libtirpc-0.2.4/src/rpc_generic.c.orig 2013-12-09 15:59:51.000000000 -0500
|
|
|
9cd3a2 |
+++ libtirpc-0.2.4/src/rpc_generic.c 2017-05-17 13:05:47.562168877 -0400
|
|
|
9cd3a2 |
@@ -615,6 +615,9 @@ __rpc_taddr2uaddr_af(int af, const struc
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
switch (af) {
|
|
|
9cd3a2 |
case AF_INET:
|
|
|
9cd3a2 |
+ if (nbuf->len < sizeof(*sin)) {
|
|
|
9cd3a2 |
+ return NULL;
|
|
|
9cd3a2 |
+ }
|
|
|
9cd3a2 |
sin = nbuf->buf;
|
|
|
9cd3a2 |
if (inet_ntop(af, &sin->sin_addr, namebuf, sizeof namebuf)
|
|
|
9cd3a2 |
== NULL)
|
|
|
9cd3a2 |
@@ -626,6 +629,9 @@ __rpc_taddr2uaddr_af(int af, const struc
|
|
|
9cd3a2 |
break;
|
|
|
9cd3a2 |
#ifdef INET6
|
|
|
9cd3a2 |
case AF_INET6:
|
|
|
9cd3a2 |
+ if (nbuf->len < sizeof(*sin6)) {
|
|
|
9cd3a2 |
+ return NULL;
|
|
|
9cd3a2 |
+ }
|
|
|
9cd3a2 |
sin6 = nbuf->buf;
|
|
|
9cd3a2 |
if (inet_ntop(af, &sin6->sin6_addr, namebuf6, sizeof namebuf6)
|
|
|
9cd3a2 |
== NULL)
|
|
|
9cd3a2 |
@@ -668,6 +674,8 @@ __rpc_uaddr2taddr_af(int af, const char
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
port = 0;
|
|
|
9cd3a2 |
sin = NULL;
|
|
|
9cd3a2 |
+ if (uaddr == NULL)
|
|
|
9cd3a2 |
+ return NULL;
|
|
|
9cd3a2 |
addrstr = strdup(uaddr);
|
|
|
9cd3a2 |
if (addrstr == NULL)
|
|
|
9cd3a2 |
return NULL;
|
|
|
9cd3a2 |
diff -up libtirpc-0.2.4/src/xdr.c.orig libtirpc-0.2.4/src/xdr.c
|
|
|
9cd3a2 |
--- libtirpc-0.2.4/src/xdr.c.orig 2013-12-09 15:59:51.000000000 -0500
|
|
|
9cd3a2 |
+++ libtirpc-0.2.4/src/xdr.c 2017-05-17 13:05:47.563168892 -0400
|
|
|
9cd3a2 |
@@ -43,8 +43,10 @@
|
|
|
9cd3a2 |
#include <stdlib.h>
|
|
|
9cd3a2 |
#include <string.h>
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
+#include <rpc/rpc.h>
|
|
|
9cd3a2 |
#include <rpc/types.h>
|
|
|
9cd3a2 |
#include <rpc/xdr.h>
|
|
|
9cd3a2 |
+#include <rpc/rpc_com.h>
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
typedef quad_t longlong_t; /* ANSI long long type */
|
|
|
9cd3a2 |
typedef u_quad_t u_longlong_t; /* ANSI unsigned long long type */
|
|
|
9cd3a2 |
@@ -54,7 +56,6 @@ typedef u_quad_t u_longlong_t;
|
|
|
9cd3a2 |
*/
|
|
|
9cd3a2 |
#define XDR_FALSE ((long) 0)
|
|
|
9cd3a2 |
#define XDR_TRUE ((long) 1)
|
|
|
9cd3a2 |
-#define LASTUNSIGNED ((u_int) 0-1)
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
/*
|
|
|
9cd3a2 |
* for unit alignment
|
|
|
9cd3a2 |
@@ -630,6 +631,7 @@ xdr_bytes(xdrs, cpp, sizep, maxsize)
|
|
|
9cd3a2 |
{
|
|
|
9cd3a2 |
char *sp = *cpp; /* sp is the actual string pointer */
|
|
|
9cd3a2 |
u_int nodesize;
|
|
|
9cd3a2 |
+ bool_t ret, allocated = FALSE;
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
/*
|
|
|
9cd3a2 |
* first deal with the length since xdr bytes are counted
|
|
|
9cd3a2 |
@@ -653,6 +655,7 @@ xdr_bytes(xdrs, cpp, sizep, maxsize)
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
if (sp == NULL) {
|
|
|
9cd3a2 |
*cpp = sp = mem_alloc(nodesize);
|
|
|
9cd3a2 |
+ allocated = TRUE;
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
if (sp == NULL) {
|
|
|
9cd3a2 |
warnx("xdr_bytes: out of memory");
|
|
|
9cd3a2 |
@@ -661,7 +664,14 @@ xdr_bytes(xdrs, cpp, sizep, maxsize)
|
|
|
9cd3a2 |
/* FALLTHROUGH */
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
case XDR_ENCODE:
|
|
|
9cd3a2 |
- return (xdr_opaque(xdrs, sp, nodesize));
|
|
|
9cd3a2 |
+ ret = xdr_opaque(xdrs, sp, nodesize);
|
|
|
9cd3a2 |
+ if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) {
|
|
|
9cd3a2 |
+ if (allocated == TRUE) {
|
|
|
9cd3a2 |
+ free(sp);
|
|
|
9cd3a2 |
+ *cpp = NULL;
|
|
|
9cd3a2 |
+ }
|
|
|
9cd3a2 |
+ }
|
|
|
9cd3a2 |
+ return (ret);
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
case XDR_FREE:
|
|
|
9cd3a2 |
if (sp != NULL) {
|
|
|
9cd3a2 |
@@ -755,6 +765,7 @@ xdr_string(xdrs, cpp, maxsize)
|
|
|
9cd3a2 |
char *sp = *cpp; /* sp is the actual string pointer */
|
|
|
9cd3a2 |
u_int size;
|
|
|
9cd3a2 |
u_int nodesize;
|
|
|
9cd3a2 |
+ bool_t ret, allocated = FALSE;
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
/*
|
|
|
9cd3a2 |
* first deal with the length since xdr strings are counted-strings
|
|
|
9cd3a2 |
@@ -794,8 +805,10 @@ xdr_string(xdrs, cpp, maxsize)
|
|
|
9cd3a2 |
switch (xdrs->x_op) {
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
case XDR_DECODE:
|
|
|
9cd3a2 |
- if (sp == NULL)
|
|
|
9cd3a2 |
+ if (sp == NULL) {
|
|
|
9cd3a2 |
*cpp = sp = mem_alloc(nodesize);
|
|
|
9cd3a2 |
+ allocated = TRUE;
|
|
|
9cd3a2 |
+ }
|
|
|
9cd3a2 |
if (sp == NULL) {
|
|
|
9cd3a2 |
warnx("xdr_string: out of memory");
|
|
|
9cd3a2 |
return (FALSE);
|
|
|
9cd3a2 |
@@ -804,7 +817,14 @@ xdr_string(xdrs, cpp, maxsize)
|
|
|
9cd3a2 |
/* FALLTHROUGH */
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
case XDR_ENCODE:
|
|
|
9cd3a2 |
- return (xdr_opaque(xdrs, sp, size));
|
|
|
9cd3a2 |
+ ret = xdr_opaque(xdrs, sp, size);
|
|
|
9cd3a2 |
+ if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) {
|
|
|
9cd3a2 |
+ if (allocated == TRUE) {
|
|
|
9cd3a2 |
+ free(sp);
|
|
|
9cd3a2 |
+ *cpp = NULL;
|
|
|
9cd3a2 |
+ }
|
|
|
9cd3a2 |
+ }
|
|
|
9cd3a2 |
+ return (ret);
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
case XDR_FREE:
|
|
|
9cd3a2 |
mem_free(sp, nodesize);
|
|
|
9cd3a2 |
@@ -824,7 +844,7 @@ xdr_wrapstring(xdrs, cpp)
|
|
|
9cd3a2 |
XDR *xdrs;
|
|
|
9cd3a2 |
char **cpp;
|
|
|
9cd3a2 |
{
|
|
|
9cd3a2 |
- return xdr_string(xdrs, cpp, LASTUNSIGNED);
|
|
|
9cd3a2 |
+ return xdr_string(xdrs, cpp, RPC_MAXDATASIZE);
|
|
|
9cd3a2 |
}
|
|
|
9cd3a2 |
|
|
|
9cd3a2 |
/*
|