xbzero(retval, sizeof(*retval));
retval->authenticator__vno = KRB5_PVNO;
- retval->crealm = krb5_data2qbuf(val->client[0]);
+ retval->crealm = krb5_data2qbuf(krb5_princ_realm(val->client));
if (!retval->crealm) {
*error = ENOMEM;
errout:
goto errout;
}
}
- retval->srealm = krb5_data2qbuf(val->server[0]);
+ retval->srealm = krb5_data2qbuf(krb5_princ_realm(val->server));
if (!retval->srealm) {
*error = ENOMEM;
goto errout;
retval->error__code = val->error;
if (val->client) {
- retval->crealm = krb5_data2qbuf(val->client[0]);
+ retval->crealm = krb5_data2qbuf(krb5_princ_realm(val->client));
if (!retval->crealm) {
*error = ENOMEM;
goto errout;
/* server is technically not optional, but... */
if (val->server) {
- retval->realm = krb5_data2qbuf(val->server[0]);
+ retval->realm = krb5_data2qbuf(krb5_princ_realm(val->server));
if (!retval->realm) {
*error = ENOMEM;
goto errout;
free_KRB5_EncTicketPart(retval);
return(0);
}
- retval->crealm = krb5_data2qbuf(val->client[0]);
+ retval->crealm = krb5_data2qbuf(krb5_princ_realm(val->client));
if (!retval->crealm) {
*error = ENOMEM;
goto errout;
#include <krb5/ext-proto.h>
-/* ISODE defines max(a,b) */
-
struct type_KRB5_TGS__REP *
krb5_kdc_rep2KRB5_KDC__REP(DECLARG(const register krb5_kdc_rep *,val),
DECLARG(register int *,error))
}
}
- retval->crealm = krb5_data2qbuf(val->client[0]);
+ retval->crealm = krb5_data2qbuf(krb5_princ_realm(val->client));
if (!retval->crealm) {
*error = ENOMEM;
errout:
#endif
register struct type_KRB5_PrincipalName *retval = 0, *rv1 = 0, *rv2;
register int i;
+ int nelem = krb5_princ_size(val);
+
/* still skipping realm */
- for (i = 1; val[i]; i++, rv1 = rv2) {
+ for (i = 0; i < nelem; i++, rv1 = rv2) {
rv2 = (struct type_KRB5_PrincipalName *) xmalloc(sizeof(*rv2));
if (!rv2) {
if (retval)
if (!retval)
retval = rv2;
- rv2->GeneralString = krb5_data2qbuf(val[i]);
+ rv2->GeneralString = krb5_data2qbuf(krb5_princ_component(val, i));
if (!rv2->GeneralString) {
/* clean up */
if (retval)
goto errout;
}
}
- retval->realm = krb5_data2qbuf(val->server[0]);
+ retval->realm = krb5_data2qbuf(krb5_princ_realm(val->server));
if (!retval->realm) {
*error = ENOMEM;
goto errout;
xbzero(retval, sizeof(*retval));
retval->tkt__vno = KRB5_PVNO;
- retval->realm = krb5_data2qbuf(val->server[0]);
+ retval->realm = krb5_data2qbuf(krb5_princ_realm(val->server));
if (!retval->realm) {
*error = ENOMEM;
errout:
#include <krb5/ext-proto.h>
-/* ISODE defines max(a,b) */
+static int qbuf_to_data(val, data)
+register const struct qbuf *val;
+krb5_data *data;
+{
+ int length;
+ if (qb_pullup(val) != OK)
+ return 1;
+ if ((length = val->qb_forw->qb_len) > 0) {
+ data->data = malloc(length);
+ memcpy(data->data, val->qb_forw->qb_data, length);
+ } else {
+ data->data = 0;
+ }
+ data->length = length;
+ return 0;
+}
+
krb5_principal
KRB5_PrincipalName2krb5_principal(val, realm, error)
for (i = 1, rv = val; rv->next; i++, rv = rv->next)
;
- /* plus one for the realm, plus one for null term */
- retval = (krb5_principal) xcalloc(i + 2, sizeof(krb5_data *));
-
+ retval = (krb5_principal) malloc(sizeof(krb5_principal_data));
+
if (!retval) {
*error = ENOMEM;
return(0);
}
+ /* plus one for the realm */
+ retval->length = i;
+ retval->data = (krb5_data *)malloc(i * sizeof(krb5_data));
+ if (retval->data == 0) {
+ xfree(retval);
+ *error = ENOMEM;
+ return 0;
+ }
- retval[0] = qbuf2krb5_data(realm, error);
- if (!retval[0]) {
+ if (qbuf_to_data(realm, krb5_princ_realm(retval))) {
+ xfree(retval->data);
xfree(retval);
- return(0);
+ *error = ENOMEM;
+ return 0;
}
- for (i = 1, rv = val; rv; rv = rv->next, i++) {
- retval[i] = qbuf2krb5_data(rv->GeneralString, error);
- if (!retval[i]) {
- krb5_free_principal(retval);
+
+ for (i = 0, rv = val; rv; rv = rv->next, i++)
+ if (qbuf_to_data(rv->GeneralString, krb5_princ_component(retval, i))) {
+ while (--i >= 0)
+ free(krb5_princ_component(retval, i)->data);
+ *error = ENOMEM;
return(0);
}
- }
- retval[i] = 0;
return(retval);
}