Commit | Line | Data |
---|---|---|
805e021f CE |
1 | /* |
2 | * Copyright 2000, International Business Machines Corporation and others. | |
3 | * All Rights Reserved. | |
4 | * | |
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 | */ | |
9 | ||
10 | #include <afsconfig.h> | |
11 | #include <afs/param.h> | |
12 | ||
13 | #include <roken.h> | |
14 | ||
15 | #include <rx/xdr.h> | |
16 | #include <afs/kauth.h> | |
17 | ||
18 | #define MAXBS 2048 /* try to avoid horrible allocs */ | |
19 | ||
20 | int | |
21 | xdr_ka_CBS(XDR * x, struct ka_CBS *abbs) | |
22 | { | |
23 | afs_int32 len; | |
24 | if (x->x_op == XDR_FREE) { | |
25 | free(abbs->SeqBody); | |
26 | return TRUE; | |
27 | } | |
28 | ||
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; | |
42 | } | |
43 | } | |
44 | ||
45 | int | |
46 | xdr_ka_BBS(XDR * x, struct ka_BBS *abbs) | |
47 | { | |
48 | afs_int32 maxLen, len; | |
49 | if (x->x_op == XDR_FREE) { | |
50 | free(abbs->SeqBody); | |
51 | return TRUE; | |
52 | } | |
53 | ||
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; | |
71 | } | |
72 | } |