From 617a82a0a5621675d52c6479607ae3f32a0c1df3 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Wed, 1 Apr 2015 19:25:55 -0500 Subject: [PATCH] Fix ENOENT msg clobbering in fcache.c By not returning the same error code as we were setting on the context, the error message was subsequently lost. --- lib/krb5/fcache.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/krb5/fcache.c b/lib/krb5/fcache.c index 0747bb131..10c5de1f4 100644 --- a/lib/krb5/fcache.c +++ b/lib/krb5/fcache.c @@ -426,7 +426,7 @@ again: return EPERM; } } else if (errno != ENOENT || !(flags & O_CREAT)) { - krb5_set_error_message(context, ret, N_("%s lstat(%s)", "file, error"), + krb5_set_error_message(context, errno, N_("%s lstat(%s)", "file, error"), operation, filename); return errno; } @@ -570,8 +570,8 @@ fcc_initialize(krb5_context context, char buf[128]; ret = errno; rk_strerror_r(ret, buf, sizeof(buf)); - krb5_set_error_message (context, ret, N_("close %s: %s", ""), - FILENAME(id), buf); + krb5_set_error_message(context, ret, N_("close %s: %s", ""), + FILENAME(id), buf); } return ret; } @@ -627,8 +627,8 @@ fcc_store_cred(krb5_context context, char buf[128]; rk_strerror_r(ret, buf, sizeof(buf)); ret = errno; - krb5_set_error_message (context, ret, N_("close %s: %s", ""), - FILENAME(id), buf); + krb5_set_error_message(context, ret, N_("close %s: %s", ""), + FILENAME(id), buf); } } return ret; @@ -662,7 +662,7 @@ init_fcc(krb5_context context, } krb5_storage_set_eof_code(sp, KRB5_CC_END); ret = krb5_ret_int8(sp, &pvno); - if(ret != 0) { + if (ret != 0) { if(ret == KRB5_CC_END) { ret = ENOENT; krb5_set_error_message(context, ret, @@ -674,7 +674,7 @@ init_fcc(krb5_context context, FILENAME(id)); goto out; } - if(pvno != 5) { + if (pvno != 5) { ret = KRB5_CCACHE_BADVNO; krb5_set_error_message(context, ret, N_("Bad version number in credential " "cache file: %s", ""), @@ -682,7 +682,7 @@ init_fcc(krb5_context context, goto out; } ret = krb5_ret_int8(sp, &tag); /* should not be host byte order */ - if(ret != 0) { + if (ret != 0) { ret = KRB5_CC_FORMAT; krb5_set_error_message(context, ret, "Error reading tag in " "cache file: %s", FILENAME(id)); @@ -1009,13 +1009,8 @@ out: if (fd > -1) { fcc_unlock(context, fd); if (close(fd) < 0 && ret == 0) { - char buf[128]; - - /* This error might be useful */ - rk_strerror_r(ret, buf, sizeof(buf)); - ret = errno; - krb5_set_error_message(context, ret, N_("close %s: %s", ""), - FILENAME(id), buf); + krb5_set_error_message(context, errno, N_("close %s", ""), + FILENAME(id)); } } krb5_data_free(&orig_cred_data); -- 2.11.4.GIT