ReactOS 0.4.15-dev-7934-g1dc8d80
xdr.c File Reference
#include <wintirpc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
Include dependency graph for xdr.c:

Go to the source code of this file.

Macros

#define XDR_FALSE   ((long) 0)
 
#define XDR_TRUE   ((long) 1)
 
#define LASTUNSIGNED   ((u_int) 0-1)
 

Typedefs

typedef quad_t longlong_t
 
typedef u_quad_t u_longlong_t
 

Functions

void xdr_free (xdrproc_t proc, void *objp)
 
bool_t xdr_void (void)
 
bool_t xdr_int (XDR *xdrs, int *ip)
 
bool_t xdr_u_int (XDR *xdrs, u_int *up)
 
bool_t xdr_long (XDR *xdrs, long *lp)
 
bool_t xdr_u_long (XDR *xdrs, u_long *ulp)
 
bool_t xdr_int32_t (XDR *xdrs, int32_t *int32_p)
 
bool_t xdr_u_int32_t (XDR *xdrs, u_int32_t *u_int32_p)
 
bool_t xdr_short (XDR *xdrs, short *sp)
 
bool_t xdr_u_short (XDR *xdrs, u_short *usp)
 
bool_t xdr_int16_t (XDR *xdrs, int16_t *int16_p)
 
bool_t xdr_u_int16_t (XDR *xdrs, u_int16_t *u_int16_p)
 
bool_t xdr_char (XDR *xdrs, char *cp)
 
bool_t xdr_u_char (XDR *xdrs, u_char *cp)
 
bool_t xdr_bool (XDR *xdrs, bool_t *bp)
 
bool_t xdr_enum (XDR *xdrs, enum_t *ep)
 
bool_t xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt)
 
bool_t xdr_bytes (XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
 
bool_t xdr_netobj (XDR *xdrs, struct netobj *np)
 
bool_t xdr_union (XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choices, xdrproc_t dfault)
 
bool_t xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
 
bool_t xdr_wrapstring (XDR *xdrs, char **cpp)
 
bool_t xdr_int64_t (XDR *xdrs, int64_t *llp)
 
bool_t xdr_u_int64_t (XDR *xdrs, u_int64_t *ullp)
 
bool_t xdr_hyper (XDR *xdrs, longlong_t *llp)
 
bool_t xdr_u_hyper (XDR *xdrs, u_longlong_t *ullp)
 
bool_t xdr_longlong_t (XDR *xdrs, longlong_t *llp)
 
bool_t xdr_u_longlong_t (XDR *xdrs, u_longlong_t *ullp)
 

Variables

static const char xdr_zero [BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }
 

Macro Definition Documentation

◆ LASTUNSIGNED

#define LASTUNSIGNED   ((u_int) 0-1)

Definition at line 65 of file xdr.c.

◆ XDR_FALSE

#define XDR_FALSE   ((long) 0)

Definition at line 62 of file xdr.c.

◆ XDR_TRUE

#define XDR_TRUE   ((long) 1)

Definition at line 63 of file xdr.c.

Typedef Documentation

◆ longlong_t

typedef quad_t longlong_t

Definition at line 56 of file xdr.c.

◆ u_longlong_t

Definition at line 57 of file xdr.c.

Function Documentation

◆ xdr_bool()

bool_t xdr_bool ( XDR xdrs,
bool_t bp 
)

Definition at line 428 of file xdr.c.

431{
432 long lb;
433
434 switch (xdrs->x_op) {
435
436 case XDR_ENCODE:
437 lb = *bp ? XDR_TRUE : XDR_FALSE;
438 return (XDR_PUTLONG(xdrs, &lb));
439
440 case XDR_DECODE:
441 if (!XDR_GETLONG(xdrs, &lb)) {
442 return (FALSE);
443 }
444 *bp = (lb == XDR_FALSE) ? FALSE : TRUE;
445 return (TRUE);
446
447 case XDR_FREE:
448 return (TRUE);
449 }
450 /* NOTREACHED */
451 return (FALSE);
452}
#define XDR_TRUE
Definition: xdr.c:63
#define XDR_FALSE
Definition: xdr.c:62
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
enum xdr_op x_op
Definition: xdr.h:104
#define XDR_PUTLONG(xdrs, longp)
Definition: xdr.h:161
@ XDR_DECODE
Definition: xdr.h:86
@ XDR_FREE
Definition: xdr.h:87
@ XDR_ENCODE
Definition: xdr.h:85
#define XDR_GETLONG(xdrs, longp)
Definition: xdr.h:156

Referenced by cb_notify_deviceid_change(), decode_file_attrs(), decode_layout_res_ok(), decode_op_bind_conn_to_session(), decode_op_layoutcommit(), decode_op_layoutget(), decode_op_layoutreturn(), decode_open_none_delegation4(), decode_open_read_delegation4(), decode_open_write_delegation4(), decode_read_res_ok(), decode_readdir_entry(), decode_readdir_list(), encode_file_attrs(), encode_op_layoutcommit(), encode_op_layoutget(), encode_op_layoutreturn(), encode_op_lock(), encode_op_openattr(), encode_op_reclaim_complete(), encode_op_sequence(), op_cb_layoutrecall_args(), op_cb_recall_args(), op_cb_sequence_args(), rpcb_set(), rpcb_unset(), xdr_change_info4(), xdr_locker4(), xdr_pmaplist(), xdr_pointer(), xdr_rpcb_entry_list_ptr(), and xdr_rpcblist_ptr().

◆ xdr_bytes()

bool_t xdr_bytes ( XDR xdrs,
char **  cpp,
u_int sizep,
u_int  maxsize 
)

Definition at line 536 of file xdr.c.

541{
542 char *sp = *cpp; /* sp is the actual string pointer */
543 u_int nodesize;
544#ifdef __REACTOS__ // CVE-2017-8779
545 bool_t ret, allocated = FALSE;
546#endif
547
548 /*
549 * first deal with the length since xdr bytes are counted
550 */
551 if (! xdr_u_int(xdrs, sizep)) {
552 return (FALSE);
553 }
554 nodesize = *sizep;
555 if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) {
556 return (FALSE);
557 }
558
559 /*
560 * now deal with the actual bytes
561 */
562 switch (xdrs->x_op) {
563
564 case XDR_DECODE:
565 if (nodesize == 0) {
566 return (TRUE);
567 }
568 if (sp == NULL) {
569 *cpp = sp = mem_alloc(nodesize);
570#ifdef __REACTOS__ // CVE-2017-8779
571 allocated = TRUE;
572#endif
573 }
574 if (sp == NULL) {
575 //warnx("xdr_bytes: out of memory");
576 return (FALSE);
577 }
578 /* FALLTHROUGH */
579
580 case XDR_ENCODE:
581#ifndef __REACTOS__ // CVE-2017-8779
582 return (xdr_opaque(xdrs, sp, nodesize));
583#else
584 ret = xdr_opaque(xdrs, sp, nodesize);
585 if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) {
586 if (allocated == TRUE) {
587 free(sp);
588 *cpp = NULL;
589 }
590 }
591 return (ret);
592#endif
593
594 case XDR_FREE:
595 if (sp != NULL) {
596 mem_free(sp, nodesize);
597 *cpp = NULL;
598 }
599 return (TRUE);
600 }
601 /* NOTREACHED */
602 return (FALSE);
603}
bool_t xdr_u_int(XDR *xdrs, u_int *up)
Definition: xdr.c:133
bool_t xdr_opaque(XDR *xdrs, caddr_t cp, u_int cnt)
Definition: xdr.c:484
#define free
Definition: debug_ros.c:5
UINT32 u_int
Definition: types.h:82
#define mem_free(ptr, bsize)
Definition: types.h:124
#define NULL
Definition: types.h:112
#define mem_alloc(bsize)
Definition: types.h:123
int32_t bool_t
Definition: types.h:101
static const WCHAR sp[]
Definition: suminfo.c:287
int ret

Referenced by common_notify4(), decode_component(), decode_file_attrs(), decode_fs_location4(), decode_op_exchange_id(), decode_op_readlink(), decode_pathname4(), decode_read_res_ok(), decode_readdir_entry(), encode_component(), encode_createtype4(), encode_file_attrs(), encode_op_write(), nfs_decode_compound(), nfs_encode_compound(), xdr_client_owner4(), xdr_fattr4(), xdr_fh(), xdr_netbuf(), xdr_netobj(), xdr_nfs_impl_id4(), xdr_opaque_auth(), xdr_pnfs_addr(), xdr_rpc_gss_cred(), xdr_rpc_gss_init_args(), xdr_rpc_gss_init_res(), xdr_rpc_gss_unwrap_data(), xdr_rpc_gss_wrap_data(), xdr_rpc_sspi_cred(), xdr_rpc_sspi_init_args(), xdr_rpc_sspi_init_res(), xdr_rpc_sspi_unwrap_data(), xdr_rpc_sspi_wrap_data(), xdr_secinfo(), xdr_server_owner4(), and xdr_state_owner4().

◆ xdr_char()

bool_t xdr_char ( XDR xdrs,
char cp 
)

Definition at line 392 of file xdr.c.

395{
396 int i;
397
398 i = (*cp);
399 if (!xdr_int(xdrs, &i)) {
400 return (FALSE);
401 }
402 *cp = (char)i;
403 return (TRUE);
404}
bool_t xdr_int(XDR *xdrs, int *ip)
Definition: xdr.c:103
unsigned char
Definition: typeof.h:29
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
POINT cp
Definition: magnifier.c:59

◆ xdr_enum()

bool_t xdr_enum ( XDR xdrs,
enum_t ep 
)

Definition at line 458 of file xdr.c.

461{
462 enum sizecheck { SIZEVAL }; /* used to find the size of an enum */
463
464 /*
465 * enums are treated as ints
466 */
467 /* LINTED */ if (sizeof (enum sizecheck) == sizeof (long)) {
468 return (xdr_long(xdrs, (long *)(void *)ep));
469 } else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (int)) {
470 return (xdr_int(xdrs, (int *)(void *)ep));
471 } else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (short)) {
472 return (xdr_short(xdrs, (short *)(void *)ep));
473 } else {
474 return (FALSE);
475 }
476}
bool_t xdr_short(XDR *xdrs, short *sp)
Definition: xdr.c:270
bool_t xdr_long(XDR *xdrs, long *lp)
Definition: xdr.c:165

Referenced by decode_getdeviceinfo_ok(), decode_layout(), decode_op_bind_conn_to_session(), decode_op_reclaim_complete(), decode_op_want_delegation(), decode_open_none_delegation4(), decode_open_res_ok(), encode_op_bind_conn_to_session(), encode_op_getdeviceinfo(), encode_op_layoutcommit(), encode_op_layoutreturn(), encode_op_secinfo_noname(), op_cb_getattr_res(), op_cb_layoutrecall_args(), op_cb_layoutrecall_res(), op_cb_notify_deviceid_res(), op_cb_notify_lock_res(), op_cb_notify_res(), op_cb_push_deleg_res(), op_cb_recall_any_res(), op_cb_recall_res(), op_cb_recall_slot_res(), op_cb_recallable_obj_avail_res(), op_cb_wants_cancelled_res(), proc_cb_compound_res(), xdr_accepted_reply(), xdr_authdes_cred(), xdr_callhdr(), xdr_callmsg(), xdr_getxiddir(), xdr_keystatus(), xdr_opaque_auth(), xdr_rejected_reply(), xdr_replymsg(), xdr_rpc_gss_cred(), xdr_rpc_sspi_cred(), xdr_secinfo(), xdr_union(), and xdr_write_verf().

◆ xdr_free()

void xdr_free ( xdrproc_t  proc,
void objp 
)

Definition at line 78 of file xdr.c.

81{
82 XDR x;
83
84 x.x_op = XDR_FREE;
85 (*proc)(&x, objp);
86}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
Definition: xdr.h:103

Referenced by __rpcb_findaddr_timed().

◆ xdr_hyper()

bool_t xdr_hyper ( XDR xdrs,
longlong_t llp 
)

Definition at line 861 of file xdr.c.

864{
865
866 /*
867 * Don't bother open-coding this; it's a fair amount of code. Just
868 * call xdr_int64_t().
869 */
870 return (xdr_int64_t(xdrs, (int64_t *)llp));
871}
bool_t xdr_int64_t(XDR *xdrs, int64_t *llp)
Definition: xdr.c:795
INT64 int64_t
Definition: types.h:72

Referenced by xdr_nfstime4().

◆ xdr_int()

bool_t xdr_int ( XDR xdrs,
int ip 
)

Definition at line 103 of file xdr.c.

106{
107 long l;
108
109 switch (xdrs->x_op) {
110
111 case XDR_ENCODE:
112 l = (long) *ip;
113 return (XDR_PUTLONG(xdrs, &l));
114
115 case XDR_DECODE:
116 if (!XDR_GETLONG(xdrs, &l)) {
117 return (FALSE);
118 }
119 *ip = (int) l;
120 return (TRUE);
121
122 case XDR_FREE:
123 return (TRUE);
124 }
125 /* NOTREACHED */
126 return (FALSE);
127}
r l[0]
Definition: byte_order.h:168
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define long
Definition: qsort.c:33
Definition: dhcpd.h:62

Referenced by rpcb_gettime(), xdr_authunix_parms(), xdr_char(), xdr_enum(), xdr_rpcb_stat(), xdr_rpcbs_addrlist(), xdr_rpcbs_proc(), and xdr_rpcbs_rmtcalllist().

◆ xdr_int16_t()

bool_t xdr_int16_t ( XDR xdrs,
int16_t int16_p 
)

Definition at line 331 of file xdr.c.

334{
335 long l;
336
337 switch (xdrs->x_op) {
338
339 case XDR_ENCODE:
340 l = (long) *int16_p;
341 return (XDR_PUTLONG(xdrs, &l));
342
343 case XDR_DECODE:
344 if (!XDR_GETLONG(xdrs, &l)) {
345 return (FALSE);
346 }
347 *int16_p = (int16_t) l;
348 return (TRUE);
349
350 case XDR_FREE:
351 return (TRUE);
352 }
353 /* NOTREACHED */
354 return (FALSE);
355}
#define int16_t
Definition: nsiface.idl:55

◆ xdr_int32_t()

bool_t xdr_int32_t ( XDR xdrs,
int32_t int32_p 
)

Definition at line 208 of file xdr.c.

211{
212 long l;
213
214 switch (xdrs->x_op) {
215
216 case XDR_ENCODE:
217 l = (long) *int32_p;
218 return (XDR_PUTLONG(xdrs, &l));
219
220 case XDR_DECODE:
221 if (!XDR_GETLONG(xdrs, &l)) {
222 return (FALSE);
223 }
224 *int32_p = (int32_t) l;
225 return (TRUE);
226
227 case XDR_FREE:
228 return (TRUE);
229 }
230 /* NOTREACHED */
231 return (FALSE);
232}
#define int32_t
Definition: nsiface.idl:56

◆ xdr_int64_t()

bool_t xdr_int64_t ( XDR xdrs,
int64_t llp 
)

Definition at line 795 of file xdr.c.

798{
799 u_long ul[2];
800
801 switch (xdrs->x_op) {
802 case XDR_ENCODE:
803 ul[0] = (u_long)((u_int64_t)*llp >> 32) & 0xffffffff;
804 ul[1] = (u_long)((u_int64_t)*llp) & 0xffffffff;
805 if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
806 return (FALSE);
807 return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
808 case XDR_DECODE:
809 if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE)
810 return (FALSE);
811 if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE)
812 return (FALSE);
813 *llp = (int64_t)
814 (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1]));
815 return (TRUE);
816 case XDR_FREE:
817 return (TRUE);
818 }
819 /* NOTREACHED */
820 return (FALSE);
821}
UINT64 u_int64_t
Definition: types.h:76
unsigned long u_long
Definition: linux.h:269
#define int64_t
Definition: nsiface.idl:57

Referenced by xdr_hyper(), and xdr_longlong_t().

◆ xdr_long()

bool_t xdr_long ( XDR xdrs,
long lp 
)

Definition at line 165 of file xdr.c.

168{
169 switch (xdrs->x_op) {
170 case XDR_ENCODE:
171 return (XDR_PUTLONG(xdrs, lp));
172 case XDR_DECODE:
173 return (XDR_GETLONG(xdrs, lp));
174 case XDR_FREE:
175 return (TRUE);
176 }
177 /* NOTREACHED */
178 return (FALSE);
179}

Referenced by xdr_enum().

◆ xdr_longlong_t()

bool_t xdr_longlong_t ( XDR xdrs,
longlong_t llp 
)

Definition at line 895 of file xdr.c.

898{
899
900 /*
901 * Don't bother open-coding this; it's a fair amount of code. Just
902 * call xdr_int64_t().
903 */
904 return (xdr_int64_t(xdrs, (int64_t *)llp));
905}

◆ xdr_netobj()

bool_t xdr_netobj ( XDR xdrs,
struct netobj np 
)

Definition at line 609 of file xdr.c.

612{
613
614 return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ));
615}
bool_t xdr_bytes(XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
Definition: xdr.c:536
u_int n_len
Definition: xdr.h:333
char * n_bytes
Definition: xdr.h:334
#define MAX_NETOBJ_SZ
Definition: xdr.h:331

Referenced by xdr_cryptkeyarg2().

◆ xdr_opaque()

bool_t xdr_opaque ( XDR xdrs,
caddr_t  cp,
u_int  cnt 
)

Definition at line 484 of file xdr.c.

488{
489 u_int rndup;
490 static int crud[BYTES_PER_XDR_UNIT];
491
492 /*
493 * if no data we are done
494 */
495 if (cnt == 0)
496 return (TRUE);
497
498 /*
499 * round byte count to full xdr units
500 */
501 rndup = cnt % BYTES_PER_XDR_UNIT;
502 if (rndup > 0)
503 rndup = BYTES_PER_XDR_UNIT - rndup;
504
505 if (xdrs->x_op == XDR_DECODE) {
506 if (!XDR_GETBYTES(xdrs, cp, cnt)) {
507 return (FALSE);
508 }
509 if (rndup == 0)
510 return (TRUE);
511 return (XDR_GETBYTES(xdrs, (caddr_t)(void *)crud, rndup));
512 }
513
514 if (xdrs->x_op == XDR_ENCODE) {
515 if (!XDR_PUTBYTES(xdrs, cp, cnt)) {
516 return (FALSE);
517 }
518 if (rndup == 0)
519 return (TRUE);
520 return (XDR_PUTBYTES(xdrs, xdr_zero, rndup));
521 }
522
523 if (xdrs->x_op == XDR_FREE) {
524 return (TRUE);
525 }
526
527 return (FALSE);
528}
static const char xdr_zero[BYTES_PER_XDR_UNIT]
Definition: xdr.c:71
char * caddr_t
Definition: rosdhcp.h:36
#define XDR_PUTBYTES(xdrs, addr, len)
Definition: xdr.h:194
#define BYTES_PER_XDR_UNIT
Definition: xdr.h:93
#define XDR_GETBYTES(xdrs, addr, len)
Definition: xdr.h:189

Referenced by cb_compound_tag(), cb_notify_deviceid_change(), cb_notify_deviceid_delete(), common_fh(), common_stateid(), decode_file_layout(), decode_op_bind_conn_to_session(), decode_op_commit(), decode_op_create_session(), decode_op_readdir(), encode_createhow4(), encode_op_bind_conn_to_session(), encode_op_destroy_session(), encode_op_getdeviceinfo(), encode_op_readdir(), encode_op_sequence(), op_cb_sequence_args(), op_cb_sequence_ref_list(), op_cb_sequence_res_ok(), xdr_authdes_cred(), xdr_authdes_verf(), xdr_bytes(), xdr_callmsg(), xdr_client_owner4(), xdr_des_block(), xdr_keybuf(), xdr_sequence_res_ok(), xdr_stateid4(), xdr_string(), and xdr_write_verf().

◆ xdr_short()

bool_t xdr_short ( XDR xdrs,
short sp 
)

Definition at line 270 of file xdr.c.

273{
274 long l;
275
276 switch (xdrs->x_op) {
277
278 case XDR_ENCODE:
279 l = (long) *sp;
280 return (XDR_PUTLONG(xdrs, &l));
281
282 case XDR_DECODE:
283 if (!XDR_GETLONG(xdrs, &l)) {
284 return (FALSE);
285 }
286 *sp = (short) l;
287 return (TRUE);
288
289 case XDR_FREE:
290 return (TRUE);
291 }
292 /* NOTREACHED */
293 return (FALSE);
294}
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94

Referenced by xdr_enum().

◆ xdr_string()

bool_t xdr_string ( XDR xdrs,
char **  cpp,
u_int  maxsize 
)

Definition at line 678 of file xdr.c.

682{
683 char *sp = *cpp; /* sp is the actual string pointer */
684 u_int size;
685 u_int nodesize;
686#ifdef __REACTOS__ // CVE-2017-8779
687 bool_t ret, allocated = FALSE;
688#endif
689
690 /*
691 * first deal with the length since xdr strings are counted-strings
692 */
693 switch (xdrs->x_op) {
694 case XDR_FREE:
695 if (sp == NULL) {
696 return(TRUE); /* already free */
697 }
698 /* FALLTHROUGH */
699 case XDR_ENCODE:
700 if (sp == NULL)
701 return FALSE;
702 size = strlen(sp);
703 break;
704 case XDR_DECODE:
705 break;
706 }
707 if (! xdr_u_int(xdrs, &size)) {
708 return (FALSE);
709 }
710 if (size > maxsize) {
711 return (FALSE);
712 }
713 nodesize = size + 1;
714 if (nodesize == 0) {
715 /* This means an overflow. It a bug in the caller which
716 * provided a too large maxsize but nevertheless catch it
717 * here.
718 */
719 return FALSE;
720 }
721
722 /*
723 * now deal with the actual bytes
724 */
725 switch (xdrs->x_op) {
726
727 case XDR_DECODE:
728#ifndef __REACTOS__ // CVE-2017-8779
729 if (sp == NULL)
730 *cpp = sp = mem_alloc(nodesize);
731#else
732 if (sp == NULL) {
733 *cpp = sp = mem_alloc(nodesize);
734 allocated = TRUE;
735 }
736#endif
737 if (sp == NULL) {
738 //warnx("xdr_string: out of memory");
739 return (FALSE);
740 }
741 sp[size] = 0;
742 /* FALLTHROUGH */
743
744 case XDR_ENCODE:
745#ifndef __REACTOS__ // CVE-2017-8779
746 return (xdr_opaque(xdrs, sp, size));
747#else
748 ret = xdr_opaque(xdrs, sp, size);
749 if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) {
750 if (allocated == TRUE) {
751 free(sp);
752 *cpp = NULL;
753 }
754 }
755 return (ret);
756#endif
757
758 case XDR_FREE:
759 mem_free(sp, nodesize);
760 *cpp = NULL;
761 return (TRUE);
762 }
763 /* NOTREACHED */
764 return (FALSE);
765}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLsizeiptr size
Definition: glext.h:5919

Referenced by encode_backchannel_sec_parms(), xdr_authdes_cred(), xdr_authunix_parms(), xdr_netnamestr(), xdr_nfsace4(), xdr_rpcb(), xdr_rpcb_entry(), xdr_rpcb_rmtcallres(), xdr_rpcbs_addrlist(), xdr_rpcbs_rmtcalllist(), and xdr_wrapstring().

◆ xdr_u_char()

bool_t xdr_u_char ( XDR xdrs,
u_char cp 
)

Definition at line 410 of file xdr.c.

413{
414 u_int u;
415
416 u = (*cp);
417 if (!xdr_u_int(xdrs, &u)) {
418 return (FALSE);
419 }
420 *cp = (u_char)u;
421 return (TRUE);
422}
UCHAR u_char
Definition: types.h:80
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240

◆ xdr_u_hyper()

◆ xdr_u_int()

bool_t xdr_u_int ( XDR xdrs,
u_int up 
)

Definition at line 133 of file xdr.c.

136{
137 u_long l;
138
139 switch (xdrs->x_op) {
140
141 case XDR_ENCODE:
142 l = (u_long) *up;
143 return (XDR_PUTLONG(xdrs, (long *)&l));
144
145 case XDR_DECODE:
146 if (!XDR_GETLONG(xdrs, (long *)&l)) {
147 return (FALSE);
148 }
149 *up = (u_int) l;
150 return (TRUE);
151
152 case XDR_FREE:
153 return (TRUE);
154 }
155 /* NOTREACHED */
156 return (FALSE);
157}
#define up(mutex)
Definition: glue.h:30

Referenced by xdr_array(), xdr_authunix_parms(), xdr_bytes(), xdr_callmsg(), xdr_rpc_gss_cred(), xdr_rpc_gss_init_res(), xdr_rpc_gss_unwrap_data(), xdr_rpc_gss_wrap_data(), xdr_rpc_sspi_cred(), xdr_rpc_sspi_init_res(), xdr_rpc_sspi_unwrap_data(), xdr_rpc_sspi_wrap_data(), xdr_rpcb_rmtcallargs(), xdr_rpcb_rmtcallres(), xdr_string(), xdr_u_char(), and xdr_unixcred().

◆ xdr_u_int16_t()

bool_t xdr_u_int16_t ( XDR xdrs,
u_int16_t u_int16_p 
)

Definition at line 361 of file xdr.c.

364{
365 u_long l;
366
367 switch (xdrs->x_op) {
368
369 case XDR_ENCODE:
370 l = (u_long) *u_int16_p;
371 return (XDR_PUTLONG(xdrs, (long *)&l));
372
373 case XDR_DECODE:
374 if (!XDR_GETLONG(xdrs, (long *)&l)) {
375 return (FALSE);
376 }
377 *u_int16_p = (u_int16_t) l;
378 return (TRUE);
379
380 case XDR_FREE:
381 return (TRUE);
382 }
383 /* NOTREACHED */
384 return (FALSE);
385}
unsigned short u_int16_t
Definition: rosdhcp.h:34

◆ xdr_u_int32_t()

bool_t xdr_u_int32_t ( XDR xdrs,
u_int32_t u_int32_p 
)

Definition at line 239 of file xdr.c.

242{
243 u_long l;
244
245 switch (xdrs->x_op) {
246
247 case XDR_ENCODE:
248 l = (u_long) *u_int32_p;
249 return (XDR_PUTLONG(xdrs, (long *)&l));
250
251 case XDR_DECODE:
252 if (!XDR_GETLONG(xdrs, (long *)&l)) {
253 return (FALSE);
254 }
255 *u_int32_p = (u_int32_t) l;
256 return (TRUE);
257
258 case XDR_FREE:
259 return (TRUE);
260 }
261 /* NOTREACHED */
262 return (FALSE);
263}
unsigned int u_int32_t
Definition: rosdhcp.h:35

Referenced by cb_compound_tag(), cb_notify_deviceid_change(), cb_notify_deviceid_delete(), common_fh(), common_stateid(), decode_file_attrs(), decode_file_layout(), decode_file_layout_handles(), decode_fs_location4(), decode_fs_locations4(), decode_getdeviceinfo_ok(), decode_layout_res_ok(), decode_lock_res_denied(), decode_modified_limit4(), decode_op_access(), decode_op_close(), decode_op_commit(), decode_op_create(), decode_op_create_session(), decode_op_delegpurge(), decode_op_delegreturn(), decode_op_destroy_clientid(), decode_op_destroy_session(), decode_op_exchange_id(), decode_op_free_stateid(), decode_op_getattr(), decode_op_getdeviceinfo(), decode_op_getfh(), decode_op_layoutcommit(), decode_op_layoutget(), decode_op_layoutreturn(), decode_op_link(), decode_op_lock(), decode_op_lockt(), decode_op_locku(), decode_op_lookup(), decode_op_open(), decode_op_openattr(), decode_op_putfh(), decode_op_putrootfh(), decode_op_read(), decode_op_readdir(), decode_op_readlink(), decode_op_remove(), decode_op_rename(), decode_op_restorefh(), decode_op_savefh(), decode_op_secinfo(), decode_op_secinfo_noname(), decode_op_sequence(), decode_op_setattr(), decode_op_test_stateid(), decode_op_want_delegation(), decode_op_write(), decode_open_res_ok(), decode_pathname4(), decode_space_limit4(), encode_backchannel_sec_parms(), encode_createhow4(), encode_createtype4(), encode_file_attrs(), encode_op_access(), encode_op_bind_conn_to_session(), encode_op_close(), encode_op_commit(), encode_op_create_session(), encode_op_exchange_id(), encode_op_getdeviceinfo(), encode_op_layoutcommit(), encode_op_layoutget(), encode_op_layoutreturn(), encode_op_lock(), encode_op_lockt(), encode_op_locku(), encode_op_open(), encode_op_read(), encode_op_readdir(), encode_op_sequence(), encode_op_want_delegation(), encode_op_write(), encode_open_claim4(), encode_openflag4(), nfs_decode_compound(), nfs_encode_compound(), op_cb_notify_args(), op_cb_notify_lock_args(), op_cb_push_deleg_args(), op_cb_recall_any_args(), op_cb_recall_slot_args(), op_cb_recallable_obj_avail_args(), op_cb_sequence_args(), op_cb_sequence_ref(), op_cb_sequence_res_ok(), op_cb_wants_cancelled_args(), proc_cb_compound_args(), xdr_accepted_reply(), xdr_bitmap4(), xdr_callhdr(), xdr_callmsg(), xdr_channel_attrs4(), xdr_data_server_list(), xdr_getcallbody(), xdr_getxiddir(), xdr_layout_types(), xdr_locker4(), xdr_mdsthreshold(), xdr_multi_addr(), xdr_netbuf(), xdr_nfsace4(), xdr_nfsdacl41(), xdr_nfstime4(), xdr_rejected_reply(), xdr_replymsg(), xdr_rpcb(), xdr_rpcb_entry(), xdr_rpcb_rmtcallargs(), xdr_rpcbs_addrlist(), xdr_rpcbs_rmtcalllist(), xdr_secinfo(), xdr_sequence_res_ok(), xdr_settime4(), xdr_state_protect4_a(), xdr_state_protect4_r(), xdr_stateid4(), xdr_stripe_indices(), xdr_threshold_item(), and xdr_write_res_ok().

◆ xdr_u_int64_t()

bool_t xdr_u_int64_t ( XDR xdrs,
u_int64_t ullp 
)

Definition at line 828 of file xdr.c.

831{
832 u_long ul[2];
833
834 switch (xdrs->x_op) {
835 case XDR_ENCODE:
836 ul[0] = (u_long)(*ullp >> 32) & 0xffffffff;
837 ul[1] = (u_long)(*ullp) & 0xffffffff;
838 if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
839 return (FALSE);
840 return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
841 case XDR_DECODE:
842 if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE)
843 return (FALSE);
844 if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE)
845 return (FALSE);
846 *ullp = (u_int64_t)
847 (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1]));
848 return (TRUE);
849 case XDR_FREE:
850 return (TRUE);
851 }
852 /* NOTREACHED */
853 return (FALSE);
854}

Referenced by common_fsid(), encode_op_delegpurge(), op_cb_layoutrecall_file(), xdr_u_hyper(), and xdr_u_longlong_t().

◆ xdr_u_long()

bool_t xdr_u_long ( XDR xdrs,
u_long ulp 
)

Definition at line 186 of file xdr.c.

189{
190 switch (xdrs->x_op) {
191 case XDR_ENCODE:
192 return (XDR_PUTLONG(xdrs, (long *)ulp));
193 case XDR_DECODE:
194 return (XDR_GETLONG(xdrs, (long *)ulp));
195 case XDR_FREE:
196 return (TRUE);
197 }
198 /* NOTREACHED */
199 return (FALSE);
200}

Referenced by __rpc_get_time_offset(), xdr_authunix_parms(), xdr_pmap(), xdr_rmtcall_args(), and xdr_rmtcallres().

◆ xdr_u_longlong_t()

bool_t xdr_u_longlong_t ( XDR xdrs,
u_longlong_t ullp 
)

Definition at line 912 of file xdr.c.

915{
916
917 /*
918 * Don't bother open-coding this; it's a fair amount of code. Just
919 * call xdr_u_int64_t().
920 */
921 return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp));
922}

◆ xdr_u_short()

bool_t xdr_u_short ( XDR xdrs,
u_short usp 
)

Definition at line 300 of file xdr.c.

303{
304 u_long l;
305
306 switch (xdrs->x_op) {
307
308 case XDR_ENCODE:
309 l = (u_long) *usp;
310 return (XDR_PUTLONG(xdrs, (long *)&l));
311
312 case XDR_DECODE:
313 if (!XDR_GETLONG(xdrs, (long *)&l)) {
314 return (FALSE);
315 }
316 *usp = (u_short) l;
317 return (TRUE);
318
319 case XDR_FREE:
320 return (TRUE);
321 }
322 /* NOTREACHED */
323 return (FALSE);
324}
unsigned short u_short
Definition: types.h:81

Referenced by __rpcb_findaddr_timed(), and pmap_getport().

◆ xdr_union()

bool_t xdr_union ( XDR xdrs,
enum_t dscmp,
char unp,
const struct xdr_discrim choices,
xdrproc_t  dfault 
)

Definition at line 629 of file xdr.c.

635{
636 enum_t dscm;
637
638 /*
639 * we deal with the discriminator; it's an enum
640 */
641 if (! xdr_enum(xdrs, dscmp)) {
642 return (FALSE);
643 }
644 dscm = *dscmp;
645
646 /*
647 * search choices for a value that matches the discriminator.
648 * if we find one, execute the xdr routine for that value.
649 */
650 for (; choices->proc != NULL_xdrproc_t; choices++) {
651 if (choices->value == dscm)
652 return ((*(choices->proc))(xdrs, unp));
653 }
654
655 /*
656 * no match - execute the default xdr routine if there is one
657 */
658 return ((dfault == NULL_xdrproc_t) ? FALSE :
659 (*dfault)(xdrs, unp));
660}
bool_t xdr_enum(XDR *xdrs, enum_t *ep)
Definition: xdr.c:458
int32_t enum_t
Definition: types.h:102
int value
Definition: xdr.h:248
xdrproc_t proc
Definition: xdr.h:249
#define NULL_xdrproc_t
Definition: xdr.h:246

Referenced by cb_compound_argop(), cb_compound_resop(), op_cb_layoutrecall_args(), op_cb_sequence_res(), xdr_getreplyunion(), and xdr_replymsg().

◆ xdr_void()

◆ xdr_wrapstring()

bool_t xdr_wrapstring ( XDR xdrs,
char **  cpp 
)

Definition at line 772 of file xdr.c.

775{
776#ifdef __REACTOS__ // CVE-2017-8779
777 return xdr_string(xdrs, cpp, RPC_MAXDATASIZE);
778#else
779 return xdr_string(xdrs, cpp, LASTUNSIGNED);
780#endif
781}
bool_t xdr_string(XDR *xdrs, char **cpp, u_int maxsize)
Definition: xdr.c:678
#define LASTUNSIGNED
Definition: xdr.c:65
#define RPC_MAXDATASIZE
Definition: rpc_com.h:51

Referenced by __rpcb_findaddr_timed(), rpcb_taddr2uaddr(), and rpcb_uaddr2taddr().

Variable Documentation

◆ xdr_zero

const char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }
static

Definition at line 71 of file xdr.c.

Referenced by xdr_opaque().