1 --- a/Linux-PAM-1.1.4/modules/pam_unix/yppasswd_xdr.c
2 +++ b/Linux-PAM-1.1.4/modules/pam_unix/yppasswd_xdr.c
3 2011-10-01 13:46:21.599443197 +0300
10 +static const char xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0};
16 +xdr_int (XDR *xdrs, int *ip)
19 +#if INT_MAX < LONG_MAX
26 + return XDR_PUTLONG (xdrs, &l);
29 + if (!XDR_GETLONG (xdrs, &l))
38 +#elif INT_MAX == LONG_MAX
39 + return xdr_long (xdrs, (long *) ip);
40 +#elif INT_MAX == SHRT_MAX
41 + return xdr_short (xdrs, (short *) ip);
43 +#error unexpected integer sizes in xdr_int()
48 + * XDR null terminated ASCII strings
49 + * xdr_string deals with "C strings" - arrays of bytes that are
50 + * terminated by a NULL character. The parameter cpp references a
51 + * pointer to storage; If the pointer is null, then the necessary
52 + * storage is allocated. The last parameter is the max allowed length
53 + * of the string as specified by a protocol.
56 +xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
58 + char *sp = *cpp; /* sp is the actual string pointer */
63 + * first deal with the length since xdr strings are counted-strings
70 + return TRUE; /* already free */
72 + /* fall through... */
81 + if (!xdr_u_int (xdrs, &size))
89 + nodesize = size + 1;
92 + * now deal with the actual bytes
102 + *cpp = sp = (char *) mem_alloc (nodesize);
106 + if (_IO_fwide (stderr, 0) > 0)
107 + (void) fwprintf (stderr, L"%s",
108 + _("xdr_string: out of memory\n"));
111 + (void) fputs (_("xdr_string: out of memory\n"), stderr);
115 + /* fall into ... */
118 + return xdr_opaque (xdrs, sp, size);
121 + mem_free (sp, nodesize);
129 + * XDR long integers
130 + * The definition of xdr_long() is kept for backward
131 + * compatibility. Instead xdr_int() should be used.
134 +xdr_long (XDR *xdrs, long *lp)
136 + if (xdrs->x_op == XDR_ENCODE
137 + && (sizeof (int32_t) == sizeof (long)
138 + || (int32_t) *lp == *lp))
139 + return XDR_PUTLONG (xdrs, lp);
141 + if (xdrs->x_op == XDR_DECODE)
142 + return XDR_GETLONG (xdrs, lp);
144 + if (xdrs->x_op == XDR_FREE)
151 + * XDR unsigned integers
154 +xdr_u_int (XDR *xdrs, u_int *up)
156 +#if UINT_MAX < ULONG_MAX
159 + switch (xdrs->x_op)
163 + return XDR_PUTLONG (xdrs, (long *) &l);
166 + if (!XDR_GETLONG (xdrs, (long *) &l))
175 +#elif UINT_MAX == ULONG_MAX
176 + return xdr_u_long (xdrs, (u_long *) up);
177 +#elif UINT_MAX == USHRT_MAX
178 + return xdr_short (xdrs, (short *) up);
180 +#error unexpected integer sizes in xdr_u_int()
186 + * Allows the specification of a fixed size sequence of opaque bytes.
187 + * cp points to the opaque object and cnt gives the byte length.
190 +xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt)
193 + static char crud[BYTES_PER_XDR_UNIT];
196 + * if no data we are done
202 + * round byte count to full xdr units
204 + rndup = cnt % BYTES_PER_XDR_UNIT;
206 + rndup = BYTES_PER_XDR_UNIT - rndup;
208 + switch (xdrs->x_op)
211 + if (!XDR_GETBYTES (xdrs, cp, cnt))
217 + return XDR_GETBYTES (xdrs, (caddr_t)crud, rndup);
220 + if (!XDR_PUTBYTES (xdrs, cp, cnt))
226 + return XDR_PUTBYTES (xdrs, xdr_zero, rndup);
235 + * XDR unsigned long integers
236 + * The definition of xdr_u_long() is kept for backward
237 + * compatibility. Instead xdr_u_int() should be used.
240 +xdr_u_long (XDR *xdrs, u_long *ulp)
242 + switch (xdrs->x_op)
248 + if (XDR_GETLONG (xdrs, &tmp) == FALSE)
251 + *ulp = (uint32_t) tmp;
256 + if (sizeof (uint32_t) != sizeof (u_long)
257 + && (uint32_t) *ulp != *ulp)
260 + return XDR_PUTLONG (xdrs, (long *) ulp);
271 xdr_xpasswd(XDR * xdrs, xpasswd * objp)