From 34e918f210a479515acf61cb7405ceb3bd47ceee Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 20 Jan 2022 11:09:04 -0500 Subject: [PATCH] lib/krb5: unparse_name_fixed ERANGE if zero buffer len The tests depend upon an ERANGE error for buffer length zero. They broken due to 8324a2af1dcd09dd574a2e155bd10458fcbdf8e2 ("lib/krb5: unparse_name_fixed error if invalid name buffer or length") which returned EINVAL. Change-Id: I81693f9d3f5fdc1838c11ffbfe0dafc742d9b207 --- lib/krb5/principal.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/krb5/principal.c b/lib/krb5/principal.c index c45863544..f604bbba1 100644 --- a/lib/krb5/principal.c +++ b/lib/krb5/principal.c @@ -457,13 +457,20 @@ unparse_name_fixed(krb5_context context, int no_realm = (flags & KRB5_PRINCIPAL_UNPARSE_NO_REALM) != 0; int display = (flags & KRB5_PRINCIPAL_UNPARSE_DISPLAY) != 0; - if (name == NULL || len == 0) { + if (name == NULL) { krb5_set_error_message(context, EINVAL, - N_("Invalid name buffer or length, " + N_("Invalid name buffer, " "can't unparse", "")); return EINVAL; } + if (len == 0) { + krb5_set_error_message(context, ERANGE, + N_("Invalid name buffer length, " + "can't unparse", "")); + return ERANGE; + } + name[0] = '\0'; if (!no_realm && princ_realm(principal) == NULL) { -- 2.11.4.GIT