From 8826dba03eee26cdc484bef9e528b756ed2cda55 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Tue, 12 Feb 1991 14:01:43 +0000 Subject: [PATCH] add file format version code git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1665 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/stdio/scc_gennew.c | 15 ++++++++++++++- src/lib/krb5/ccache/stdio/scc_gprin.c | 5 +++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/lib/krb5/ccache/stdio/scc_gennew.c b/src/lib/krb5/ccache/stdio/scc_gennew.c index 9a98d71f6..1296f5c8e 100644 --- a/src/lib/krb5/ccache/stdio/scc_gennew.c +++ b/src/lib/krb5/ccache/stdio/scc_gennew.c @@ -76,7 +76,20 @@ krb5_scc_generate_new (id) if (!f) return krb5_scc_interpret (errno); else { - fclose(f); + krb5_int16 scc_fvno = htons(KRB5_SCC_FVNO); + int errsave; + + if (!fwrite((char *)&scc_fvno, sizeof(scc_fvno), 1, f)) { + errsave = errno; + (void) fclose(f); + (void) remove(((krb5_scc_data *) lid->data)->filename); + return krb5_scc_interpret(errsave); + } + if (fclose(f) == EOF) { + errsave = errno; + (void) remove(((krb5_scc_data *) lid->data)->filename); + return krb5_scc_interpret(errsave); + } *id = lid; return KRB5_OK; } diff --git a/src/lib/krb5/ccache/stdio/scc_gprin.c b/src/lib/krb5/ccache/stdio/scc_gprin.c index 7b8dad889..87e05da47 100644 --- a/src/lib/krb5/ccache/stdio/scc_gprin.c +++ b/src/lib/krb5/ccache/stdio/scc_gprin.c @@ -37,8 +37,9 @@ krb5_scc_get_principal(id, princ) { krb5_error_code kret; - MAYBE_OPEN (id, "r"); - fseek(((krb5_scc_data *) id->data)->file, 0, 0); + MAYBE_OPEN (id, SCC_OPEN_RDONLY); + /* skip over vno at beginning of file */ + fseek(((krb5_scc_data *) id->data)->file, sizeof(krb5_int16), 0); kret = krb5_scc_read_principal(id, princ); -- 2.26.2