From efbd8d58ccaa71c8d22a73ba853a35cf271c47f6 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Thu, 6 Jul 2006 15:49:31 +0000 Subject: [PATCH] Ensure that we don't accidentally attempt to use or fclose() a file which we have already fclose()d. --- krb5-1.5-fclose.patch | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 krb5-1.5-fclose.patch diff --git a/krb5-1.5-fclose.patch b/krb5-1.5-fclose.patch new file mode 100644 index 0000000..743b24a --- /dev/null +++ b/krb5-1.5-fclose.patch @@ -0,0 +1,40 @@ +Ensure that we don't accidentally attempt to use or fclose() a file which we +have already fclose()d. + +--- krb5-1.5/src/lib/krb5/keytab/kt_file.c 2006-06-13 10:14:27.000000000 -0400 ++++ krb5-1.5/src/lib/krb5/keytab/kt_file.c 2006-07-05 14:55:11.000000000 -0400 +@@ -1083,29 +1083,32 @@ + if (writevno) { + kt_vno = htons(krb5_kt_default_vno); + KTVERSION(id) = krb5_kt_default_vno; + if (!xfwrite(&kt_vno, sizeof(kt_vno), 1, KTFILEP(id))) { +- kerror = errno; ++ kerror = errno ? errno : EIO; + (void) krb5_unlock_file(context, fileno(KTFILEP(id))); + (void) fclose(KTFILEP(id)); ++ KTFILEP(id) = 0; + return kerror; + } + } else { + /* gotta verify it instead... */ + if (!xfread(&kt_vno, sizeof(kt_vno), 1, KTFILEP(id))) { + if (feof(KTFILEP(id))) + kerror = KRB5_KEYTAB_BADVNO; + else +- kerror = errno; ++ kerror = errno ? errno : EIO; + (void) krb5_unlock_file(context, fileno(KTFILEP(id))); + (void) fclose(KTFILEP(id)); ++ KTFILEP(id) = 0; + return kerror; + } + kt_vno = KTVERSION(id) = ntohs(kt_vno); + if ((kt_vno != KRB5_KT_VNO) && + (kt_vno != KRB5_KT_VNO_1)) { + (void) krb5_unlock_file(context, fileno(KTFILEP(id))); + (void) fclose(KTFILEP(id)); ++ KTFILEP(id) = 0; + return KRB5_KEYTAB_BADVNO; + } + } + return 0;