VirtualBox

Changeset 77815 in vbox


Ignore:
Timestamp:
Mar 20, 2019 11:56:41 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/ASN.1: Allow zero terminators at the end of IA5STRING so we can load some 2018 microsoft root cert.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/asn1/asn1-ut-string.cpp

    r76553 r77815  
    12401240            if (RT_SUCCESS(rc))
    12411241                break;
    1242             return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_UTF8_STRING_ENCODING,
    1243                                  "%s: Bad UTF-8 encoding (%Rrc)", pszErrorTag, rc);
     1242            return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_UTF8_STRING_ENCODING, "%s: Bad UTF-8 encoding (%Rrc, %.*Rhxs)",
     1243                                 pszErrorTag, rc, pThis->Asn1Core.cb, pThis->Asn1Core.uData.pch);
    12441244
    12451245        case ASN1_TAG_NUMERIC_STRING:
     
    12501250                    && ch != ' ')
    12511251                    return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_NUMERIC_STRING_ENCODING,
    1252                                          "%s: Bad numberic string: ch=%#x", pszErrorTag, ch);
     1252                                         "%s: Bad numeric string: ch=%#x (pos %u in %.*Rhxs)", pszErrorTag, ch,
     1253                                         pThis->Asn1Core.cb - cch + 1, pThis->Asn1Core.cb, pThis->Asn1Core.uData.pch);
    12531254            }
    12541255            break;
     
    12731274                   )
    12741275                    return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_PRINTABLE_STRING_ENCODING,
    1275                                          "%s: Bad printable string: ch=%#x", pszErrorTag, ch);
     1276                                         "%s: Bad printable string: ch=%#x (pos %u in %.*Rhxs)", pszErrorTag, ch,
     1277                                         pThis->Asn1Core.cb - cch + 1, pThis->Asn1Core.cb, pThis->Asn1Core.uData.pch);
    12761278            }
    12771279            break;
     
    12821284                unsigned char ch = *pch++;
    12831285                if (ch == 0 || ch >= 0x80)
    1284                     return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_IA5_STRING_ENCODING,
    1285                                          "%s: Bad IA5 string: ch=%#x", pszErrorTag, ch);
     1286                {
     1287                    /* Ignore C-style zero terminator as the "Microsoft ECC Product Root Certificate Authority 2018"
     1288                       for instance, has a policy qualifier string "http://www.microsoft.com/pkiops/Docs/Repository.htm\0" */
     1289                    /** @todo should '\0' really be excluded above? */
     1290                    if (ch != 0 || cch != 0)
     1291                        return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_IA5_STRING_ENCODING,
     1292                                             "%s: Bad IA5 string: ch=%#x (pos %u in %.*Rhxs)", pszErrorTag, ch,
     1293                                             pThis->Asn1Core.cb - cch + 1, pThis->Asn1Core.cb, pThis->Asn1Core.uData.pch);
     1294                    break;
     1295                }
    12861296            }
    12871297            break;
     
    13131323                if (ch < 0x20 || ch >= 0x7f)
    13141324                    return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_VISIBLE_STRING_ENCODING,
    1315                                          "%s: Bad visible string: ch=%#x", pszErrorTag, ch);
     1325                                         "%s: Bad visible string: ch=%#x (pos %u in %.*Rhxs)", pszErrorTag, ch,
     1326                                         pThis->Asn1Core.cb - cch + 1, pThis->Asn1Core.cb, pThis->Asn1Core.uData.pch);
    13161327            }
    13171328            break;
     
    13301341                    if (!RTUniCpIsValid(uc))
    13311342                        return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_UNIVERSAL_STRING_ENCODING,
    1332                                              "%s: Bad universal string: uc=%#x", pszErrorTag, uc);
     1343                                             "%s: Bad universal string: uc=%#x (pos %u in %.*Rhxs)", pszErrorTag, uc,
     1344                                             pThis->Asn1Core.cb - cch + 1, pThis->Asn1Core.cb, pThis->Asn1Core.uData.pch);
    13331345                    cchUtf8 += RTUniCpCalcUtf8Len(uc);
    13341346
     
    13401352            }
    13411353            return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_UNIVERSAL_STRING_ENCODING,
    1342                                  "%s: Bad universal string: size not a multiple of 4: cch=%#x", pszErrorTag, cch);
     1354                                 "%s: Bad universal string: size not a multiple of 4: cch=%#x (%.*Rhxs)",
     1355                                 pszErrorTag, cch, pThis->Asn1Core.cb, pThis->Asn1Core.uData.pch);
    13431356
    13441357        case ASN1_TAG_BMP_STRING:
     
    13521365                    if (!RTUniCpIsValid(uc))
    13531366                        return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_BMP_STRING_ENCODING,
    1354                                              "%s: Bad BMP string: uc=%#x", pszErrorTag, uc);
     1367                                             "%s: Bad BMP string: uc=%#x (pos %u in %.*Rhxs)", pszErrorTag, uc,
     1368                                             pThis->Asn1Core.cb - cch + 1, pThis->Asn1Core.cb, pThis->Asn1Core.uData.pch);
    13551369                    cchUtf8 += RTUniCpCalcUtf8Len(uc);
    13561370
     
    13621376            }
    13631377            return RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_BMP_STRING_ENCODING,
    1364                                  "%s: Bad BMP string: odd number of bytes cch=%#x", pszErrorTag, cch);
     1378                                 "%s: Bad BMP string: odd number of bytes cch=%#x (pos %u in %.*Rhxs)",
     1379                                 pszErrorTag, cch, pThis->Asn1Core.cb, pThis->Asn1Core.uData.pch);
    13651380
    13661381        default:
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette