VirtualBox

Changeset 64894 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Dec 16, 2016 12:43:05 AM (8 years ago)
Author:
vboxsync
Message:

asn1-ut-core.cpp: Encoding fix for Weird vtable for lone RTASN1CORE structures to prevent them from beling left out of the output. Because we have an pfnEnum callback and doesn't actually do anything, we need a pfnEncodePrep callback that doesn't do anything either and a pfnEncodeWrite that does what it says on the label.

File:
1 edited

Legend:

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

    r62564 r64894  
    179179
    180180
     181/**
     182 * @interface_method_impl{RTASN1COREVTABLE,pfnEncodePrep,
     183 *      This is for not dropping the unparsed content of a 'core' structure when
     184 *      re-encoding it. }
     185 */
     186static DECLCALLBACK(int) rtAsn1Core_EncodePrep(PRTASN1CORE pThisCore, uint32_t fFlags, PRTERRINFO pErrInfo)
     187{
     188    /* We don't update anything here. */
     189    RT_NOREF(pThisCore, fFlags, pErrInfo);
     190    return VINF_SUCCESS;
     191}
     192
     193
     194/**
     195 * @interface_method_impl{RTASN1COREVTABLE,pfnEncodeWrite,
     196 *      This is for not dropping the unparsed content of a 'core' structure when
     197 *      re-encoding it. }
     198 */
     199static DECLCALLBACK(int) rtAsn1Core_EncodeWrite(PRTASN1CORE pThisCore, uint32_t fFlags, PFNRTASN1ENCODEWRITER pfnWriter,
     200                                                void *pvUser, PRTERRINFO pErrInfo)
     201{
     202    int rc = RTAsn1EncodeWriteHeader(pThisCore, fFlags, pfnWriter, pvUser, pErrInfo);
     203    if (RT_SUCCESS(rc) && rc != VINF_ASN1_NOT_ENCODED)
     204    {
     205        Assert(!RTASN1CORE_IS_DUMMY(pThisCore));
     206        AssertPtrReturn(pThisCore->uData.pv,
     207                        RTErrInfoSetF(pErrInfo, VERR_ASN1_INVALID_DATA_POINTER,
     208                                      "Invalid uData pointer %p for lone ASN.1 core with %#x bytes of content",
     209                                      pThisCore->uData.pv, pThisCore->cb));
     210        rc = pfnWriter(pThisCore->uData.pv, pThisCore->cb, pvUser, pErrInfo);
     211    }
     212    return rc;
     213}
     214
     215
    181216
    182217/*
    183218 * ASN.1 Core - Standard Methods.
    184219 *
    185  * Note! Children of the ASN.1 Core doesn't normally call these, they are for
     220 * @note Children of the ASN.1 Core doesn't normally call these, they are for
    186221 *       when RTASN1CORE is used as a member type.
    187222 */
     
    199234    (PFNRTASN1COREVTCOMPARE)RTAsn1Core_Compare,
    200235    (PFNRTASN1COREVTCHECKSANITY)RTAsn1Core_CheckSanity,
    201     NULL,
    202     NULL
     236    rtAsn1Core_EncodePrep,
     237    rtAsn1Core_EncodeWrite
    203238};
    204239
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