From: Ken Raeburn Date: Tue, 20 Jun 2006 23:27:01 +0000 (+0000) Subject: (kadmin_cpw): Don't crash if principal name is not given. Based on a X-Git-Tag: krb5-1.6-alpha1~285 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=95d68c2a356ea86513446d24cd46facbcc0c8fef;p=krb5.git (kadmin_cpw): Don't crash if principal name is not given. Based on a patch from S Rahul. (extended_com_err_fn): If error code is zero, don't fetch an error message. ticket: 3308 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18179 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/cli/kadmin.c b/src/kadmin/cli/kadmin.c index e7594170d..64b4c3f1c 100644 --- a/src/kadmin/cli/kadmin.c +++ b/src/kadmin/cli/kadmin.c @@ -176,10 +176,14 @@ kadmin_parse_name(name, principal) static void extended_com_err_fn (const char *myprog, errcode_t code, const char *fmt, va_list args) { - const char *emsg; - emsg = krb5_get_error_message (context, code); - fprintf (stderr, "%s: %s ", myprog, emsg); - krb5_free_error_message (context, emsg); + if (code) { + const char *emsg; + emsg = krb5_get_error_message (context, code); + fprintf (stderr, "%s: %s ", myprog, emsg); + krb5_free_error_message (context, emsg); + } else { + fprintf (stderr, "%s: ", myprog); + } vfprintf (stderr, fmt, args); fprintf (stderr, "\n"); } @@ -725,6 +729,10 @@ void kadmin_cpw(argc, argv) } goto usage; } + if (*argv == NULL) { + com_err("change_password", 0, "missing principal name"); + goto usage; + } retval = kadmin_parse_name(*argv, &princ); if (retval) { com_err("change_password", retval, "while parsing principal name");