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 8324a2af1d
("lib/krb5: unparse_name_fixed error if invalid name buffer or length")
which returned EINVAL.

Change-Id: I81693f9d3f5fdc1838c11ffbfe0dafc742d9b207
This commit is contained in:
Jeffrey Altman
2022-01-20 11:09:04 -05:00
parent d55abd8f50
commit 34e918f210

View File

@@ -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) {