Changeset 52533 in vbox for trunk/src/VBox/Runtime/common/asn1
- Timestamp:
- Aug 29, 2014 10:51:39 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 95788
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/asn1/asn1-cursor.cpp
r51770 r52533 40 40 41 41 /******************************************************************************* 42 * Defined Constants And Macros * 43 *******************************************************************************/ 44 /** @def RTASN1_MAX_NESTING 45 * The maximum nesting depth we allow. This limit is enforced to avoid running 46 * out of stack due to malformed ASN.1 input. 47 * 48 * For reference, 'RTSignTool verify-exe RTSignTool.exe', requires a value of 15 49 * to work without hitting the limit. 50 */ 51 #ifdef IN_RING3 52 # define RTASN1_MAX_NESTING 64 53 #else 54 # define RTASN1_MAX_NESTING 32 55 #endif 56 57 58 /******************************************************************************* 42 59 * Global Variables * 43 60 *******************************************************************************/ … … 50 67 const char *pszErrorTag) 51 68 { 52 pPrimaryCursor->Cursor.pbCur = (uint8_t const *)pvFirst; 53 pPrimaryCursor->Cursor.cbLeft = cb; 54 pPrimaryCursor->Cursor.fFlags = fFlags; 55 pPrimaryCursor->Cursor.pPrimary = pPrimaryCursor; 56 pPrimaryCursor->Cursor.pUp = NULL; 57 pPrimaryCursor->Cursor.pszErrorTag = pszErrorTag; 58 pPrimaryCursor->pErrInfo = pErrInfo; 59 pPrimaryCursor->pAllocator = pAllocator; 69 pPrimaryCursor->Cursor.pbCur = (uint8_t const *)pvFirst; 70 pPrimaryCursor->Cursor.cbLeft = cb; 71 pPrimaryCursor->Cursor.fFlags = fFlags; 72 pPrimaryCursor->Cursor.cDepth = 0; 73 pPrimaryCursor->Cursor.abReserved[0] = 0; 74 pPrimaryCursor->Cursor.abReserved[1] = 0; 75 pPrimaryCursor->Cursor.pPrimary = pPrimaryCursor; 76 pPrimaryCursor->Cursor.pUp = NULL; 77 pPrimaryCursor->Cursor.pszErrorTag = pszErrorTag; 78 pPrimaryCursor->pErrInfo = pErrInfo; 79 pPrimaryCursor->pAllocator = pAllocator; 60 80 return &pPrimaryCursor->Cursor; 61 81 } 62 82 63 83 64 RTDECL(PRTASN1CURSOR) RTAsn1CursorInitSub(PRTASN1CURSOR pParent, uint32_t cb, PRTASN1CURSOR pChild, const char *pszErrorTag) 65 { 66 Assert(pParent->pPrimary); 67 Assert(pParent->pbCur); 68 69 pChild->pbCur = pParent->pbCur; 70 pChild->cbLeft = cb; 71 pChild->fFlags = pParent->fFlags; 72 pChild->pPrimary = pParent->pPrimary; 73 pChild->pUp = pParent; 74 pChild->pszErrorTag = pszErrorTag; 75 76 AssertRelease(pParent->cbLeft >= cb); 84 RTDECL(int) RTAsn1CursorInitSub(PRTASN1CURSOR pParent, uint32_t cb, PRTASN1CURSOR pChild, const char *pszErrorTag) 85 { 86 AssertReturn(pParent->pPrimary, VERR_ASN1_INTERNAL_ERROR_1); 87 AssertReturn(pParent->pbCur, VERR_ASN1_INTERNAL_ERROR_2); 88 89 pChild->pbCur = pParent->pbCur; 90 pChild->cbLeft = cb; 91 pChild->fFlags = pParent->fFlags; 92 pChild->cDepth = pParent->cDepth + 1; 93 AssertReturn(pChild->cDepth < RTASN1_MAX_NESTING, VERR_ASN1_TOO_DEEPLY_NESTED); 94 pChild->abReserved[0] = 0; 95 pChild->abReserved[1] = 0; 96 pChild->pPrimary = pParent->pPrimary; 97 pChild->pUp = pParent; 98 pChild->pszErrorTag = pszErrorTag; 99 100 AssertReturn(pParent->cbLeft >= cb, VERR_ASN1_INTERNAL_ERROR_3); 77 101 pParent->pbCur += cb; 78 102 pParent->cbLeft -= cb; 79 103 80 return pChild; 81 } 82 83 84 RTDECL(PRTASN1CURSOR) RTAsn1CursorInitSubFromCore(PRTASN1CURSOR pParent, PRTASN1CORE pAsn1Core, 85 PRTASN1CURSOR pChild, const char *pszErrorTag) 86 { 87 Assert(pParent->pPrimary); 88 Assert(pParent->pbCur); 89 90 pChild->pbCur = pAsn1Core->uData.pu8; 91 pChild->cbLeft = pAsn1Core->cb; 92 pChild->fFlags = pParent->fFlags; 93 pChild->pPrimary = pParent->pPrimary; 94 pChild->pUp = pParent; 95 pChild->pszErrorTag = pszErrorTag; 96 97 return pChild; 104 return VINF_SUCCESS; 105 } 106 107 108 RTDECL(int) RTAsn1CursorInitSubFromCore(PRTASN1CURSOR pParent, PRTASN1CORE pAsn1Core, 109 PRTASN1CURSOR pChild, const char *pszErrorTag) 110 { 111 AssertReturn(pParent->pPrimary, VERR_ASN1_INTERNAL_ERROR_1); 112 AssertReturn(pParent->pbCur, VERR_ASN1_INTERNAL_ERROR_2); 113 114 pChild->pbCur = pAsn1Core->uData.pu8; 115 pChild->cbLeft = pAsn1Core->cb; 116 pChild->fFlags = pParent->fFlags; 117 pChild->cDepth = pParent->cDepth + 1; 118 AssertReturn(pChild->cDepth < RTASN1_MAX_NESTING, VERR_ASN1_TOO_DEEPLY_NESTED); 119 pChild->abReserved[0] = 0; 120 pChild->abReserved[1] = 0; 121 pChild->pPrimary = pParent->pPrimary; 122 pChild->pUp = pParent; 123 pChild->pszErrorTag = pszErrorTag; 124 125 return VINF_SUCCESS; 98 126 } 99 127 … … 357 385 "%s: Unexpected %s type/flags: %#x/%#x (expected %#x/%#x)", 358 386 pszErrorTag, pszWhat, pAsn1Core->uTag, pAsn1Core->fClass, uTag, fClass); 359 RTAsn1CursorInitSub(pCursor, pAsn1Core->cb, pRetCursor, pszErrorTag); 360 pAsn1Core->fFlags |= RTASN1CORE_F_PRIMITE_TAG_STRUCT; 361 return VINF_SUCCESS; 387 rc = RTAsn1CursorInitSub(pCursor, pAsn1Core->cb, pRetCursor, pszErrorTag); 388 if (RT_SUCCESS(rc)) 389 { 390 pAsn1Core->fFlags |= RTASN1CORE_F_PRIMITE_TAG_STRUCT; 391 return VINF_SUCCESS; 392 } 362 393 } 363 394 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.