1 --- a/modules/pam_unix/yppasswd_xdr.c
2 +++ b/modules/pam_unix/yppasswd_xdr.c
9 +static const char xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0};
15 +xdr_int (XDR *xdrs, int *ip)
18 +#if INT_MAX < LONG_MAX
25 + return XDR_PUTLONG (xdrs, &l);
28 + if (!XDR_GETLONG (xdrs, &l))
37 +#elif INT_MAX == LONG_MAX
38 + return xdr_long (xdrs, (long *) ip);
39 +#elif INT_MAX == SHRT_MAX
40 + return xdr_short (xdrs, (short *) ip);
42 +#error unexpected integer sizes in xdr_int()
47 + * XDR null terminated ASCII strings
48 + * xdr_string deals with "C strings" - arrays of bytes that are
49 + * terminated by a NULL character. The parameter cpp references a
50 + * pointer to storage; If the pointer is null, then the necessary
51 + * storage is allocated. The last parameter is the max allowed length
52 + * of the string as specified by a protocol.
55 +xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
57 + char *sp = *cpp; /* sp is the actual string pointer */
62 + * first deal with the length since xdr strings are counted-strings
69 + return TRUE; /* already free */
71 + /* fall through... */
80 + if (!xdr_u_int (xdrs, &size))
88 + nodesize = size + 1;
91 + * now deal with the actual bytes
101 + *cpp = sp = (char *) mem_alloc (nodesize);
105 + if (_IO_fwide (stderr, 0) > 0)
106 + (void) fwprintf (stderr, L"%s",
107 + _("xdr_string: out of memory\n"));
110 + (void) fputs (_("xdr_string: out of memory\n"), stderr);
114 + /* fall into ... */
117 + return xdr_opaque (xdrs, sp, size);
120 + mem_free (sp, nodesize);
128 + * XDR long integers
129 + * The definition of xdr_long() is kept for backward
130 + * compatibility. Instead xdr_int() should be used.
133 +xdr_long (XDR *xdrs, long *lp)
135 + if (xdrs->x_op == XDR_ENCODE
136 + && (sizeof (int32_t) == sizeof (long)
137 + || (int32_t) *lp == *lp))
138 + return XDR_PUTLONG (xdrs, lp);
140 + if (xdrs->x_op == XDR_DECODE)
141 + return XDR_GETLONG (xdrs, lp);
143 + if (xdrs->x_op == XDR_FREE)
150 + * XDR unsigned integers
153 +xdr_u_int (XDR *xdrs, u_int *up)
155 +#if UINT_MAX < ULONG_MAX
158 + switch (xdrs->x_op)
162 + return XDR_PUTLONG (xdrs, (long *) &l);
165 + if (!XDR_GETLONG (xdrs, (long *) &l))
174 +#elif UINT_MAX == ULONG_MAX
175 + return xdr_u_long (xdrs, (u_long *) up);
176 +#elif UINT_MAX == USHRT_MAX
177 + return xdr_short (xdrs, (short *) up);
179 +#error unexpected integer sizes in xdr_u_int()
185 + * Allows the specification of a fixed size sequence of opaque bytes.
186 + * cp points to the opaque object and cnt gives the byte length.
189 +xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt)
192 + static char crud[BYTES_PER_XDR_UNIT];
195 + * if no data we are done
201 + * round byte count to full xdr units
203 + rndup = cnt % BYTES_PER_XDR_UNIT;
205 + rndup = BYTES_PER_XDR_UNIT - rndup;
207 + switch (xdrs->x_op)
210 + if (!XDR_GETBYTES (xdrs, cp, cnt))
216 + return XDR_GETBYTES (xdrs, (caddr_t)crud, rndup);
219 + if (!XDR_PUTBYTES (xdrs, cp, cnt))
225 + return XDR_PUTBYTES (xdrs, xdr_zero, rndup);
234 + * XDR unsigned long integers
235 + * The definition of xdr_u_long() is kept for backward
236 + * compatibility. Instead xdr_u_int() should be used.
239 +xdr_u_long (XDR *xdrs, u_long *ulp)
241 + switch (xdrs->x_op)
247 + if (XDR_GETLONG (xdrs, &tmp) == FALSE)
250 + *ulp = (uint32_t) tmp;
255 + if (sizeof (uint32_t) != sizeof (u_long)
256 + && (uint32_t) *ulp != *ulp)
259 + return XDR_PUTLONG (xdrs, (long *) ulp);
270 xdr_xpasswd(XDR * xdrs, xpasswd * objp)