[380] in Kerberos-V5-bugs
more: parse/unparse inconsitency
daemon@ATHENA.MIT.EDU (Jim Miller)
Mon Oct 18 21:06:10 1993
From: jim@bilbo.suite.com (Jim Miller)
Date: Mon, 18 Oct 93 19:34:30 -0500
To: krb5-bugs@MIT.EDU
Cc: Jim-Miller@bilbo.MIT.EDU
Reply-To: Jim_Miller@suite.com
Actually, looking at "unparse" again, I believe it doesn't even handle '\t'
correctly.
I think the "for" loops should be:
for (j=0; j < length; j++,cp++) {
switch (*cp) {
case COMPONENT_SEP:
case REALM_SEP:
case '\\':
*q++ = '\\';
*q++ = *cp;
break;
case '\n':
*q++ = '\\';
*q++ = 'n';
break;
case '\t':
*q++ = '\\';
*q++ = 't';
break;
case '\b':
*q++ = '\\';
*q++ = 'b';
break;
case '\0':
*q++ = '\\';
*q++ = '0';
break;
default:
*q++ = *cp;
}
Of course, if you do the above, you will also have to do the following in the
appropriate places:
for (cp = krb5_princ_realm(principal)->data; *cp; cp++)
if (*cp == REALM_SEP || *cp == COMPONENT_SEP ||
*cp == '\0' || *cp == '\\' || *cp == '\t' ||
*cp == '\n' || *cp == '\b')
totalsize++;
and
for (j=0; j < length; j++,cp++)
if (*cp == REALM_SEP || *cp == COMPONENT_SEP ||
*cp == '\0' || *cp == '\\' || *cp == '\t' ||
*cp == '\n' || *cp == '\b')
totalsize++;
Hmm, looking at the "for" loop for the realm, I think it will give an
incorrect "totalsize" if the original realm string contained any inbedded '\0's
(which krb5_parse_name allows). Probably should change the realm "for" loop
to:
register int totalsize = krb5_princ_realm(principal)->length + 1;
length = krb5_princ_realm(principal)->length;
cp = krb5_princ_realm(principal)->data;
for (j=0; j < length; j++,cp++)
if (*cp == REALM_SEP || *cp == COMPONENT_SEP ||
*cp == '\0' || *cp == '\\' || *cp == '\t' ||
*cp == '\n' || *cp == '\b')
totalsize++;
Jim_Miller@suite.com