summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1992-06-10 22:50:57 +0000
committerTheodore Tso <tytso@mit.edu>1992-06-10 22:50:57 +0000
commitbee55701e1c775bd27a0eaadc1aa79cf9507df3a (patch)
treea87dd81215a0438c0624740e433aa9f763a05365 /src/lib
parent02082d421c8e331da19b0ba349c93f0d54a49050 (diff)
downloadkrb5-bee55701e1c775bd27a0eaadc1aa79cf9507df3a.tar.gz
krb5-bee55701e1c775bd27a0eaadc1aa79cf9507df3a.tar.xz
krb5-bee55701e1c775bd27a0eaadc1aa79cf9507df3a.zip
Checked in jfc's changes to handle the new principal structure
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2296 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/krb5/ccache/stdio/scc_read.c68
-rw-r--r--src/lib/krb5/ccache/stdio/scc_write.c28
2 files changed, 47 insertions, 49 deletions
diff --git a/src/lib/krb5/ccache/stdio/scc_read.c b/src/lib/krb5/ccache/stdio/scc_read.c
index 62514fc6f..864c885fd 100644
--- a/src/lib/krb5/ccache/stdio/scc_read.c
+++ b/src/lib/krb5/ccache/stdio/scc_read.c
@@ -83,45 +83,43 @@ krb5_scc_read_principal(id, princ)
krb5_ccache id;
krb5_principal *princ;
{
- krb5_error_code kret;
- krb5_int32 length;
- int i;
-
- *princ = 0;
-
- /* Read the number of components */
- kret = krb5_scc_read_int32(id, &length);
- CHECK(kret);
-
- /*
- * The # of levels of indirection is confusing. A krb5_principal
- * is an array of pointers to krb5_data. princ is a pointer to
- * an array of pointers to krb5_data. (*princ)[i] a pointer to
- * krb5_data.
- */
+ krb5_error_code kret;
+ register krb5_principal tmpprinc;
+ krb5_int32 length;
+ int i;
+
+ /* Read the number of components */
+ kret = krb5_scc_read_int32(id, &length);
+ if (kret != KRB5_OK)
+ return kret;
+
+ tmpprinc = (krb5_principal) malloc(sizeof(krb5_principal_data));
+ if (tmpprinc == NULL)
+ return KRB5_CC_NOMEM;
+ tmpprinc->data = malloc(length * sizeof(krb5_principal_data));
+ if (tmpprinc->data == 0) {
+ free((char *)tmpprinc);
+ return KRB5_CC_NOMEM;
+ }
+ tmpprinc->length = length;
- /* Make *princ able to hold length pointers to krb5_data structs
- * Add one extra for a null-terminated list
- */
- *princ = (krb5_principal) calloc(length+1, sizeof(krb5_data *));
- if (*princ == NULL)
- return KRB5_CC_NOMEM;
+ kret = krb5_scc_read_data(id, krb5_princ_realm(tmpprinc));
+ i = 0;
+ CHECK(kret);
- for (i=0; i < length; i++) {
- (*princ)[i] = (krb5_data *) malloc(sizeof(krb5_data));
- if ((*princ)[i] == NULL) {
- krb5_free_principal(*princ);
- return KRB5_CC_NOMEM;
- }
- kret = krb5_scc_read_data(id, (*princ)[i]);
- CHECK(kret);
- }
+ for (i=0; i < length; i++) {
+ kret = krb5_scc_read_data(id, krb5_princ_component(tmpprinc, i));
+ CHECK(kret);
+ }
+ *princ = tmpprinc;
+ return KRB5_OK;
- return kret;
errout:
- if (*princ)
- krb5_free_principal(*princ);
- return kret;
+ while(--i >= 0)
+ free(krb5_princ_component(tmpprinc, i)->data);
+ free((char *)tmpprinc->data);
+ free((char *)tmpprinc);
+ return KRB5_CC_NOMEM;
}
krb5_error_code
diff --git a/src/lib/krb5/ccache/stdio/scc_write.c b/src/lib/krb5/ccache/stdio/scc_write.c
index 5db04a669..47b23af32 100644
--- a/src/lib/krb5/ccache/stdio/scc_write.c
+++ b/src/lib/krb5/ccache/stdio/scc_write.c
@@ -81,23 +81,23 @@ krb5_scc_store_principal(id, princ)
krb5_ccache id;
krb5_principal princ;
{
- krb5_error_code ret;
- krb5_principal temp;
- krb5_int32 i, length = 0;
+ krb5_error_code ret;
+ krb5_int32 i, length;
- /* Count the number of components */
- temp = princ;
- while (*temp++)
- length += 1;
+ length = krb5_princ_size(princ);
- ret = krb5_scc_store_int32(id, &length);
- CHECK(ret);
- for (i=0; i < length; i++) {
- ret = krb5_scc_store_data(id, princ[i]);
- CHECK(ret);
- }
+ ret = krb5_scc_store_int32(id, &length);
+ CHECK(ret);
- return KRB5_OK;
+ ret = krb5_scc_store_data(id, krb5_princ_realm(princ));
+ CHECK(ret);
+
+ for (i=0; i < length; i++) {
+ ret = krb5_scc_store_data(id, krb5_princ_component(princ, i));
+ CHECK(ret);
+ }
+
+ return KRB5_OK;
}
krb5_error_code