Merge 1.8.0~pre4 packaging into master
[pkg-k5-afs_openafs.git] / src / kauth / kaaux.c
blobeea1402a24a1b31d45831d9d34ec4894c0eb0075
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
10 #include <afsconfig.h>
11 #include <afs/param.h>
13 #include <roken.h>
15 #include <rx/xdr.h>
16 #include <afs/kauth.h>
18 #define MAXBS 2048 /* try to avoid horrible allocs */
20 int
21 xdr_ka_CBS(XDR * x, struct ka_CBS *abbs)
23 afs_int32 len;
24 if (x->x_op == XDR_FREE) {
25 free(abbs->SeqBody);
26 return TRUE;
29 if (x->x_op == XDR_ENCODE) {
30 xdr_afs_int32(x, &abbs->SeqLen);
31 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
32 return TRUE;
33 } else {
34 xdr_afs_int32(x, &len);
35 if (len < 0 || len > MAXBS)
36 return FALSE;
37 if (!abbs->SeqBody)
38 abbs->SeqBody = malloc(len);
39 abbs->SeqLen = len;
40 xdr_opaque(x, abbs->SeqBody, len);
41 return TRUE;
45 int
46 xdr_ka_BBS(XDR * x, struct ka_BBS *abbs)
48 afs_int32 maxLen, len;
49 if (x->x_op == XDR_FREE) {
50 free(abbs->SeqBody);
51 return TRUE;
54 if (x->x_op == XDR_ENCODE) {
55 if (!xdr_afs_int32(x, &abbs->MaxSeqLen)
56 || !xdr_afs_int32(x, &abbs->SeqLen)
57 || !xdr_opaque(x, abbs->SeqBody, abbs->SeqLen))
58 return FALSE;
59 return TRUE;
60 } else {
61 if (!xdr_afs_int32(x, &maxLen) || !xdr_afs_int32(x, &len) || (len < 0)
62 || (len > MAXBS) || (len > maxLen))
63 return FALSE;
64 if (!abbs->SeqBody)
65 abbs->SeqBody = malloc(maxLen);
66 abbs->MaxSeqLen = maxLen;
67 abbs->SeqLen = len;
68 if (!xdr_opaque(x, abbs->SeqBody, len))
69 return FALSE;
70 return TRUE;