ReactOS  0.4.15-dev-489-g75a0787
rpcb_prot.c File Reference
#include <wintirpc.h>
#include <rpc/rpc.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/rpcb_prot.h>
Include dependency graph for rpcb_prot.c:

Go to the source code of this file.

Functions

bool_t xdr_rpcb (XDR *xdrs, RPCB *objp)
 
bool_t xdr_rpcblist_ptr (XDR *xdrs, rpcblist_ptr *rp)
 
bool_t xdr_rpcblist (XDR *xdrs, RPCBLIST **rp)
 
bool_t xdr_rpcb_entry (XDR *xdrs, rpcb_entry *objp)
 
bool_t xdr_rpcb_entry_list_ptr (XDR *xdrs, rpcb_entry_list_ptr *rp)
 
bool_t xdr_rpcb_rmtcallargs (XDR *xdrs, struct rpcb_rmtcallargs *p)
 
bool_t xdr_rpcb_rmtcallres (XDR *xdrs, struct rpcb_rmtcallres *p)
 
bool_t xdr_netbuf (XDR *xdrs, struct netbuf *objp)
 

Function Documentation

◆ xdr_netbuf()

bool_t xdr_netbuf ( XDR xdrs,
struct netbuf objp 
)

Definition at line 344 of file rpcb_prot.c.

347 {
348  bool_t dummy;
349 
350  if (!xdr_u_int32_t(xdrs, (u_int32_t *) &objp->maxlen)) {
351  return (FALSE);
352  }
353 #ifdef __REACTOS__ // CVE-2017-8779
354 
355  if (objp->maxlen > RPC_MAXDATASIZE) {
356  return (FALSE);
357  }
358 
359 #endif
360  dummy = xdr_bytes(xdrs, (char **)&(objp->buf),
361  (u_int *)&(objp->len), objp->maxlen);
362  return (dummy);
363 }
int32_t bool_t
Definition: types.h:101
void * buf
Definition: types.h:147
unsigned int maxlen
Definition: types.h:145
unsigned int len
Definition: types.h:146
unsigned int u_int32_t
Definition: rosdhcp.h:35
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239
UINT32 u_int
Definition: types.h:82
unsigned char dummy
Definition: maze.c:118
#define RPC_MAXDATASIZE
Definition: rpc_com.h:51
bool_t xdr_bytes(XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
Definition: xdr.c:536

Referenced by rpcb_taddr2uaddr(), and rpcb_uaddr2taddr().

◆ xdr_rpcb()

bool_t xdr_rpcb ( XDR xdrs,
RPCB objp 
)

Definition at line 50 of file rpcb_prot.c.

53 {
54  if (!xdr_u_int32_t(xdrs, &objp->r_prog)) {
55  return (FALSE);
56  }
57  if (!xdr_u_int32_t(xdrs, &objp->r_vers)) {
58  return (FALSE);
59  }
60 #ifndef __REACTOS__ // CVE-2017-8779
61  if (!xdr_string(xdrs, &objp->r_netid, (u_int)~0)) {
62  return (FALSE);
63  }
64  if (!xdr_string(xdrs, &objp->r_addr, (u_int)~0)) {
65  return (FALSE);
66  }
67  if (!xdr_string(xdrs, &objp->r_owner, (u_int)~0)) {
68  return (FALSE);
69  }
70 #else
71  if (!xdr_string(xdrs, &objp->r_netid, RPC_MAXDATASIZE)) {
72  return (FALSE);
73  }
74  if (!xdr_string(xdrs, &objp->r_addr, RPC_MAXDATASIZE)) {
75  return (FALSE);
76  }
77  if (!xdr_string(xdrs, &objp->r_owner, RPC_MAXDATASIZE)) {
78  return (FALSE);
79  }
80 #endif
81  return (TRUE);
82 }
#define TRUE
Definition: types.h:120
bool_t xdr_string(XDR *xdrs, char **cpp, u_int maxsize)
Definition: xdr.c:678
char * r_netid
Definition: rpcb_prot.h:143
rpcprog_t r_prog
Definition: rpcb_prot.h:141
char * r_addr
Definition: rpcb_prot.h:144
char * r_owner
Definition: rpcb_prot.h:145
rpcvers_t r_vers
Definition: rpcb_prot.h:142
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239
UINT32 u_int
Definition: types.h:82
#define RPC_MAXDATASIZE
Definition: rpc_com.h:51

Referenced by __rpcb_findaddr_timed(), rpcb_set(), rpcb_unset(), and xdr_rpcblist_ptr().

◆ xdr_rpcb_entry()

bool_t xdr_rpcb_entry ( XDR xdrs,
rpcb_entry objp 
)

Definition at line 174 of file rpcb_prot.c.

177 {
178 #ifndef __REACTOS__ // CVE-2017-8779
179  if (!xdr_string(xdrs, &objp->r_maddr, (u_int)~0)) {
180  return (FALSE);
181  }
182  if (!xdr_string(xdrs, &objp->r_nc_netid, (u_int)~0)) {
183  return (FALSE);
184  }
185 #else
186  if (!xdr_string(xdrs, &objp->r_maddr, RPC_MAXDATASIZE)) {
187  return (FALSE);
188  }
189  if (!xdr_string(xdrs, &objp->r_nc_netid, RPC_MAXDATASIZE)) {
190  return (FALSE);
191  }
192 #endif
193  if (!xdr_u_int32_t(xdrs, &objp->r_nc_semantics)) {
194  return (FALSE);
195  }
196 #ifndef __REACTOS__ // CVE-2017-8779
197  if (!xdr_string(xdrs, &objp->r_nc_protofmly, (u_int)~0)) {
198  return (FALSE);
199  }
200  if (!xdr_string(xdrs, &objp->r_nc_proto, (u_int)~0)) {
201  return (FALSE);
202  }
203 #else
204  if (!xdr_string(xdrs, &objp->r_nc_protofmly, RPC_MAXDATASIZE)) {
205  return (FALSE);
206  }
207  if (!xdr_string(xdrs, &objp->r_nc_proto, RPC_MAXDATASIZE)) {
208  return (FALSE);
209  }
210 #endif
211  return (TRUE);
212 }
#define TRUE
Definition: types.h:120
bool_t xdr_string(XDR *xdrs, char **cpp, u_int maxsize)
Definition: xdr.c:678
char * r_nc_proto
Definition: rpcb_prot.h:310
char * r_nc_protofmly
Definition: rpcb_prot.h:309
u_int r_nc_semantics
Definition: rpcb_prot.h:308
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239
UINT32 u_int
Definition: types.h:82
char * r_nc_netid
Definition: rpcb_prot.h:307
#define RPC_MAXDATASIZE
Definition: rpc_com.h:51
char * r_maddr
Definition: rpcb_prot.h:306

Referenced by xdr_rpcb_entry_list_ptr().

◆ xdr_rpcb_entry_list_ptr()

bool_t xdr_rpcb_entry_list_ptr ( XDR xdrs,
rpcb_entry_list_ptr rp 
)

Definition at line 215 of file rpcb_prot.c.

218 {
219  /*
220  * more_elements is pre-computed in case the direction is
221  * XDR_ENCODE or XDR_FREE. more_elements is overwritten by
222  * xdr_bool when the direction is XDR_DECODE.
223  */
224  bool_t more_elements;
225  int freeing = (xdrs->x_op == XDR_FREE);
227  rpcb_entry_list_ptr next_copy;
228 
229  next = NULL;
230  for (;;) {
231  more_elements = (bool_t)(*rp != NULL);
232  if (! xdr_bool(xdrs, &more_elements)) {
233  return (FALSE);
234  }
235  if (! more_elements) {
236  return (TRUE); /* we are done */
237  }
238  /*
239  * the unfortunate side effect of non-recursion is that in
240  * the case of freeing we must remember the next object
241  * before we free the current object ...
242  */
243  if (freeing)
244  next = (*rp)->rpcb_entry_next;
245  if (! xdr_reference(xdrs, (caddr_t *)rp,
246  (u_int)sizeof (rpcb_entry_list),
248  return (FALSE);
249  }
250  if (freeing) {
251  next_copy = next;
252  rp = &next_copy;
253  /*
254  * Note that in the subsequent iteration, next_copy
255  * gets nulled out by the xdr_reference
256  * but next itself survives.
257  */
258  } else {
259  rp = &((*rp)->rpcb_entry_next);
260  }
261  }
262  /*NOTREACHED*/
263 }
Definition: rpcb_prot.h:326
#define TRUE
Definition: types.h:120
bool_t xdr_reference(XDR *xdrs, caddr_t *pp, u_int size, xdrproc_t proc)
Definition: xdr_reference.c:62
int32_t bool_t
Definition: types.h:101
char * caddr_t
Definition: rosdhcp.h:36
bool_t(* xdrproc_t)(XDR *,...)
Definition: xdr.h:144
smooth NULL
Definition: ftsmooth.c:416
enum xdr_op x_op
Definition: xdr.h:104
static unsigned __int64 next
Definition: rand_nt.c:6
UINT32 u_int
Definition: types.h:82
bool_t xdr_bool(XDR *xdrs, bool_t *bp)
Definition: xdr.c:428
Definition: xdr.h:87
bool_t xdr_rpcb_entry(XDR *xdrs, rpcb_entry *objp)
Definition: rpcb_prot.c:174

◆ xdr_rpcb_rmtcallargs()

bool_t xdr_rpcb_rmtcallargs ( XDR xdrs,
struct rpcb_rmtcallargs p 
)

Definition at line 270 of file rpcb_prot.c.

273 {
274  struct r_rpcb_rmtcallargs *objp =
275  (struct r_rpcb_rmtcallargs *)(void *)p;
276  u_int lenposition, argposition, position;
277  int32_t *buf;
278 
279  buf = XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT);
280  if (buf == NULL) {
281  if (!xdr_u_int32_t(xdrs, &objp->prog)) {
282  return (FALSE);
283  }
284  if (!xdr_u_int32_t(xdrs, &objp->vers)) {
285  return (FALSE);
286  }
287  if (!xdr_u_int32_t(xdrs, &objp->proc)) {
288  return (FALSE);
289  }
290  } else {
291  IXDR_PUT_U_INT32(buf, objp->prog);
292  IXDR_PUT_U_INT32(buf, objp->vers);
293  IXDR_PUT_U_INT32(buf, objp->proc);
294  }
295 
296  /*
297  * All the jugglery for just getting the size of the arguments
298  */
299  lenposition = XDR_GETPOS(xdrs);
300  if (! xdr_u_int(xdrs, &(objp->args.args_len))) {
301  return (FALSE);
302  }
303  argposition = XDR_GETPOS(xdrs);
304  if (! (*objp->xdr_args)(xdrs, objp->args.args_val)) {
305  return (FALSE);
306  }
307  position = XDR_GETPOS(xdrs);
308  objp->args.args_len = (u_int)((u_long)position - (u_long)argposition);
309  XDR_SETPOS(xdrs, lenposition);
310  if (! xdr_u_int(xdrs, &(objp->args.args_len))) {
311  return (FALSE);
312  }
313  XDR_SETPOS(xdrs, position);
314  return (TRUE);
315 }
rpcprog_t prog
Definition: rpcb_prot.h:253
#define TRUE
Definition: types.h:120
#define XDR_GETPOS(xdrs)
Definition: xdr.h:199
unsigned long u_long
Definition: linux.h:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
rpcvers_t vers
Definition: rpcb_prot.h:254
smooth NULL
Definition: ftsmooth.c:416
bool_t xdr_u_int(XDR *xdrs, u_int *up)
Definition: xdr.c:133
#define IXDR_PUT_U_INT32(buf, v)
Definition: rpcb_prot.h:21
struct r_rpcb_rmtcallargs::@195 args
rpcproc_t proc
Definition: rpcb_prot.h:255
xdrproc_t xdr_args
Definition: rpcb_prot.h:260
#define XDR_INLINE(xdrs, len)
Definition: xdr.h:209
INT32 int32_t
Definition: types.h:71
#define XDR_SETPOS(xdrs, pos)
Definition: xdr.h:204
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239
UINT32 u_int
Definition: types.h:82
GLfloat GLfloat p
Definition: glext.h:8902
#define BYTES_PER_XDR_UNIT
Definition: xdr.h:93

Referenced by rpc_broadcast_exp().

◆ xdr_rpcb_rmtcallres()

bool_t xdr_rpcb_rmtcallres ( XDR xdrs,
struct rpcb_rmtcallres p 
)

Definition at line 322 of file rpcb_prot.c.

325 {
326  bool_t dummy;
327  struct r_rpcb_rmtcallres *objp = (struct r_rpcb_rmtcallres *)(void *)p;
328 
329 #ifdef __REACTOS__ // CVE-2017-8779
330  if (!xdr_string(xdrs, &objp->addr, RPC_MAXDATASIZE)) {
331 #else
332  if (!xdr_string(xdrs, &objp->addr, (u_int)~0)) {
333 #endif
334  return (FALSE);
335  }
336  if (!xdr_u_int(xdrs, &objp->results.results_len)) {
337  return (FALSE);
338  }
339  dummy = (*(objp->xdr_res))(xdrs, objp->results.results_val);
340  return (dummy);
341 }
int32_t bool_t
Definition: types.h:101
bool_t xdr_string(XDR *xdrs, char **cpp, u_int maxsize)
Definition: xdr.c:678
xdrproc_t xdr_res
Definition: rpcb_prot.h:295
struct r_rpcb_rmtcallres::@197 results
bool_t xdr_u_int(XDR *xdrs, u_int *up)
Definition: xdr.c:133
UINT32 u_int
Definition: types.h:82
unsigned char dummy
Definition: maze.c:118
#define RPC_MAXDATASIZE
Definition: rpc_com.h:51
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by rpc_broadcast_exp().

◆ xdr_rpcblist()

bool_t xdr_rpcblist ( XDR xdrs,
RPCBLIST **  rp 
)

Definition at line 162 of file rpcb_prot.c.

165 {
166  bool_t dummy;
167 
168  dummy = xdr_rpcblist_ptr(xdrs, (rpcblist_ptr *)rp);
169  return (dummy);
170 }
int32_t bool_t
Definition: types.h:101
bool_t xdr_rpcblist_ptr(XDR *xdrs, rpcblist_ptr *rp)
Definition: rpcb_prot.c:108
unsigned char dummy
Definition: maze.c:118

◆ xdr_rpcblist_ptr()

bool_t xdr_rpcblist_ptr ( XDR xdrs,
rpcblist_ptr rp 
)

Definition at line 108 of file rpcb_prot.c.

111 {
112  /*
113  * more_elements is pre-computed in case the direction is
114  * XDR_ENCODE or XDR_FREE. more_elements is overwritten by
115  * xdr_bool when the direction is XDR_DECODE.
116  */
117  bool_t more_elements;
118  int freeing = (xdrs->x_op == XDR_FREE);
120  rpcblist_ptr next_copy;
121 
122  next = NULL;
123  for (;;) {
124  more_elements = (bool_t)(*rp != NULL);
125  if (! xdr_bool(xdrs, &more_elements)) {
126  return (FALSE);
127  }
128  if (! more_elements) {
129  return (TRUE); /* we are done */
130  }
131  /*
132  * the unfortunate side effect of non-recursion is that in
133  * the case of freeing we must remember the next object
134  * before we free the current object ...
135  */
136  if (freeing)
137  next = (*rp)->rpcb_next;
138  if (! xdr_reference(xdrs, (caddr_t *)rp,
139  (u_int)sizeof (rpcblist), (xdrproc_t)xdr_rpcb)) {
140  return (FALSE);
141  }
142  if (freeing) {
143  next_copy = next;
144  rp = &next_copy;
145  /*
146  * Note that in the subsequent iteration, next_copy
147  * gets nulled out by the xdr_reference
148  * but next itself survives.
149  */
150  } else {
151  rp = &((*rp)->rpcb_next);
152  }
153  }
154  /*NOTREACHED*/
155 }
#define TRUE
Definition: types.h:120
bool_t xdr_reference(XDR *xdrs, caddr_t *pp, u_int size, xdrproc_t proc)
Definition: xdr_reference.c:62
int32_t bool_t
Definition: types.h:101
char * caddr_t
Definition: rosdhcp.h:36
bool_t(* xdrproc_t)(XDR *,...)
Definition: xdr.h:144
smooth NULL
Definition: ftsmooth.c:416
enum xdr_op x_op
Definition: xdr.h:104
static unsigned __int64 next
Definition: rand_nt.c:6
UINT32 u_int
Definition: types.h:82
bool_t xdr_bool(XDR *xdrs, bool_t *bp)
Definition: xdr.c:428
bool_t xdr_rpcb(XDR *xdrs, RPCB *objp)
Definition: rpcb_prot.c:50
Definition: xdr.h:87

Referenced by rpcb_getmaps(), and xdr_rpcblist().