summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5/asn.1/err2kerr.c
blob: f25f65ed53a7da7835c3e53e8b3556f52744c805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * $Source$
 * $Author$
 *
 * Copyright 1989,1990 by the Massachusetts Institute of Technology.
 *
 * For copying and distribution information, please see the file
 * <krb5/copyright.h>.
 *
 * Glue between Kerberos version and ISODE 6.0 version of structures.
 */

#if !defined(lint) && !defined(SABER)
static char rcsid_err2kerr_c[] =
"$Id$";
#endif	/* lint || saber */

#include <krb5/copyright.h>
#include <krb5/krb5.h>

/*#include <time.h> */
#include <isode/psap.h>
#include <krb5/asn1.h>
#include "asn1glue.h"

#include <krb5/ext-proto.h>

/* ISODE defines max(a,b) */

krb5_error *
KRB5_KRB__ERROR2krb5_error(val, error)
const register struct type_KRB5_KRB__ERROR *val;
register int *error;
{
    register krb5_error *retval;
    krb5_data *temp;

    retval = (krb5_error *)xmalloc(sizeof(*retval));
    if (!retval) {
	*error = ENOMEM;
	return(0);
    }
    xbzero(retval, sizeof(*retval));


    if (val->ctime) {
	retval->ctime = gentime2unix(val->ctime, error);
	if (*error) {
	errout:
	    krb5_free_error(retval);
	    return(0);
	}	
    }
    if (val->optionals & opt_KRB5_KRB__ERROR_cmsec)
	retval->cmsec = val->cmsec;
    else
	retval->cmsec = 0;

    retval->stime = gentime2unix(val->stime, error);
    if (*error) {
	goto errout;
    }	
    retval->smsec = val->smsec;
    retval->error = val->error__code;
    if (val->crealm && val->cname) {
	retval->client = KRB5_PrincipalName2krb5_principal(val->cname,
							   val->crealm,
							   error);
	if (!retval->client) {
	    goto errout;
	}
    }
    if (val->sname && val->realm) {
	retval->server = KRB5_PrincipalName2krb5_principal(val->sname,
							   val->realm,
							   error);
	if (!retval->server) {
	    goto errout;
	}
    }
    if (val->e__text) {
	temp = qbuf2krb5_data(val->e__text, error);
	if (temp) {
	    retval->text = *temp;
	    xfree(temp);
	} else {
	    goto errout;
	}
    }
    if (val->e__data) {
	temp = qbuf2krb5_data(val->e__text, error);
	if (temp) {
	    retval->text = *temp;
	    xfree(temp);
	} else {
	    goto errout;
	}
    }
    return(retval);
}