From bac976303a251f08b2a6df95fa54af00b22541ea Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Sun, 25 Jun 2006 22:28:12 +0000 Subject: [PATCH] pull up r18179 from trunk r18179@cathode-dark-space: raeburn | 2006-06-20 19:27:01 -0400 ticket: 3308 tags: pullup (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 version_fixed: 1.5 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-5@18213 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/cli/kadmin.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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"); -- 2.26.2