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
+Fri Mar 28 03:52:14 1997 Theodore Y. Ts'o <tytso@mit.edu>
+
+ * 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 <tytso@rsts-11.mit.edu>
* Makefile.in: Add canon_name.c, duplicate_name.c, export_name.c
}
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;
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
*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;
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);
}
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);
}