From: Tom Yu Date: Wed, 24 Nov 2004 01:28:03 +0000 (+0000) Subject: set errno=0 prior to fopen in kt_file X-Git-Tag: ms-bug-test-20060525~443 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=30f0fa1e2ef25e2c43105606ce2e663956990695;p=krb5.git set errno=0 prior to fopen in kt_file * kt_file.c (krb5_ktfileint_open): Update previous change by explicitly setting errno=0 prior to calling fopen(). Also, return EMFILE, not ENFILE, for compatibility with Solaris 8, which does set errno when out of file descriptors. ticket: new target_version: 1.4 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16904 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/keytab/ChangeLog b/src/lib/krb5/keytab/ChangeLog index 4b62fddb7..cf203ff84 100644 --- a/src/lib/krb5/keytab/ChangeLog +++ b/src/lib/krb5/keytab/ChangeLog @@ -1,3 +1,10 @@ +2004-11-23 Tom Yu + + * kt_file.c (krb5_ktfileint_open): Update previous change by + explicitly setting errno=0 prior to calling fopen(). Also, return + EMFILE, not ENFILE, for compatibility with Solaris 8, which does + set errno when out of file descriptors. + 2004-11-19 Tom Yu * kt_file.c (krb5_ktfileint_open): Patch from Roland Dowdeswell to diff --git a/src/lib/krb5/keytab/kt_file.c b/src/lib/krb5/keytab/kt_file.c index d39fc0b3d..580302e50 100644 --- a/src/lib/krb5/keytab/kt_file.c +++ b/src/lib/krb5/keytab/kt_file.c @@ -999,6 +999,7 @@ krb5_ktfileint_open(krb5_context context, krb5_keytab id, int mode) krb5_kt_vno kt_vno; int writevno = 0; + errno = 0; KTFILEP(id) = fopen(KTFILENAME(id), (mode == KRB5_LOCKMODE_EXCLUSIVE) ? fopen_mode_rbplus : fopen_mode_rb); @@ -1006,12 +1007,13 @@ krb5_ktfileint_open(krb5_context context, krb5_keytab id, int mode) if ((mode == KRB5_LOCKMODE_EXCLUSIVE) && (errno == ENOENT)) { /* try making it first time around */ krb5_create_secure_file(context, KTFILENAME(id)); + errno = 0; KTFILEP(id) = fopen(KTFILENAME(id), fopen_mode_rbplus); if (!KTFILEP(id)) - return errno ? errno : ENFILE; + return errno ? errno : EMFILE; writevno = 1; } else /* some other error */ - return errno ? errno : ENFILE; + return errno ? errno : EMFILE; } if ((kerror = krb5_lock_file(context, fileno(KTFILEP(id)), mode))) { (void) fclose(KTFILEP(id));