krb5_error_code code;
krb5_data data;
+ if (enc_length == 0)
+ return 0;
+
code = krb5_authdata_context_init(context, &ad_context);
if (code != 0)
return code;
#ifndef NO_PASSWORD
struct passwd *pw;
#endif
- int has_ad = 0;
+ int is_composite = 0;
krb5_authdata_context ad_context = NULL;
OM_uint32 status = GSS_S_FAILURE;
krb5_gss_name_t name;
case 0x01:
break;
case 0x02:
- has_ad++; /* is composite name */
+ is_composite++;
break;
default:
goto fail_name;
stringrep = tmp2;
cp += length;
- if (has_ad) {
+ if (is_composite) {
BOUNDS_CHECK(cp, end, 4);
length = *cp++;
length = (length << 8) | *cp++;
/* 04 02 OID Name AuthData */
exp_composite_name->length = 10 + gss_mech_krb5->length + princlen;
+ exp_composite_name->length += 4; /* length of encoded attributes */
if (attrs != NULL)
- exp_composite_name->length += 4 + attrs->length;
+ exp_composite_name->length += attrs->length;
exp_composite_name->value = malloc(exp_composite_name->length);
if (exp_composite_name->value == NULL) {
code = ENOMEM;
/* Note: we assume the OID will be less than 128 bytes... */
*cp++ = 0x04;
- if (attrs != NULL)
- *cp++ = 0x02;
- else
- *cp++ = 0x01;
+ *cp++ = 0x02;
store_16_be(gss_mech_krb5->length + 2, cp);
cp += 2;
memcpy(cp, princstr, princlen);
cp += princlen;
+ store_32_be(attrs != NULL ? attrs->length : 0, cp);
+ cp += 4;
+
if (attrs != NULL) {
- store_32_be(attrs->length, cp);
- cp += 4;
memcpy(cp, attrs->data, attrs->length);
cp += attrs->length;
}