X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=mech_eap%2Futil_saml.cpp;h=9658bf0848be41d51de500d8578f35468ee90105;hb=bef2c64ab820c067e3384c9cbb455b97d04601dc;hp=fd84e446ac8986025334e48fd5e2e6d1bbb9576a;hpb=d63dd622db24c0f0bdf13eddddf1c7e9fcffe566;p=moonshot.git diff --git a/mech_eap/util_saml.cpp b/mech_eap/util_saml.cpp index fd84e44..9658bf0 100644 --- a/mech_eap/util_saml.cpp +++ b/mech_eap/util_saml.cpp @@ -662,7 +662,7 @@ gss_eap_saml_attr_provider::getAttribute(const gss_buffer_t attr, if (i == -1) i = 0; - else if (i >= nvalues) + if (i >= nvalues) return false; #ifdef __APPLE__ av = (const saml2::AttributeValue *)((void *)(a->getAttributeValues().at(i))); @@ -671,8 +671,27 @@ gss_eap_saml_attr_provider::getAttribute(const gss_buffer_t attr, #endif if (av != NULL) { if (value != NULL) { - value->value = toUTF8(av->getTextContent(), true); - value->length = strlen((char *)value->value); + char *stringValue = toUTF8(av->getTextContent(), true); + size_t stringValueLen = strlen(stringValue); + + if (base64Valid(stringValue)) { + ssize_t binaryLen; + + value->value = GSSEAP_MALLOC(stringValueLen); + if (value->value == NULL) + throw new std::bad_alloc; + + binaryLen = base64Decode(stringValue, value->value); + if (binaryLen < 0) { + GSSEAP_FREE(value->value); + value->value = NULL; + return false; + } + value->length = binaryLen; + } else { + value->value = stringValue; + value->length = stringValueLen; + } } if (display_value != NULL) { display_value->value = toUTF8(av->getTextContent(), true);