(init_fcc): provide better error codes

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21977 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-10-18 20:09:22 +00:00
parent cea8c2b309
commit 38251964e0

View File

@@ -463,9 +463,13 @@ 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 == KRB5_CC_END)
ret = ENOENT; /* empty file */
krb5_clear_error_string(context);
if(ret == KRB5_CC_END) {
krb5_set_error_string(context, "Empty credential cache file: %s",
FILENAME(id));
ret = ENOENT;
} else
krb5_set_error_string(context, "Error reading pvno in "
"cache file: %s", FILENAME(id));
goto out;
}
if(pvno != 5) {
@@ -476,7 +480,8 @@ init_fcc (krb5_context context,
}
ret = krb5_ret_int8(sp, &tag); /* should not be host byte order */
if(ret != 0) {
krb5_clear_error_string(context);
krb5_set_error_string(context, "Error reading tag in "
"cache file: %s", FILENAME(id));
ret = KRB5_CC_FORMAT;
goto out;
}
@@ -489,7 +494,8 @@ init_fcc (krb5_context context,
ret = krb5_ret_int16 (sp, &length);
if(ret) {
ret = KRB5_CC_FORMAT;
krb5_clear_error_string(context);
krb5_set_error_string(context, "Error reading tag length in "
"cache file: %s", FILENAME(id));
goto out;
}
while(length > 0) {
@@ -499,13 +505,15 @@ init_fcc (krb5_context context,
ret = krb5_ret_int16 (sp, &dtag);
if(ret) {
krb5_clear_error_string(context);
krb5_set_error_string(context, "Error reading dtag in "
"cache file: %s", FILENAME(id));
ret = KRB5_CC_FORMAT;
goto out;
}
ret = krb5_ret_int16 (sp, &data_len);
if(ret) {
krb5_clear_error_string(context);
krb5_set_error_string(context, "Error reading dlength in "
"cache file: %s", FILENAME(id));
ret = KRB5_CC_FORMAT;
goto out;
}
@@ -513,13 +521,15 @@ init_fcc (krb5_context context,
case FCC_TAG_DELTATIME :
ret = krb5_ret_int32 (sp, &context->kdc_sec_offset);
if(ret) {
krb5_clear_error_string(context);
krb5_set_error_string(context, "Error reading kdc_sec in "
"cache file: %s", FILENAME(id));
ret = KRB5_CC_FORMAT;
goto out;
}
ret = krb5_ret_int32 (sp, &context->kdc_usec_offset);
if(ret) {
krb5_clear_error_string(context);
krb5_set_error_string(context, "Error reading kdc_usec in "
"cache file: %s", FILENAME(id));
ret = KRB5_CC_FORMAT;
goto out;
}
@@ -528,7 +538,9 @@ init_fcc (krb5_context context,
for (i = 0; i < data_len; ++i) {
ret = krb5_ret_int8 (sp, &dummy);
if(ret) {
krb5_clear_error_string(context);
krb5_set_error_string(context, "Error reading unknown "
"tag in cache file: %s",
FILENAME(id));
ret = KRB5_CC_FORMAT;
goto out;
}