From 71d231627af7a203f742c2b730120af300cb2e15 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Tue, 12 Sep 1995 00:56:25 +0000 Subject: [PATCH] Reinstate previous changes that were lost git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6762 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/stdio/scc.h | 2 +- src/lib/krb5/ccache/stdio/scc_maybe.c | 26 ++++++++++++++++++++++---- src/lib/krb5/ccache/stdio/scc_read.c | 10 ++++------ src/lib/krb5/ccache/stdio/scc_write.c | 7 +++---- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/lib/krb5/ccache/stdio/scc.h b/src/lib/krb5/ccache/stdio/scc.h index 5fed5330a..6212adc14 100644 --- a/src/lib/krb5/ccache/stdio/scc.h +++ b/src/lib/krb5/ccache/stdio/scc.h @@ -46,7 +46,7 @@ * some overriding compatibility reasons not to do so. */ -#define KRB5_SCC_FVNO_1 0x0501 /* krb v5, scc v1 */ +#define KRB5_SCC_FVNO_1 0x0501 /* krb v5, scc v1 */ #define KRB5_SCC_FVNO_2 0x0502 /* krb v5, scc v2 */ #define KRB5_SCC_FVNO_3 0x0503 /* krb v5, scc v3 */ #define KRB5_SCC_FVNO_4 0x0504 /* krb v5, scc v4 */ diff --git a/src/lib/krb5/ccache/stdio/scc_maybe.c b/src/lib/krb5/ccache/stdio/scc_maybe.c index f6e008ddd..706b10bf9 100644 --- a/src/lib/krb5/ccache/stdio/scc_maybe.c +++ b/src/lib/krb5/ccache/stdio/scc_maybe.c @@ -164,12 +164,30 @@ krb5_scc_open_file (context, id, mode) data->version = (fvno_bytes[0] << 8) + fvno_bytes[1]; if ((data->version != KRB5_SCC_FVNO_1) && (data->version != KRB5_SCC_FVNO_2) && - (data->version != KRB5_SCC_FVNO_3)) { + (data->version != KRB5_SCC_FVNO_3) && + (data->version != KRB5_SCC_FVNO_4)) { (void) krb5_unlock_file(context, fileno(f)); (void) fclose(f); return KRB5_CCACHE_BADVNO; } - } - data->file = f; - return 0; + if (data->version == KRB5_SCC_FVNO_4) { + char buf[1024]; + int len; + + if (!fread((char *)fvno_bytes, sizeof(fvno_bytes), 1, f)) { + (void) krb5_unlock_file(context, fileno(f)); + (void) fclose(f); + return KRB5_CCACHE_BADVNO; + } + if (len = (fvno_bytes[0] << 8) + fvno_bytes[1]) { + if (!fread(buf, len, 1, f)) { + (void) krb5_unlock_file(context, fileno(f)); + (void) fclose(f); + return KRB5_CCACHE_BADVNO; + } + } + } + } + data->file = f; + return 0; } diff --git a/src/lib/krb5/ccache/stdio/scc_read.c b/src/lib/krb5/ccache/stdio/scc_read.c index 88bf62011..de297949d 100644 --- a/src/lib/krb5/ccache/stdio/scc_read.c +++ b/src/lib/krb5/ccache/stdio/scc_read.c @@ -197,14 +197,12 @@ krb5_scc_read_keyblock(context, id, keyblock) keyblock->contents = 0; kret = krb5_scc_read_ui_2(context, id, &ui2); - keyblock->keytype = ui2; + keyblock->enctype = ui2; CHECK(kret); - if ((data->version == KRB5_SCC_FVNO_1) || - (data->version == KRB5_SCC_FVNO_2)) - keyblock->etype = ETYPE_UNKNOWN; - else { + if (data->version == KRB5_SCC_FVNO_3) { + /* This works because the old etype is the same as the new enctype. */ kret = krb5_scc_read_ui_2(context, id, &ui2); - keyblock->etype = ui2; + keyblock->enctype = ui2; CHECK(kret); } diff --git a/src/lib/krb5/ccache/stdio/scc_write.c b/src/lib/krb5/ccache/stdio/scc_write.c index 9226bb1f6..3c552004a 100644 --- a/src/lib/krb5/ccache/stdio/scc_write.c +++ b/src/lib/krb5/ccache/stdio/scc_write.c @@ -148,11 +148,10 @@ krb5_scc_store_keyblock(context, id, keyblock) krb5_scc_data *data = (krb5_scc_data *)id->data; krb5_error_code ret; - ret = krb5_scc_store_ui_2(context, id, keyblock->keytype); + ret = krb5_scc_store_ui_2(context, id, keyblock->enctype); CHECK(ret); - if ((data->version != KRB5_SCC_FVNO_1) && - (data->version != KRB5_SCC_FVNO_2)) { - ret = krb5_scc_store_ui_2(context, id, keyblock->etype); + if (data->version == KRB5_SCC_FVNO_3) { + ret = krb5_scc_store_ui_2(context, id, keyblock->enctype); CHECK(ret); } ret = krb5_scc_store_int32(context, id, keyblock->length); -- 2.26.2