- Timestamp:
- Dec 12, 2009 2:33:26 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 55936
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r25340 r25341 1118 1118 Log(("rtldrPEOpen: %s: dir no. %d (SECURITY) VirtualAddress=%#x Size=%#x is not supported!!!\n", 1119 1119 pszLogName, i, pDir->VirtualAddress, pDir->Size)); 1120 if (pDir->Size < sizeof(WIN_CERTIFICATE)) 1121 { 1122 Log(("rtldrPEOpen: %s: Security directory is too small: %#x bytes\n", pszLogName, i, pDir->Size)); 1123 return VERR_LDRPE_MALFORMED_CERT; 1124 } 1125 if (pDir->Size >= _1M) 1126 { 1127 Log(("rtldrPEOpen: %s: Security directory is too large: %#x bytes\n", pszLogName, i, pDir->Size)); 1128 return VERR_LDRPE_MALFORMED_CERT; 1129 } 1130 if (pDir->VirtualAddress & 7) 1131 { 1132 Log(("rtldrPEOpen: %s: Security directory is misaligned: %#x\n", pszLogName, i, pDir->VirtualAddress)); 1133 return VERR_LDRPE_MALFORMED_CERT; 1134 } 1120 1135 break; 1121 1136 … … 1413 1428 } 1414 1429 } 1430 1431 /* 1432 * If the image is signed, take a look at the signature. 1433 */ 1434 Dir = pOptHdr->DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]; 1435 if (Dir.Size) 1436 { 1437 PWIN_CERTIFICATE pFirst = (PWIN_CERTIFICATE)RTMemTmpAlloc(Dir.Size); 1438 if (!pFirst) 1439 return VERR_NO_TMP_MEMORY; 1440 int rc = pModPe->pReader->pfnRead(pModPe->pReader, pFirst, Dir.Size, Dir.VirtualAddress); 1441 if (RT_SUCCESS(rc)) 1442 { 1443 uint32_t off = 0; 1444 PWIN_CERTIFICATE pCur = pFirst; 1445 do 1446 { 1447 /* validate the members. */ 1448 uint32_t const cbCur = RT_ALIGN_32(pCur->dwLength, 8); 1449 if ( cbCur < sizeof(WIN_CERTIFICATE) 1450 || cbCur + off > RT_ALIGN_32(Dir.Size, 8)) 1451 { 1452 Log(("rtldrPEOpen: %s: cert at %#x/%#x: dwLength=%#x\n", pszLogName, off, Dir.Size, pCur->dwLength)); 1453 rc = VERR_LDRPE_MALFORMED_CERT; 1454 break; 1455 } 1456 if ( pCur->wRevision != WIN_CERT_REVISION_2_0 1457 && pCur->wRevision != WIN_CERT_REVISION_1_0) 1458 { 1459 Log(("rtldrPEOpen: %s: cert at %#x/%#x: wRevision=%#x\n", pszLogName, off, Dir.Size, pCur->wRevision)); 1460 rc = pCur->wRevision >= WIN_CERT_REVISION_1_0 ? VERR_LDRPE_CERT_UNSUPPORTED : VERR_LDRPE_CERT_MALFORMED; 1461 break; 1462 } 1463 if ( pCur->wCertificateType != WIN_CERT_TYPE_PKCS_SIGNED_DATA 1464 && pCur->wCertificateType != WIN_CERT_TYPE_X509 1465 /*&& pCur->wCertificateType != WIN_CERT_TYPE_RESERVED_1*/ 1466 /*&& pCur->wCertificateType != WIN_CERT_TYPE_TS_STACK_SIGNED*/ 1467 && pCur->wCertificateType != WIN_CERT_TYPE_EFI_PKCS115 1468 && pCur->wCertificateType != WIN_CERT_TYPE_EFI_GUID 1469 ) 1470 { 1471 Log(("rtldrPEOpen: %s: cert at %#x/%#x: wRevision=%#x\n", pszLogName, off, Dir.Size, pCur->wRevision)); 1472 rc = pCur->wCertificateType ? VERR_LDRPE_CERT_UNSUPPORTED : VERR_LDRPE_CERT_MALFORMED; 1473 break; 1474 } 1475 1476 /** @todo Rainy Day: Implement further verfication using openssl. */ 1477 1478 /* next */ 1479 off += cbCur; 1480 pCur = (PWIN_CERTIFICATE)((uint8_t *)pCur + cbCur); 1481 } while (off < Dir.Size); 1482 } 1483 RTMemTmpFree(pFirst); 1484 if (RT_FAILURE(rc)) 1485 return rc; 1486 } 1487 1488 1415 1489 return VINF_SUCCESS; 1416 1490 } -
trunk/src/VBox/Runtime/include/internal/ldrPE.h
r24106 r25341 196 196 #define IMAGE_DEBUG_TYPE_BORLAND 0x9 197 197 #define IMAGE_DEBUG_TYPE_RESERVED10 0x10 198 199 /* security directory */ 200 #define WIN_CERT_REVISION_1_0 UINT16_C(0x0100) 201 #define WIN_CERT_REVISION_2_0 UINT16_C(0x0200) 202 203 #define WIN_CERT_TYPE_X509 UINT16_C(1) 204 #define WIN_CERT_TYPE_PKCS_SIGNED_DATA UINT16_C(2) 205 #define WIN_CERT_TYPE_RESERVED_1 UINT16_C(3) 206 #define WIN_CERT_TYPE_TS_STACK_SIGNED UINT16_C(4) 207 #define WIN_CERT_TYPE_EFI_PKCS115 UINT16_C(0x0ef0) 208 #define WIN_CERT_TYPE_EFI_GUID UINT16_C(0x0ef1) 198 209 199 210 … … 468 479 typedef IMAGE_DEBUG_DIRECTORY *PIMAGE_DEBUG_DIRECTORY; 469 480 481 482 typedef struct WIN_CERTIFICATE 483 { 484 uint32_t dwLength; 485 uint16_t wRevision; 486 uint16_t wCertificateType; 487 uint8_t bCertificate[8]; 488 } WIN_CERTIFICATE; 489 typedef WIN_CERTIFICATE *PWIN_CERTIFICATE; 490 470 491 #pragma pack() 471 492
Note:
See TracChangeset
for help on using the changeset viewer.