From 7143f3daeaebca9839771ee36bf7b4ee1d11a3ac Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Mon, 1 Nov 2010 15:19:00 +0000 Subject: [PATCH] krb5_get_error_message cannot return NULL, and returns "Success" on error code 0. Simplify some overly paranoid code accordingly. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24489 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/dbutil/dump.c | 28 ++++------------------------ src/kdc/kdc_authdata.c | 20 ++++++++------------ src/kdc/kdc_preauth.c | 10 ++++------ src/lib/kadm5/srv/kadm5_hook.c | 6 ++---- src/lib/krb5/krb/fast.c | 8 +++----- src/lib/krb5/os/trace.c | 3 +-- 6 files changed, 22 insertions(+), 53 deletions(-) diff --git a/src/kadmin/dbutil/dump.c b/src/kadmin/dbutil/dump.c index caff137a4..0e1b60959 100644 --- a/src/kadmin/dbutil/dump.c +++ b/src/kadmin/dbutil/dump.c @@ -2514,18 +2514,8 @@ load_db(argc, argv) if((kret = krb5_db_create(kcontext, db5util_db_args))) { const char *emsg = krb5_get_error_message(kcontext, kret); - /* - * See if something (like DAL KDB plugin) has set a specific error - * message and use that otherwise use default. - */ - - if (emsg != NULL) { - fprintf(stderr, "%s: %s\n", progname, emsg); - krb5_free_error_message (kcontext, emsg); - } else { - fprintf(stderr, dbcreaterr_fmt, - progname, dbname, error_message(kret)); - } + fprintf(stderr, "%s: %s\n", progname, emsg); + krb5_free_error_message (kcontext, emsg); exit_status++; if (dumpfile) fclose(f); return; @@ -2538,18 +2528,8 @@ load_db(argc, argv) if ((kret = krb5_db_open(kcontext, db5util_db_args, KRB5_KDB_OPEN_RW | KRB5_KDB_SRV_TYPE_ADMIN))) { const char *emsg = krb5_get_error_message(kcontext, kret); - /* - * See if something (like DAL KDB plugin) has set a specific - * error message and use that otherwise use default. - */ - - if (emsg != NULL) { - fprintf(stderr, "%s: %s\n", progname, emsg); - krb5_free_error_message (kcontext, emsg); - } else { - fprintf(stderr, dbinit_err_fmt, - progname, error_message(kret)); - } + fprintf(stderr, "%s: %s\n", progname, emsg); + krb5_free_error_message (kcontext, emsg); exit_status++; goto error; } diff --git a/src/kdc/kdc_authdata.c b/src/kdc/kdc_authdata.c index a4f81a60a..5861e7048 100644 --- a/src/kdc/kdc_authdata.c +++ b/src/kdc/kdc_authdata.c @@ -291,12 +291,10 @@ load_authdata_plugins(krb5_context context) ((initerr = (*server_init_proc)(context, &pctx)) != 0)) { const char *emsg; emsg = krb5_get_error_message(context, initerr); - if (emsg) { - krb5_klog_syslog(LOG_ERR, - "authdata %s failed to initialize: %s", - ftable->name, emsg); - krb5_free_error_message(context, emsg); - } + krb5_klog_syslog(LOG_ERR, + "authdata %s failed to initialize: %s", + ftable->name, emsg); + krb5_free_error_message(context, emsg); memset(&authdata_systems[k], 0, sizeof(authdata_systems[k])); continue; @@ -329,12 +327,10 @@ load_authdata_plugins(krb5_context context) ((initerr = (*server_init_proc)(context, &pctx)) != 0)) { const char *emsg; emsg = krb5_get_error_message(context, initerr); - if (emsg) { - krb5_klog_syslog(LOG_ERR, - "authdata %s failed to initialize: %s", - ftable->name, emsg); - krb5_free_error_message(context, emsg); - } + krb5_klog_syslog(LOG_ERR, + "authdata %s failed to initialize: %s", + ftable->name, emsg); + krb5_free_error_message(context, emsg); memset(&authdata_systems[k], 0, sizeof(authdata_systems[k])); continue; diff --git a/src/kdc/kdc_preauth.c b/src/kdc/kdc_preauth.c index 52fb51a0c..397155542 100644 --- a/src/kdc/kdc_preauth.c +++ b/src/kdc/kdc_preauth.c @@ -471,12 +471,10 @@ load_preauth_plugins(krb5_context context) if (initerr) { const char *emsg; emsg = krb5_get_error_message(context, initerr); - if (emsg) { - krb5_klog_syslog(LOG_ERR, - "preauth %s failed to initialize: %s", - ftable->name, emsg); - krb5_free_error_message(context, emsg); - } + krb5_klog_syslog(LOG_ERR, + "preauth %s failed to initialize: %s", + ftable->name, emsg); + krb5_free_error_message(context, emsg); memset(&preauth_systems[k], 0, sizeof(preauth_systems[k])); diff --git a/src/lib/kadm5/srv/kadm5_hook.c b/src/lib/kadm5/srv/kadm5_hook.c index 386715d72..73016c8bd 100644 --- a/src/lib/kadm5/srv/kadm5_hook.c +++ b/src/lib/kadm5/srv/kadm5_hook.c @@ -117,10 +117,8 @@ log_failure(krb5_context context, { const char *e = krb5_get_error_message(context, ret); - if (e) { - krb5_klog_syslog(LOG_ERR, "kadm5_hook %s failed postcommit %s: %s", - name, function, e); - } + krb5_klog_syslog(LOG_ERR, "kadm5_hook %s failed postcommit %s: %s", + name, function, e); krb5_free_error_message(context, e); } diff --git a/src/lib/krb5/krb/fast.c b/src/lib/krb5/krb/fast.c index 50321cc86..cc9f899a7 100644 --- a/src/lib/krb5/krb/fast.c +++ b/src/lib/krb5/krb/fast.c @@ -182,11 +182,9 @@ krb5int_fast_as_armor(krb5_context context, if (retval != 0) { const char * errmsg; errmsg = krb5_get_error_message(context, retval); - if (errmsg) { - krb5_set_error_message(context, retval, - "%s constructing AP-REQ armor", errmsg); - krb5_free_error_message(context, errmsg); - } + krb5_set_error_message(context, retval, + "%s constructing AP-REQ armor", errmsg); + krb5_free_error_message(context, errmsg); } } if (ccache) diff --git a/src/lib/krb5/os/trace.c b/src/lib/krb5/os/trace.c index 3f31ea920..30942cd97 100644 --- a/src/lib/krb5/os/trace.c +++ b/src/lib/krb5/os/trace.c @@ -179,8 +179,7 @@ trace_format(krb5_context context, const char *fmt, va_list ap) } else if (strcmp(tmpbuf, "kerr") == 0) { kerr = va_arg(ap, krb5_error_code); p = krb5_get_error_message(context, kerr); - krb5int_buf_add_fmt(&buf, "%ld/%s", (long) kerr, - (kerr == 0) ? "success" : p); + krb5int_buf_add_fmt(&buf, "%ld/%s", (long) kerr, p); krb5_free_error_message(context, p); } else if (strcmp(tmpbuf, "keyblock") == 0) { keyblock = va_arg(ap, const krb5_keyblock *); -- 2.26.2