From: Theodore Tso Date: Fri, 28 Mar 1997 09:22:57 +0000 (+0000) Subject: import_name.c (krb5_gss_import_name): Add support for importing the X-Git-Tag: krb5-1.1-beta1~1160 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=561767bac759dc4ac55a95b4813222d61b5e80a3;p=krb5.git import_name.c (krb5_gss_import_name): Add support for importing the exported name call export_name.c (gss_export_name): Fix export_name emit the token exactly as specified by RFC 2078. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10038 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/gssapi/krb5/ChangeLog b/src/lib/gssapi/krb5/ChangeLog index 1834e6a36..083d78c73 100644 --- a/src/lib/gssapi/krb5/ChangeLog +++ b/src/lib/gssapi/krb5/ChangeLog @@ -1,3 +1,11 @@ +Fri Mar 28 03:52:14 1997 Theodore Y. Ts'o + + * import_name.c (krb5_gss_import_name): Add support for importing + the exported name call + + * export_name.c (gss_export_name): Fix export_name emit the token + exactly as specified by RFC 2078. + Thu Mar 27 15:52:04 1997 Theodore Ts'o * Makefile.in: Add canon_name.c, duplicate_name.c, export_name.c diff --git a/src/lib/gssapi/krb5/export_name.c b/src/lib/gssapi/krb5/export_name.c index ea6d893f6..25c8976cb 100644 --- a/src/lib/gssapi/krb5/export_name.c +++ b/src/lib/gssapi/krb5/export_name.c @@ -52,13 +52,21 @@ OM_uint32 gss_export_name(OM_uint32 *minor_status, } length = strlen(str); - exported_name->length = 8 + length + gss_mech_krb5->length; + exported_name->length = 10 + length + gss_mech_krb5->length; exported_name->value = malloc(exported_name->length); + if (!exported_name->value) { + free(str); + *minor_status = ENOMEM; + return(GSS_S_FAILURE); + } cp = exported_name->value; + /* Note: we assume the OID will be less than 128 bytes... */ *cp++ = 0x04; *cp++ = 0x01; - *cp++ = gss_mech_krb5->length >> 8; - *cp++ = gss_mech_krb5->length & 0xFF; + *cp++ = (gss_mech_krb5->length+2) >> 8; + *cp++ = (gss_mech_krb5->length+2) & 0xFF; + *cp++ = 0x06; + *cp++ = (gss_mech_krb5->length+2) & 0xFF; memcpy(cp, gss_mech_krb5->elements, gss_mech_krb5->length); cp += gss_mech_krb5->length; *cp++ = length >> 24; diff --git a/src/lib/gssapi/krb5/import_name.c b/src/lib/gssapi/krb5/import_name.c index 5c2c6f43a..d16cf45e3 100644 --- a/src/lib/gssapi/krb5/import_name.c +++ b/src/lib/gssapi/krb5/import_name.c @@ -54,7 +54,8 @@ krb5_gss_import_name(minor_status, input_name_buffer, krb5_context context; krb5_principal princ; krb5_error_code code; - char *stringrep, *tmp; + char *stringrep, *tmp, *tmp2, *cp; + OM_uint32 length; #ifndef NO_PASSWORD struct passwd *pw; #endif @@ -115,6 +116,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, *minor_status = ENOMEM; return(GSS_S_FAILURE); } + tmp2 = 0; memcpy(tmp, input_name_buffer->value, input_name_buffer->length); tmp[input_name_buffer->length] = 0; @@ -135,7 +137,40 @@ krb5_gss_import_name(minor_status, input_name_buffer, else *minor_status = (OM_uint32) G_NOUSER; #endif - } else { + } else if (g_OID_equal(input_name_type, gss_nt_exported_name)) { + cp = tmp; + if (*cp++ != 0x04) + goto fail_name; + if (*cp++ != 0x01) + goto fail_name; + if (*cp++ != 0x00) + goto fail_name; + length = *cp++; + if (length != gss_mech_krb5->length+2) + goto fail_name; + if (*cp++ != 0x06) + goto fail_name; + length = *cp++; + if (length != gss_mech_krb5->length) + goto fail_name; + if (memcmp(cp, gss_mech_krb5->elements, length) != 0) + goto fail_name; + cp += length; + length = *cp++; + length = (length << 8) | *cp++; + length = (length << 8) | *cp++; + length = (length << 8) | *cp++; + tmp2 = malloc(length+1); + if (tmp2 == NULL) { + xfree(tmp); + *minor_status = ENOMEM; + return GSS_S_FAILURE; + } + strncpy(tmp2, cp, length); + tmp2[length] = 0; + + stringrep = tmp; + } else { return(GSS_S_BAD_NAMETYPE); } @@ -143,9 +178,16 @@ krb5_gss_import_name(minor_status, input_name_buffer, if (stringrep) code = krb5_parse_name(context, (char *) stringrep, &princ); - else + else { + fail_name: + xfree(tmp); + if (tmp2) + xfree(tmp2); return(GSS_S_BAD_NAME); + } + if (tmp2) + xfree(tmp2); xfree(tmp); }