[379] in Kerberos-V5-bugs

home help back first fref pref prev next nref lref last post

parse/unparse inconsistency

daemon@ATHENA.MIT.EDU (Jim Miller)
Mon Oct 18 20:25:02 1993

From: jim@bilbo.suite.com (Jim Miller)
Date: Mon, 18 Oct 93 19:11:13 -0500
To: krb5-bugs@MIT.EDU
Reply-To: Jim_Miller@suite.com


In Kerberos 5, pre-beta 3...

The functions "krb5_parse_name" and "krb5_unparse_name" do not handle quoted  
characters the same.

In krb5_parse_name:

	/*
	 * Pass 3.  Now we go through the string a *third* time, this
	 * time filling in the krb5_principal structure which we just
	 * allocated.
	 */
	q = krb5_princ_component(principal, 0)->data;
	for (i=0,cp = name; c = *cp; cp++) {
		if (c == QUOTECHAR) {
			cp++;
			switch (c = *cp) {
			case 'n':
				*q++ = '\n';
				break;
			case 't':
				*q++ = '\t';
				break;
			case 'b':
				*q++ = '\b';
				break;
			case '0':
				*q++ = '\0';
				break;
			default:
				*q++ = c;
			}
		} else if ((c == COMPONENT_SEP) || (c == REALM_SEP)) {
			i++;
			*q++ = '\0';
			if (c == COMPONENT_SEP) 

				q = krb5_princ_component(principal, i)->data;
			else
				q = krb5_princ_realm(principal)->data;
		} else
			*q++ = c;
	}



In krb5_unparse_name:

	for (i = 0; i < nelem; i++) {
		cp = krb5_princ_component(principal, i)->data;
		length = krb5_princ_component(principal, i)->length;
		for (j=0; j < length; j++,cp++) {
			switch (*cp) {
			case COMPONENT_SEP:
			case REALM_SEP:
			case '\t':
			case '\\':
				*q++ = '\\';
				*q++ = *cp;
				break;
			case '\0':
				*q++ = '\\';
				*q++ = '0';
				break;
			default:
				*q++ = *cp;
			}
		}
		*q++ = COMPONENT_SEP;
	}


Krb5_unparse_name does not handle '\n' or '\b'.  Or perhaps, krb5_parse_name  
handles them unnecessarily.

Jim_Miller@suite.com


home help back first fref pref prev next nref lref last post